diff options
-rw-r--r-- | config/essentials/shell/aliases.sh | 189 | ||||
-rw-r--r-- | config/essentials/zsh/.zshrc | 204 | ||||
-rw-r--r-- | config/essentials/zsh/comp.zsh | 49 | ||||
-rw-r--r-- | config/essentials/zsh/plugins.zsh | 10 | ||||
-rw-r--r-- | config/essentials/zsh/prompt.zsh | 16 |
5 files changed, 153 insertions, 315 deletions
diff --git a/config/essentials/shell/aliases.sh b/config/essentials/shell/aliases.sh index 051de5a..950cea7 100644 --- a/config/essentials/shell/aliases.sh +++ b/config/essentials/shell/aliases.sh @@ -2,7 +2,7 @@ # s/alias \([^-]\)/alias -g \1 # The most important one -alias vi='emacsclient -nw' +alias vi='nvim' # Zsh specific aliases if [ $SHELL = "/bin/zsh" ] @@ -77,7 +77,7 @@ alias lst2='ls --tree -L2' alias lst3='ls --tree -L3' alias ls.='ls -dl .*' which exa >/dev/null 2>&1 && - alias ls='exa --sort extension --group-directories-first' || + alias ls='exa --sort extension --group-directories-first --no-time --git' || alias ls='ls --color --group-directories-first --sort=extension' # pacman aliases @@ -126,6 +126,7 @@ alias nvn='nvim "+Telekasten panel"' alias xrandr-rpgmaker='xrandr --auto --output VGA-1 --mode 1024x768 --left-of HDMI-1 && ~/.fehbg' alias xrandr-default='xrandr --auto --output VGA-1 --mode 1920x1080 --left-of HDMI-1 --output HDMI-1 --mode 1920x1080 && ~/.fehbg' +alias xrhdmi='xrandr --auto --output HDMI-4 --left-of DP-1-2' alias d='du -d 0 -h' alias dud='du .* * -d 0 -h 2>/dev/null | sort -h' @@ -316,187 +317,3 @@ alias dbsmu='rsync -rlpP db:/media/basilisk/music/ /media/kilimanjaro/music' alias config='GIT_WORK_TREE=~/src/dotfiles/ GIT_DIR=~/src/dotfiles/.git' alias cfg='vi ~/src/dotfiles/"$(config git ls-files | fzf || exit)"' alias gmod='git status --short | sed '\''/^\s*M/!d;s/^\s*M\s*//'\'' | fzf | xargs vi' -alias g='git' -alias ga='git add' -alias gaa='git add --all' -alias gapa='git add --patch' -alias gau='git add --update' -alias gav='git add --verbose' -alias gap='git apply' -alias gapt='git apply --3way' -alias gb='git branch' -alias gba='git branch --all' -alias gbd='git branch --delete' -alias gbda='git branch --no-color --merged | command grep -vE "^([+*]|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs git branch --delete 2>/dev/null' -alias gbD='git branch --delete --force' -alias gbg='git branch -vv | grep ": gone\]"' -alias gbgd='local res=$(gbg | awk '"'"'{print $1}'"'"') && [[ $res ]] && echo $res | xargs git branch -d' -alias gbgD='local res=$(gbg | awk '"'"'{print $1}'"'"') && [[ $res ]] && echo $res | xargs git branch -D' -alias gbl='git blame -b -w' -alias gbnm='git branch --no-merged' -alias gbr='git branch --remote' -alias gbs='git bisect' -alias gbsb='git bisect bad' -alias gbsg='git bisect good' -alias gbsr='git bisect reset' -alias gbss='git bisect start' -alias gc='git commit --verbose' -alias gc!='git commit --verbose --amend' -alias gcn!='git commit --verbose --no-edit --amend' -alias gca='git commit --verbose --all' -alias gca!='git commit --verbose --all --amend' -alias gcan!='git commit --verbose --all --no-edit --amend' -alias gcans!='git commit --verbose --all --signoff --no-edit --amend' -alias gcam='git commit --all --message' -alias gcsm='git commit --signoff --message' -alias gcas='git commit --all --signoff' -alias gcasm='git commit --all --signoff --message' -alias gcb='git checkout -b' -alias gcf='git config --list' -alias gcl='git clone' -alias gclc='git clone "$(clipo)"' -alias gclr='git clone --recurse-submodules' -alias gc1='git clone --depth 1' -alias gclean='git clean --interactive -d' -alias gpristine='git reset --hard && git clean --force -dfx' -alias grsf='git reset --soft HEAD~' -alias gcm='git checkout $(git_main_branch)' -alias gcd='git checkout $(git_develop_branch)' -alias gcmsg='git commit --message' -alias gco='git checkout' -alias gcor='git checkout --recurse-submodules' -alias gcount='git shortlog --summary --numbered' -alias gcp='git cherry-pick' -alias gcpa='git cherry-pick --abort' -alias gcpc='git cherry-pick --continue' -alias gcs='git commit --gpg-sign' -alias gcss='git commit --gpg-sign --signoff' -alias gcssm='git commit --gpg-sign --signoff --message' -alias gd='git diff' -alias gdca='git diff --cached' -alias gdcw='git diff --cached --word-diff' -alias gdct='git describe --tags $(git rev-list --tags --max-count=1)' -alias gds='git diff --staged' -alias gdt='git diff-tree --no-commit-id --name-only -r' -alias gdup='git diff @{upstream}' -alias gdw='git diff --word-diff' -alias gdl='git diff HEAD^ HEAD' -alias gf='git fetch' -alias gfo='git fetch origin' -alias gfg='git ls-files | grep' -alias gg='git gui citool' -alias gga='git gui citool --amend' -alias ggpur='ggu' -alias ggpull='git pull origin "$(git_current_branch)"' -alias ggpush='git push origin "$(git_current_branch)"' -alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)' -alias gpsup='git push --set-upstream origin $(git_current_branch)' -alias ghh='git help' -alias gignore='git update-index --assume-unchanged' -alias gignored='git ls-files -v | grep "^[[:lower:]]"' -alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk' -alias gk='\gitk --all --branches &!' -alias gke='\gitk --all $(git log --walk-reflogs --pretty=%h) &!' -alias gl='git pull' -alias glg='git log --stat' -alias glgp='git log --stat --patch' -alias glgg='git log --graph' -alias glgga='git log --graph --decorate --all' -alias glgm='git log --graph --max-count=10' -alias glo='git log --oneline --decorate' -alias glol="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset'" -alias glols="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat" -alias glod="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'" -alias glods="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short" -alias glola="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --all" -alias glog='git log --oneline --decorate --graph' -alias gloga='git log --oneline --decorate --graph --all' -alias glp="_git_log_prettily" -alias gm='git merge' -alias gmom='git merge origin/$(git_main_branch)' -alias gmtl='git mergetool --no-prompt' -alias gmtlvim='git mergetool --no-prompt --tool=vimdiff' -alias gmum='git merge upstream/$(git_main_branch)' -alias gma='git merge --abort' -alias gp='git push' -alias gpd='git push --dry-run' -alias gpf!='git push --force' -alias gpoat='git push origin --all && git push origin --tags' -alias gpod='git push origin --delete' -alias gpr='git pull --rebase' -alias gpu='git push upstream' -alias gpv='git push --verbose' -alias gr='git remote' -alias gra='git remote add' -alias grb='git rebase' -alias grba='git rebase --abort' -alias grbc='git rebase --continue' -alias grbd='git rebase $(git_develop_branch)' -alias grbi='git rebase --interactive' -alias grbm='git rebase $(git_main_branch)' -alias grbom='git rebase origin/$(git_main_branch)' -alias grbo='git rebase --onto' -alias grbs='git rebase --skip' -alias grev='git revert' -alias grh='git reset' -alias grhh='git reset --hard' -alias groh='git reset origin/$(git_current_branch) --hard' -alias grm='git rm' -alias grmc='git rm --cached' -alias grmv='git remote rename' -alias grrm='git remote remove' -alias grs='git restore' -alias grset='git remote set-url' -alias grss='git restore --source' -alias grst='git restore --staged' -alias grt='cd "$(git rev-parse --show-toplevel || echo .)"' -alias gru='git reset --' -alias grup='git remote update' -alias grv='git remote --verbose' -alias gsb='git status --short --branch' -alias gsd='git svn dcommit' -alias gsh='git show' -alias gsi='git submodule init' -alias gsps='git show --pretty=short --show-signature' -alias gsr='git svn rebase' -alias gss='git status --short' -alias gst='git status' -alias gstaa='git stash apply' -alias gstc='git stash clear' -alias gstd='git stash drop' -alias gstl='git stash list' -alias gstp='git stash pop' -alias gsts='git stash show --text' -alias gstu='gsta --include-untracked' -alias gstall='git stash --all' -alias gsu='git submodule update' -alias gsw='git switch' -alias gswc='git switch --create' -alias gswm='git switch $(git_main_branch)' -alias gswd='git switch $(git_develop_branch)' -alias gts='git tag --sign' -alias gtv='git tag | sort -V' -alias gtl='gtl(){ git tag --sort=-v:refname -n --list "${1}*" }; noglob gtl' -alias gunignore='git update-index --no-assume-unchanged' -alias gunwip='git log --max-count=1 | grep -q -c "\--wip--" && git reset HEAD~1' -alias gup='git pull --rebase' -alias gupv='git pull --rebase --verbose' -alias gupa='git pull --rebase --autostash' -alias gupav='git pull --rebase --autostash --verbose' -alias gupom='git pull --rebase origin $(git_main_branch)' -alias gupomi='git pull --rebase=interactive origin $(git_main_branch)' -alias glum='git pull upstream $(git_main_branch)' -alias gluc='git pull upstream $(git_current_branch)' -alias gwch='git whatchanged -p --abbrev-commit --pretty=medium' -alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"' -alias gwt='git worktree' -alias gwta='git worktree add' -alias gwtls='git worktree list' -alias gwtmv='git worktree move' -alias gwtrm='git worktree remove' -alias gam='git am' -alias gamc='git am --continue' -alias gams='git am --skip' -alias gama='git am --abort' -alias gamscp='git am --show-current-patch' -alias xrhdmi='xrandr --auto --output HDMI-4 --left-of DP-1-2' diff --git a/config/essentials/zsh/.zshrc b/config/essentials/zsh/.zshrc index 7785b72..f9ca5c3 100644 --- a/config/essentials/zsh/.zshrc +++ b/config/essentials/zsh/.zshrc @@ -14,73 +14,69 @@ fi autoload -U select-word-style autoload -z edit-command-line zle -N edit-command-line -zstyle ':compinstall' filename '/home/aluc/.zshrc' - -### Completion -# cache -zstyle ':completion:*' use-cache on -zstyle ':completion:*' cache-path "$ZDOTDIR/zcompcache" - -# completers -zstyle ':completion:*' completer _extensions _complete - -# format -zstyle ':completion:*:*:*:*:descriptions' format '%F{blue}-- %D%d --%f' -zstyle ':completion:*:*:*:*:messages' format '%F{purple}-- %d --%f' -zstyle ':completion:*:*:*:*:warnings' format '%F{red}-- no matches found --%f' -zstyle ':completion:*:default' list-prompt '%S%M matches%s' -# show a 'ls -a' like outptut when listing files -zstyle ':completion:*:*:*:*:default' list-colors ${(s.:.)LS_COLORS} - -# Group completions by categories -zstyle ':completion:*' group-name '' -zstyle ':completion:*:*:-command-:*:*' group-order aliases builtins functions commands - -zstyle ':completion:*' squeeze-slashes true - -# Prefer completing for an option (think cd -) -zstyle ':completion:*' complete-options true - -# keep prefix when completing -zstyle ':completion:*' keep-prefix true - -# ui -zstyle ':completion:*' menu select -# Move around using h j k l in completion menu -zmodload zsh/complist -bindkey -M menuselect 'h' vi-backward-char -bindkey -M menuselect 'k' vi-up-line-or-history -bindkey -M menuselect 'j' vi-down-line-or-history -bindkey -M menuselect 'l' vi-forward-char -bindkey -M menuselect '^xg' clear-screen -# interactive mode -bindkey -M menuselect '^xi' vi-insert -bindkey -M menuselect '^xh' accept-and-hold # Hold -bindkey -M menuselect '^xn' accept-and-infer-next-history # Next -bindkey -M menuselect '^xu' undo # Undo - -autoload -Uz compinit; compinit - autoload -Uz surround zle -N delete-surround surround zle -N add-surround surround zle -N change-surround surround -# Source files +### Source files . $XDG_CONFIG_HOME/shell/functions.sh . $XDG_CONFIG_HOME/shell/aliases.sh +# . $XDG_CONFIG_HOME/zsh/prompt.zsh +# . $XDG_CONFIG_HOME/zsh/comp.zsh +# . $XDG_CONFIG_HOME/zsh/plugins.zsh + +### Programs +eval "$(starship init zsh)" +eval "$(zoxide init zsh)" + +### Plugins +[ -f "$HOME/.local/share/zap/zap.zsh" ] && source "$HOME/.local/share/zap/zap.zsh" +plug "kutsan/zsh-system-clipboard" +plug "xPMo/zsh-toggle-command-prefix" +plug "zap-zsh/completions" +plug "zap-zsh/vim" +plug "zsh-users/zsh-autosuggestions" +plug "zsh-users/zsh-completions" +plug "chivalryq/git-alias" +plug "zap-zsh/fzf" +plug "zdharma-continuum/fast-syntax-highlighting" +plug "zsh-users/zsh-history-substring-search" +plug "MichaelAquilina/zsh-you-should-use" + +# Substring search settings +export HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND="bg=blue,fg=black,bold" +export HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=black,bold' +bindkey -M vicmd 'k' history-substring-search-up +bindkey -M vicmd 'j' history-substring-search-down + +# Zsh System keyboard settings +if [ -n "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ]; then + ZSH_SYSTEM_CLIPBOARD_METHOD="xsc" +else + ZSH_SYSTEM_CLIPBOARD_METHOD="wlc" +fi + + +# Add nnn shell level to prompt +[ -n "$NNNLVL" ] && PS1="N$NNNLVL $PS1" + +# cd on nnn quiting +nnn_cd () +{ + if ! [ -z "$NNN_PIPE" ]; then + printf "%s\0" "0c${PWD}" > "${NNN_PIPE}" !& + fi +} + +trap nnn_cd EXIT -for file in /{etc,usr/lib}/os-release -do [ -f "$file" ] && . "$file" && break -done -case "${ID:=unknown}" in - debian|ubuntu) PLUGPATH=/usr/share/ ;; - unknown) PLUGPATH=$ZDOTDIR/plugins ;; - *) PLUGPATH=/usr/share/zsh/plugins ;; -esac -. $PLUGPATH/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh -. $PLUGPATH/zsh-autosuggestions/zsh-autosuggestions.zsh +# Check if in tmux and if a venv directory exists activate the python environment +if [ ! -z "$TMUX" ] && [ -d "./env" ]; then + . ./env/bin/activate +fi +### Keybinds bindkey -v bindkey -a cs change-surround bindkey -a ds delete-surround @@ -98,20 +94,21 @@ bindkey "^Xa" _expand_alias bindkey "^Xe" edit-command-line bindkey "^[." insert-last-word bindkey "^['" quote-line +## Move around using h j k l in completion menu +zmodload zsh/complist +bindkey -M menuselect 'h' vi-backward-char +bindkey -M menuselect 'k' vi-up-line-or-history +bindkey -M menuselect 'j' vi-down-line-or-history +bindkey -M menuselect 'l' vi-forward-char +bindkey -M menuselect '^xg' clear-screen +## interactive mode +bindkey -M menuselect '^xi' vi-insert +bindkey -M menuselect '^xh' accept-and-hold # Hold +bindkey -M menuselect '^xn' accept-and-infer-next-history # Next +bindkey -M menuselect '^xu' undo # Undo -isTextFile() -{ - [ -f "$1" ] && - # will execute the file, I'd rather not have an error message - [ ${1::2} != "./" ] && - [ ${1::1} != "/" ] && - ! type "$1" > /dev/null && - # is text file? - file -b --mime-type "$1" | grep -q "^text/" || - return 1 -} - -# rehash hook +### Hooks +## rehash hook zshcache_time="$(date +%s%N)" autoload -Uz add-zsh-hook rehash_precmd() { @@ -123,7 +120,7 @@ rehash_precmd() { fi fi } -# window title hooks +## window title hooks add-zsh-hook -Uz precmd rehash_precmd set_wt_action () { print -n "\e]0;$1\a\033[0m" @@ -133,67 +130,16 @@ set_wt () { print -Pn "\e]0;%n@%m on %~\a" } add-zsh-hook -Uz precmd set_wt -function osc7 { - local LC_ALL=C - export LC_ALL - - setopt localoptions extendedglob - input=( ${(s::)PWD} ) - uri=${(j::)input/(#b)([^A-Za-z0-9_.\!~*\'\(\)-\/])/%${(l:2::0:)$(([##16]#match))}} - print -n "\e]7;file://${HOSTNAME}${uri}\e\\" -} -add-zsh-hook -Uz chpwd osc7 -command_not_found_handler () { - if [[ -o interactive ]] && isTextFile "$1" - then "$EDITOR" "$1" - else echo "zsh: command not found: $1" >&2 - fi -} - -# automatic ls after cd +## automatic ls after cd add-zsh-hook -Uz chpwd (){[ "$PWD" != "$HOME" ] && ls -a; } -# prompt -PS1=' %K{16}%B%(#.%F{1}.%F{13})%n%b%f@%B%F{6}%m%b%f %3~%k ' -RPROMPT='%F{blue}$(parse_git_remote)%f%F{red}$(parse_git_status)%f%F{green}$(parse_git_branch)%f%(?.. %?)' - -setopt prompt_subst -parse_git_remote() { - git branch -v 2> /dev/null | - awk -F '[][]' '/^\*/ {print $2}' | - sed 's/ahead/↑ /;s/behind/↓ /;s/[^↓↑]*/ /g' -} -parse_git_branch() { - git symbolic-ref --short HEAD 2> /dev/null || git rev-parse --short HEAD 2> /dev/null -} -parse_git_status() { - git status --short 2> /dev/null | head -n1 | awk '{print $1 " "}' -} - -# Completion -_dotnet_zsh_complete() -{ - local completions=("$(dotnet complete "$words")") - - # If the completion list is empty, just continue with filename selection - if [ -z "$completions" ] - then - _arguments '*::arguments: _normal' - return - fi - - # This is not a variable assignment, don't remove spaces! - _values = "${(ps:\n:)completions}" -} -compdef _dotnet_zsh_complete dotnet - -export REPORTTIME=2 -export TIMEFMT="-> %*E" -# override built-in time command -alias time='/usr/bin/time' +### Variables +## Run menuscripts with fzf export MENUCMD='fzf' +## vi mode escape fix +export KEYTIMEOUT=1 -# Options +### Options setopt correct setopt nonomatch setopt autocd diff --git a/config/essentials/zsh/comp.zsh b/config/essentials/zsh/comp.zsh new file mode 100644 index 0000000..94d76b1 --- /dev/null +++ b/config/essentials/zsh/comp.zsh @@ -0,0 +1,49 @@ +# ### Completion + +# autoload -Uz compinit; compinit +# zstyle ':compinstall' filename '/home/aluc/.zshrc' +# # cache +# zstyle ':completion:*' use-cache on +# zstyle ':completion:*' cache-path "$ZDOTDIR/zcompcache" + +# # completers +# zstyle ':completion:*' completer _extensions _complete + +# # format +# zstyle ':completion:*:*:*:*:descriptions' format '%F{blue}-- %D%d --%f' +# zstyle ':completion:*:*:*:*:messages' format '%F{purple}-- %d --%f' +# zstyle ':completion:*:*:*:*:warnings' format '%F{red}-- no matches found --%f' +# zstyle ':completion:*:default' list-prompt '%S%M matches%s' +# # show a 'ls -a' like outptut when listing files +# zstyle ':completion:*:*:*:*:default' list-colors ${(s.:.)LS_COLORS} + +# # Group completions by categories +# zstyle ':completion:*' group-name '' +# zstyle ':completion:*:*:-command-:*:*' group-order aliases builtins functions commands + +# zstyle ':completion:*' squeeze-slashes true + +# # Prefer completing for an option (think cd -) +# zstyle ':completion:*' complete-options true + +# # keep prefix when completing +# zstyle ':completion:*' keep-prefix true + +# # ui +# zstyle ':completion:*' menu select + +# _dotnet_zsh_complete() +# { +# local completions=("$(dotnet complete "$words")") + +# # If the completion list is empty, just continue with filename selection +# if [ -z "$completions" ] +# then +# _arguments '*::arguments: _normal' +# return +# fi + +# # This is not a variable assignment, don't remove spaces! +# _values = "${(ps:\n:)completions}" +# } +# compdef _dotnet_zsh_complete dotnet
\ No newline at end of file diff --git a/config/essentials/zsh/plugins.zsh b/config/essentials/zsh/plugins.zsh new file mode 100644 index 0000000..d8de390 --- /dev/null +++ b/config/essentials/zsh/plugins.zsh @@ -0,0 +1,10 @@ +for file in /{etc,usr/lib}/os-release +do [ -f "$file" ] && . "$file" && break +done +case "${ID:=unknown}" in + debian|ubuntu) PLUGPATH=/usr/share/ ;; + unknown) PLUGPATH=$ZDOTDIR/plugins ;; + *) PLUGPATH=/usr/share/zsh/plugins ;; +esac +. $PLUGPATH/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh +. $PLUGPATH/zsh-autosuggestions/zsh-autosuggestions.zsh diff --git a/config/essentials/zsh/prompt.zsh b/config/essentials/zsh/prompt.zsh new file mode 100644 index 0000000..5364401 --- /dev/null +++ b/config/essentials/zsh/prompt.zsh @@ -0,0 +1,16 @@ +# prompt +# PS1=' %K{16}%B%(#.%F{1}.%F{13})%n%b%f@%B%F{6}%m%b%f %3~%k ' +# RPROMPT='%F{blue}$(parse_git_remote)%f%F{red}$(parse_git_status)%f%F{green}$(parse_git_branch)%f%(?.. %?)' + +setopt prompt_subst +parse_git_remote() { + git branch -v 2> /dev/null | + awk -F '[][]' '/^\*/ {print $2}' | + sed 's/ahead/↑ /;s/behind/↓ /;s/[^↓↑]*/ /g' +} +parse_git_branch() { + git symbolic-ref --short HEAD 2> /dev/null || git rev-parse --short HEAD 2> /dev/null +} +parse_git_status() { + git status --short 2> /dev/null | head -n1 | awk '{print $1 " "}' +}
\ No newline at end of file |