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