dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit 5362a88f732fcfef04b94fbab42683b3f89718aa
parent 46a822ea43aa897e1c68a5c66c387f39ca40cb54
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Wed, 28 Aug 2019 12:10:03 +0200

Use tabs for indentation

Diffstat:
M.zshrc | 154+++++++++++++++++++++++++++++++++++++------------------------------------------
1 file changed, 73 insertions(+), 81 deletions(-)

diff --git a/.zshrc b/.zshrc @@ -61,56 +61,56 @@ bindkey '^_' autosuggest-execute # use Ctrl-Z as fg _foreground() { - if [[ $#BUFFER -eq 0 ]]; then - BUFFER="fg" - zle accept-line - else - zle push-input - zle clear-screen - fi + if [[ $#BUFFER -eq 0 ]]; then + BUFFER="fg" + zle accept-line + else + zle push-input + zle clear-screen + fi } zle -N _foreground bindkey '^Z' _foreground # launch $EDITOR with Ctrl-e _editor() { - BUFFER="$EDITOR" - zle accept-line + BUFFER="$EDITOR" + zle accept-line } zle -N _editor bindkey '^e' _editor # launch $EDITOR+fzf with Ctrl-f _editor_fuzzy_find() { - #BUFFER="$EDITOR -c ':fzf'" # (n)vim - BUFFER="$EDITOR +':fzf'" # vis - zle accept-line + #BUFFER="$EDITOR -c ':fzf'" # (n)vim + BUFFER="$EDITOR +':fzf'" # vis + zle accept-line } zle -N _editor_fuzzy_find bindkey '^f' _editor_fuzzy_find # launch $EDITOR+fzf for recent files with Ctrl-o _editor_fuzzy_history() { - #BUFFER="$EDITOR -c ':History'" # (n)vim - BUFFER="$EDITOR +':fzfmru'" # vis - zle accept-line + #BUFFER="$EDITOR -c ':History'" # (n)vim + BUFFER="$EDITOR +':fzfmru'" # vis + zle accept-line } zle -N _editor_fuzzy_history bindkey '^o' _editor_fuzzy_history # launch $EDITOR+fzf+rg with Ctrl-g _editor_fuzzy_grep() { - #BUFFER="$EDITOR -c ':Rg'" # (n)vim - BUFFER="$EDITOR +':Rg'" # vis - zle accept-line + #BUFFER="$EDITOR -c ':Rg'" # (n)vim + BUFFER="$EDITOR +':Rg'" # vis + zle accept-line } zle -N _editor_fuzzy_grep bindkey '^g' _editor_fuzzy_grep # launch $TERMINAL with Alt-p _terminal() { - BUFFER="setsid $TERMINAL >/dev/null 2>&1" - zle accept-line + BUFFER="setsid $TERMINAL >/dev/null 2>&1" + zle accept-line } zle -N _terminal bindkey '\ep' _terminal @@ -126,77 +126,70 @@ alias zsy='noglob zmv -Ls' # show execution time of previous command if more than 1 sec convertsecs() { - ((d=${1}/3600/24)) - ((h=${1}/3600%24)) - ((m=(${1}%3600)/60)) - ((s=${1}%60)) - if [ "$d" -gt "0" ]; then - printf " %dd%02dh%02dm%02ds" $d $h $m $s - elif [ "$h" -gt "0" ]; then - printf " %dh%02dm%02ds" $h $m $s - elif [ "$m" -gt "0" ]; then - printf " %dm%02ds" $m $s - elif [ "$s" -gt "0" ]; then - printf " %ds" $s - fi + ((d=${1}/3600/24)) + ((h=${1}/3600%24)) + ((m=(${1}%3600)/60)) + ((s=${1}%60)) + if [ "$d" -gt "0" ]; then + printf " %dd%02dh%02dm%02ds" $d $h $m $s + elif [ "$h" -gt "0" ]; then + printf " %dh%02dm%02ds" $h $m $s + elif [ "$m" -gt "0" ]; then + printf " %dm%02ds" $m $s + elif [ "$s" -gt "0" ]; then + printf " %ds" $s + fi } preexec() { - timer=${timer:-$SECONDS} + timer=${timer:-$SECONDS} } precmd() { - if [ $timer ]; then - timer_show=$(convertsecs $(($SECONDS - $timer))) - export EXECTIME="${timer_show}" - unset timer - fi + if [ $timer ]; then + timer_show=$(convertsecs $(($SECONDS - $timer))) + export EXECTIME="${timer_show}" + unset timer + fi } _fix_cursor() { - echo -ne '\e[5 q' + echo -ne '\e[5 q' } precmd_functions+=(_fix_cursor) git_branch() { - branch_name=$(git symbolic-ref --short HEAD 2> /dev/null) - - if [ -n "$branch_name" ] - then - echo "$branch_name$(git_modified) " - fi + branch_name=$(git symbolic-ref --short HEAD 2> /dev/null) + [ -n "$branch_name" ] && echo "$branch_name$(git_modified) " || : } git_grep_modified_files() { - grep -e "^.M" -e "^M." -e "^A." -e "^D." -e "^.D" + grep -e "^.M" -e "^M." -e "^A." -e "^D." -e "^.D" } git_modified() { - if [ -n "$(git status --porcelain 2> /dev/null | git_grep_modified_files)" ] - then - echo "*" - fi + [ -n "$(git status --porcelain 2> /dev/null | \ + git_grep_modified_files)" ] && echo "*" || : } function prompt_with_vimode { - #echo -e "\a" - echo - echo -n '%(1j.%jbg .)' # background jobs - echo -n "$1" - [ -z "$1" ] && # show prompt symbol if no insert/normal mode is passed - echo -n '%(!.%{$fg_bold[red]%}#.$)' - echo -n '%{$reset_color%} ' + echo + echo -n '%(1j.%jbg .)' # background jobs + echo -n "$1" + [ -z "$1" ] && # show prompt symbol if no insert/normal mode is passed + echo -n '%(!.%{$fg_bold[red]%}#.$)' || : + echo -n '%{$reset_color%} ' } insert_mode='' normal_mode='N' # normal mode indicator rprompt() { - echo -n "%(?..%{$fg[red]%}[%?]%{$reset_color%})" # return status - echo -n "${EXECTIME} " # runtime of prev cmd - echo -n "%{$fg[cyan]%}$(git_branch)%{$reset_color%}" # git branch - echo -n "%~ " # pwd - [ "$USER" != "ad" ] && echo -n "%n@" || : - [ "$HOST" != "idkfa" ] && echo -n "%m" || : + echo -n "%(?..%{$fg[red]%}[%?]%{$reset_color%})" # return status + echo -n "${EXECTIME} " # runtime of prev cmd + echo -n "%{$fg[cyan]%}$(git_branch)%{$reset_color%}" # git branch + echo -n "%~ " # pwd + [ "$USER" != "ad" ] && echo -n "%n@" || : + [ "$HOST" != "idkfa" ] && echo -n "%m" || : } set_prompt() { @@ -206,23 +199,22 @@ set_prompt() { add-zsh-hook precmd set_prompt function zle-keymap-select { - if [[ ${KEYMAP} == vicmd ]] || [[ $1 = 'block' ]]; then - echo -ne '\e[1 q' - - elif [[ ${KEYMAP} == main ]] || [[ ${KEYMAP} == viins ]] || - [[ ${KEYMAP} = '' ]] || [[ $1 = 'beam' ]]; then - echo -ne '\e[5 q' - fi + if [[ ${KEYMAP} == vicmd ]] || [[ $1 = 'block' ]]; then + echo -ne '\e[1 q' + elif [[ ${KEYMAP} == main ]] || [[ ${KEYMAP} == viins ]] || + [[ ${KEYMAP} = '' ]] || [[ $1 = 'beam' ]]; then + echo -ne '\e[5 q' + fi } zle -N zle-keymap-select #### PLUGINS if [ -f "$HOME/.config/fffs/lib/zsh/sources" ]; then - . "$HOME/.config/fffs/lib/zsh/sources" + . "$HOME/.config/fffs/lib/zsh/sources" else - fffs zsh init - . "$HOME/.config/fffs/lib/zsh/sources" + fffs zsh init + . "$HOME/.config/fffs/lib/zsh/sources" fi @@ -230,13 +222,13 @@ fi # pass **<tab> _fzf_complete_pass() { - _fzf_complete "--no-multi --preview-window=right:hidden" "$@" < <( - pwdir=${PASSWORD_STORE_DIR-~/.password-store/} - stringsize="${#pwdir}" - find "$pwdir" -name "*.gpg" -print | - cut -c "$((stringsize + 1))"- | - sed -e 's/\(.*\)\.gpg/\1/' - ) + _fzf_complete "--no-multi --preview-window=right:hidden" "$@" < <( + pwdir=${PASSWORD_STORE_DIR-~/.password-store/} + stringsize="${#pwdir}" + find "$pwdir" -name "*.gpg" -print | + cut -c "$((stringsize + 1))"- | + sed -e 's/\(.*\)\.gpg/\1/' + ) } . ~/.commands.sh