Skip to content

Instantly share code, notes, and snippets.

@Thaodan
Created March 19, 2014 05:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Thaodan/9636081 to your computer and use it in GitHub Desktop.
Save Thaodan/9636081 to your computer and use it in GitHub Desktop.
zshrc
#------------------------------------------------------------------#
# File: .zshrc ZSH resource file #
# Version: 0.1.16 #
# Author: Øyvind "Mr.Elendig" Heggstad <mrelendig@har-ikkje.net> #
#------------------------------------------------------------------#
. /etc/profile
#------------------------------
# History stuff
#------------------------------
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
setopt inc_append_history
setopt share_history
#------------------------------
# Variables
#------------------------------
export BROWSER="firefox"
export EDITOR="editor"
#export PAGER="vimpager"
export PATH="${PATH}:${HOME}/.local/bin"
#-----------------------------
# Dircolors
#-----------------------------
LS_COLORS='rs=0:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:';
export LS_COLORS
#------------------------------
# Keybindings
#------------------------------
bindkey -e
typeset -g -A key
#bindkey '\e[3~' delete-char
bindkey '\e[1~' beginning-of-line
bindkey '\e[4~' end-of-line
#bindkey '\e[2~' overwrite-mode
bindkey '^?' backward-delete-char
bindkey '^[[1~' beginning-of-line
bindkey '^[[5~' up-line-or-history
bindkey '^[[3~' delete-char
bindkey '^[[4~' end-of-line
bindkey '^[[6~' down-line-or-history
bindkey '^[[A' up-line-or-search
bindkey '^[[D' backward-char
bindkey '^[[B' down-line-or-search
bindkey '^[[C' forward-char
# for rxvt
bindkey "\e[8~" end-of-line
bindkey "\e[7~" beginning-of-line
# for gnome-terminal
bindkey "\eOH" beginning-of-line
bindkey "\eOF" end-of-line
bindkey '^[[1;5C' emacs-forward-word
bindkey '^[[1;5D' emacs-backward-word
#------------------------------
# Alias stuff
#------------------------------
if [ -f ~/.sh_aliases ] ; then # global aliases for bash and zsh
source ~/.sh_aliases
fi
#------------------------------
# Comp stuff
#------------------------------
zmodload zsh/complist
autoload -Uz compinit
compinit
zstyle :compinstall filename '${HOME}/.zshrc'
#- buggy
zstyle ':completion:*:descriptions' format '%U%B%d%b%u'
zstyle ':completion:*:warnings' format '%BSorry, no matches for: %d%b'
#-/buggy
zstyle ':completion:*:pacman:*' force-list always
zstyle ':completion:*:*:pacman:*' menu yes select
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*:*:kill:*' menu yes select
zstyle ':completion:*:kill:*' force-list always
zstyle ':completion:*:*:killall:*' menu yes select
zstyle ':completion:*:killall:*' force-list always
#- complete pacman-color the same as pacman
compdef _pacman pacman-color=pacman
#------------------------------
# Window title
#------------------------------
case $TERM in
termite|*xterm*|rxvt|rxvt-unicode|rxvt-256color|rxvt-unicode-256color|(dt|k|E)term)
precmd () { print -Pn "\e]0;[%n@%M][%~]%#\a" }
preexec () { print -Pn "\e]0;[%n@%M][%~]%# ($1)\a" }
;;
screen|screen-256color)
precmd () {
print -Pn "\e]83;title \"$1\"\a"
print -Pn "\e]0;$TERM - (%L) [%n@%M]%# [%~]\a"
}
preexec () {
print -Pn "\e]83;title \"$1\"\a"
print -Pn "\e]0;$TERM - (%L) [%n@%M]%# [%~] ($1)\a"
}
;;
esac
# Keys.
# keybindings
bindkey -d
bindkey -e
bindkey ' ' magic-space
bindkey -M emacs '\ee' edit-command-line
case $TERM in
screen*|xterm*|putty*)
bindkey '\e[H' beginning-of-line
bindkey '\e[F' end-of-line
bindkey '\eOH' beginning-of-line
bindkey '\eOF' end-of-line
bindkey '\e[1~' beginning-of-line
bindkey '\e[4~' end-of-line
bindkey '\e[7~' beginning-of-line
bindkey '\e[8~' end-of-line
bindkey '\e[3~' delete-char
bindkey '\e[1;5C' emacs-forward-word
bindkey '\e[1;5D' emacs-backward-word
bindkey '\e[5C' emacs-forward-word
bindkey '\e[5D' emacs-backward-word
bindkey '\eO5C' emacs-forward-word
bindkey '\eO5D' emacs-backward-word
bindkey '\eOC' emacs-forward-word
bindkey '\eOD' emacs-backward-word
bindkey '\eOc' emacs-forward-word
bindkey '\eOd' emacs-backward-word
bindkey '\e[c' emacs-forward-word
bindkey '\e[d' emacs-backward-word
bindkey '\M-B\M-^H' backward-kill-word
bindkey '\M-^H' backward-kill-word
bindkey '\M-C\M-?' backward-kill-word
;;
mlterm|kterm)
bindkey '\e[H' beginning-of-line
bindkey '\e[F' end-of-line
bindkey '\e[1~' beginning-of-line
bindkey '\e[4~' end-of-line
bindkey '\e[1;5C' emacs-forward-word
bindkey '\e[1;5D' emacs-backward-word
bindkey '\e[3~' delete-char
;;
linux|vt100)
bindkey '\e[1~' beginning-of-line
bindkey '\e[4~' end-of-line
bindkey '\e[3~' delete-char
;;
*rxvt*|Eterm|aterm)
bindkey '\e[c' emacs-forward-word
bindkey '\e[d' emacs-backward-word
bindkey '\eOc' emacs-forward-word
bindkey '\eOd' emacs-backward-word
bindkey '\e[3~' delete-char
bindkey '\e[7~' beginning-of-line
bindkey '\e[8~' end-of-line
;;
cons*)
bindkey '\e[H' beginning-of-line
bindkey '\e[F' end-of-line
bindkey '^?' delete-char
;;
interix)
bindkey '\e[H' beginning-of-line
bindkey '\e[U' end-of-line
bindkey '^?' delete-char
;;
sun*)
bindkey '\e[214z' beginning-of-line
bindkey '\e[220z' end-of-line
bindkey '^?' delete-char
;;
cygwin*)
bindkey '\e[1~' beginning-of-line
bindkey '\e[4~' end-of-line
bindkey '\e[1;5C' emacs-forward-word
bindkey '\e[1;5D' emacs-backward-word
bindkey '\e[3~' delete-char
;;
esac
bindkey "^R" history-incremental-pattern-search-backward
bindkey "^S" history-incremental-pattern-search-forward
if [ -f ~/.alert ]; then cat ~/.alert; fi
autoload -U promptinit
promptinit
if [ $TERM = "dumb" ] ; then
PS1="[\u@\h \w]$ "
unsetopt zle
unsetopt prompt_cr
unsetopt prompt_subst
unfunction precmd
unfunction preexec
else
if [ $UID -eq 0 ] ; then
PROMPT="%F{red}%B%K{red}█▓▒░%F{white}%K{red}%B%n@%m%b%F{red}%K{black}█▓▒░%F{white}%K{black}%B %D{%I:%M:%S%P}
%}%F{blue}%K{black}%B%~/%b%k%f:"
else
PROMPT="%F{blue}%B%K{blue}█▓▒░%F{white}%K{blue}%B%n@%m%b%F{blue}%K{black}█▓▒░%F{white}%K{black}%B %D{%I:%M:%S%P}
%}%F{blue}%K{black}%B%~/%b%k%f:"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment