# -*- shell-script -*- . ~/.zshrc.from_grml zstyle :prompt:grml:right:setup use-rprompt false zstyle :prompt:grml:left:items:shlvl pre $'\n' function qsx_prompt_shlvl() { if (( SHLVL > 1 )); then REPLY="%F{green}(${SHLVL})%f " fi } grml_theme_add_token shlvl -i qsx_prompt_shlvl # With upstream grml config, both path and vcs components of the prompt tokens # always contain a trailing space, so that 'path vcs percent' is separated by # one space each, but if vcs is empty, there is still only one space between # path and percent. With the :…:percent pre zstyle above, however, we have a # newline in between, and the trailing spaces are superfluous—but we still need # one between path and vcs. Thus, we have no trailing space in path, but a # leading one in vcs. function qsx_theme_path() { emulate -L zsh if (( !vcscalled )); then vcs_info vcscalled=1 fi # displayed length of $vcs_info_msg_0_, # cf. https://stackoverflow.com/a/10564427 local zero='%([BSUbfksu]|([FK]|){*})' local len=${#${(S%%)vcs_info_msg_0_//$~zero/}} # "%-${len}<": fill the remaining terminal width, but leave room for vcs REPLY="%-${len}<…<%~%<<" } grml_theme_add_token path-qsx -f qsx_theme_path '%B' '%b' local -a items if zstyle -a :prompt:grml:left:setup items items; then items[-1]="shlvl" items+=("percent") # find index of "path" local i=${items[(i)path]} # if it exists … if (( ${+items[$i]} )); then # … replace with our version … items[$i]="path-qsx" fi # … and apply zstyle :prompt:grml:left:setup items ${items} unset i fi unset items function qsx_fix_vcs_info() { emulate -L zsh for i in actionformats formats; do local -a fs zstyle -a ':vcs_info:*' $i fs || continue (( ${+fs[1]} )) || continue # strip trailing space, but add leading fs[1]=" ${fs[1]% }" zstyle ':vcs_info:*' $i $fs done } qsx_fix_vcs_info (( $+commands[bsdtar] )) && alias tar=bsdtar (( $+commands[nvim] )) && function vim { command nvim "$@" # Reset terminal cursor printf "\033[0 q" } if ! (( $+commands[open] )) && (( $+commands[gio] )); then function open { gio open "$@" >/dev/null 2>/dev/null } fi alias g=git alias ec="emacsclient -n" alias et="emacsclient -t" alias hl="highlight -O ansi" if (( $+commands[exa] )); then alias ls="exa" alias l="exa -g -l --git" alias la="exa -g -la --git" fi if (( $+commands[eza] )); then alias ls="eza" alias l="eza -g -l --git" alias la="eza -g -la --git" fi if (( $+commands[rsync] )); then alias rs="rsync -vahPi" fi if ! (( $+_CONTAINERS_USERNS_CONFIGURED )); then gpg-connect-agent /bye ssh-add -l fi function countdown { ENDTIME=$(date -d "$1" +%s) watch -b -e -n 1 -x sh -c 'DIFF=$(($ENDTIME - $(date +%s))); echo $(($DIFF / 60)) min $(($DIFF % 60)) s; if [ $DIFF -lt 1 ]; then exit 1; fi' } function fspass () { PASSWORD_STORE_DIR=~/RWTH/FSMPI/passwords pass $@ } function passta () { PASSWORD_STORE_DIR=~/RWTH/AStA/pass pass $@ }