commit a93fcef96e25219ba2089835f4b1df40cbe55c20 parent 49db5431bf8e044a0f63de939a90aea448e60f40 Author: Stefan Koch <programming@stefan-koch.name> Date: Sun, 9 Oct 2022 21:12:15 +0200 add .zshrc Diffstat:
A | dot_zshrc | | | 68 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 68 insertions(+), 0 deletions(-)
diff --git a/dot_zshrc b/dot_zshrc @@ -0,0 +1,68 @@ +setopt PROMPT_SUBST + +function ledger-xact() { + year=$(date +%Y) + echo "" >> sync-data/finances/ledger/$year.journal + ledger xact $@ >> sync-data/finances/ledger/$year.journal +} + +precmd () { + vcs_info +} + +# Setup prompt +if [[ -n $SSH_CONNECTION ]]; then + local user='%{%F{green}%}%n%{%F{yellow}%}@%{%F{blue}%}%m%{%F{white}%}' +else + local user='%{%F{green}%}%n%{%F{white}%}' +fi + +local pwd='%{%F{cyan}%}%3~%{%F{white}%}' +local return_code='%(?..%{%F{red}%}%? ↵%{%F{white}%})' +local vcs_status='${vcs_info_msg_0_}' + +autoload -Uz vcs_info + +zstyle ':vcs_info:*' enable git + +zstyle ':vcs_info:*' actionformats '%F{5}[%F{2}%s:%b%F{3}|%F{1}%a%F{5}]%f ' +zstyle ':vcs_info:*' formats '%F{5}[%F{2}%s:%b%F{5}]%f ' +zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r' + +PROMPT="${user}:${pwd} \$ " +RPROMPT="${return_code} ${vcs_status}" + +# Fix special keys +bindkey "${terminfo[khome]}" beginning-of-line +bindkey "${terminfo[kend]}" end-of-line +bindkey "${terminfo[kdch1]}" delete-char + +# Setup ssh-agent +if ! pgrep -u "$USER" ssh-agent > /dev/null; then + ssh-agent > "$XDG_RUNTIME_DIR/ssh-agent.env" +fi +if [[ ! "$SSH_AUTH_SOCK" ]]; then + eval "$(<"$XDG_RUNTIME_DIR/ssh-agent.env")" > /dev/null +fi + +# Set history +HISTFILE=~/.zsh_history +HISTSIZE=1000 +SAVEHIST=1000 +setopt appendhistory + +# Set command completion +autoload -Uz compinit +compinit +# Remove completion for "gm", because I use this for givematerial +unset '_comps[gm]' +function _backup { + local -a subcmds + subcmds=('weekly:Run the weekly backup to external disk') + _describe 'interval' subcmds +} +compdef _backup backup.sh + +# Adjust execution path +path+=("$HOME/bin" "$HOME/.gem/ruby/2.7.0/bin") +export PATH