config/shell/functions: add automatic reverse-translation to dic

And improve some helpers with kitty & co
This commit is contained in:
xeruf 2022-08-03 15:58:14 +02:00
parent fe63972fba
commit a28368cfa0
2 changed files with 9 additions and 5 deletions

View File

@ -244,7 +244,7 @@ sshl() {
mkdir -p "$authcache" mkdir -p "$authcache"
file="$authcache/$1" file="$authcache/$1"
test "$all" && pass scp ~/.bash_aliases "$@:" test "$all" && pass scp ~/.bash_aliases "$@:"
if ssh -G "$1" | grep --silent "^user root$" if ssh -G "$1" | grep --silent "^user root$" && ! [[ "$1" =~ "pve*" ]]
then TERM=xterm-256color pass ssh "$@" then TERM=xterm-256color pass ssh "$@"
else else
test ! -e "$file" && test ! -e "$file" &&
@ -253,7 +253,7 @@ sshl() {
cut -d " " -f2- | cut -d " " -f2- |
sed "s|^~|$HOME|")" "$1" && sed "s|^~|$HOME|")" "$1" &&
touch "$file" touch "$file"
TERM=xterm-256color kitty +kitten ssh -R 2489:127.0.0.1:2489 "$@" $(case $TERM in (*-kitty) TERM=xterm-256color echo 'kitty +kitten';; esac) ssh -R 2489:127.0.0.1:2489 "$@"
return $? return $?
fi fi
} }
@ -308,7 +308,11 @@ alias hx='sudo hexedit --maximize --color'
hex() { hexyl "$@" | "${PAGER:-less}"; } hex() { hexyl "$@" | "${PAGER:-less}"; }
export DICT="$XDG_DATA_HOME/dictcc" export DICT="$XDG_DATA_HOME/dictcc"
alias dic="cat $DICT/dict.txt | sed '/#/d;/&/d;/^$/d' | fzy -l $(expr $(tput lines) / 3 * 2)" dic() {
# TODO tiebreak=chunk
result=$(cat $DICT/dict.txt | sed '/#/d;/&/d;/^$/d' | fzf --tiebreak=length --bind='alt-bspace:clear-query' --print-query --query="$1") &&
dic "$(echo "$result" | sed 's/ /\n/g' | grep --invert-match --ignore-case $(echo "$result" | head -1) | head -1)"
}
#fzf --tiebreak=length --bind='alt-bspace:clear-query' #fzf --tiebreak=length --bind='alt-bspace:clear-query'
alias dict="rlwrap rdictcc --directory $DICT" alias dict="rlwrap rdictcc --directory $DICT"
alias dict_update="dict -i $DICT/dict.txt" alias dict_update="dict -i $DICT/dict.txt"

View File

@ -18,7 +18,7 @@ do file="$dir/$f"
test -f "$file" || test -d "$file" && echo "Removing superfluous $file" && rm -rf $i "$file" test -f "$file" || test -d "$file" && echo "Removing superfluous $file" && rm -rf $i "$file"
done done
find "$dir" -maxdepth 2 -not -name ".stfolder" -empty -printf "Removing empty %p\n" -delete find "$dir" -maxdepth 2 -not -name ".stfolder" -empty -printf "Removing empty %p\n" -delete
find -L -maxdepth 2 -type l -printf "Removing broken symlink %p\n" -delete find -L -maxdepth 2 -type l -printf "Removing broken symlink %p\n" -delete 2>/dev/null
highlight "y :: recursively remove empty folders and files" highlight "y :: recursively remove empty folders and files"
[[ $1 =~ "y" ]] && [[ $1 =~ "y" ]] &&
@ -26,7 +26,7 @@ highlight "y :: recursively remove empty folders and files"
highlight "e :: remove downloaded emacs packages (rebuild takes minutes!)" highlight "e :: remove downloaded emacs packages (rebuild takes minutes!)"
[[ $1 =~ "e" ]] && [[ $1 =~ "e" ]] &&
find $DOOMLOCALDIR -maxdepth 1 \( -name straight -o -type f \) -exec rm -rf {} + find $DOOMLOCALDIR -maxdepth 1 \( -name straight -o -type f \) -printf "Removing %p\n" -exec rm -rf {} +
for k in "${!_clean_map[@]}"; do for k in "${!_clean_map[@]}"; do
folder="${_clean_map[$k]}" folder="${_clean_map[$k]}"