add old zshconfig

This commit is contained in:
Thomas Preisner 2016-10-25 18:21:43 +02:00
parent ffda4c1ff4
commit 1ef3a363de
8 changed files with 267 additions and 0 deletions

36
zsh/aliases.zsh Normal file
View file

@ -0,0 +1,36 @@
# -------------------------------------------------------------------
# directory movement
# -------------------------------------------------------------------
alias cd..='cd ..'
# -------------------------------------------------------------------
# directory information
# -------------------------------------------------------------------
alias ll='ls -l'
alias la='ls -la'
# -------------------------------------------------------------------
# MAC only
# -------------------------------------------------------------------
if [[ $IS_MAC -eq 1 ]]; then
alias ls='ls -G'
alias refreshbrew='brew outdated | while read cask; do brew upgrade $cask; done'
alias uni='~/Dropbox/University/Semester\ 3'
fi
# -------------------------------------------------------------------
# LINUX only
# -------------------------------------------------------------------
if [[ $IS_LINUX -eq 1 ]]; then
alias ls='ls --color=auto'
alias valgrind='valgrind --leak-check=full --show-reachable=yes'
alias sp1='cd /proj/i4sp1/ty28wuqu/trunk'
alias sp2='cd /proj/i4sp2/ty28wuqu/trunk'
alias submit1='/proj/i4sp1/bin/submit'
alias submit2='/proj/i4sp2/bin/submit'
fi
# -------------------------------------------------------------------
# misc aliases
# -------------------------------------------------------------------
alias irc='ssh -t irc tmux attach'

23
zsh/checks.zsh Normal file
View file

@ -0,0 +1,23 @@
if [[ $(uname) = 'Linux' ]]; then
IS_LINUX=1
fi
if [[ $(uname) = 'Darwin' ]]; then
IS_MAC=1
fi
if [[ -x `which brew` ]]; then
HAS_BREW=1
fi
if [[ -x `which apt-get` ]]; then
HAS_APT=1
fi
if [[ -x `which pmset` ]]; then
HAS_PMSET=1
fi
if [[ -x `which acpi` ]]; then
HAS_ACPI=1
fi

26
zsh/colors.zsh Normal file
View file

@ -0,0 +1,26 @@
autoload colors; colors
# The variables are wrapped in \%\{\%\}. This should be the case for every
# variable that does not contain space.
for COLOR in RED GREEN YELLOW BLUE MAGENTA CYAN BLACK WHITE; do
eval PR_$COLOR='%{$fg_no_bold[${(L)COLOR}]%}'
eval PR_BOLD_$COLOR='%{$fg_bold[${(L)COLOR}]%}'
done
eval RESET='$reset_color'
export PR_RED PR_GREEN PR_YELLOW PR_BLUE PR_WHITE PR_BLACK
export PR_BOLD_RED PR_BOLD_GREEN PR_BOLD_YELLOW PR_BOLD_BLUE
export PR_BOLD_WHITE PR_BOLD_BLACK
# Clear LSCOLORS
unset LSCOLORS
# Main change, you can see directories on a dark background
#export LSCOLORS=gxfxcxdxbxegedabagacad
export CLICOLOR=1
if [[ $IS_MAC -eq 1 ]]; then
export LSCOLORS=gxfxcxdxbxegedabagacad
fi
export LS_COLORS=di='36;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:'

59
zsh/completion.zsh Normal file
View file

@ -0,0 +1,59 @@
autoload -U compinit && compinit
zmodload -i zsh/complist
# man zshcontrib
zstyle ':vcs_info:*' actionformats '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
zstyle ':vcs_info:*' formats '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{5}]%f '
zstyle ':vcs_info:*' enable git
# Enable completion caching, use rehash to clear
zstyle ':completion::complete:*' use-cache on
zstyle ':completion::complete:*' cache-path ~/.zsh/cache/$HOST
# Fallback to built in ls colors
#zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-colors "${(@s.:.)LS_COLORS}"
# Make the list prompt friendly
zstyle ':completion:*' list-prompt '%SAt %p: Hit TAB for more, or the character to insert%s'
# Make the selection prompt friendly when there are a lot of choices
zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s'
# Add simple colors to kill
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
# list of completers to use
zstyle ':completion:*::::' completer _expand _complete _ignored _approximate
zstyle ':completion:*' menu select=1 _complete _ignored _approximate
# insert all expansions for expand completer
# zstyle ':completion:*:expand:*' tag-order all-expansions
# match uppercase from lowercase
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
# offer indexes before parameters in subscripts
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
# formatting and messages
zstyle ':completion:*' verbose yes
zstyle ':completion:*:descriptions' format '%B%d%b'
zstyle ':completion:*:messages' format '%d'
zstyle ':completion:*:warnings' format 'No matches for: %d'
zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b'
zstyle ':completion:*' group-name ''
# ignore completion functions (until the _ignored completer)
zstyle ':completion:*:functions' ignored-patterns '_*'
zstyle ':completion:*:scp:*' tag-order files users 'hosts:-host hosts:-domain:domain hosts:-ipaddr"IP\ Address *'
zstyle ':completion:*:scp:*' group-order files all-files users hosts-domain hosts-host hosts-ipaddr
zstyle ':completion:*:ssh:*' tag-order users 'hosts:-host hosts:-domain:domain hosts:-ipaddr"IP\ Address *'
zstyle ':completion:*:ssh:*' group-order hosts-domain hosts-host users hosts-ipaddr
zstyle '*' single-ignored show
# apt-get recommendations
#if [[ $HAS_APT -eq 1 ]]; then
# source /etc/zsh_command_not_found
#fi

