From 345d1c06117bbbb75877b0b9e2eb389976c039e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Av=C3=A9?= Date: Sun, 21 Apr 2024 14:21:48 +0200 Subject: [PATCH] Better git in home dir --- .config/zsh/.zshrc | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 1239eda..39a2ff4 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -243,6 +243,21 @@ function xterm_title_preexec () { print -Pn -- '\e]2;' && print -n -- "${(q)1}\a" } + +if [[ "$TERM" == (Eterm*|alacritty*|aterm*|gnome*|konsole*|kterm*|putty*|rxvt*|screen*|tmux*|xterm*) ]]; then + add-zsh-hook -Uz precmd xterm_title_precmd + add-zsh-hook -Uz preexec xterm_title_preexec +fi + + +########################################### +# Aliases +########################################### + + +if command -v fdfind &> /dev/null; then + alias fd="fdfind" +fi function o () { xdg-open "$1" &! } @@ -253,32 +268,28 @@ function run_waypipe() { SSH_SESSION_ID=$SSH_SESSION_ID waypipe ssh -t $1 env REMOTE_PATH=\"$REMOTE_PATH\" SSH_SESSION_ID=$SSH_SESSION_ID "zsh --login" } +function git() { + if [ "$HOME" = "$(pwd)" ]; then + /usr/bin/git --git-dir="$HOME/.dotfiles/" --work-tree="$HOME" "$@" + else + /usr/bin/git "$@" + fi +} + alias mallorea="run_waypipe mallorea" alias vault="run_waypipe vault" alias riva="run_waypipe riva" alias kell="run_waypipe kell" -if [[ "$TERM" == (Eterm*|alacritty*|aterm*|gnome*|konsole*|kterm*|putty*|rxvt*|screen*|tmux*|xterm*) ]]; then - add-zsh-hook -Uz precmd xterm_title_precmd - add-zsh-hook -Uz preexec xterm_title_preexec -fi - -# Aliases -if command -v fdfind &> /dev/null; then - alias fd="fdfind" -fi alias ls="ls --color=auto" alias gdb='gdb -q' alias ll='ls -lhat' -alias clip="xsel --clipboard" alias compress="tar --use-compress-program=lbzip2 -cvf" alias vim="nvim" -alias dot='/usr/bin/git --git-dir="$HOME/.dotfiles/" --work-tree="$HOME"' alias wget=wget --hsts-file="$XDG_DATA_HOME/wget-hsts" -alias xbindkeys="xbindkeys -f $XDG_CONFIG_HOME/xbindkeys/config" alias python=python3 -alias r=". ranger" -alias v="vim . && cd \"\$(cat /tmp/oil_dir 2> /dev/null || pwd)\"" +alias r="cd \"\$(lf -print-selection -print-last-dir)\"" +alias v="nvim -c ':lua require(\"oil\").open()' && cd \"\$(cat /tmp/oil_dir 2> /dev/null || pwd)\"" alias cpr="rsync --archive -hh --partial --info=stats1,progress2 --modify-window=1" alias mvr="rsync --archive -hh --partial --info=stats1,progress2 --modify-window=1 --remove-source-files" alias rg="rg -i --colors 'match:bg:yellow' --colors 'match:fg:black' --colors 'match:style:nobold' --colors 'path:fg:green' --colors 'path:style:bold' --colors 'line:fg:yellow' --colors 'line:style:bold'"