More zsh improvements
This commit is contained in:
parent
e3abbe810c
commit
86eadfdc15
|
@ -48,15 +48,8 @@ function cd_to() {
|
||||||
zle reset-prompt
|
zle reset-prompt
|
||||||
}
|
}
|
||||||
|
|
||||||
function find_local_directories() {
|
function find_local() {
|
||||||
cd_to "$(fd . -t d | fzy -l 20)"
|
fd . -t $1 | fzy -l 20
|
||||||
}
|
|
||||||
|
|
||||||
function push_local_files() {
|
|
||||||
emulate -L zsh
|
|
||||||
zle -I
|
|
||||||
LBUFFER="${LBUFFER}\"$(fd . -t f | fzy -l 20)\""
|
|
||||||
zle reset-prompt
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function find_global() {
|
function find_global() {
|
||||||
|
@ -88,24 +81,28 @@ function find_global() {
|
||||||
echo $file
|
echo $file
|
||||||
}
|
}
|
||||||
|
|
||||||
function find_global_directories() {
|
function open_path() {
|
||||||
cd_to "$(find_global d)"
|
file_type=$1
|
||||||
}
|
search_fn=$2
|
||||||
|
selection="$($search_fn $file_type)"
|
||||||
function edit_global_files() {
|
if [ "$selection" = "" ]; then
|
||||||
file="$(find_global f)"
|
zle reset-prompt
|
||||||
if [ -z "$file" ]; then
|
return
|
||||||
return 0
|
|
||||||
fi
|
fi
|
||||||
cd_to "$(dirname $file)"
|
if [ "$LBUFFER" = "" ]; then
|
||||||
nvim "$file"
|
if [ "$file_type" = "d" ]; then
|
||||||
}
|
cd_to "$selection"
|
||||||
|
else
|
||||||
function push_global_directories() {
|
selection=$(realpath "$selection")
|
||||||
|
cd_to "$(dirname $selection)"
|
||||||
|
nvim "$selection"
|
||||||
|
fi
|
||||||
|
else
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
zle -I
|
zle -I
|
||||||
LBUFFER="${LBUFFER}\"$(find_global d)\""
|
LBUFFER="${LBUFFER}\"$selection\""
|
||||||
zle reset-prompt
|
zle reset-prompt
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function zvm_after_init() {
|
function zvm_after_init() {
|
||||||
|
@ -160,37 +157,24 @@ function zvm_after_init() {
|
||||||
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
|
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
zle -N find_global_directories
|
function open_global_path_d() { open_path d find_global }
|
||||||
zle -N push_global_directories
|
function open_global_path_f() { open_path f find_global }
|
||||||
|
function open_local() { open_path f find_local }
|
||||||
|
|
||||||
zle -N push_local_files
|
zle -N push_local_files
|
||||||
zle -N find_local_directories
|
zle -N find_local_directories
|
||||||
zle -N edit_global_files
|
|
||||||
|
|
||||||
bindkey "^T" find_global_directories
|
function register_key() {
|
||||||
bindkey -M emacs "^T" find_global_directories
|
zle -N $2
|
||||||
bindkey -M vicmd "^T" find_global_directories
|
bindkey "^$1" $2
|
||||||
bindkey -M viins "^T" find_global_directories
|
bindkey -M emacs "^$1" $2
|
||||||
|
bindkey -M vicmd "^$1" $2
|
||||||
bindkey "^U" push_global_directories
|
bindkey -M viins "^$1" $2
|
||||||
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
|
|
||||||
bindkey -M viins "^Y" find_local_directories
|
|
||||||
|
|
||||||
bindkey "^E" edit_global_files
|
|
||||||
bindkey -M emacs "^E" edit_global_files
|
|
||||||
bindkey -M vicmd "^E" edit_global_files
|
|
||||||
bindkey -M viins "^E" edit_global_files
|
|
||||||
|
|
||||||
|
register_key "T" open_global_path_d
|
||||||
|
register_key "E" open_global_path_f
|
||||||
|
register_key "W" open_local
|
||||||
|
|
||||||
if [ "$SSH_SESSION_ID" != "" ]; then
|
if [ "$SSH_SESSION_ID" != "" ]; then
|
||||||
mkdir -p /tmp/ssh_sessions
|
mkdir -p /tmp/ssh_sessions
|
||||||
|
|
Loading…
Reference in New Issue