Merge branch 'master' into laptop

This commit is contained in:
Thomas Avé 2024-04-24 15:45:54 +02:00
commit d8bebeaab2
1 changed files with 47 additions and 60 deletions

View File

@ -19,6 +19,11 @@ setopt autocd
# to add other keys to this hash, see: man 5 terminfo
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
source ${XDG_CONFIG_HOME}/zsh/zsh-vi-mode/zsh-vi-mode.plugin.zsh
ZVM_VI_INSERT_ESCAPE_BINDKEY=jj
@ -48,15 +53,8 @@ function cd_to() {
zle reset-prompt
}
function find_local_directories() {
cd_to "$(fd . -t d | 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_local() {
fd . -t $1 | fzy -l 20
}
function find_global() {
@ -77,34 +75,39 @@ function find_global() {
search_dirs=(~/Workspace/ ~/Containers/ /home/server/Storage/Thomas/)
for i in "$search_dirs[@]"; do
if [ -d $i ]; then
PATHS="$PATHS$i\n"
PATHS+="$(ssh mallorea fdfind . $i -t $file_type -d 8)"
PATHS="$PATHS\n$i"
PATHS+="\n$(ssh mallorea fdfind . $i -t $file_type -d 8)"
fi
done
echo -e "$PATHS" > $FZY_CACHE
fi
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
}
function find_global_directories() {
cd_to "$(find_global d)"
}
function edit_global_files() {
file="$(find_global f)"
if [ -z "$file" ]; then
return 0
function open_path() {
file_type=$1
search_fn=$2
selection="$($search_fn $file_type)"
if [ "$selection" = "" ]; then
zle reset-prompt
return
fi
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
cd_to "$(dirname $file)"
nvim "$file"
}
function push_global_directories() {
emulate -L zsh
zle -I
LBUFFER="${LBUFFER}\"$(find_global d)\""
zle reset-prompt
}
function zvm_after_init() {
@ -159,37 +162,24 @@ function zvm_after_init() {
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
fi
zle -N find_global_directories
zle -N push_global_directories
function open_global_path_d() { open_path d find_global }
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 edit_global_files
bindkey "^T" find_global_directories
bindkey -M emacs "^T" find_global_directories
bindkey -M vicmd "^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 -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
function register_key() {
zle -N $2
bindkey "^$1" $2
bindkey -M emacs "^$1" $2
bindkey -M vicmd "^$1" $2
bindkey -M viins "^$1" $2
}
register_key "T" open_global_path_d
register_key "E" open_global_path_f
register_key "W" open_local
if [ "$SSH_SESSION_ID" != "" ]; then
mkdir -p /tmp/ssh_sessions
@ -246,7 +236,7 @@ export ARCHFLAGS="-arch x86_64"
export SSH_KEY_PATH="~/.ssh/rsa_id"
export PYTHONDONTWRITEBYTECODE=1
export TERM="screen-256color"
export PATH=$HOME/.local/bin:$PATH
export PATH=$HOME/.local/bin:$HOME/.cargo/bin:$PATH
export GOPATH=/tmp/go
if command -v micromamba &> /dev/null; then
@ -283,10 +273,6 @@ else
alias lf="cd \"\$(/usr/bin/lf -print-selection -print-last-dir)\""
fi
if command -v fdfind &> /dev/null; then
alias fd="fdfind"
fi
function o () {
xdg-open "$1" &!
}
@ -309,6 +295,7 @@ alias mallorea="run_waypipe mallorea"
alias vault="run_waypipe vault"
alias riva="run_waypipe riva"
alias kell="run_waypipe kell"
alias aloria="run_waypipe aloria"
alias ls="ls --color=auto"
alias gdb='gdb -q'