From 3ba0316e7d8899be50640fad33228409b6ed875e Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Mon, 27 Jun 2022 22:21:33 +0200 Subject: [PATCH] config: improve rdictcc integration & co --- .config/doom/config.el | 8 +++++++- .config/shell/functions | 9 +++++---- .local/bin/scripts/help | 10 ++++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.config/doom/config.el b/.config/doom/config.el index 2669ed2..1f24a49 100644 --- a/.config/doom/config.el +++ b/.config/doom/config.el @@ -649,7 +649,7 @@ Version 2019-11-04 2021-02-16" (interactive) (let* ((file (dired-get-filename nil t)) (mime (get-mimetype file))) - (if (or (string-prefix-p "audio" mime) (string-prefix-p "video" mime) (member mime unsupported-mime-types)) + (if (or (string-suffix-p ".desktop" file) (string-prefix-p "audio" mime) (string-prefix-p "video" mime) (member mime unsupported-mime-types)) (call-process "xdg-open" nil 0 nil file) (find-file file)))) @@ -813,6 +813,12 @@ Version 2019-11-04 2021-02-16" ) (setq ispell-personal-dictionary (expand-file-name "personal-dictionary" custom-emacs-data-dir)) +(use-package! rdictcc + :bind (("C-c t". 'rdictcc-translate-word-at-point) + ("C-c T". 'rdictcc-translate-word)) + :config (setq rdictcc-program-args "--directory $XDG_DATA_HOME/dictcc") + ) + (after! tramp (setq tramp-default-method "scpx") (add-to-list 'tramp-methods diff --git a/.config/shell/functions b/.config/shell/functions index 859fa31..f01a942 100644 --- a/.config/shell/functions +++ b/.config/shell/functions @@ -70,7 +70,7 @@ wh() { tool="$(echo "$res" | head -1 | cut -d' ' -f$(expr 5 '&' "$res" : ".*to \(sudo\|noglob\) " '|' 4) | cut -d'(' -f2)" wh $(test $tool = $1 && echo "-p") $tool # use command which for other shells - else test -r "$res" && b "$res" || echo "$res" | bat --style=plain --language=sh + else test -r "$res" && b -- --language=sh "$res" || echo "$res" | bat --style=plain --language=sh fi } compdef wh=which @@ -294,10 +294,11 @@ alias hx='sudo hexedit --maximize --color' # Paginated hexyl hex() { hexyl "$@" | "${PAGER:-less}"; } -alias dic="cat $XDG_DATA_HOME/dictcc/dict.txt | sed '/#/d;/&/d;/^$/d' | fzy" +export DICT="$XDG_DATA_HOME/dictcc" +alias dic="cat $DICT/dict.txt | sed '/#/d;/&/d;/^$/d' | fzy" #fzf --tiebreak=length --bind='alt-bspace:clear-query' -alias dict="rlwrap rdictcc -d $XDG_DATA_HOME/dictcc" -alias dictu="dict -i $XDG_DATA_HOME/dictcc/dict.txt" +alias dict="rlwrap rdictcc --directory $DICT" +alias dict_update="dict -i $DICT/dict.txt" npm-reinstall() { rm -rf $TMPDIR/react-* diff --git a/.local/bin/scripts/help b/.local/bin/scripts/help index dfbd267..b28722d 100755 --- a/.local/bin/scripts/help +++ b/.local/bin/scripts/help @@ -24,10 +24,12 @@ case "$cmd" in (swaymsg) test $# -gt 1 && shift && man sway "$@" || man swaymsg;; (swaymsg-*) man sway "${1#swaymsg-}";; (*) { - case $EDITOR in - (*vim) info "$@" -w | grep -q . && $EDITOR -R -M -c "Info $*" +only;; - (*) { which info >/dev/null 2>&1 && info -f "$@" 2>/dev/null; } || man "$@";; - esac + which info >/dev/null 2>&1 && + case $EDITOR in + (*vim) info "$@" -w | grep -q . && $EDITOR -R -M -c "Info $*" +only;; + (*) info -f "$@" 2>/dev/null;; + esac || + man "$@" } || if which "$cmd" >/dev/null then { "$@" --help || { test $? == 1 && "$@" -help; } || { test $? == 1 && "$@" -h; }; } 2>&1 | $paginate