update
This commit is contained in:
parent
0f0aa768fb
commit
eccccddc3e
47
.zshrc
47
.zshrc
@ -51,26 +51,52 @@ zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}
|
||||
autoload -Uz promptinit
|
||||
promptinit
|
||||
|
||||
compdef sshpy=ssh
|
||||
|
||||
export FZF_COMPLETION_TRIGGER="''"
|
||||
export FZF_COMPLETION_DIR_COMMANDS='cd pushd rmdir ls ll'
|
||||
export FZF_DEFAULT_COMMAND='fdfind --strip-cwd-prefix --hidden --exclude .git --exclude __pycache__ --exclude node_modules --exclude .cache'
|
||||
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
|
||||
export FZF_ALT_C_COMMAND='fdfind --type d --strip-cwd-prefix --hidden --exclude .git --exclude __pycache__ --exclude node_modules --exclude .cache'
|
||||
# Override default
|
||||
_fzf_compgen_path() {
|
||||
fdfind --hidden --exclude .git --exclude __pycache__ --exclude node_modules --exclude .cache . "$1"
|
||||
}
|
||||
_fzf_compgen_dir() {
|
||||
fdfind --type d --hidden --exclude .git --exclude __pycache__ --exclude node_modules --exclude .cache . "$1"
|
||||
}
|
||||
# Self-defined
|
||||
__fzf_compgen_file(){
|
||||
fdfind --type f --hidden --exclude .git --exclude __pycache__ --exclude node_modules --exclude .cache . "$1"
|
||||
}
|
||||
|
||||
# For **<TAB>
|
||||
_fzf_comprun() {
|
||||
local command=$1
|
||||
shift
|
||||
|
||||
case "$command" in
|
||||
ssh) fzf --preview 'ssh -tt -G {} | head -n 4' "$@" ;;
|
||||
*) fzf "$@" ;;
|
||||
ssh|mosh|sshpy) fzf --preview 'ssh -tt -G {} | head -n 4' "$@" ;;
|
||||
cd|ls|ll) fzf --preview 'tree -C -L1 {} | head -200' "$@" ;;
|
||||
cat|nano) fzf --preview 'cat -s {} | head -200' "$@" ;;
|
||||
*) fzf "$@" ;;
|
||||
esac
|
||||
}
|
||||
source /usr/share/doc/fzf/examples/completion.zsh
|
||||
source /usr/share/doc/fzf/examples/key-bindings.zsh
|
||||
_fzf_complete_sshpy() {
|
||||
_fzf_complete +m -- "$@" < <(
|
||||
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 '[*?%]') |
|
||||
awk '{if (length($2) > 0) {print $2}}' | sort -u
|
||||
)
|
||||
}
|
||||
alias _fzf_complete_mosh=_fzf_complete_sshpy
|
||||
alias _fzf_complete_ssh=_fzf_complete_sshpy
|
||||
_fzf_complete_cat(){
|
||||
__fzf_generic_path_completion "$prefix" "$1" __fzf_compgen_file \
|
||||
"-m" "" " "
|
||||
}
|
||||
alias _fzf_complete_nano=_fzf_complete_cat
|
||||
source <(fzf --zsh)
|
||||
|
||||
prompt fire
|
||||
|
||||
@ -79,6 +105,19 @@ export PATH=$HOME/.yarn/bin:$HOME/.local/bin:$PATH
|
||||
|
||||
eval "$(zoxide init --cmd cd zsh)"
|
||||
|
||||
function fzf_packages(){
|
||||
local cmd="dpkg --get-selections | grep -v deinstall | awk '{print $1}' | fzf --multi --preview 'dpkg -s {1}' | command tr '\n' ' '"
|
||||
setopt localoptions pipefail no_aliases 2> /dev/null
|
||||
LBUFFER=${LBUFFER}$(eval $cmd)
|
||||
local ret=$?
|
||||
zle reset-prompt
|
||||
return $ret
|
||||
}
|
||||
zle -N fzf_packages
|
||||
bindkey "^_" fzf_packages
|
||||
|
||||
|
||||
export MANROFFOPT="-c"
|
||||
export MANPAGER="sh -c 'col -bx|batcat -l man -p'"
|
||||
alias cat="batcat -pp"
|
||||
alias h="batcat -pl help"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user