diff --git a/.gitmodules b/.gitmodules index 09e2591..b5ce4c1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "zsh/zsh-vi-mode"] path = zsh/zsh-vi-mode 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 diff --git a/nvim/spell/ltex.dictionary.en-GB.txt b/nvim/spell/ltex.dictionary.en-GB.txt index bcc22c4..1bf0d2c 100644 --- a/nvim/spell/ltex.dictionary.en-GB.txt +++ b/nvim/spell/ltex.dictionary.en-GB.txt @@ -6,3 +6,4 @@ Feywild closeby ECML theshold-based +distill diff --git a/zsh/.zshrc b/zsh/.zshrc index d702444..6f65304 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -87,36 +87,76 @@ function zvm_after_init() { source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh fi - # Use FZY instead of FZF for ctrl-t - function find_files() { - zle -I - PATHS="" - if [ -d ~/.dotfiles ]; then - PATHS="$PATHS\n$(fd . ~/.dotfiles -t d -d 1)" + source "$XDG_CONFIG_HOME/zsh/zsh-quiet-accept-line/quiet-accept-line.plugin.zsh" + function cd_to() { + setopt localoptions pipefail no_aliases 2> /dev/null + local dir=$1 + if [[ -z "$dir" ]]; then + zle redisplay + return 0 fi - if [ -d ~/Workspace ]; then - PATHS="$PATHS\n$(fd . ~/Workspace -t d -d 5)" - 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 - BUFFER=cd "$(echo $PATHS | fzy -l 20)" - zle accept-line - clear + zle push-line # Clear buffer. Auto-restored on next prompt. + BUFFER="cd ${(q)dir}" + zle quiet-accept-line + local ret=$? + unset dir # ensure this doesn't end up appearing in prompt expansion + zle reset-prompt + return $ret } - zle -N find_files - bindkey "^T" find_files - bindkey -M emacs "^T" find_files - bindkey -M vicmd "^T" find_files - bindkey -M viins "^T" find_files + + # Use FZY instead of FZF for ctrl-t + function find_global_files() { + zle -I + 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:|=*' diff --git a/zsh/powerlevel10k b/zsh/powerlevel10k index 307bce2..da9b037 160000 --- a/zsh/powerlevel10k +++ b/zsh/powerlevel10k @@ -1 +1 @@ -Subproject commit 307bce24d19fa09d971a0d33c39f3c9fda82924e +Subproject commit da9b03777c4f2390c7e3f5c720ee4689336f811b diff --git a/zsh/zsh-quiet-accept-line b/zsh/zsh-quiet-accept-line new file mode 160000 index 0000000..2081e8b --- /dev/null +++ b/zsh/zsh-quiet-accept-line @@ -0,0 +1 @@ +Subproject commit 2081e8b394a605d3b776c4318cf77b4f067dc4a8 diff --git a/zsh/zsh-vi-mode b/zsh/zsh-vi-mode index 1f28e18..7cf6fd1 160000 --- a/zsh/zsh-vi-mode +++ b/zsh/zsh-vi-mode @@ -1 +1 @@ -Subproject commit 1f28e1886dc8e49f41b817634d5c7695b6abb145 +Subproject commit 7cf6fd19cf2ab38ec5b116eced158377cb3c35f6