diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-03-09 11:06:38 +0100 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-03-09 11:07:42 +0100 |
commit | 8f4bff3514f31b88762e3b3e48773907f85265f8 (patch) | |
tree | 7023cfcaee37f2d49237275f24e2ea6ab9daae0f /config/essentials | |
parent | 2b38ce5ff4754f3edcfea25ea06ca23a7354ae7d (diff) |
use XDG base directories, set directories in .zshenv
Diffstat (limited to 'config/essentials')
-rw-r--r-- | config/essentials/zsh/aliases.zsh | 2 | ||||
-rw-r--r-- | config/essentials/zsh/zshrc | 99 |
2 files changed, 101 insertions, 0 deletions
diff --git a/config/essentials/zsh/aliases.zsh b/config/essentials/zsh/aliases.zsh index 33648a2..cfad09e 100644 --- a/config/essentials/zsh/aliases.zsh +++ b/config/essentials/zsh/aliases.zsh @@ -7,6 +7,8 @@ alias -g nb='newsboat' alias -g sr='surfraw' alias -g ccu='calcurse' +alias arduino-cli='arduino-cli --config-file $XDG_CONFIG_HOME/arduino15/arduino-cli.yaml' + if [ -x /usr/bin/dircolors ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" # alias ls='ls -h --color --group-directories-first' diff --git a/config/essentials/zsh/zshrc b/config/essentials/zsh/zshrc new file mode 100644 index 0000000..dd52e5e --- /dev/null +++ b/config/essentials/zsh/zshrc @@ -0,0 +1,99 @@ +#!/bin/zsh + +if [ ! $(pgrep Xorg) ] && [ "tty1" = "$(basename $(tty))" ] +then + clear + eval "$(keychain --dir "$XDG_CONFIG_HOME/keychain" --eval --quiet --agents gpg 3A626DD20A32EB2E5DD9CE71CFD9ABC97158CD5D 2> /dev/null)" + eval "$(keychain --dir "$XDG_CONFIG_HOME/keychain" --noask --eval --quiet --agents ssh 2> /dev/null)" + clear + startx 2&> /dev/null + exit +fi + +autoload -U select-word-style +autoload -z edit-command-line +zle -N edit-command-line +zstyle ':compinstall' filename '/home/aluc/.zshrc' +zstyle ':completion:*' menu select +autoload -Uz compinit +compinit -d $XDG_CACHE_HOME/zsh/zcompdump-$ZSH_VERSION +autoload -Uz surround +zle -N delete-surround surround +zle -N add-surround surround +zle -N change-surround surround +compinit + +for f in \ + /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh \ + /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh \ + ~/.config/zsh/functions.zsh \ + ~/.config/zsh/aliases.zsh +do + test -f $f && source $f +done + +bindkey -v +bindkey -a cs change-surround +bindkey -a ds delete-surround +bindkey -a ys add-surround +bindkey -M visual S add-surround +bindkey "^A" beginning-of-line +bindkey "^E" end-of-line +bindkey '^I' expand-or-complete-prefix # necessary for completeinword +bindkey '^Y' autosuggest-accept +bindkey "^K" kill-line +bindkey "^P" up-line-or-history +bindkey "^N" down-line-or-history +bindkey "^V" quoted-insert +bindkey "^Xa" _expand_alias +bindkey "^Xe" edit-command-line +bindkey "^[." insert-last-word +bindkey "^['" quote-line + +# pacman synced rehash +zshcache_time="$(date +%s%N)" +autoload -Uz add-zsh-hook +rehash_precmd() { + if [[ -a /var/cache/zsh/pacman ]]; then + local paccache_time="$(date -r /var/cache/zsh/pacman +%s%N)" + if (( zshcache_time < paccache_time )); then + rehash + zshcache_time="$paccache_time" + fi + fi +} +add-zsh-hook -Uz precmd rehash_precmd + +# prompt +PS1=' %B%(#.%F{1}.%F{13})[%n%b%f@%B%F{6}%m]%b%f %3~ ' +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() { + b="$(git branch -v 2> /dev/null | grep "^*" | sed 's/.\+\[\([^ ]\+\).*$/\1/')" + if [ "$b" = "behind" ] + then + echo -n "↓ " + elif [ "$b" = "ahead" ] + then + echo -n "↑ " + fi +} +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 " "}' +} + +# Options +setopt correct +setopt nonomatch +setopt autocd +setopt completeinword +setopt extendedglob +setopt histignorealldups +setopt histreduceblanks +setopt interactivecomments +setopt notify +setopt cdablevars |