new zsh-config: 1. step

main
Thomas Ba. 10 years ago
parent e123cb4676
commit 1897ad3dde

@ -12,9 +12,11 @@ elif [[ $1 = +[0-9]* ]] || [[ $1 = -[0-9]* ]] ; then
volume="$1"
#amixer -q -c 0 -- sset Master playback $(calc $(amixer sget Master | sed -rn 's/^.*Front Right: [^\[]*\[([0-9]+)%\].*$/\1/p')$volume)%
amixer -c $CARD set $CH $(echo $1|sed -e 's/^\(.\)\(.*\)$/\2%\1/') > /dev/null
pkill -RTMIN+1 i3blocks||true
elif [[ $1 = [0-9]* ]] ; then
volume=$1
amixer -q -c $CARD -- sset $CH playback $volume%
pkill -RTMIN+1 i3blocks||true
else
echo "Usage: $0 ±<int>"
echo " ±<int> change volume relative"

@ -194,7 +194,7 @@ mode "resize" {
bindsym $mod+r mode "resize"
bar {
status_command i3status
status_command i3blocks
i3bar_command /usr/bin/i3bar-icons
tray_output DVI-0
}

@ -29,6 +29,7 @@ Plugin 'othree/html5.vim'
Plugin 'vim-scripts/bbcode'
Plugin 'tpope/vim-markdown'
Plugin 'vim-scripts/JSON.vim'
Plugin 'PProvost/vim-ps1'
" Files
Plugin 'scrooloose/nerdtree'

@ -5,41 +5,60 @@ alias -s dvi=okular
alias -s eps=okular
alias -s pdf=okular
# text files
alias -s cc=vim
alias -s coffee=vim
alias -s conf=vim
alias -s cpp=vim
alias -s css=vim
alias -s csv=vim
alias -s c=vim
alias -s haml=vim
alias -s html=vim
alias -s htm=vim
alias -s h=vim
alias -s ini=vim
alias -s java=vim
alias -s json=vim
alias -s js=vim
alias -s lua=vim
alias -s patch=vim
alias -s php=vim
alias -s pl=vim
alias -s py=vim
alias -s rb=vim
alias -s rhtml=vim
alias -s sass=vim
alias -s scss=vim
alias -s sh=vim
alias -s sql=vim
alias -s sublime-project=vim
alias -s tex=vim
alias -s todo=vim
alias -s txt=vim
alias -s vim=vim
alias -s xhtml=vim
alias -s xml=vim
alias -s yaml=vim
alias -s yml=vim
alias -s zsh-theme=vim
alias -s zsh=vim
alias -s markdown=vim
alias -s md=vim
alias -s mkd=vim
# office
alias -s xls=libreoffice
alias -s xlsx=libreoffice
alias -s doc=libreoffice
alias -s docx=libreoffice
alias -s mpp=libreoffice
alias -s ods=libreoffice
alias -s odt=libreoffice
alias -s ppt=libreoffice
alias -s pptx=libreoffice
alias -s mpp=libreoffice
alias -s rtf=libreoffice
alias -s odt=libreoffice
alias -s ods=libreoffice
alias -s xls=libreoffice
alias -s xlsx=libreoffice
# video files
alias -s avi=mplayer
@ -61,9 +80,9 @@ alias -s ogg=mplayer
alias -s wav=mplayer
alias -s wma=mplayer
# images
alias -s bmp=mirage
alias -s gif=mirage
alias -s jpeg=mirage
alias -s jpg=mirage
alias -s png=mirage
@ -71,5 +90,4 @@ alias -s tiff=mirage
alias -s tif=mirage
alias -s xcf=gimp
# vim: set ft=zsh :

@ -0,0 +1,181 @@
# Created by thomasba <mail@thomasba·de>
prompt_tba_help () {
cat <<EOH
This prompt is color-scheme-able. You can invoke it thus:
prompt tba [<text-color> [<parentheses-color> [<time-pwd-color>]]]
The default colors are white cyan. This theme works best with
a dark background.
EOH
}
prompt_tba_setup () {
local text_col=${1:-'white'}
local parens_col=${2:-'cyan'}
local time_col=${3:-'yellow'}
local text="%b%F{$text_col}"
local parens="%b%F{$parens_col}"
local punct="%B%F{black}"
local reset="%b%f"
local lpar="$parens($text"
local rpar="$parens)$text"
local time_color="%b%F{$time_col}"
local hostname="%B%F{green}"
local user_color="%b%F{green}"
if [[ "$(id -u)" = "0" ]] ; then
user_color="%B%F{red}"
fi
precmd () {
# let's get the current get branch that we are under
# ripped from /etc/bash_completion.d/git from the git devs
git_ps1 () {
if which git > /dev/null; then
local g="$(git rev-parse --git-dir 2>/dev/null)"
if [ -n "$g" ]; then
local r
local b
local date=$(git log --pretty=format:%cd --date=short -n1)
local v=$(git describe --tags --always)
if [ -d "$g/rebase-apply" ]; then
if test -f "$g/rebase-apply/rebasing"; then
r="|REBASE"
elif test -f "$g/rebase-apply/applying"; then
r="|AM"
else
r="|AM/REBASE"
fi
b="$(git symbolic-ref HEAD 2>/dev/null)"
elif [ -f "$g/rebase-merge/interactive" ]; then
r="|REBASE-i"
b="$(cat "$g/rebase-merge/head-name")"
elif [ -d "$g/rebase-merge" ]; then
r="|REBASE-m"
b="$(cat "$g/rebase-merge/head-name")"
elif [ -f "$g/MERGE_HEAD" ]; then
r="|MERGING"
b="$(git symbolic-ref HEAD 2>/dev/null)"
else
if [ -f "$g/BISECT_LOG" ]; then
r="|BISECTING"
fi
if ! b="$(git symbolic-ref HEAD 2>/dev/null)"; then
if ! b="$(git describe --exact-match HEAD 2>/dev/null)"; then
b="$(cut -c1-7 "$g/HEAD")..."
fi
fi
fi
if [ -n "$1" ]; then
printf "$1·%s·%s" "${b##refs/heads/}$r" "$date" "$v"
else
printf "%s·%s·%s" "${b##refs/heads/}$r" "$date" "$v"
fi
fi
else
printf ""
fi
}
GITBRANCH="$(git_ps1)"
if [ -n "$GITBRANCH" ] ; then
GITBRANCH=" g:$GITBRANCH"
fi
# The following 9 lines of code comes directly from Phil!'s ZSH prompt
# http://aperiodic.net/phil/prompt/
local TERMWIDTH
(( TERMWIDTH = ${COLUMNS} - 1 ))
#local PROMPTSIZE=${#${(%):--- %D{%R.%S %a %b %d %Y}\! }}
local PROMPTSIZE=${#${(%):----%n-%m----0000-00-00 00:00----}}
local PWDSIZE=${#${(%):-%~}}
if [[ "$PROMPTSIZE + $PWDSIZE" -gt $TERMWIDTH ]]; then
(( PR_PWDLEN = $TERMWIDTH - $PROMPTSIZE ))
fi
# set a simple variable to show when in screen
if [[ -n "${WINDOW}" ]]; then
SCREEN=" S:${WINDOW}"
else
SCREEN=""
fi
# check if jobs are executing
if [[ $(jobs | wc -l) -gt 0 ]]; then
JOBS=" J:%j"
else
JOBS=""
fi
# I want to know my battery percentage when running on battery power
if which acpi &> /dev/null; then
local BATTSTATE="$(acpi -b 2> /dev/null)"
local BATTPRCNT="$(echo ${BATTSTATE[(w)4]}|sed -r 's/(^[0-9]+).*/\1/')"
if [[ -z "${BATTPRCNT}" ]]; then
PR_BATTERY=""
elif [[ "${BATTPRCNT}" -lt 20 ]]; then
PR_BATTERY=" ${PR_BOLD_RED}B:${BATTPRCNT}%%"
elif [[ "${BATTPRCNT}" -lt 40 ]]; then
PR_BATTERY=" ${PR_BOLD_YELLOW}B:${BATTPRCNT}%%"
else
PR_BATTERY=" B:${BATTPRCNT}%%"
fi
fi
IS_SSH_CONN=""
if [ -n "$SSH_CONNECTION" ] ; then
IS_SSH_CONN=" ${PR_RED}⚡$PR_NO_COLOR "
fi
}
# If I am using vi keys, I want to know what mode I'm currently using.
# zle-keymap-select is executed every time KEYMAP changes.
# From http://zshwiki.org/home/examples/zlewidgets
zle-keymap-select() {
VIMODE="${${KEYMAP/vicmd/ vim:command}/(main|viins)}"
RPROMPT2="${PR_BOLD_BLUE}${VIMODE}"
zle reset-prompt
}
zle -N zle-keymap-select
PS1="$parens┌─[ $user_color%n$text@$hostname%m$reset $parens]─($reset$time_color%D{%Y-%m-%d %H:%M}$reset$parens)─→ \
$reset$time_color%\${PR_PWDLEN}<...<%~%<<\
$reset\
$parens├─($reset\${IS_SSH_CONN}$text\${PR_BATTERY}\${SCREEN}\${JOBS}%(?.. ${PR_RED}E:%?$reset)\
\${GITBRANCH} $parens)$reset\
$parens└─[%(!.#.$)]${text} "
PS2="$parens└─[$reset $parens%_$reset $parens]──→$reset "
PS3="$parens╶─[$text?#$parens]──→$reset "
PS4="$parens├──→$reset "
prompt_opts=(cr subst percent)
}
prompt_tba_preview () {
local color colors
colors=(red yellow green blue magenta)
if (( ! $#* )); then
for (( i = 1; i <= $#colors; i++ )); do
color=$colors[$i]
prompt_preview_theme tba $color
(( i < $#colors )) && print
done
else
prompt_preview_theme tba "$@"
fi
}
prompt_tba_setup "$@"
# Vim: set ft=zsh :

@ -1,161 +0,0 @@
# prompts for zsh
setopt ALL_EXPORT
autoload colors zsh/terminfo
if [[ "$terminfo[colors]" -ge 8 ]]; then
colors
fi
PR_NO_COLOR="$terminfo[sgr0]"
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE BLACK; do
eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
eval BG_$color='%{$terminfo[bold]$bg[${(L)color}]%}'
eval BG_LIGHT_$color='%{$bg[${(L)color}]%}'
(( count = $count + 1 ))
done
PR_NO_COLOR="%{$terminfo[sgr0]%}"
PR_USER_COLOR=$PR_CYAN
if [[ "`whoami`" = "root" ]]; then
PR_USER_COLOR=$PR_RED
else
PR_USER_COLOR=$PR_LIGHT_GREEN
fi
function precmd {
# let's get the current get branch that we are under
# ripped from /etc/bash_completion.d/git from the git devs
git_ps1 () {
if which git > /dev/null; then
local g="$(git rev-parse --git-dir 2>/dev/null)"
if [ -n "$g" ]; then
local r
local b
local date=$(git log --pretty=format:%cd --date=short -n1)
local v=$(git describe --tags --always)
if [ -d "$g/rebase-apply" ]; then
if test -f "$g/rebase-apply/rebasing"; then
r="|REBASE"
elif test -f "$g/rebase-apply/applying"; then
r="|AM"
else
r="|AM/REBASE"
fi
b="$(git symbolic-ref HEAD 2>/dev/null)"
elif [ -f "$g/rebase-merge/interactive" ]; then
r="|REBASE-i"
b="$(cat "$g/rebase-merge/head-name")"
elif [ -d "$g/rebase-merge" ]; then
r="|REBASE-m"
b="$(cat "$g/rebase-merge/head-name")"
elif [ -f "$g/MERGE_HEAD" ]; then
r="|MERGING"
b="$(git symbolic-ref HEAD 2>/dev/null)"
else
if [ -f "$g/BISECT_LOG" ]; then
r="|BISECTING"
fi
if ! b="$(git symbolic-ref HEAD 2>/dev/null)"; then
if ! b="$(git describe --exact-match HEAD 2>/dev/null)"; then
b="$(cut -c1-7 "$g/HEAD")..."
fi
fi
fi
if [ -n "$1" ]; then
printf "$1·%s·%s" "${b##refs/heads/}$r" "$date" "$v"
else
printf "%s·%s·%s" "${b##refs/heads/}$r" "$date" "$v"
fi
fi
else
printf ""
fi
}
GITBRANCH="$(git_ps1)"
if [ -n "$GITBRANCH" ] ; then
GITBRANCH=" g:$GITBRANCH"
fi
# The following 9 lines of code comes directly from Phil!'s ZSH prompt
# http://aperiodic.net/phil/prompt/
local TERMWIDTH
(( TERMWIDTH = ${COLUMNS} - 1 ))
#local PROMPTSIZE=${#${(%):--- %D{%R.%S %a %b %d %Y}\! }}
local PROMPTSIZE=${#${(%):----%n-%m----%D{%Y-%m-%d %H:%M}----}}
local PWDSIZE=${#${(%):-%~}}
if [[ "$PROMPTSIZE + $PWDSIZE" -gt $TERMWIDTH ]]; then
(( PR_PWDLEN = $TERMWIDTH - $PROMPTSIZE ))
fi
# set a simple variable to show when in screen
if [[ -n "${WINDOW}" ]]; then
SCREEN=" S:${WINDOW}"
else
SCREEN=""
fi
# check if jobs are executing
if [[ $(jobs | wc -l) -gt 0 ]]; then
JOBS=" J:%j"
else
JOBS=""
fi
# I want to know my battery percentage when running on battery power
if which acpi &> /dev/null; then
local BATTSTATE="$(acpi -b)"
local BATTPRCNT="$(echo ${BATTSTATE[(w)4]}|sed -r 's/(^[0-9]+).*/\1/')"
if [[ -z "${BATTPRCNT}" ]]; then
PR_BATTERY=""
elif [[ "${BATTPRCNT}" -lt 20 ]]; then
PR_BATTERY="${PR_BOLD_RED}B:${BATTPRCNT}%%"
elif [[ "${BATTPRCNT}" -lt 50 ]]; then
PR_BATTERY="${PR_BOLD_YELLOW}B:${BATTPRCNT}%%"
else
PR_BATTERY="B:${BATTPRCNT}%%"
fi
fi
}
# If I am using vi keys, I want to know what mode I'm currently using.
# zle-keymap-select is executed every time KEYMAP changes.
# From http://zshwiki.org/home/examples/zlewidgets
zle-keymap-select() {
VIMODE="${${KEYMAP/vicmd/ vim:command}/(main|viins)}"
RPROMPT2="${PR_BOLD_BLUE}${VIMODE}"
zle reset-prompt
}
zle -N zle-keymap-select
function setprompt() {
setopt prompt_subst
IS_SSH_CONN=""
if [ -n "$SSH_CONNECTION" ] ; then
IS_SSH_CONN=" ${PR_RED}⚡$PR_NO_COLOR "
fi
PROMPT="$PR_LIGHT_CYAN┌─[ $PR_USER_COLOR%n$PR_WHITE@$PR_GREEN%m$PR_NO_COLOR $PR_LIGHT_CYAN]─($PR_NO_COLOR$PR_LIGHT_YELLOW%D{%Y-%m-%d %H:%M}$PR_NO_COLOR$PR_LIGHT_CYAN)─→ \
$PR_NO_COLOR$PR_LIGHT_YELLOW%\${PR_PWDLEN}<...<%~%<<\
$PR_NO_COLOR\
$PR_LIGHT_CYAN├─(\${IS_SSH_CONN}$PR_NO_COLOR\${PR_BATTERY}\${SCREEN}\${JOBS}%(?.. ${PR_RED}E:%?${PR_NO_COLOR} )\
\${GITBRANCH}$PR_LIGHT_CYAN)$PR_NO_COLOR\
${PR_LIGHT_CYAN}└─[%(!.#.$)]${PR_NO_COLOR} "
}
setprompt
PS2="$PR_LIGHT_CYAN└─[$PR_NO_COLOR $PR_WHITE%_$PR_NO_COLOR $PR_LIGHT_CYAN]──→$PR_NO_COLOR "
PS3="$PR_LIGHT_CYAN╶─[$PR_NO_COLOR?#$PR_LIGHT_CYAN]──→$PR_NO_COLOR "
PS4="$fg[${cyan}]├──→$terminfo[sgr0] "
# vim: ft=zsh :

@ -1,99 +0,0 @@
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
#ZSH_THEME="mortalscumbag"
#ZSH_THEME="af-magic"
ZSH_THEME="../../../zsh/thomasba"
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# 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_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# 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
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
HIST_STAMPS="yyyy-mm-dd"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# 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 docker rand-quote sublime sudo web-search pass)
# User configuration
export PATH="$PATH:$HOME/.gem/ruby/2.1.0/bin"
# export MANPATH="/usr/local/man:$MANPATH"
source $ZSH/oh-my-zsh.sh
source $HOME/.zsh/programs
source $HOME/.zsh/commands
case "$MTYPE" in
"PC")
source $HOME/.zsh/commands-pc
;;
"SERVER")
source $HOME/.zsh/commands-server
;;
esac
if [ -f "$HOME/.zsh/rbenv" -a -d "$HOME/.rbenv" ] ; then
source $HOME/.zsh/rbenv
fi
if [ -d "$HOME/bin" ] ; then
export PATH="$PATH:$HOME/bin"
fi
source $HOME/.zsh/git-commands
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
alias zshconfig="vim ~/.zsh"
alias ohmyzsh="vim ~/.zsh/oh-my-zsh"
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:*:kill:*:processes' command 'ps --forest -A -o pid,user,cmd'
zstyle ':completion:*:processes-names' command 'ps axho command'
# vim: ft=zsh :

@ -0,0 +1,27 @@
source $HOME/.zsh/commands
source $HOME/.zsh/programs
case "$MTYPE" in
"PC")
source $HOME/.zsh/commands-pc
;;
"SERVER")
source $HOME/.zsh/commands-server
;;
esac
if [ -f "$HOME/.zsh/rbenv" -a -d "$HOME/.rbenv" ] ; then
source $HOME/.zsh/rbenv
fi
if [ -d "$HOME/bin" ] ; then
export PATH="$PATH:$HOME/bin"
fi
if [ -f "/usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ] ; then
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
else
printf "-!- zsh-syntax-highlighting not installed!"
fi
export EDITOR='vim'
Loading…
Cancel
Save