dotfiles

config files and scripts
git clone git://git.hanetzok.net/dotfiles
Log | Files | Refs

.zshrc (2774B)


      1 # Luke's config for the Zoomer Shell
      2 
      3 # Enable colors and change prompt:
      4 autoload -U colors && colors	# Load colors
      5 PS1="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~%{$fg[red]%}]%{$reset_color%}$%b "
      6 setopt autocd		# Automatically cd into typed directory.
      7 stty stop undef		# Disable ctrl-s to freeze terminal.
      8 setopt interactive_comments
      9 
     10 # History in cache directory:
     11 HISTSIZE=10000000
     12 SAVEHIST=10000000
     13 HISTFILE="${XDG_CACHE_HOME:-$HOME/.cache}/zsh/history"
     14 setopt inc_append_history
     15 
     16 # Load aliases and shortcuts if existent.
     17 [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc"
     18 [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutenvrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutenvrc"
     19 [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc"
     20 [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc"
     21 
     22 # Basic auto/tab complete:
     23 autoload -U compinit
     24 zstyle ':completion:*' menu select
     25 zmodload zsh/complist
     26 compinit
     27 _comp_options+=(globdots)		# Include hidden files.
     28 
     29 # vi mode
     30 bindkey -v
     31 export KEYTIMEOUT=1
     32 
     33 # Use vim keys in tab complete menu:
     34 bindkey -M menuselect 'h' vi-backward-char
     35 bindkey -M menuselect 'k' vi-up-line-or-history
     36 bindkey -M menuselect 'l' vi-forward-char
     37 bindkey -M menuselect 'j' vi-down-line-or-history
     38 bindkey -v '^?' backward-delete-char
     39 
     40 # Change cursor shape for different vi modes.
     41 function zle-keymap-select () {
     42     case $KEYMAP in
     43         vicmd) echo -ne '\e[1 q';;      # block
     44         viins|main) echo -ne '\e[5 q';; # beam
     45     esac
     46 }
     47 zle -N zle-keymap-select
     48 zle-line-init() {
     49     zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere)
     50     echo -ne "\e[5 q"
     51 }
     52 zle -N zle-line-init
     53 echo -ne '\e[5 q' # Use beam shape cursor on startup.
     54 preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt.
     55 
     56 # Use lf to switch directories and bind it to ctrl-o
     57 lfcd () {
     58     tmp="$(mktemp -uq)"
     59     trap 'rm -f $tmp >/dev/null 2>&1 && trap - HUP INT QUIT TERM PWR EXIT' HUP INT QUIT TERM PWR EXIT
     60     lf -last-dir-path="$tmp" "$@"
     61     if [ -f "$tmp" ]; then
     62         dir="$(cat "$tmp")"
     63         [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
     64     fi
     65 }
     66 bindkey -s '^o' '^ulfcd\n'
     67 
     68 bindkey -s '^a' '^ubc -lq\n'
     69 
     70 bindkey -s '^f' '^ucd "$(dirname "$(fzf)")"\n'
     71 
     72 bindkey '^[[P' delete-char
     73 
     74 # Edit line in vim with ctrl-e:
     75 autoload edit-command-line; zle -N edit-command-line
     76 bindkey '^e' edit-command-line
     77 bindkey -M vicmd '^[[P' vi-delete-char
     78 bindkey -M vicmd '^e' edit-command-line
     79 bindkey -M visual '^[[P' vi-delete