This commit is contained in:
hl committed 2024-11-18 18:20:40 +08:00
1 parent 6aa1160dd3
commit 7f1cf9a54b
1 file changed
+5 -5
+5 -5
View File
@@ -43,7 +43,7 @@ compinit
autoload -Uz promptinit autoload -Uz promptinit
promptinit promptinit
compdef sshpy=ssh compdef pyssh=ssh
export FZF_COMPLETION_TRIGGER="''" export FZF_COMPLETION_TRIGGER="''"
export FZF_COMPLETION_DIR_COMMANDS='cd pushd rmdir ls ll' export FZF_COMPLETION_DIR_COMMANDS='cd pushd rmdir ls ll'
@@ -68,21 +68,21 @@ _fzf_comprun() {
shift shift
case "$command" in case "$command" in
ssh|mosh|sshpy) fzf --preview 'ssh -tt -G {} | head -n 4' "$@" ;; ssh|mosh|pyssh) fzf --preview 'ssh -tt -G {} | head -n 4' "$@" ;;
cd|ls|ll) fzf --preview 'tree -C -L1 {} | head -200' "$@" ;; cd|ls|ll) fzf --preview 'tree -C -L1 {} | head -200' "$@" ;;
cat|nano) fzf --preview 'cat -s {} | head -200' "$@" ;; cat|nano) fzf --preview 'cat -s {} | head -200' "$@" ;;
*) fzf "$@" ;; *) fzf "$@" ;;
esac esac
} }
_fzf_complete_sshpy() { _fzf_complete_pyssh() {
_fzf_complete +m -- "$@" < <( _fzf_complete +m -- "$@" < <(
setopt localoptions nonomatch setopt localoptions nonomatch
command cat <(command tail -n +1 ~/.ssh/config ~/.ssh/config.d/* 2> /dev/null | command grep -i '^\s*host ' | awk '{for (i = 2; i <= NF; i++) print $1 " " $i}' | command grep -v '[*?%]') | command cat <(command tail -n +1 ~/.ssh/config ~/.ssh/config.d/* 2> /dev/null | command grep -i '^\s*host ' | awk '{for (i = 2; i <= NF; i++) print $1 " " $i}' | command grep -v '[*?%]') |
awk '{if (length($2) > 0) {print $2}}' | sort -u awk '{if (length($2) > 0) {print $2}}' | sort -u
) )
} }
alias _fzf_complete_mosh=_fzf_complete_sshpy alias _fzf_complete_mosh=_fzf_complete_pyssh
alias _fzf_complete_ssh=_fzf_complete_sshpy alias _fzf_complete_ssh=_fzf_complete_pyssh
_fzf_complete_cat(){ _fzf_complete_cat(){
__fzf_generic_path_completion "$prefix" "$1" __fzf_compgen_file \ __fzf_generic_path_completion "$prefix" "$1" __fzf_compgen_file \
"-m" "" " " "-m" "" " "