Compare commits

..

No commits in common. "d8bebeaab27ad404c50bbd982e0a99971481585f" and "a80781ede9fd8cf921d5f0a6120442435aed9cff" have entirely different histories.

1 changed files with 49 additions and 48 deletions

View File

@ -19,11 +19,6 @@ setopt autocd
# to add other keys to this hash, see: man 5 terminfo # to add other keys to this hash, see: man 5 terminfo
typeset -g -A key typeset -g -A key
# We need this here since it's used below
if command -v fdfind &> /dev/null; then
alias fd="fdfind"
fi
# Use vi-mode # Use vi-mode
source ${XDG_CONFIG_HOME}/zsh/zsh-vi-mode/zsh-vi-mode.plugin.zsh source ${XDG_CONFIG_HOME}/zsh/zsh-vi-mode/zsh-vi-mode.plugin.zsh
ZVM_VI_INSERT_ESCAPE_BINDKEY=jj ZVM_VI_INSERT_ESCAPE_BINDKEY=jj
@ -53,8 +48,16 @@ function cd_to() {
zle reset-prompt zle reset-prompt
} }
function find_local() { function find_local_directories() {
fd . -t $1 | fzy -l 20 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 find_global() { function find_global() {
@ -75,39 +78,27 @@ function find_global() {
search_dirs=(~/Workspace/ ~/Containers/ /home/server/Storage/Thomas/) search_dirs=(~/Workspace/ ~/Containers/ /home/server/Storage/Thomas/)
for i in "$search_dirs[@]"; do for i in "$search_dirs[@]"; do
if [ -d $i ]; then if [ -d $i ]; then
PATHS="$PATHS\n$i" PATHS="$PATHS$i\n"
PATHS+="\n$(ssh mallorea fdfind . $i -t $file_type -d 8)" PATHS+="$(ssh mallorea fdfind . $i -t $file_type -d 8)"
fi fi
done done
echo -e "$PATHS" > $FZY_CACHE echo -e "$PATHS" > $FZY_CACHE
fi fi
file="$(cat $FZY_CACHE | fzy -l 20)" file="$(cat $FZY_CACHE | fzy -l 20)"
echo $file | cat - $FZY_CACHE | awk '!x[$0]++' > /tmp/fzy_paths_$file_type && mv /tmp/fzy_paths_$file_type $FZY_CACHE
echo $file echo $file
} }
function open_path() { function find_global_directories() {
file_type=$1 cd_to "$(find_global d)"
search_fn=$2 }
selection="$($search_fn $file_type)"
if [ "$selection" = "" ]; then function edit_global_files() {
zle reset-prompt file="$(find_global f)"
return if [ -z "$file" ]; then
fi return 0
if [ "$LBUFFER" = "" ]; then
if [ "$file_type" = "d" ]; then
cd_to "$selection"
else
selection=$(realpath "$selection")
cd_to "$(dirname $selection)"
nvim "$selection"
fi
else
emulate -L zsh
zle -I
LBUFFER="${LBUFFER}\"$selection\""
zle reset-prompt
fi fi
cd_to "$(dirname $file)"
nvim "$file"
} }
function zvm_after_init() { function zvm_after_init() {
@ -162,24 +153,31 @@ 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
function open_global_path_d() { open_path d find_global } zle -N find_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 find_local_directories zle -N find_local_directories
zle -N edit_global_files
zle -N edit_local_files
function register_key() { bindkey "^T" find_global_directories
zle -N $2 bindkey -M emacs "^T" find_global_directories
bindkey "^$1" $2 bindkey -M vicmd "^T" find_global_directories
bindkey -M emacs "^$1" $2 bindkey -M viins "^T" find_global_directories
bindkey -M vicmd "^$1" $2
bindkey -M viins "^$1" $2 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
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
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
@ -236,7 +234,7 @@ export ARCHFLAGS="-arch x86_64"
export SSH_KEY_PATH="~/.ssh/rsa_id" export SSH_KEY_PATH="~/.ssh/rsa_id"
export PYTHONDONTWRITEBYTECODE=1 export PYTHONDONTWRITEBYTECODE=1
export TERM="screen-256color" export TERM="screen-256color"
export PATH=$HOME/.local/bin:$HOME/.cargo/bin:$PATH export PATH=$HOME/.local/bin:$PATH
export GOPATH=/tmp/go export GOPATH=/tmp/go
if command -v micromamba &> /dev/null; then if command -v micromamba &> /dev/null; then
@ -273,6 +271,10 @@ else
alias lf="cd \"\$(/usr/bin/lf -print-selection -print-last-dir)\"" alias lf="cd \"\$(/usr/bin/lf -print-selection -print-last-dir)\""
fi fi
if command -v fdfind &> /dev/null; then
alias fd="fdfind"
fi
function o () { function o () {
xdg-open "$1" &! xdg-open "$1" &!
} }
@ -295,7 +297,6 @@ alias mallorea="run_waypipe mallorea"
alias vault="run_waypipe vault" alias vault="run_waypipe vault"
alias riva="run_waypipe riva" alias riva="run_waypipe riva"
alias kell="run_waypipe kell" alias kell="run_waypipe kell"
alias aloria="run_waypipe aloria"
alias ls="ls --color=auto" alias ls="ls --color=auto"
alias gdb='gdb -q' alias gdb='gdb -q'