Better fzy
This commit is contained in:
parent
a879cc0d2a
commit
dc9b23333a
|
@ -13,3 +13,6 @@
|
||||||
[submodule "zsh/zsh-vi-mode"]
|
[submodule "zsh/zsh-vi-mode"]
|
||||||
path = zsh/zsh-vi-mode
|
path = zsh/zsh-vi-mode
|
||||||
url = https://github.com/jeffreytse/zsh-vi-mode.git
|
url = https://github.com/jeffreytse/zsh-vi-mode.git
|
||||||
|
[submodule "zsh/zsh-quiet-accept-line"]
|
||||||
|
path = zsh/zsh-quiet-accept-line
|
||||||
|
url = git@github.com:AdrieanKhisbe/zsh-quiet-accept-line.git
|
||||||
|
|
|
@ -6,3 +6,4 @@ Feywild
|
||||||
closeby
|
closeby
|
||||||
ECML
|
ECML
|
||||||
theshold-based
|
theshold-based
|
||||||
|
distill
|
||||||
|
|
96
zsh/.zshrc
96
zsh/.zshrc
|
@ -87,36 +87,76 @@ 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
|
||||||
|
|
||||||
# Use FZY instead of FZF for ctrl-t
|
source "$XDG_CONFIG_HOME/zsh/zsh-quiet-accept-line/quiet-accept-line.plugin.zsh"
|
||||||
function find_files() {
|
function cd_to() {
|
||||||
zle -I
|
setopt localoptions pipefail no_aliases 2> /dev/null
|
||||||
PATHS=""
|
local dir=$1
|
||||||
if [ -d ~/.dotfiles ]; then
|
if [[ -z "$dir" ]]; then
|
||||||
PATHS="$PATHS\n$(fd . ~/.dotfiles -t d -d 1)"
|
zle redisplay
|
||||||
|
return 0
|
||||||
fi
|
fi
|
||||||
if [ -d ~/Workspace ]; then
|
zle push-line # Clear buffer. Auto-restored on next prompt.
|
||||||
PATHS="$PATHS\n$(fd . ~/Workspace -t d -d 5)"
|
BUFFER="cd ${(q)dir}"
|
||||||
fi
|
zle quiet-accept-line
|
||||||
if [ -d ~/Containers ]; then
|
local ret=$?
|
||||||
PATHS="$PATHS\n$(fd . ~/Containers -t d -d 2)"
|
unset dir # ensure this doesn't end up appearing in prompt expansion
|
||||||
fi
|
zle reset-prompt
|
||||||
if [ -d ~/Storage/Shared ]; then
|
return $ret
|
||||||
PATHS="$PATHS\n~/Storage/Shared"
|
|
||||||
PATHS="$PATHS\n$(fd . ~/Storage/Shared -t d -d 2)"
|
|
||||||
fi
|
|
||||||
if [ -d ~/Storage/Thomas ]; then
|
|
||||||
PATHS="$PATHS\n~/Storage/Thomas"
|
|
||||||
PATHS="$PATHS\n$(fd . ~/Storage/Thomas -t d -d 1)"
|
|
||||||
fi
|
|
||||||
BUFFER=cd "$(echo $PATHS | fzy -l 20)"
|
|
||||||
zle accept-line
|
|
||||||
clear
|
|
||||||
}
|
}
|
||||||
zle -N find_files
|
|
||||||
bindkey "^T" find_files
|
# Use FZY instead of FZF for ctrl-t
|
||||||
bindkey -M emacs "^T" find_files
|
function find_global_files() {
|
||||||
bindkey -M vicmd "^T" find_files
|
zle -I
|
||||||
bindkey -M viins "^T" find_files
|
FZY_CACHE=~/.cache/fzy_paths
|
||||||
|
if [ -f $FZY_CACHE ]; then
|
||||||
|
# Check if cache is older than 1 day
|
||||||
|
if [ $(($(date +%s) - $(date -r $FZY_CACHE +%s))) -gt 86400 ]; then
|
||||||
|
rm $FZY_CACHE
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ ! -f $FZY_CACHE ]; then
|
||||||
|
PATHS=""
|
||||||
|
if [ -d ~/.dotfiles ]; then
|
||||||
|
PATHS="$PATHS\n$(fd . ~/.dotfiles -t d -d 2)"
|
||||||
|
fi
|
||||||
|
if [ -d ~/Workspace ]; then
|
||||||
|
PATHS="$PATHS\n$(fd . ~/Workspace -t d -d 8)"
|
||||||
|
fi
|
||||||
|
if [ -d ~/Containers ]; then
|
||||||
|
PATHS="$PATHS\n$(fd . ~/Containers -t d -d 2)"
|
||||||
|
fi
|
||||||
|
if [ -d ~/Storage/Shared ]; then
|
||||||
|
PATHS="$PATHS\n~/Storage/Shared"
|
||||||
|
PATHS="$PATHS\n$(fd . ~/Storage/Shared -t d -d 2)"
|
||||||
|
fi
|
||||||
|
if [ -d ~/Storage/Thomas ]; then
|
||||||
|
PATHS="$PATHS\n~/Storage/Thomas"
|
||||||
|
PATHS="$PATHS\n$(fd . ~/Storage/Thomas -t d -d 1)"
|
||||||
|
fi
|
||||||
|
echo -e $PATHS > $FZY_CACHE
|
||||||
|
fi
|
||||||
|
cd_to "$(cat $FZY_CACHE | fzy -l 20)"
|
||||||
|
zle accept-line
|
||||||
|
}
|
||||||
|
|
||||||
|
function find_local_files() {
|
||||||
|
zle -I
|
||||||
|
cd_to "$(fd . -t d | fzy -l 20)"
|
||||||
|
zle accept-line
|
||||||
|
}
|
||||||
|
|
||||||
|
zle -N find_global_files
|
||||||
|
zle -N find_local_files
|
||||||
|
|
||||||
|
bindkey "^T" find_global_files
|
||||||
|
bindkey -M emacs "^T" find_global_files
|
||||||
|
bindkey -M vicmd "^T" find_global_files
|
||||||
|
bindkey -M viins "^T" find_global_files
|
||||||
|
|
||||||
|
bindkey "^Y" find_local_files
|
||||||
|
bindkey -M emacs "^Y" find_local_files
|
||||||
|
bindkey -M vicmd "^Y" find_local_files
|
||||||
|
bindkey -M viins "^Y" find_local_files
|
||||||
}
|
}
|
||||||
|
|
||||||
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
|
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 307bce24d19fa09d971a0d33c39f3c9fda82924e
|
Subproject commit da9b03777c4f2390c7e3f5c720ee4689336f811b
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 2081e8b394a605d3b776c4318cf77b4f067dc4a8
|
|
@ -1 +1 @@
|
||||||
Subproject commit 1f28e1886dc8e49f41b817634d5c7695b6abb145
|
Subproject commit 7cf6fd19cf2ab38ec5b116eced158377cb3c35f6
|
Loading…
Reference in New Issue