My zsh configuration
git clone https://github.com/m-col/zshrc
Files | Refs | Readme

Commit 897bd71badcffd05c7d776c11d42666d1add1d54
Parent: 
Author: mcol <mcol@posteo.net>
Date: 2019-02-09 00:21:39 +0000
Committer: mcol <mcol@posteo.net>
Committed: 2019-02-09 00:21:39 +0000

commit with working setup

zshrc Added

@@ -0,0 +1,37 @@
+#
+# zshrc
+#
+
+
+ZSH="$HOME/.zsh"
+HYPHEN_INSENSITIVE="true"
+COMPLETION_WAITING_DOTS="true"
+ZSH_COMPDUMP="$HOME/.zcompdump"
+HISTFILE="$HOME/.zsh_history"
+bindkey '^A' autosuggest-execute
+
+for plugin ($ZSH/*.zsh)
+do
+    source $plugin
+done
+
+
+so () { [[ -e $1 ]] && source $1 }
+
+so $ZSH/aliases	    # general aliases
+so $HOME/.aliases   # machine-specific aliases
+
+ZSH_THEME="ban"
+so $ZSH/themes/$ZSH_THEME.zsh-theme
+
+_Z_DATA=$HOME/.config/z
+so $ZSH/z/z.sh
+
+ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)
+so $ZSH/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
+
+
+# Ensure that the prompt is redrawn when the terminal size changes.
+TRAPWINCH () {
+    zle &&  zle -R
+}

zsh-autosuggestions.zsh Added

@@ -0,0 +1,78 @@
+# -------------------------------------------------#
+# https://github.com/zsh-users/zsh-autosuggestions #
+# -------------------------------------------------#
+
+if [[ -e $ZSH/zsh-autosuggestions/zsh-autosuggestions.zsh ]]
+then
+    source $ZSH/zsh-autosuggestions/zsh-autosuggestions.zsh
+else
+    return
+fi
+
+# Color to use when highlighting suggestion
+# Uses format of `region_highlight`
+# More info: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Widgets
+ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8'
+
+# Prefix to use when saving original versions of bound widgets
+ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig-
+
+#ZSH_AUTOSUGGEST_STRATEGY=default
+ZSH_AUTOSUGGEST_STRATEGY=match_prev_cmd
+
+# Widgets that clear the suggestion
+ZSH_AUTOSUGGEST_CLEAR_WIDGETS=(
+	history-search-forward
+	history-search-backward
+	history-beginning-search-forward
+	history-beginning-search-backward
+	history-substring-search-up
+	history-substring-search-down
+	up-line-or-beginning-search
+	down-line-or-beginning-search
+	up-line-or-history
+	down-line-or-history
+	accept-line
+)
+
+# Widgets that accept the entire suggestion
+ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=(
+	forward-char
+	end-of-line
+	vi-forward-char
+	vi-end-of-line
+	vi-add-eol
+)
+
+# Widgets that accept the entire suggestion and execute it
+ZSH_AUTOSUGGEST_EXECUTE_WIDGETS=(
+)
+
+# Widgets that accept the suggestion as far as the cursor moves
+ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS=(
+	forward-word
+	emacs-forward-word
+	vi-forward-word
+	vi-forward-word-end
+	vi-forward-blank-word
+	vi-forward-blank-word-end
+	vi-find-next-char
+	vi-find-next-char-skip
+)
+
+# Widgets that should be ignored (globbing supported but must be escaped)
+ZSH_AUTOSUGGEST_IGNORE_WIDGETS=(
+	orig-\*
+	beep
+	run-help
+	set-local-history
+	which-command
+	yank
+	yank-pop
+)
+
+# Max size of buffer to trigger autosuggestion. Leave undefined for no upper bound.
+ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=
+
+# Pty name for calculating autosuggestions asynchronously
+ZSH_AUTOSUGGEST_ASYNC_PTY_NAME=zsh_autosuggest_pty

themes/simple2.zsh-theme Added

@@ -0,0 +1,6 @@
+PROMPT='%(!.%{$fg[red]%}.%{$fg[green]%})%~%{$fg_bold[blue]%}$(git_prompt_info)%{$reset_color%} '
+
+ZSH_THEME_GIT_PROMPT_PREFIX="("
+ZSH_THEME_GIT_PROMPT_SUFFIX=")"
+ZSH_THEME_GIT_PROMPT_DIRTY=" √"
+ZSH_THEME_GIT_PROMPT_CLEAN=" x"

themes/ban.zsh-theme Added

@@ -0,0 +1,193 @@
+### Segment drawing
+# A few utility functions to make it easy and re-usable to draw segmented prompts
+
+CURRENT_BG='NONE'
+
+# Special Powerline characters
+
+() {
+  local LC_ALL="" LC_CTYPE="en_US.UTF-8"
+  # NOTE: This segment separator character is correct.  In 2012, Powerline changed
+  # the code points they use for their special characters. This is the new code point.
+  # If this is not working for you, you probably have an old version of the
+  # Powerline-patched fonts installed. Download and install the new version.
+  # Do not submit PRs to change this unless you have reviewed the Powerline code point
+  # history and have new information.
+  # This is defined using a Unicode escape sequence so it is unambiguously readable, regardless of
+  # what font the user is viewing this source code in. Do not replace the
+  # escape sequence with a single literal character.
+  # Do not change this! Do not make it '\u2b80'; that is the old, wrong code point.
+  #SEGMENT_SEPARATOR=$'\ue0b0'
+  SEGMENT_SEPARATOR=$''
+}
+
+# Begin a segment
+# Takes two arguments, background and foreground. Both can be omitted,
+# rendering default background/foreground.
+prompt_segment() {
+  local bg fg
+  [[ -n $1 ]] && bg="%K{$1}" || bg="%k"
+  [[ -n $2 ]] && fg="%F{$2}" || fg="%f"
+  if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then
+    echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} "
+  else
+    echo -n "%{$bg%}%{$fg%} "
+  fi
+  CURRENT_BG=$1
+  [[ -n $3 ]] && echo -n $3
+}
+
+# End the prompt, closing any open segments
+prompt_end() {
+  if [[ -n $CURRENT_BG ]]; then
+    echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR"
+  else
+    echo -n "%{%k%}"
+  fi
+  echo -n "%{%f%}"
+  CURRENT_BG=''
+}
+
+prompt_context() {
+  if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
+    prompt_segment black default "%(!.%{%F{yellow}%}.)$USER"
+  fi
+}
+
+prompt_git() {
+  (( $+commands[git] )) || return
+  local PL_BRANCH_CHAR
+  () {
+    local LC_ALL="" LC_CTYPE="en_US.UTF-8"
+    #PL_BRANCH_CHAR=$'\ue0a0'         # 
+    PL_BRANCH_CHAR=$''
+  }
+  local ref dirty mode repo_path
+  repo_path=$(git rev-parse --git-dir 2>/dev/null)
+
+  if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
+    dirty=$(parse_git_dirty)
+    ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)"
+    if [[ -n $dirty ]]; then
+      prompt_segment yellow black
+    else
+      prompt_segment green black
+    fi
+
+    if [[ -e "${repo_path}/BISECT_LOG" ]]; then
+      mode=" <B>"
+    elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then
+      mode=" >M<"
+    elif [[ -e "${repo_path}/rebase" || -e "${repo_path}/rebase-apply" || -e "${repo_path}/rebase-merge" || -e "${repo_path}/../.dotest" ]]; then
+      mode=" >R>"
+    fi
+
+    setopt promptsubst
+    autoload -Uz vcs_info
+
+    zstyle ':vcs_info:*' enable git
+    zstyle ':vcs_info:*' get-revision true
+    zstyle ':vcs_info:*' check-for-changes true
+    zstyle ':vcs_info:*' stagedstr '+'
+    zstyle ':vcs_info:*' unstagedstr '**'
+    zstyle ':vcs_info:*' formats ' %u%c'
+    zstyle ':vcs_info:*' actionformats ' %u%c'
+    vcs_info
+    echo -n "${ref/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}"
+  fi
+}
+
+# Dir: current working directory
+prompt_dir() {
+  prompt_segment magenta black '%3~'
+}
+
+prompt_mes() {
+  [[ $RETVAL -ne 0 ]] && prompt_segment red black '>'
+  [[ $RETVAL -eq 0 ]] && prompt_segment blue black '>'
+}
+
+# Virtualenv: current working virtualenv
+prompt_virtualenv() {
+  local virtualenv_path="$VIRTUAL_ENV"
+  if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then
+    prompt_segment red black "(`basename $virtualenv_path`)"
+  fi
+}
+
+prompt_status() {
+  local symbols
+  symbols=()
+  [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}x"
+  [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡"
+  [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙"
+
+  [[ -n "$symbols" ]] && prompt_segment black default "$symbols"
+}
+
+
+##### vi mode
+VIM_PROMPT="--INSERT--"
+export KEYTIMEOUT=1
+bindkey -v
+prompt_vi(){
+    prompt_segment default white $VIM_PROMPT
+}
+zle-line-init() { zle -K viins; }
+zle -N zle-line-init
+######
+
+## Main left prompt
+build_prompt() {
+  RETVAL=$?
+  prompt_dir
+  prompt_mes
+  prompt_end
+}
+
+build_rprompt() {
+  RETVAL=$?
+  prompt_virtualenv
+  prompt_vi
+  prompt_git
+  prompt_end
+}
+
+PROMPT='%{%f%b%k%}$(build_prompt) '
+RPROMPT='%{%f%b%k%}$(build_rprompt)'
+
+# redraw prompt on mode changes
+zle-keymap-select() {
+    if [ $KEYMAP = vicmd ]; then
+	printf "\033[2 q" # block cursor
+	VIM_PROMPT="-- NORMAL --"
+    else
+	printf "\033[4 q" # underline. Change 4 to 6 for vertical line
+	VIM_PROMPT=""
+    fi
+
+    PROMPT='%{%f%b%k%}$(build_prompt) '
+    RPROMPT='%{%f%b%k%}$(build_rprompt)'
+    zle reset-prompt
+    zle -R
+}
+zle -N zle-keymap-select
+
+#PROMPT='%{$FG[001]%}> %{$reset_color%}'
+#RPROMPT='%{$FG[001]%}%2~ $(git_prompt_info)$(git_prompt_status)%{$reset_color%}'
+
+
+#ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}✗%{$reset_color%}"
+#ZSH_THEME_GIT_PROMPT_PREFIX="("
+#ZSH_THEME_GIT_PROMPT_SUFFIX=")"
+
+#ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[magenta]%}["
+#ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}"
+#ZSH_THEME_GIT_PROMPT_DIRTY=""
+#ZSH_THEME_GIT_PROMPT_CLEAN=""
+#ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[cyan]%}+"
+#ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[yellow]%}*"
+#ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%}x"
+#ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}~"
+#ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[magenta]%}><"
+#ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[white]%}**"

theme-and-appearance.zsh Added

@@ -0,0 +1,55 @@
+# ls colors
+autoload -U colors && colors
+
+# Enable ls colors
+export LSCOLORS="Gxfxcxdxbxegedabagacad"
+
+# TODO organise this chaotic logic
+
+if [[ "$DISABLE_LS_COLORS" != "true" ]]; then
+  # Find the option for using colors in ls, depending on the version
+  if [[ "$OSTYPE" == netbsd* ]]; then
+    # On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors);
+    # otherwise, leave ls as is, because NetBSD's ls doesn't support -G
+    gls --color -d . &>/dev/null && alias ls='gls --color=tty'
+  elif [[ "$OSTYPE" == openbsd* ]]; then
+    # On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base,
+    # with color and multibyte support) are available from ports.  "colorls"
+    # will be installed on purpose and can't be pulled in by installing
+    # coreutils, so prefer it to "gls".
+    gls --color -d . &>/dev/null && alias ls='gls --color=tty'
+    colorls -G -d . &>/dev/null && alias ls='colorls -G'
+  elif [[ "$OSTYPE" == darwin* ]]; then
+    # this is a good alias, it works by default just using $LSCOLORS
+    ls -G . &>/dev/null && alias ls='ls -G'
+
+    # only use coreutils ls if there is a dircolors customization present ($LS_COLORS or .dircolors file)
+    # otherwise, gls will use the default color scheme which is ugly af
+    [[ -n "$LS_COLORS" || -f "$HOME/.dircolors" ]] && gls --color -d . &>/dev/null && alias ls='gls --color=tty'
+  else
+    # For GNU ls, we use the default ls color theme. They can later be overwritten by themes.
+    if [[ -z "$LS_COLORS" ]]; then
+      (( $+commands[dircolors] )) && eval "$(dircolors -b)"
+    fi
+
+    ls --color -d . &>/dev/null && alias ls='ls --color=tty' || { ls -G . &>/dev/null && alias ls='ls -G' }
+
+    # Take advantage of $LS_COLORS for completion as well.
+    zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
+  fi
+fi
+
+setopt auto_cd
+setopt multios
+setopt prompt_subst
+
+[[ -n "$WINDOW" ]] && SCREEN_NO="%B$WINDOW%b " || SCREEN_NO=""
+
+# Apply theming defaults
+PS1="%n@%m:%~%# "
+
+# git theming default: Variables for theming the git info prompt
+ZSH_THEME_GIT_PROMPT_PREFIX="git:("         # Prefix at the very beginning of the prompt, before the branch name
+ZSH_THEME_GIT_PROMPT_SUFFIX=")"             # At the very end of the prompt
+ZSH_THEME_GIT_PROMPT_DIRTY="*"              # Text to display if the branch is dirty
+ZSH_THEME_GIT_PROMPT_CLEAN=""               # Text to display if the branch is clean

misc.zsh Added

@@ -0,0 +1,34 @@
+## Load smart urls if available
+# bracketed-paste-magic is known buggy in zsh 5.1.1 (only), so skip it there; see #4434
+autoload -Uz is-at-least
+if [[ $ZSH_VERSION != 5.1.1 ]]; then
+  for d in $fpath; do
+  	if [[ -e "$d/url-quote-magic" ]]; then
+  		if is-at-least 5.1; then
+  			autoload -Uz bracketed-paste-magic
+  			zle -N bracketed-paste bracketed-paste-magic
+  		fi
+  		autoload -Uz url-quote-magic
+  		zle -N self-insert url-quote-magic
+      break
+  	fi
+  done
+fi
+
+## jobs
+setopt long_list_jobs
+
+## more intelligent acking for ubuntu users
+if which ack-grep &> /dev/null; then
+  alias afind='ack-grep -il'
+else
+  alias afind='ack -il'
+fi
+
+# only define LC_CTYPE if undefined
+if [[ -z "$LC_CTYPE" && -z "$LC_ALL" ]]; then
+	export LC_CTYPE=${LANG%%:*} # pick the first entry from LANG
+fi
+
+# recognize comments
+setopt interactivecomments

key-bindings.zsh Added

@@ -0,0 +1,93 @@
+# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html
+# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Builtins
+# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Standard-Widgets
+
+# Make sure that the terminal is in application mode when zle is active, since
+# only then values from $terminfo are valid
+if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
+  function zle-line-init() {
+    echoti smkx
+  }
+  function zle-line-finish() {
+    echoti rmkx
+  }
+  zle -N zle-line-init
+  zle -N zle-line-finish
+fi
+
+bindkey -e                                            # Use emacs key bindings
+
+bindkey '\ew' kill-region                             # [Esc-w] - Kill from the cursor to the mark
+bindkey -s '\el' 'ls\n'                               # [Esc-l] - run command: ls
+bindkey '^r' history-incremental-search-backward      # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line.
+if [[ "${terminfo[kpp]}" != "" ]]; then
+  bindkey "${terminfo[kpp]}" up-line-or-history       # [PageUp] - Up a line of history
+fi
+if [[ "${terminfo[knp]}" != "" ]]; then
+  bindkey "${terminfo[knp]}" down-line-or-history     # [PageDown] - Down a line of history
+fi
+
+# start typing + [Up-Arrow] - fuzzy find history forward
+if [[ "${terminfo[kcuu1]}" != "" ]]; then
+  autoload -U up-line-or-beginning-search
+  zle -N up-line-or-beginning-search
+  bindkey "${terminfo[kcuu1]}" up-line-or-beginning-search
+fi
+# start typing + [Down-Arrow] - fuzzy find history backward
+if [[ "${terminfo[kcud1]}" != "" ]]; then
+  autoload -U down-line-or-beginning-search
+  zle -N down-line-or-beginning-search
+  bindkey "${terminfo[kcud1]}" down-line-or-beginning-search
+fi
+
+if [[ "${terminfo[khome]}" != "" ]]; then
+  bindkey "${terminfo[khome]}" beginning-of-line      # [Home] - Go to beginning of line
+fi
+if [[ "${terminfo[kend]}" != "" ]]; then
+  bindkey "${terminfo[kend]}"  end-of-line            # [End] - Go to end of line
+fi
+
+bindkey ' ' magic-space                               # [Space] - do history expansion
+
+bindkey '^[[1;5C' forward-word                        # [Ctrl-RightArrow] - move forward one word
+bindkey '^[[1;5D' backward-word                       # [Ctrl-LeftArrow] - move backward one word
+
+if [[ "${terminfo[kcbt]}" != "" ]]; then
+  bindkey "${terminfo[kcbt]}" reverse-menu-complete   # [Shift-Tab] - move through the completion menu backwards
+fi
+
+bindkey '^?' backward-delete-char                     # [Backspace] - delete backward
+if [[ "${terminfo[kdch1]}" != "" ]]; then
+  bindkey "${terminfo[kdch1]}" delete-char            # [Delete] - delete forward
+else
+  bindkey "^[[3~" delete-char
+  bindkey "^[3;5~" delete-char
+  bindkey "\e[3~" delete-char
+fi
+
+# Edit the current command line in $EDITOR
+autoload -U edit-command-line
+zle -N edit-command-line
+bindkey '\C-x\C-e' edit-command-line
+
+# file rename magick
+bindkey "^[m" copy-prev-shell-word
+
+# consider emacs keybindings:
+
+#bindkey -e  ## emacs key bindings
+#
+#bindkey '^[[A' up-line-or-search
+#bindkey '^[[B' down-line-or-search
+#bindkey '^[^[[C' emacs-forward-word
+#bindkey '^[^[[D' emacs-backward-word
+#
+#bindkey -s '^X^Z' '%-^M'
+#bindkey '^[e' expand-cmd-path
+#bindkey '^[^I' reverse-menu-complete
+#bindkey '^X^N' accept-and-infer-next-history
+#bindkey '^W' kill-region
+#bindkey '^I' complete-word
+## Fix weird sequence that rxvt produces
+#bindkey -s '^[[Z' '\t'
+#

install Added

@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+
+dir=$(dirname "$(readlink -f "$0")")
+
+# source this zshrc from ~/.zshrc
+echo "source $dir/zshrc" >> $HOME/.zshrc
+
+# we may need a config directory for a plugin
+[[ ! -d $HOME/.config ]] && mkdir $HOME/.config
+
+# if installation didn't include submodules they need installing
+

functions.zsh Added

@@ -0,0 +1,21 @@
+function take() {
+  mkdir -p $@ && cd ${@:$#}
+}
+
+
+#
+# Set variable "$1" to default value "$2" if "$1" is not yet defined.
+#
+# Arguments:
+#    1. name - The variable to set
+#    2. val  - The default value
+# Return value:
+#    0 if the variable exists, 3 if it was set
+#
+function default() {
+    test `typeset +m "$1"` && return 0
+    typeset -g "$1"="$2"   && return 3
+}
+
+# Required for $langinfo
+zmodload zsh/langinfo

completion.zsh Added

@@ -0,0 +1,84 @@
+# Load all stock functions (from $fpath files) called below.
+autoload -U compaudit compinit
+
+if [[ $ZSH_DISABLE_COMPFIX != true ]]; then
+  # If completion insecurities exist, warn the user
+  if ! compaudit &>/dev/null; then
+    handle_completion_insecurities
+  fi
+  # Load only from secure directories
+  compinit -i -d "${ZSH_COMPDUMP}"
+else
+  # If the user wants it, load from all found directories
+  compinit -u -d "${ZSH_COMPDUMP}"
+fi
+
+# fixme - the load process here seems a bit bizarre
+zmodload -i zsh/complist
+
+WORDCHARS=''
+
+unsetopt menu_complete   # do not autoselect the first completion entry
+unsetopt flowcontrol
+setopt auto_menu         # show completion menu on successive tab press
+setopt complete_in_word
+setopt always_to_end
+
+# should this be in keybindings?
+bindkey -M menuselect '^o' accept-and-infer-next-history
+zstyle ':completion:*:*:*:*:*' menu select
+
+# case insensitive (all), partial-word and substring completion
+if [[ "$CASE_SENSITIVE" = true ]]; then
+  zstyle ':completion:*' matcher-list 'r:|=*' 'l:|=* r:|=*'
+else
+  if [[ "$HYPHEN_INSENSITIVE" = true ]]; then
+    zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*'
+  else
+    zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
+  fi
+fi
+unset CASE_SENSITIVE HYPHEN_INSENSITIVE
+
+# Complete . and .. special directories
+zstyle ':completion:*' special-dirs true
+
+zstyle ':completion:*' list-colors ''
+zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
+
+zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w"
+
+# disable named-directories autocompletion
+zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
+
+# Use caching so that commands like apt and dpkg complete are useable
+zstyle ':completion::complete:*' use-cache 1
+zstyle ':completion::complete:*' cache-path $ZSH_CACHE_DIR
+
+# Don't complete uninteresting users
+zstyle ':completion:*:*:*:users' ignored-patterns \
+        adm amanda apache at avahi avahi-autoipd beaglidx bin cacti canna \
+        clamav daemon dbus distcache dnsmasq dovecot fax ftp games gdm \
+        gkrellmd gopher hacluster haldaemon halt hsqldb ident junkbust kdm \
+        ldap lp mail mailman mailnull man messagebus  mldonkey mysql nagios \
+        named netdump news nfsnobody nobody nscd ntp nut nx obsrun openvpn \
+        operator pcap polkitd postfix postgres privoxy pulse pvm quagga radvd \
+        rpc rpcuser rpm rtkit scard shutdown squid sshd statd svn sync tftp \
+        usbmux uucp vcsa wwwrun xfs '_*'
+
+# ... unless we really want to.
+zstyle '*' single-ignored show
+
+if [[ $COMPLETION_WAITING_DOTS = true ]]; then
+  expand-or-complete-with-dots() {
+    # toggle line-wrapping off and back on again
+    [[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti rmam
+    print -Pn "%{%F{red}......%f%}"
+    [[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti smam
+
+    zle expand-or-complete
+    zle redisplay
+  }
+  zle -N expand-or-complete-with-dots
+  bindkey "^I" expand-or-complete-with-dots
+fi

compfix.zsh Added

@@ -0,0 +1,44 @@
+# Handle completions insecurities (i.e., completion-dependent directories with
+# insecure ownership or permissions) by:
+#
+# * Human-readably notifying the user of these insecurities.
+function handle_completion_insecurities() {
+  # List of the absolute paths of all unique insecure directories, split on
+  # newline from compaudit()'s output resembling:
+  #
+  #     There are insecure directories:
+  #     /usr/share/zsh/site-functions
+  #     /usr/share/zsh/5.0.6/functions
+  #     /usr/share/zsh
+  #     /usr/share/zsh/5.0.6
+  #
+  # Since the ignorable first line is printed to stderr and thus not captured,
+  # stderr is squelched to prevent this output from leaking to the user. 
+  local -aU insecure_dirs
+  insecure_dirs=( ${(f@):-"$(compaudit 2>/dev/null)"} )
+
+  # If no such directories exist, get us out of here.
+  (( ! ${#insecure_dirs} )) && return
+
+  # List ownership and permissions of all insecure directories.
+  print "[oh-my-zsh] Insecure completion-dependent directories detected:"
+  ls -ld "${(@)insecure_dirs}"
+
+  cat <<EOD
+
+[oh-my-zsh] For safety, we will not load completions from these directories until
+[oh-my-zsh] you fix their permissions and ownership and restart zsh.
+[oh-my-zsh] See the above list for directories with group or other writability.
+
+[oh-my-zsh] To fix your permissions you can do so by disabling
+[oh-my-zsh] the write permission of "group" and "others" and making sure that the
+[oh-my-zsh] owner of these directories is either root or your current user.
+[oh-my-zsh] The following command may help:
+[oh-my-zsh]     compaudit | xargs chmod g-w,o-w
+
+[oh-my-zsh] If the above didn't help or you want to skip the verification of
+[oh-my-zsh] insecure directories you can set the variable ZSH_DISABLE_COMPFIX to
+[oh-my-zsh] "true" before oh-my-zsh is sourced in your zshrc file.
+
+EOD
+}

aliases Added

@@ -0,0 +1,107 @@
+#
+# General aliases go here
+# Machine-specific aliases go in $HOME/.aliases
+#
+
+# misc
+alias ..='cd ../'
+alias ...='cd ../../'
+alias l='ls -alhF'
+alias lc='ls -c1'
+alias q="exit"
+alias :q="exit"
+alias tmp="cd /tmp; l"
+alias _="sudo"
+
+# networking
+alias eduroam='nmcli con up eduroam'
+alias pinga='ping archlinux.org'
+alias ip="ip -c"
+
+# launchers
+alias ra="ranger"
+alias vi="vim"
+
+# git
+alias gs="git status"
+alias ad="git add"
+alias cm="git commit -m"
+alias psh="git push"
+alias pshu="git push --set-upstream"
+alias pl="git pull"
+alias grm="git rm"
+alias br="git branch"
+alias ch="git checkout"
+
+# tools
+alias usync="rsync -avPzh --delete"
+alias cl='clear; cd $HOME'
+alias sc="sudo systemctl"
+alias removespaces="for run in {1..20}; do; find . -type f -name \"* *\" -exec rename \" \" \"_\" {} \; ; done"
+
+# quick edits
+alias modalia='vim $HOME/.aliases && source $HOME/.aliases'
+alias vimrc='vim $HOME/.vim/bundle/vim-misc/vimrc'
+alias vimkeys='vim $HOME/.vim/bundle/vim-misc/plugin/keybindings.vim'
+alias modtux='vim $HOME/.vim/bundle/vim-misc/tmux.conf'
+alias zshrc='vim $HOME/.zsh/zshrc'
+alias modrc='vim $HOME/.config/ranger/rc.conf'
+
+# shortcuts
+alias gh='cd $HOME; ls'
+alias gd='cd $HOME/documents'
+alias gD='cd $HOME/Downloads'
+alias ge='cd /etc'
+alias gv='cd $HOME/.vim; ranger'
+alias gvm='cd $HOME/.vim/bundle/vim-misc; ra'
+alias gz='cd $HOME/.zsh; l'
+
+
+# colourise man pages
+function man() {
+    env \
+	LESS_TERMCAP_mb=$(printf "\e[1;31m") \
+	LESS_TERMCAP_md=$(printf "\e[1;31m") \
+	LESS_TERMCAP_me=$(printf "\e[0m") \
+	LESS_TERMCAP_se=$(printf "\e[0m") \
+	LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
+	LESS_TERMCAP_ue=$(printf "\e[0m") \
+	LESS_TERMCAP_us=$(printf "\e[1;32m") \
+	PAGER="${commands[less]:-$PAGER}" \
+	_NROFF_U=1 \
+	PATH="$HOME/bin:$PATH" \
+	man "$@"
+}
+
+# use last browsed directory automatically with ranger
+ranger-cd() { 
+    tempfile="$(mktemp -t tmp.XXXXXX)"
+    if [[ -f /usr/local/bin/ranger ]]
+    then
+	/usr/local/bin/ranger --choosedir="$tempfile" "${@:-$(pwd)}"
+    else
+	/usr/bin/ranger --choosedir="$tempfile" "${@:-$(pwd)}"
+    fi
+    test -f "$tempfile" &&
+	if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
+	    cd -- "$(cat "$tempfile")"
+	fi
+	rm -f -- "$tempfile"
+}
+ranger() { # prevent nested ranger instances when shelling from ranger
+    if [ -z "$RANGER_LEVEL" ]; then
+	ranger-cd "$@"
+    else
+	exit
+    fi
+}
+
+
+shebang() { # create new file, add shebang, and vim
+    touch $1
+    chmod +x $1
+    echo -e "#!/usr/bin/env bash\n" > $1
+    vim +2 $1
+}
+
+# vim: ft=sh