add push shortcuts

This commit is contained in:
Thomas Avé 2024-04-24 13:43:27 +02:00
parent 3228a5d271
commit f8b3a4979e
1 changed files with 24 additions and 12 deletions

View File

@ -52,12 +52,11 @@ function find_local_directories() {
cd_to "$(fd . -t d | fzy -l 20)"
}
function edit_local_files() {
file=$(fd . -t f | fzy -l 20)
if [ -z "$file" ]; then
return 0
fi
nvim "$file"
function push_local_files() {
emulate -L zsh
zle -I
LBUFFER="${LBUFFER}\"$(fd . -t f | fzy -l 20)\""
zle reset-prompt
}
function find_global() {
@ -101,6 +100,13 @@ function edit_global_files() {
nvim "$file"
}
function push_global_directories() {
emulate -L zsh
zle -I
LBUFFER="${LBUFFER}\"$(find_global d)\""
zle reset-prompt
}
function zvm_after_init() {
key[Home]="${terminfo[khome]}"
key[End]="${terminfo[kend]}"
@ -154,15 +160,26 @@ function zvm_after_init() {
fi
zle -N find_global_directories
zle -N push_global_directories
zle -N push_local_files
zle -N find_local_directories
zle -N edit_global_files
zle -N edit_local_files
bindkey "^T" find_global_directories
bindkey -M emacs "^T" find_global_directories
bindkey -M vicmd "^T" find_global_directories
bindkey -M viins "^T" find_global_directories
bindkey "^U" push_global_directories
bindkey -M emacs "^U" push_global_directories
bindkey -M vicmd "^U" push_global_directories
bindkey -M viins "^U" push_global_directories
bindkey "^W" push_local_files
bindkey -M emacs "^W" push_local_files
bindkey -M vicmd "^W" push_local_files
bindkey -M viins "^W" push_local_files
bindkey "^Y" find_local_directories
bindkey -M emacs "^Y" find_local_directories
bindkey -M vicmd "^Y" find_local_directories
@ -173,11 +190,6 @@ function zvm_after_init() {
bindkey -M vicmd "^E" edit_global_files
bindkey -M viins "^E" edit_global_files
bindkey "^W" edit_global_files
bindkey -M emacs "^W" edit_local_files
bindkey -M vicmd "^W" edit_local_files
bindkey -M viins "^W" edit_local_files
if [ "$SSH_SESSION_ID" != "" ]; then
mkdir -p /tmp/ssh_sessions