@ -1,111 +1,145 @@
# If you come from bash you might have to change your $PATH.
### History
# export PATH=$HOME/bin:/usr/local/bin:$PATH
HISTFILE = " $HOME /.zsh_history "
HISTSIZE = 500000000
# Path to your oh-my-zsh installation.
SAVEHIST = 100000000
export ZSH = " $HOME /.oh-my-zsh "
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME = "agnoster"
# ZSH_THEME="dracula"
# Set list of themes to pick from when loading at random
setopt extended_history # record timestamp of command in HISTFILE
# Setting this variable when ZSH_THEME=random will cause zsh to load
setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE
# a theme from this variable instead of looking in ~/.oh-my-zsh/themes/
setopt hist_ignore_dups # ignore duplicated commands history list
# If set to an empty array, this variable will have no effect.
setopt hist_ignore_space # ignore commands that start with space
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
setopt hist_verify # show command with history expansion to user before running it
setopt share_history # share command history data
### Aliases
alias upgrade = ' sudo apt-get update && \
sudo apt upgrade && \
sudo apt-get autoremove --purge && \
sudo apt-get clean' # System clean upgrade
alias history = 'history 1' # Print whole history
alias diff = 'diff --color'
alias ls = 'ls --color=tty'
### Keybinds
# See:
# https://stackoverflow.com/a/21965133
# https://github.com/sorin-ionescu/prezto/pull/314
# https://vinipsmaker.wordpress.com/2014/02/23/my-zsh-config/
# https://github.com/ohmyzsh/ohmyzsh/blob/master/lib/key-bindings.zsh
# /etc/zsh/zshrc
# Use emacs key bindings
bindkey -e
# 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
# Uncomment the following line to use case-sensitive completion.
typeset -A key
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion.
# List of keys
# Case-sensitive completion must be off. _ and - will be interchangeable.
key = (
# HYPHEN_INSENSITIVE="true"
Up " ${ terminfo [kcuu1] } "
Down " ${ terminfo [kcud1] } "
PageUp " ${ terminfo [kpp] } "
PageDown " ${ terminfo [knp] } "
)
else
# Fallback to manually managed user-driven database
printf 'Failed to setup keys using terminfo (application mode unsuported).\n'
# TODO: set zkbd mode
# See: https://github.com/vinipsmaker/dotfiles/blob/master/config/.zshrc
fi
# Uncomment the following line to disable bi-weekly auto-update checks.
if [ [ -n " ${ key [Up] } " ] ] && [ [ -n " ${ key [Down] } " ] ] ; then
DISABLE_AUTO_UPDATE = "true"
autoload -U up-line-or-beginning-search
autoload -U down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
# Uncomment the following line to automatically update without prompting.
bindkey " ${ key [Up] } " up-line-or-beginning-search
DISABLE_UPDATE_PROMPT = "true"
bindkey " ${ key [Down] } " down-line-or-beginning-search
fi
[ [ -n " ${ key [PageUp] } " ] ] && bindkey " ${ key [PageUp] } " up-line-or-history
[ [ -n " ${ key [PageDown] } " ] ] && bindkey " ${ key [PageDown] } " down-line-or-history
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
# Uncomment the following line if pasting URLs and other text is messed up.
### Completion (dump)
DISABLE_MAGIC_FUNCTIONS = true
# Note: This stuff probably has to be run before defining completion configs
# TODO: Check if the above note is true
# See:
# https://www.csse.uwa.edu.au/programming/linux/zsh-doc/zsh_23.html
# https://linux.die.net/man/1/zshcompsys
# Uncomment the following line to disable colors in ls.
# Load all stock functions (from $fpath files) called below .
# DISABLE_LS_COLORS="true"
autoload -U compinit
# Uncomment the following line to disable auto-setting terminal title.
# Save the location of the current completion dump file.
# DISABLE_AUTO_TITLE="true"
ZSH_COMPDUMP = " ${ ZDOTDIR :- ${ HOME } } /.zcompdump- ${ ZSH_VERSION } "
compinit -u -C -d " ${ ZSH_COMPDUMP } "
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
### Completion
# COMPLETION_WAITING_DOTS="true"
zmodload -i zsh/complist
# Uncomment the following line if you want to disable marking untracked files
WORDCHARS = ''
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
unsetopt menu_complete # do not autoselect the first completion entry
# stamp shown in the history command output.
unsetopt flowcontrol
# You can set one of the optional three formats:
setopt auto_menu # show completion menu on successive tab press
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
setopt complete_in_word
# or set a custom format using the strftime function format specifications,
setopt always_to_end
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# should this be in keybindings?
# ZSH_CUSTOM=/path/to/new-custom-folder
bindkey -M menuselect '^o' accept-and-infer-next-history
zstyle ':completion:*:*:*:*:*' menu select
# Which plugins would you like to load?
# case insensitive (all), partial-word and substring completion
# Standard plugins can be found in ~/.oh-my-zsh/plugins/*
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins = ( git)
source $ZSH /oh-my-zsh.sh
# Complete . and .. special directories
zstyle ':completion:*' special-dirs true
# User configuration
zstyle ':completion:*' list-colors ''
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
# export MANPATH="/usr/local/man:$MANPATH "
zstyle ':completion:*:*:*:*:processes' command " ps -u $USERNAME -o pid,user,comm -w -w "
# You may need to manually set your language environment
# disable named-directories autocompletion
# export LANG=en_US.UTF-8
zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
# Preferred editor for local and remote sessions
# Use caching so that commands like apt and dpkg complete are useable
# if [[ -n $SSH_CONNECTION ]]; then
zstyle ':completion:*' use-cache yes
# export EDITOR='vim'
zstyle ':completion:*' cache-path " $HOME /.cache/zsh "
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# Don't complete uninteresting users
# export ARCHFLAGS="-arch x86_64"
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 '_*'
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# ... unless we really want to.
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
zstyle '*' single-ignored show
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
HISTFILE = " $HOME /.zsh_history "
# automatically load bash completion functions
HISTSIZE = 500000000
autoload -U +X bashcompinit && bashcompinit
SAVEHIST = 100000000
#Upgrade the system
alias upgrade = 'sudo apt-get update && sudo apt upgrade && sudo apt-get autoremove --purge && sudo apt-get clean'
### Addons
# Colored manpages
# Colored manpages
man( ) {
man( ) {
env \
env \
@ -118,3 +152,88 @@ man() {
LESS_TERMCAP_us = $( printf "\e[4;93m" ) \
LESS_TERMCAP_us = $( printf "\e[4;93m" ) \
man " $@ "
man " $@ "
}
}
# Colored `ls` command and colored dir and files suggestions
autoload -U colors && colors
if [ [ " $DISABLE_LS_COLORS " != "true" ] ] ; then
# 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
# Take advantage of $LS_COLORS for completion as well.
zstyle ':completion:*' list-colors " ${ (s. : .)LS_COLORS } "
fi
# TODO: check what `multios` really does
# See: http://zsh.sourceforge.net/Doc/Release/Options.html
#setopt auto_cd
setopt multios
### Custom zsh-specific Functions
function zsh_stats( ) {
fc -l 1 | \
awk '{ CMD[$2]++; count++; } END { for (a in CMD) print CMD[a] " " CMD[a]*100/count "% " a }' | \
grep -v "./" | sort -nr | head -20 | column -c3 -s " " -t | nl
}
## Theme
# This is ugly as hell, but is efficient and reliable
# TODO: find a clean, reliable and efficient solution to this mess
zsh_base_dir = " $HOME /.config/zsh "
# Git
# git theming default: Variables for theming the git info prompt
function zsh_git_theme( ) {
ZSH_THEME_GIT_PROMPT_PREFIX = "git:(" # At the very beginning of the prompt
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
ZSH_THEME_RUBY_PROMPT_PREFIX = "("
ZSH_THEME_RUBY_PROMPT_SUFFIX = ")"
}
# Source: https://github.com/ohmyzsh/ohmyzsh/blob/master/lib/git.zsh
zsh_tmp_path = " $zsh_base_dir /git.zsh "
if [ -f " $zsh_tmp_path " ] ; then
zsh_git_theme && \
source " $zsh_tmp_path " || echo " An error has occurred sourcing: $zsh_tmp_path "
else
mkdir -p " $zsh_base_dir "
src_url = 'https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/lib/git.zsh'
echo " Downloading $src_url ... "
eval "curl -s --max-time 5 -o \"" $zsh_tmp_path " \" \" $src_url \" " && \
unset src_url && \
zsh_git_theme && \
source " $zsh_tmp_path " || \
echo " [Warning] Failed to create the file or unrecheable URL: $src_url " && \
rmdir --ignore-fail-on-non-empty " $zsh_base_dir "
fi
unfunction zsh_git_theme
# For `prompt_subst` see:
# https://github.com/agnoster/agnoster-zsh-theme/pull/12
# Fork used:
# https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/agnoster.zsh-theme
zsh_tmp_path = " $zsh_base_dir /agnoster.zsh-theme "
if [ -f " $zsh_tmp_path " ] ; then
setopt prompt_subst
source " $zsh_tmp_path "
else
mkdir -p " $zsh_base_dir "
src_url = 'https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/themes/agnoster.zsh-theme'
echo " Downloading $src_url ... "
eval "curl -s --max-time 5 -o \"" $zsh_tmp_path " \" \" $src_url \" " && \
unset src_url && \
setopt prompt_subst && \
source " $zsh_tmp_path " || \
echo " [Warning] Failed to create the file or unrecheable URL: $src_url " && \
rmdir --ignore-fail-on-non-empty " $zsh_base_dir " && \
PS1 = " %B%{ $fg [red]%}[%{ $fg [yellow]%}%n%{ $fg [green]%}@%{ $fg [blue]%}%M %{ $fg [magenta]%}%~%{ $fg [red]%}]%{ $reset_color %} $%b "
fi
unset zsh_tmp_path
unset zsh_base_dir