bin: overall helper improvements
This commit is contained in:
parent
ac370731ad
commit
4c522a0985
|
@ -53,7 +53,7 @@ cd() {
|
||||||
|
|
||||||
# LOCATE {{{1
|
# LOCATE {{{1
|
||||||
# TODO no double heading with bat
|
# TODO no double heading with bat
|
||||||
alias fselect='fzf -0 -1 --reverse --height=30% | while read f; do test -d "$f" && cd "$f" || { highlight "$f" && print -s "b $f" && b "$f"; }; done';
|
alias fselect='fzf -0 -1 --reverse --height=30% | while read f; do test -d "$f" && cd "$f" || { highlight "$f" && print -s "b \"$f\"" && b "$f"; }; done';
|
||||||
loci() {
|
loci() {
|
||||||
locate --all --ignore-case --basename --existing "$@" |
|
locate --all --ignore-case --basename --existing "$@" |
|
||||||
command grep --extended-regexp --ignore-case --color=always $(echo "$|${@:$#}" | sed 's/ /|/g') |
|
command grep --extended-regexp --ignore-case --color=always $(echo "$|${@:$#}" | sed 's/ /|/g') |
|
||||||
|
|
|
@ -247,6 +247,8 @@ sshl() {
|
||||||
|
|
||||||
alias startMinecraftServer='curl https://ipinfo.io/ip | xclip -sel clip && cd ~/daten/games/sharedgames/minecraft/server && java -jar forge-1.12.2-14.23.5.2768-universal.jar -mx 8G'
|
alias startMinecraftServer='curl https://ipinfo.io/ip | xclip -sel clip && cd ~/daten/games/sharedgames/minecraft/server && java -jar forge-1.12.2-14.23.5.2768-universal.jar -mx 8G'
|
||||||
|
|
||||||
|
alias scenic='/usr/lib/jvm/java-11-openjdk/bin/java --module-path /usr/lib/jvm/java-11-openjfx/lib --add-modules javafx.web,javafx.fxml,javafx.swing -jar scenicview.jar'
|
||||||
|
|
||||||
# Listen to loopback of mic
|
# Listen to loopback of mic
|
||||||
alias listen='pactl load-module module-loopback; echo "Press Enter to stop"; read; pactl unload-module module-loopback'
|
alias listen='pactl load-module module-loopback; echo "Press Enter to stop"; read; pactl unload-module module-loopback'
|
||||||
|
|
||||||
|
@ -280,7 +282,9 @@ grpr() { grp --color=always --recursive $(echo $DIRS_IGNORE | sed 's|-x |--exclu
|
||||||
grsh() { grpr --no-ignore-case "$@" $HOME/.{ba,z}sh* $HOME/.local/bin $CONFIG_SHELLS $CONFIG_ZSH; }
|
grsh() { grpr --no-ignore-case "$@" $HOME/.{ba,z}sh* $HOME/.local/bin $CONFIG_SHELLS $CONFIG_ZSH; }
|
||||||
|
|
||||||
# Recover stray swap files from neovim
|
# Recover stray swap files from neovim
|
||||||
alias vrec="ls $XDG_DATA_HOME/nvim/swap | sed 's/\%/\//g' | sed 's|\(.*\)\..*|\1|' | head -1 | xargs --no-run-if-empty nvim"
|
vrec() {
|
||||||
|
ls "$XDG_DATA_HOME/nvim/swap/$1" | sed 's/\%/\//g' | sed 's|\(.*\)\..*|\1|' | head -1 | xargs --no-run-if-empty nvim
|
||||||
|
}
|
||||||
alias vrecd="ls $XDG_DATA_HOME/nvim/swap | head -1 | xargs -r -i mv {} /tmp"
|
alias vrecd="ls $XDG_DATA_HOME/nvim/swap | head -1 | xargs -r -i mv {} /tmp"
|
||||||
|
|
||||||
# I think this was something about recovering backup files
|
# I think this was something about recovering backup files
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#assume_yes = true
|
#assume_yes = true
|
||||||
|
|
||||||
# Disable specific steps - same options as the command line flag
|
# Disable specific steps - same options as the command line flag
|
||||||
disable = ["node", "pnpm", "nix", "emacs"] #, "config-update"]
|
disable = ["node", "nix", "emacs"] #, "pnpm", "config-update"]
|
||||||
|
|
||||||
# Ignore failures for these steps
|
# Ignore failures for these steps
|
||||||
#ignore_failures = ["powershell"]
|
#ignore_failures = ["powershell"]
|
||||||
|
|
|
@ -151,7 +151,7 @@ if test "$bat" -o "$batplain"; then
|
||||||
test "$(bat --version | cut -d. -f2)" -gt 16 && rule=,rule
|
test "$(bat --version | cut -d. -f2)" -gt 16 && rule=,rule
|
||||||
if test $# -gt ${#bat[@]} -a $# -gt ${#batplain[@]} && test -z "$flags"
|
if test $# -gt ${#bat[@]} -a $# -gt ${#batplain[@]} && test -z "$flags"
|
||||||
then cut="--line-range :7"
|
then cut="--line-range :7"
|
||||||
batpager="cut -c-$(echo $(tput cols) \* 19 / 10 | cut -d. -f1)"
|
batpager="cut -c-$(expr $(tput cols) \* 19 / 10 | cut -d. -f1)"
|
||||||
fi
|
fi
|
||||||
batcommand="$elevate bat $cut $flags --pager"
|
batcommand="$elevate bat $cut $flags --pager"
|
||||||
batstyle="--style plain$rule"
|
batstyle="--style plain$rule"
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
# interactive diff with pagination and nice coloring
|
# interactive diff with pagination and nice coloring
|
||||||
if file --mime "$1" "$2" | grep --quiet audio
|
if file --mime "$1" "$2" | grep --quiet audio
|
||||||
then ff() { ffprobe -loglevel warning -print_format default=noprint_wrappers=1 -show_format -pretty "$@"; }
|
then ff() { ffprobe -loglevel warning -print_format default=noprint_wrappers=1 -show_format -pretty "$@"; }
|
||||||
$(test $(tput cols) -gt 120 && echo "diff --color=always --side-by-side" || echo "diff-color") --label="$1" --label="$2" <(ff "$1") <(ff "$2")
|
$(test $(tput cols) -gt 120 && echo "diff --color=always --side-by-side" || echo "diff-color") --report-identical-files --label="$1" --label="$2" <(ff "$1") <(ff "$2")
|
||||||
else diff-color "$@"
|
else diff-color --report-identical-files "$@"
|
||||||
fi | less --RAW-CONTROL-CHARS --quit-on-intr --quit-if-one-screen
|
fi | less --RAW-CONTROL-CHARS --quit-on-intr --quit-if-one-screen
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Colorize with diffr
|
# Colorize with diffr
|
||||||
diff --color=always --report-identical-files --unified=2 "$@" |
|
diff --color=always --unified=2 "$@" |
|
||||||
diffr --colors refine-added:none:background:0x33,0x66,0x33:bold --colors added:none:background:0x33,0x44,0x33 --colors refine-removed:none:background:0x66,0x33,0x33:bold --colors removed:none:background:0x44,0x33,0x33
|
diffr --colors refine-added:none:background:0x33,0x66,0x33:bold --colors added:none:background:0x33,0x44,0x33 --colors refine-removed:none:background:0x66,0x33,0x33:bold --colors removed:none:background:0x44,0x33,0x33
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
# Delete files under current or given path which exist elsewhere as listed in the locate database
|
# Delete files under current or given path which exist elsewhere as listed in the locate database
|
||||||
# Matches first by name, then by checksum (currently inefficiently via md5)
|
# Matches first by name, then by checksum (currently inefficiently via md5)
|
||||||
find "$@" -size +5M -type f -exec sh -c "IFS=$'\n'"'
|
case "$1" in ([0-9]) size=$1; shift;; esac
|
||||||
|
find "$@" -size +${size:-5}M -type f -exec sh -c "IFS=$'\n'"'
|
||||||
filepath="{}"
|
filepath="{}"
|
||||||
target="$(basename "$filepath" | synct-unarchive)"
|
target="$(basename "$filepath" | synct-unarchive)"
|
||||||
highlight "$filepath"
|
highlight "$filepath"
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
# and shows progress indications for some operations
|
# and shows progress indications for some operations
|
||||||
# optdepends: rewrite(part of my dotfiles)
|
# optdepends: rewrite(part of my dotfiles)
|
||||||
for arg do
|
for arg do
|
||||||
|
case $arg in
|
||||||
|
(-d) del=$(expr ${del:-0} + 1);;
|
||||||
|
(-*) param="$arg";;
|
||||||
|
(*)
|
||||||
if test -r "$arg"; then
|
if test -r "$arg"; then
|
||||||
fullpath="$(realpath "$arg")"
|
fullpath="$(realpath "$arg")"
|
||||||
name="$(basename "${fullpath%.*}")"
|
name="$(basename "${fullpath%.*}")"
|
||||||
|
@ -21,7 +25,7 @@ for arg do
|
||||||
(*.tgz) tar xzf "$fullpath" ;;
|
(*.tgz) tar xzf "$fullpath" ;;
|
||||||
(*.7z|*.z01|*.zip|*.jar)
|
(*.7z|*.z01|*.zip|*.jar)
|
||||||
if which 7z >/dev/null
|
if which 7z >/dev/null
|
||||||
then 7z x "$fullpath"
|
then 7z x $param "$fullpath"
|
||||||
else unzip "$fullpath" | rewrite
|
else unzip "$fullpath" | rewrite
|
||||||
fi;;
|
fi;;
|
||||||
(*.gz) gunzip "$fullpath" ;;
|
(*.gz) gunzip "$fullpath" ;;
|
||||||
|
@ -35,13 +39,18 @@ for arg do
|
||||||
# If we created a temporary subfolder, check if it can be eliminated
|
# If we created a temporary subfolder, check if it can be eliminated
|
||||||
if test "$(basename "$PWD")" = "$namepart"
|
if test "$(basename "$PWD")" = "$namepart"
|
||||||
then if test $# -lt 2 -a "$(ls -U | wc -l)" -lt 3
|
then if test $# -lt 2 -a "$(ls -U | wc -l)" -lt 3
|
||||||
then test "$(ls)" && mv * ..
|
then test "$(ls)" && mv -v * ..
|
||||||
cd .. && rm -d "$namepart"
|
cd .. && rm -d "$namepart"
|
||||||
else cd .. && mv "$namepart" "$name"
|
else cd .. && mv -v "$namepart" "$name"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
case $del in
|
||||||
|
(2) rm "$arg";;
|
||||||
|
(1) mv -v "$arg" "/tmp";;
|
||||||
|
esac
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
echo "'$1' is not a readable file"
|
echo "'$1' is not a readable file"
|
||||||
fi
|
fi;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
|
|
|
@ -13,6 +13,7 @@ if test -d ".git"
|
||||||
then repo="$(basename "$PWD")"
|
then repo="$(basename "$PWD")"
|
||||||
git remote set-url origin "$(git-repo "${3:-github.com}" "$repo" "$2" "${@:4}")"
|
git remote set-url origin "$(git-repo "${3:-github.com}" "$repo" "$2" "${@:4}")"
|
||||||
else repo="$1" && shift
|
else repo="$1" && shift
|
||||||
|
# TODO cd into 1-/0-forks
|
||||||
git-get "${3:-github.com}" "$repo" "${2:-$(git config --get user.name)}" "${@:4}"
|
git-get "${3:-github.com}" "$repo" "${2:-$(git config --get user.name)}" "${@:4}"
|
||||||
cd "$(expr "$4" \| "$repo")"
|
cd "$(expr "$4" \| "$repo")"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue