From e1ba38a16d313785a9558d4c3b18304920cd2cd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20P=C5=82azie=C5=84ski?= Date: Tue, 27 Feb 2024 20:37:29 +0100 Subject: [PATCH] Reformat using shfmt --- zsh.d/zplug.zsh | 12 +- zshrc | 497 ++++++++++++++++++++++++------------------------ 2 files changed, 253 insertions(+), 256 deletions(-) diff --git a/zsh.d/zplug.zsh b/zsh.d/zplug.zsh index 395bcc6..99d39a5 100644 --- a/zsh.d/zplug.zsh +++ b/zsh.d/zplug.zsh @@ -3,7 +3,7 @@ export ZPLUG_ROOT=${ZPLUG_ROOT:-/usr/share/zplug} if [[ ! -f "${ZPLUG_ROOT}/init.zsh" ]]; then - return + return fi source ${ZPLUG_ROOT}/init.zsh @@ -17,10 +17,10 @@ zplug "zsh-users/zsh-completions" zplug "junegunn/fzf", use:"shell/*.zsh" if ! zplug check --verbose; then - printf "Install? [y/N]: " - if read -q; then - echo; zplug install - fi + printf "Install? [y/N]: " + if read -q; then + echo + zplug install + fi fi zplug load - diff --git a/zshrc b/zshrc index 4198628..e78f944 100644 --- a/zshrc +++ b/zshrc @@ -15,63 +15,62 @@ autoload -Uz add-zsh-hook LAST_RETURN_VALUE=0 # Characters -if [[ -n $(echo '\u2603' 2>/dev/null) ]] then - MULTIBYTE_SUPPORTED="\u2603" +if [[ -n $(echo '\u2603' 2>/dev/null) ]]; then + MULTIBYTE_SUPPORTED="\u2603" fi -if [[ -n $MULTIBYTE_SUPPORTED ]] then - UNSTAGED_CHARACTER="\ue168" - CHANGES_CHARACTER="\ue16b" - UNTRACKED_CHARACTER="\ue16c" - BRANCH_CHARACTER="\ue822" - DETACHED_CHARACTER="\ue899" - REVISION_CHARACTER="\ue821" - FAILED_CHARACTER="\ue125" - SUCCESS_CHARACTER="\ue124" - SUPERUSER_CHARACTER="\ue22b" - JOBS_CHARACTER="\ue12a" - NO_JOBS_CHARACTER="\u2022" - AHEAD_CHARACTER="\ue174 " - BEHIND_CHARACTER="\ue175 " - ACTIONS_CHARACTER="\ue831" - SEGMENT_SEPARATOR_FORWARD="\ue0b0" - SEGMENT_SEPARATOR_BACKWARD="\ue0b2" +if [[ -n $MULTIBYTE_SUPPORTED ]]; then + UNSTAGED_CHARACTER="\ue168" + CHANGES_CHARACTER="\ue16b" + UNTRACKED_CHARACTER="\ue16c" + BRANCH_CHARACTER="\ue822" + DETACHED_CHARACTER="\ue899" + REVISION_CHARACTER="\ue821" + FAILED_CHARACTER="\ue125" + SUCCESS_CHARACTER="\ue124" + SUPERUSER_CHARACTER="\ue22b" + JOBS_CHARACTER="\ue12a" + NO_JOBS_CHARACTER="\u2022" + AHEAD_CHARACTER="\ue174 " + BEHIND_CHARACTER="\ue175 " + ACTIONS_CHARACTER="\ue831" + SEGMENT_SEPARATOR_FORWARD="\ue0b0" + SEGMENT_SEPARATOR_BACKWARD="\ue0b2" else - UNSTAGED_CHARACTER="!" - CHANGES_CHARACTER="*" - UNTRACKED_CHARACTER="?" - BRANCH_CHARACTER="~" - DETACHED_CHARACTER="%" - REVISION_CHARACTER="r" - FAILED_CHARACTER="X" - SUCCESS_CHARACTER="V" - SUPERUSER_CHARACTER="#" - JOBS_CHARACTER="O" - NO_JOBS_CHARACTER="." - AHEAD_CHARACTER="+" - BEHIND_CHARACTER="-" - ACTIONS_CHARACTER="!" - SEGMENT_SEPARATOR_FORWARD="" - SEGMENT_SEPARATOR_BACKWARD="" + UNSTAGED_CHARACTER="!" + CHANGES_CHARACTER="*" + UNTRACKED_CHARACTER="?" + BRANCH_CHARACTER="~" + DETACHED_CHARACTER="%" + REVISION_CHARACTER="r" + FAILED_CHARACTER="X" + SUCCESS_CHARACTER="V" + SUPERUSER_CHARACTER="#" + JOBS_CHARACTER="O" + NO_JOBS_CHARACTER="." + AHEAD_CHARACTER="+" + BEHIND_CHARACTER="-" + ACTIONS_CHARACTER="!" + SEGMENT_SEPARATOR_FORWARD="" + SEGMENT_SEPARATOR_BACKWARD="" fi - #---------------------------------- Helpers ----------------------------------- # Search file up in directory tree. Either print path to found file or nothing -find_up () { - path=$(pwd) - while [[ "$path" != "" ]]; do - if [[ -e "$path/$1" ]]; then - echo "$path/$1" - return; - fi - path=${path%/*} - done +find_up() { + path=$(pwd) + while [[ "$path" != "" ]]; do + if [[ -e "$path/$1" ]]; then + echo "$path/$1" + return + fi + path=${path%/*} + done } -command-exists () { - return $(command -v $1 >/dev/null); +command-exists() { + return $(command -v $1 >/dev/null) } NEWLINE=$'\n' ZDOTDIR=${ZDOTDIR:-$HOME/.zsh} @@ -79,22 +78,22 @@ ZDOTDIR=${ZDOTDIR:-$HOME/.zsh} #---------------------------------- Listings ---------------------------------- if command-exists dircolors; then - eval "$(dircolors -b)" + eval "$(dircolors -b)" fi if command-exists exa; then - alias ls='exa --git --long --all --time-style long-iso' + alias ls='exa --git --long --all --time-style long-iso' else - LSOPTS="-lAvF --color=auto" # long mode, show all, natural sort, type squiggles, friendly sizes - alias ls="ls $LSOPTS" -fi; + LSOPTS="-lAvF --color=auto" # long mode, show all, natural sort, type squiggles, friendly sizes + alias ls="ls $LSOPTS" +fi #---------------------------------- Tab completion ---------------------------- # Force a reload of completion system if nothing matched; this fixes installing # a program and then trying to tab-complete its name _force_rehash() { - (( CURRENT == 1 )) && rehash - return 1 # Because we didn't really complete anything + ((CURRENT == 1)) && rehash + return 1 # Because we didn't really complete anything } # Always use menu completion, and make the colors pretty! @@ -171,21 +170,21 @@ autoload predict-off zle -N predict-on zle -N predict-off bindkey "^Z" predict-on # C-z -bindkey "^X^Z" predict-off # C-x C-z +bindkey "^X^Z" predict-off # C-x C-z #---------------------------------- History ----------------------------------- -setopt append_history # Allow multiple terminal sessions to all append to one zsh command history -setopt extended_history # save timestamp of command and duration -setopt inc_append_history # Add comamnds as they are typed, don't wait until shell exit +setopt append_history # Allow multiple terminal sessions to all append to one zsh command history +setopt extended_history # save timestamp of command and duration +setopt inc_append_history # Add comamnds as they are typed, don't wait until shell exit setopt hist_expire_dups_first # when trimming history, lose oldest duplicates first -setopt hist_ignore_dups # Do not write events to history that are duplicates of previous events -setopt hist_ignore_space # remove command line from history list when first character on the line is a space -setopt hist_find_no_dups # When searching history don't display results already cycled through twice -setopt hist_reduce_blanks # Remove extra blanks from each command line being added to history -setopt hist_verify # don't execute, just expand history -setopt share_history # imports new commands and appends typed commands to history -setopt hist_no_store # remove the history (fc -l) command from the history when invoked. +setopt hist_ignore_dups # Do not write events to history that are duplicates of previous events +setopt hist_ignore_space # remove command line from history list when first character on the line is a space +setopt hist_find_no_dups # When searching history don't display results already cycled through twice +setopt hist_reduce_blanks # Remove extra blanks from each command line being added to history +setopt hist_verify # don't execute, just expand history +setopt share_history # imports new commands and appends typed commands to history +setopt hist_no_store # remove the history (fc -l) command from the history when invoked. export HISTFILE=~/.zsh_history export HISTSIZE=1000000 @@ -198,38 +197,38 @@ export SAVEHIST=1000000 CURRENT_BG='NONE' prompt_segment() { - local direction newbg newfg text - direction="$1" - newbg="$2" - newfg="$3" - text="$4" - if [[ -z $text ]]; then return; fi - if [[ $newbg != $CURRENT_BG ]]; then - if [[ "$direction" == 'forward' ]]; then - if [[ $CURRENT_BG != 'NONE' ]]; then - print -n "%{%K{$newbg}%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR_FORWARD%{%F{$newfg}%}" - else - print -n "%{%K{$newbg}%F{$newfg}%}" + local direction newbg newfg text + direction="$1" + newbg="$2" + newfg="$3" + text="$4" + if [[ -z $text ]]; then return; fi + if [[ $newbg != $CURRENT_BG ]]; then + if [[ "$direction" == 'forward' ]]; then + if [[ $CURRENT_BG != 'NONE' ]]; then + print -n "%{%K{$newbg}%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR_FORWARD%{%F{$newfg}%}" + else + print -n "%{%K{$newbg}%F{$newfg}%}" + fi + else + print -n "%{%F{$newbg}%}$SEGMENT_SEPARATOR_BACKWARD%{%F{$newfg}%K{$newbg}%}" fi - else - print -n "%{%F{$newbg}%}$SEGMENT_SEPARATOR_BACKWARD%{%F{$newfg}%K{$newbg}%}" fi - fi - print -n " $text " - CURRENT_BG=$newbg + print -n " $text " + CURRENT_BG=$newbg } # End the prompt, closing any open segments prompt_end() { - if [[ -n $CURRENT_BG ]]; then - print -n "%{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR_FORWARD" - fi - CURRENT_BG='' + if [[ -n $CURRENT_BG ]]; then + print -n "%{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR_FORWARD" + fi + CURRENT_BG='' } prompt_clear() { - print -n "%{%k%f%}" - CURRENT_BG='' + print -n "%{%k%f%}" + CURRENT_BG='' } ### Prompt components @@ -237,99 +236,98 @@ prompt_clear() { # Root privileges prompt_root() { - if [[ $UID -eq 0 ]]; then - print -n $SUPERUSER_CHARACTER - fi + if [[ $UID -eq 0 ]]; then + print -n $SUPERUSER_CHARACTER + fi } # Different username prompt_user() { - local user=$USER - if command-exists whoami && [[ -z $user ]] then - user=$(whoami) - fi - if [[ "$user" != "$DEFAULT_USER" && $UID -ne 0 ]]; then - print -n $user - fi + local user=$USER + if command-exists whoami && [[ -z $user ]]; then + user=$(whoami) + fi + if [[ "$user" != "$DEFAULT_USER" && $UID -ne 0 ]]; then + print -n $user + fi } # Different host prompt_host() { - if [[ -n "$SSH_CONNECTION" ]]; then - print -n "%m" - fi + if [[ -n "$SSH_CONNECTION" ]]; then + print -n "%m" + fi } # Makefile exists prompt_makefile() { - if [[ -f Makefile ]]; then - print -n "make" - fi + if [[ -f Makefile ]]; then + print -n "make" + fi } - # Status: # - was there an error # - are there background jobs? prompt_status() { - local symbols - symbols=() - if [[ $LAST_RETURN_VALUE -ne 0 ]]; then - symbols+="%{%F{red}%}$FAILED_CHARACTER%{%f%}" - else - symbols+="%{%F{green}%}$SUCCESS_CHARACTER%{%f%}" - fi - if [[ $(jobs -l) ]]; then - symbols+="%{%F{cyan}%}$JOBS_CHARACTER%{%f%}" - else - symbols+="%{%F{white}%}$NO_JOBS_CHARACTER%{%f%}" - fi - echo "$symbols" + local symbols + symbols=() + if [[ $LAST_RETURN_VALUE -ne 0 ]]; then + symbols+="%{%F{red}%}$FAILED_CHARACTER%{%f%}" + else + symbols+="%{%F{green}%}$SUCCESS_CHARACTER%{%f%}" + fi + if [[ $(jobs -l) ]]; then + symbols+="%{%F{cyan}%}$JOBS_CHARACTER%{%f%}" + else + symbols+="%{%F{white}%}$NO_JOBS_CHARACTER%{%f%}" + fi + echo "$symbols" } ## Main prompt prompt_forward() { - CURRENT_BG='NONE' - prompt_segment forward black default "$(prompt_status)" - prompt_segment forward red yellow "$(prompt_root)" - prompt_segment forward magenta black "$(prompt_user)" - prompt_segment forward cyan black "$(prompt_host)" - prompt_segment forward blue black '%~' # prompt directory - prompt_end - prompt_clear + CURRENT_BG='NONE' + prompt_segment forward black default "$(prompt_status)" + prompt_segment forward red yellow "$(prompt_root)" + prompt_segment forward magenta black "$(prompt_user)" + prompt_segment forward cyan black "$(prompt_host)" + prompt_segment forward blue black '%~' # prompt directory + prompt_end + prompt_clear } ## Reverse prompt prompt_backward() { - CURRENT_BG='NONE' - prompt_segment backward magenta black "$MAVEN_PROJECT" # prompt maven project - prompt_segment backward cyan black "$PACKAGE_JSON_PROJECT" # prompt package.json project - prompt_segment backward cyan black "$(prompt_makefile)" - prompt_segment backward yellow black "$vcs_info_msg_0_" # prompt vcs - prompt_segment backward green black "%T" # prompt time - prompt_clear + CURRENT_BG='NONE' + prompt_segment backward magenta black "$MAVEN_PROJECT" # prompt maven project + prompt_segment backward cyan black "$PACKAGE_JSON_PROJECT" # prompt package.json project + prompt_segment backward cyan black "$(prompt_makefile)" + prompt_segment backward yellow black "$vcs_info_msg_0_" # prompt vcs + prompt_segment backward green black "%T" # prompt time + prompt_clear } prompt2_forward() { - CURRENT_BG='NONE' - prompt_segment forward black default "$(prompt_status)" - prompt_segment forward red yellow "$(prompt_root)" - prompt_segment forward magenta black "$(prompt_user)" - prompt_segment forward cyan black "$(prompt_host)" - prompt_segment forward blue black '%~' # prompt directory - prompt_segment forward red black '%_' # unmatched quote - prompt_end - prompt_clear + CURRENT_BG='NONE' + prompt_segment forward black default "$(prompt_status)" + prompt_segment forward red yellow "$(prompt_root)" + prompt_segment forward magenta black "$(prompt_user)" + prompt_segment forward cyan black "$(prompt_host)" + prompt_segment forward blue black '%~' # prompt directory + prompt_segment forward red black '%_' # unmatched quote + prompt_end + prompt_clear } prompt_precmd() { - vcs_info - PROMPT="%{%f%b%k%}$(prompt_forward) " - PS="$PROMPT" - PS2="%{%f%b%k%}$(prompt2_forward) " - RPROMPT="%{%f%b%k%}$(prompt_backward)" - PRS="$RPROMPT" - SPROMPT="Correct %{%F{red}%}%R%{%f%} to %{%F{green}%}%r%f? [%Uy%ues|%Un%uo|%Ua%ubort|%Ue%udit] " + vcs_info + PROMPT="%{%f%b%k%}$(prompt_forward) " + PS="$PROMPT" + PS2="%{%f%b%k%}$(prompt2_forward) " + RPROMPT="%{%f%b%k%}$(prompt_backward)" + PRS="$RPROMPT" + SPROMPT="Correct %{%F{red}%}%R%{%f%} to %{%F{green}%}%r%f? [%Uy%ues|%Un%uo|%Ua%ubort|%Ue%udit] " } ZLE_RPROMPT_INDENT=1 @@ -361,70 +359,69 @@ zstyle ':vcs_info:git*' stagedstr " $CHANGES_CHARACTER" zstyle ':vcs_info:git*+set-message:*' hooks git-additional function +vi-git-additional() { - local ahead behind - local -a branchstatus - ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l) - (( $ahead )) && branchstatus+=( " $AHEAD_CHARACTER${ahead}" ) - behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l) - (( $behind )) && branchstatus+=( " $BEHIND_CHARACTER${behind}" ) - hook_com[misc]="${(j::)branchstatus}" - if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' && \ - -n $(git status --porcelain | grep -E '^\?\?' 2> /dev/null | tail -n1) ]]; then - hook_com[unstaged]+=" $UNTRACKED_CHARACTER" - fi + local ahead behind + local -a branchstatus + ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l) + (($ahead)) && branchstatus+=(" $AHEAD_CHARACTER${ahead}") + behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l) + (($behind)) && branchstatus+=(" $BEHIND_CHARACTER${behind}") + hook_com[misc]="${(j::)branchstatus}" + if [[ $(git rev-parse --is-inside-work-tree 2>/dev/null) == 'true' && + -n $(git status --porcelain | grep -E '^\?\?' 2>/dev/null | tail -n1) ]]; then + hook_com[unstaged]+=" $UNTRACKED_CHARACTER" + fi } #---------------------------------- Screen ------------------------------------ function title { - # param: title to use + # param: title to use - local prefix='' + local prefix='' - # If I'm in a screen, all the windows are probably on the same machine, so - # I don't really need to title every single one with the machine name. - # On the other hand, if I'm not logged in as me (but, e.g., root), I'd - # certainly like to know that! - if [[ $USER != "$DEFAULT_USER" ]]; then - prefix="[$USER] " - fi - # Set screen window title - if [[ $TERM == "screen"* ]]; then - print -n "\ek$prefix$1\e\\" - fi + # If I'm in a screen, all the windows are probably on the same machine, so + # I don't really need to title every single one with the machine name. + # On the other hand, if I'm not logged in as me (but, e.g., root), I'd + # certainly like to know that! + if [[ $USER != "$DEFAULT_USER" ]]; then + prefix="[$USER] " + fi + # Set screen window title + if [[ $TERM == "screen"* ]]; then + print -n "\ek$prefix$1\e\\" + fi + # Prefix the xterm title with the current machine name, but only if I'm not + # on a local machine. This is tricky, because screen won't reliably know + # whether I'm using SSH right now! So just assume I'm local iff I'm not + # running over SSH *and* not using screen. Local screens are fairly rare. + prefix=$HOST + if [[ $SSH_CONNECTION == '' && $TERM != "screen"* ]]; then + prefix='' + fi + # If we're showing host and not default user prepend it + if [[ $prefix != '' && $USER != "$DEFAULT_USER" ]]; then + prefix="$USER@$prefix" + fi + # Wrap it in brackets + if [[ $prefix != '' ]]; then + prefix="[$prefix] " + fi - # Prefix the xterm title with the current machine name, but only if I'm not - # on a local machine. This is tricky, because screen won't reliably know - # whether I'm using SSH right now! So just assume I'm local iff I'm not - # running over SSH *and* not using screen. Local screens are fairly rare. - prefix=$HOST - if [[ $SSH_CONNECTION == '' && $TERM != "screen"* ]]; then - prefix='' - fi - # If we're showing host and not default user prepend it - if [[ $prefix != '' && $USER != "$DEFAULT_USER" ]]; then - prefix="$USER@$prefix" - fi - # Wrap it in brackets - if [[ $prefix != '' ]]; then - prefix="[$prefix] " - fi - - # Set xterm window title - if [[ $TERM == "xterm"* || $TERM == "screen"* ]]; then - print -n "\e]2;$prefix$1\a" - fi + # Set xterm window title + if [[ $TERM == "xterm"* || $TERM == "screen"* ]]; then + print -n "\e]2;$prefix$1\a" + fi } function title_precmd { - # Shorten homedir back to '~' - local shortpwd=${PWD/$HOME/\~} - title "zsh $shortpwd" + # Shorten homedir back to '~' + local shortpwd=${PWD/$HOME/\~} + title "zsh $shortpwd" } function title_preexec { - title $* + title $* } add-zsh-hook preexec title_preexec @@ -470,21 +467,21 @@ zle -N expand-or-complete-with-indicator bindkey "^I" expand-or-complete-with-indicator bindkey "^r" history-incremental-search-backward -bindkey "\e[Z" reverse-menu-complete # shift-tab to reverse menu +bindkey "\e[Z" reverse-menu-complete # shift-tab to reverse menu # Up/down arrow. # I want shared history for ^R, but I don't want another shell's activity to # mess with up/down. This does that. down-line-or-local-history() { - zle set-local-history 1 - zle down-line-or-history - zle set-local-history 0 + zle set-local-history 1 + zle down-line-or-history + zle set-local-history 0 } zle -N down-line-or-local-history up-line-or-local-history() { - zle set-local-history 1 - zle up-line-or-history - zle set-local-history 0 + zle set-local-history 1 + zle up-line-or-history + zle set-local-history 0 } zle -N up-line-or-local-history @@ -518,15 +515,15 @@ alias bd=". bd -si" #---------------------------------- VIM pager -------------------------------- vim_pager() { - local source_file; + local source_file if [ ! -t 1 ]; then echo "Cannot use vim pager with non-terminal output" 1>&2 return 1 fi if [ $# -gt 0 ]; then - source_file="$@"; + source_file="$@" elif [ ! -t 0 ]; then - source_file="-"; + source_file="-" else echo "Input stream or file name missing" 1>&2 return 2 @@ -543,20 +540,20 @@ maven_read_project() { location=$(find_up pom.xml) if [[ ! -r "$location" || -z $commands[xmllint] ]]; then MAVEN_PROJECT="" - return 1; + return 1 fi # executing xmllint takes some time, so this does it in single execution parts=($(echo "cat /*[local-name()='project']/*[local-name()='artifactId']/text()\n" \ - "cat /*[local-name()='project']/*[local-name()='version']/text()\n" \ - "cat /*[local-name()='project']/*[local-name()='parent']/*[local-name()='version']/text()\n" | \ - xmllint --shell $location 2>/dev/null | \ - sed '/^\/ >/d' | \ + "cat /*[local-name()='project']/*[local-name()='version']/text()\n" \ + "cat /*[local-name()='project']/*[local-name()='parent']/*[local-name()='version']/text()\n" | + xmllint --shell $location 2>/dev/null | + sed '/^\/ >/d' | sed '/^ -------/d')) if [[ "${#parts}" > 1 ]]; then MAVEN_PROJECT="${parts[1]}@${parts[2]}" - else + else MAVEN_PROJECT="pom!" - fi; + fi } add-zsh-hook chpwd maven_read_project @@ -569,31 +566,31 @@ package_json_read_project() { location=$(find_up package.json) if [[ ! -r "$location" || -z $commands[jq] ]]; then PACKAGE_JSON_PROJECT="" - return 1; + return 1 fi PACKAGE_JSON_PROJECT=$(jq -r '.name + "@" + .version' $location) } add-zsh-hook chpwd package_json_read_project -#---------------------------------- Miscellaneous ---------------------------- +#---------------------------------- Miscellaneous ---------------------------- -setopt extended_glob -setopt correct # try to correct the spelling of commands. -setopt correct_all # try to correct the spelling of all arguments in a line. -setopt numeric_glob_sort # if numeric filenames are matched by a filename generation pattern, sort the filenames numerically rather than lexicographically. -setopt nomatch # if there is match on file pattern, dont run command (instead of running command with unchanged parameters) +setopt extended_glob +setopt correct # try to correct the spelling of commands. +setopt correct_all # try to correct the spelling of all arguments in a line. +setopt numeric_glob_sort # if numeric filenames are matched by a filename generation pattern, sort the filenames numerically rather than lexicographically. +setopt nomatch # if there is match on file pattern, dont run command (instead of running command with unchanged parameters) setopt interactive_comments # allow comments in command line -setopt multios # enable multiple input/output redirections that work as expected +setopt multios # enable multiple input/output redirections that work as expected -unsetopt beep # (dont) beep on errors -unsetopt notify # (dont) report the status of background jobs immediately, rather than waiting until just before printing a prompt. -unsetopt auto_cd # (dont) enter the directory that was inputed as command +unsetopt beep # (dont) beep on errors +unsetopt notify # (dont) report the status of background jobs immediately, rather than waiting until just before printing a prompt. +unsetopt auto_cd # (dont) enter the directory that was inputed as command unsetopt auto_remove_slash # (dont) remove last slash when next character is delimiter -unsetopt csh_junkie_quotes # (dont) complain if a quoted expression runs off the end of a line; prevent quoted expressions from containing un-escaped newlines. +unsetopt csh_junkie_quotes # (dont) complain if a quoted expression runs off the end of a line; prevent quoted expressions from containing un-escaped newlines. # Don't count common path separators as word characters -WORDCHARS=${WORDCHARS//[&.;\/]} +WORDCHARS=${WORDCHARS//[&.;\/]/} # Report time if command takes too long REPORTTIME=5 @@ -601,8 +598,9 @@ REPORTTIME=5 TIMEFMT=$(echo "$fg[green]${SEGMENT_SEPARATOR_BACKWARD}$bg[green]$fg[black] %*Es $fg[yellow]$SEGMENT_SEPARATOR_BACKWARD$bg[yellow]$fg[black] %P $reset_color") # Don't glob with commands that expects glob patterns -for command in find wget git; \ - alias $command="noglob $command" +for command in find wget git; do + alias $command="noglob $command" +done # load zsh extended move autoload -Uz zmv @@ -610,17 +608,17 @@ autoload -Uz zmv #---------------------------------- Machine specific -------------------------- if [[ -r $HOME/.zlocal ]]; then - source $HOME/.zlocal + source $HOME/.zlocal fi #---------------------------------- Post Setup -------------------------------- # at last initialize completion autoload -Uz compinit -if [[ -n ${ZDOTDIR}/.zcompdump(#qN.mh+24) ]]; then - compinit +if [[ -n "${ZDOTDIR}/.zcompdump(#qN.mh+24)" ]]; then + compinit else - compinit -C + compinit -C fi store_last_return_value() { @@ -634,19 +632,19 @@ precmd_functions=(store_last_return_value $precmd_functions) # If kubectl is present, load completions from it. # This must be done after compinit was called if [[ $commands[kubectl] ]]; then - source <(kubectl completion zsh); + source <(kubectl completion zsh) fi # If k3s is present, load completions from it. # This must be done after compinit was called if [[ $commands[k3s] ]]; then - source <(k3s completion zsh); + source <(k3s completion zsh) fi # If minikube is present, load completions from it. # This must be done after compinit was called if [[ $commands[minikube] ]]; then - source <(minikube completion zsh); + source <(minikube completion zsh) fi zmodload zsh/complist @@ -654,21 +652,20 @@ zmodload zsh/complist #---------------------------------- Partials ------------------------------------ for partial in ${ZDOTDIR}/zsh.d/*.zsh; do - source $partial + source $partial done #---------------------------------- Broot ------------------------------------ function br { - local cmd cmd_file code - cmd_file=$(mktemp) - if broot --outcmd "$cmd_file" "$@"; then - cmd=$(<"$cmd_file") - command rm -f "$cmd_file" - eval "$cmd" - else - code=$? - command rm -f "$cmd_file" - return "$code" - fi + local cmd cmd_file code + cmd_file=$(mktemp) + if broot --outcmd "$cmd_file" "$@"; then + cmd=$(<"$cmd_file") + command rm -f "$cmd_file" + eval "$cmd" + else + code=$? + command rm -f "$cmd_file" + return "$code" + fi } -