4
zsh/history.zsh Normal file
View file

@ -0,0 +1,4 @@
# History
HISTSIZE=10000
SAVEHIST=9000
HISTFILE=~/.zsh/zsh_history

70
zsh/prompt.zsh Normal file
View file

@ -0,0 +1,70 @@
function precmd {
local TERMWIDTH
(( TERMWIDTH = ${COLUMNS} - 1 ))
###
# Truncate the path if it's too long.
PR_FILLBAR=""
PR_PWDLEN=""
local promptsize=${#${(%):---(%n@%m)---()--}}
local pwdsize=${#${(%):-%~}}
if [[ "$promptsize + $pwdsize" -gt $TERMWIDTH ]]; then
((PR_PWDLEN=$TERMWIDTH - $promptsize))
else
PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $pwdsize)))..${PR_HBAR}.)}"
fi
}
function show_battery {
if [[ $HAS_PMSET -eq 1 ]]; then
~/.zsh/scripts/battery_osx.sh
fi
}
function setprompt {
PR_HBAR="─"
if [[ "$TERM" != "xterm" ]]; then
PR_ULCORNER="╭"
PR_LLCORNER="╰"
PR_LRCORNER="╯"
PR_URCORNER="╮"
else
PR_ULCORNER="+"
PR_LLCORNER="+"
PR_LRCORNER="+"
PR_URCORNER="+"
fi
PR_RESET="%{$terminfo[sgr0]%}"
###
# Finally, the prompt.
PROMPT='$PR_CYAN$PR_ULCORNER$PR_BLUE$PR_HBAR(\
$PR_MAGENTA%$PR_PWDLEN<...<%~%<<$\
PR_BLUE)$PR_HBAR$PR_CYAN$PR_HBAR${(e)PR_FILLBAR}$PR_BLUE$PR_HBAR(\
$PR_GREEN%n@%m$PR_BLUE\
$PR_BLUE)$PR_HBAR$PR_CYAN$PR_URCORNER\
$PR_CYAN$PR_LLCORNER$PR_BLUE$PR_HBAR(\
$PR_YELLOW%D{%H:%M}\
$PR_BLUE)$PR_HBAR$PR_CYAN$PR_HBAR\
$PR_RESET '
RPROMPT='$PR_CYAN$PR_HBAR$PR_BLUE$PR_HBAR(\
$PR_YELLOW$(show_battery)\
$PR_BLUE)$PR_HBAR$PR_CYAN$PR_LRCORNER\
$PR_RESET'
PS2='$PR_CYAN$PR_HBAR$PR_BLUE$PR_HBAR(\
$PR_LIGHT_GREEN%_
$PR_BLUE)$PR_HBAR$PR_CYAN$PR_HBAR\
$PR_RESET '
}
setprompt

42
zsh/setopt.zsh Normal file
View file

@ -0,0 +1,42 @@
# ===== Basics
setopt no_beep # don't beep on error
setopt interactive_comments # Allow comments even in interactive shells (especially for Muness)
# ===== Changing Directories
setopt auto_cd # If you type foo, and it isn't a command, and it is a directory in your cdpath, go there
setopt cdablevarS # if argument to cd is the name of a parameter whose value is a valid directory, it will become the current directory
# setopt pushd_ignore_dups # don't push multiple copies of the same directory onto the directory stack
# ===== Expansion and Globbing
setopt extended_glob # treat #, ~, and ^ as part of patterns for filename generation
# ===== History
setopt append_history # Allow multiple terminal sessions to all append to one zsh command history
setopt extended_history # save timestamp of command and duration
setopt inc_append_history # Add comamnds as they are typed, don't wait until shell exit
setopt hist_expire_dups_first # when trimming history, lose oldest duplicates first
setopt hist_ignore_dups # Do not write events to history that are duplicates of previous events
setopt hist_ignore_space # remove command line from history list when first character on the line is a space
setopt hist_find_no_dups # When searching history don't display results already cycled through twice
setopt hist_reduce_blanks # Remove extra blanks from each command line being added to history
setopt hist_verify # don't execute, just expand history
setopt share_history # imports new commands and appends typed commands to history
# ===== Completion
setopt always_to_end # When completing from the middle of a word, move the cursor to the end of the word
setopt auto_menu # show completion menu on successive tab press. needs unsetop menu_complete to work
setopt auto_name_dirs # any parameter that is set to the absolute name of a directory immediately becomes a name for that directory
setopt complete_in_word # Allow completion from within a word/phrase
unsetopt menu_complete # do not autoselect the first completion entry
# ===== Correction
# setopt correct # spelling correction for commands
# setopt correctall # spelling correction for arguments
# ===== Prompt
setopt prompt_subst # Enable parameter expansion, command substitution, and arithmetic expansion in the prompt
setopt transient_rprompt # only show the rprompt on the current prompt
# ===== Scripts and Functions
setopt multios # perform implicit tees or cats when multiple redirections are attempted