cleanup and fixes for config in home dir

This commit is contained in:
crater 2013-03-18 09:27:26 +01:00 committed by Alexander Gehrke (crater2150)
parent 57fa0afede
commit 6023ed42bf
13 changed files with 66 additions and 344 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
aliases/local aliases/local
*.zwc *.zwc
.zcompdump

1
.zlogin Symbolic link
View file

@ -0,0 +1 @@
zlogin

1
.zprofile Symbolic link
View file

@ -0,0 +1 @@
zprofile

1
.zshrc Symbolic link
View file

@ -0,0 +1 @@
zshrc

21
env_template Normal file
View file

@ -0,0 +1,21 @@
export ZDOTDIR="$HOME/.zsh"
PROMPT_UNICODE=yes
LANG=en_US.UTF-8
export LANG
zcpath="$ZDOTDIR"
# on foreign server I don't want to accidentaly alarm admins
sudo() {
echo "no root here";
}
su() {
echo "no root here";
}
# set modules to load. here: exclude highlight, because it is no fun over slow
# connections
ZMODLOAD_ONLY=( autoloader bindings completion vcs prompt )
source $zcpath/zprofile
source $zcpath/zshrc

View file

@ -7,14 +7,13 @@
# Lets you load custom functions and zle widgets split into single files. # Lets you load custom functions and zle widgets split into single files.
# #
# zle widgets are stored in the "widgets" folder in your configuration directory # zle widgets are stored in the "widgets" folder in your configuration directory
# (default: /etc/zsh, if you want to use this in a user configuration file, set # (set with $ZDOTDIR, see manpage. defaults to /etc/zsh)
# the variable $zcpath to your zsh configuration directory)
# #
# functions are stored in the "functions" folder analogous. # functions are stored in the "functions" folder analogous.
# #
ZWIDGETPATH=${ZWIDGETPATH:-"${zcpath:-/etc/zsh}/widgets"} ZWIDGETPATH=${ZWIDGETPATH:-"${ZDOTDIR:-/etc/zsh}/widgets"}
ZFUNCTIONPATH=${ZFUNCTIONPATH:-"${zcpath:-/etc/zsh}/functions"} ZFUNCTIONPATH=${ZFUNCTIONPATH:-"${ZDOTDIR:-/etc/zsh}/functions"}
fpath+=( "${ZWIDGETPATH}" ) fpath+=( "${ZWIDGETPATH}" )
fpath+=( "${ZFUNCTIONPATH}" ) fpath+=( "${ZFUNCTIONPATH}" )

View file

@ -7,7 +7,7 @@
# #
# Modules are stored in the "modules" folder in your configuration directory # Modules are stored in the "modules" folder in your configuration directory
# (default: /etc/zsh, if you want to use this in a user configuration file, set # (default: /etc/zsh, if you want to use this in a user configuration file, set
# the variable $zcpath to your zsh configuration directory) # the variable $ZDOTDIR to your zsh configuration directory in ~/.zshenv)
# #
# Each module should have a file called "init". This file is sourced, when the # Each module should have a file called "init". This file is sourced, when the
# module is loaded and is responsible for sourcing any other files needed by the # module is loaded and is responsible for sourcing any other files needed by the
@ -21,7 +21,7 @@
################################# #################################
# Path to module directory # Path to module directory
ZMODPATH=${ZMODPATH:-"${zcpath:-/etc/zsh}/modules"} ZMODPATH=${ZMODPATH:-"${ZDOTDIR:-/etc/zsh}/modules"}
. $ZMODPATH/helpers.zsh . $ZMODPATH/helpers.zsh
errdetails="" errdetails=""
@ -100,7 +100,8 @@ mod_check_dep() {
if ! mod_queue "$dep" is_dep ${modpath}; then if ! mod_queue "$dep" is_dep ${modpath}; then
errdetails="$dep" errdetails="$dep"
return 1; return 1;
fi;; fi
;;
"after") "after")
if [ -z "$ZMODLOAD_ONLY" ] \ if [ -z "$ZMODLOAD_ONLY" ] \
|| in_array "$dep" "${(@)ZMODLOAD_ONLY}"; then || in_array "$dep" "${(@)ZMODLOAD_ONLY}"; then

View file

@ -61,8 +61,8 @@ function prompt_preexec {
# if running gnu screen, set the window name to the last run command # if running gnu screen, set the window name to the last run command
# FIXME any way to make this not change certain window titles (by window # FIXME any way to make this not change certain window titles (by window
# number or if a title isn't already set?) # number or if a title isn't already set?)
if [[ "$TERM" =~ "screen" ]] \ if [[ -n "$TMUX" ]] \
&& [[ "$(tmux show -w au)" != "automatic-rename off" ]]; then && ! tmux show -w | grep -q "automatic-rename off"; then
local CMD=${1[(wr)^(*=*|ssh|sudo|-*)]} local CMD=${1[(wr)^(*=*|ssh|sudo|-*)]}
echo -ne "\ek$CMD\e\\" echo -ne "\ek$CMD\e\\"
fi fi
@ -73,6 +73,8 @@ if mod_loaded todo; then
count=$(todo_count all ${TO_READ_FILE:-$HOME/.to_read}) count=$(todo_count all ${TO_READ_FILE:-$HOME/.to_read})
if [ "$count" -gt 1 ]; then if [ "$count" -gt 1 ]; then
echo -n "${PVPREFIX}${pathcolor}To read: $((count -1)) ${rpscolor}${PVSUFFIX}" echo -n "${PVPREFIX}${pathcolor}To read: $((count -1)) ${rpscolor}${PVSUFFIX}"
elif [ "$count" -lt 0 ]; then
echo -n "${PVPREFIX}${pathcolor}no todo${rpscolor}${PVSUFFIX}"
fi fi
} }
fi fi

View file

@ -1,10 +1,15 @@
#!/bin/zsh #!/bin/zsh
if command -v todo >/dev/null; then
todo_count() { todo_count() {
if [ -n "$2" ]; then if [ -n "$2" ]; then
file="--database $2" file="--database $2"
else else
file="-G" file="-G"
fi fi
todo ${=file} -f +${1:-high} | wc -l todo ${=file} -f +${1:-high} | wc -l
} }
else
todo_count() {
echo -1
}
fi

301
prompt
View file

@ -1,301 +0,0 @@
#!/bin/zsh
# Best Goddamn zsh prompt in the whole world.
# Author: Seth House <seth@eseth.com>
PROMPT_UNICODE=${PROMPT_UNICODE:-yes}
setopt prompt_subst
autoload -U colors && colors
autoload -U promptinit
autoload -Uz vcs_info
local reset
reset="%{${reset_color}%}"
#=================================================================256-color-term
if [[ "`tput colors`" == "256" ]] || [[ "`tput colors`" == "88" ]] ; then
pathcolor="%{${FG[27]}%}"
ropathcolor="%{${FG[92]}%}"
gitdirty="%{${FX[bold]}${FG[160]}%}"
gitstaged="%{${FX[bold]}${FG[34]}%}"
gitclean="%{${FG[240]}%}"
stycolor="%{${FG[240]}%}"
exitcolor=$gitdirty
rpscolor="%{${FG[238]}%}"
gituntracked="%{$FX[bold]$FG[253]%}●%{$reset$rpscolor%}"
local ucnum
if [ "$EUID" = "0" ] || [ "$USER" = "root" ] ; then
ucnum=196
else
ucnum=47
fi
if [ ! -z $SSH_CLIENT ]; then
ucnum=$((ucnum + 3))
hostcolor="%{${FG[226]}%}"
else
hostcolor=$gitclean
fi
usercolor="%{${FX[bold]}${FG[$ucnum]}%}"
#===================================================================8-color-term
else
pathcolor="%{$fg_bold[blue]}%}"
gitdirty="%{${fg[yellow]}%}"
gitstaged="%{${fg[green]}%}"
gitclean="%{$rightcolor%}"
vcs_revision="%{${fg[250]}%}"
exitcolor="%{$gitdirty%}"
rpscolor="%{$fg_bold[black]}%}"
if [ "$EUID" = "0" ] || [ "$USER" = "root" ] ; then
if [ ! -z $SSH_CLIENT ]; then
usercolor="%{${fg_bold[yellow]}%}"
hostcolor="%{${fg_no_bold[blue]}%}"
else
usercolor="%{${fg_bold[red]}%}"
hostcolor="%{${fg_bold[black]}%}"
fi
else
if [ ! -z $SSH_CLIENT ]; then
usercolor="%{${fg_bold[blue]}%}"
hostcolor="%{${fg_no_bold[blue]}%}"
else
usercolor="%{${fg_bold[green]}%}"
hostcolor="%{${fg_bold[black]}%}"
fi
fi
fi
if [[ "$PROMPT_UNICODE" = "yes" ]]; then
PVPREFIX="╼╢"
PVSUFFIX="╟╾"
PR_HBAR='─'
PR_VBAR='│'
CORNER_LU='╭'
CORNER_LD='╰'
CORNER_RU='╮'
CORNER_RD='╯'
else
PVPREFIX="["
PVSUFFIX="]"
PR_HBAR='-'
PR_VBAR='|'
fi
# Set up VCS_INFO
zstyle ':vcs_info:*' enable git hg svn
zstyle ':vcs_info:(hg*|git*):*' get-revision true
zstyle ':vcs_info:(hg*|git*):*' check-for-changes true
zstyle ':vcs_info:hg*' formats "(%s)[%i%u %b %m]" # rev+changes branch misc
zstyle ':vcs_info:hg*' actionformats "(%s|${white}%a${rpscolor})[%i%u %b %m]"
zstyle ':vcs_info:hg*:netbeans' use-simple true
zstyle ':vcs_info:hg*:*' get-bookmarks true
zstyle ':vcs_info:hg*:*' get-mq true
zstyle ':vcs_info:hg*:*' get-unapplied true
zstyle ':vcs_info:hg*:*' patch-format "mq(%g):%n/%c %p"
zstyle ':vcs_info:hg*:*' nopatch-format "mq(%g):%n/%c %p"
zstyle ':vcs_info:hg*:*' hgrevformat "%r" # only show local rev.
zstyle ':vcs_info:hg*:*' branchformat "%b" # only show branch
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat "%b$vcs_revision:%f%r%f"
if [[ -z $(git ls-files --other --exclude-standard 2> /dev/null) ]] {
zstyle ':vcs_info:git*' formats "${GIT_PROMPT_PREFIX}(%s) %12.12i %c%u %b%m${GIT_PROMPT_SUFFIX}" # hash changes branch misc
zstyle ':vcs_info:git*' actionformats "(%s|${white}%a${rpscolor}) %12.12i %c%u %b%m"
} else {
zstyle ':vcs_info:git*' formats "${GIT_PROMPT_PREFIX}(%s) %12.12i %c%u${gituntracked} %b%m${GIT_PROMPT_SUFFIX}" # hash changes branch misc
zstyle ':vcs_info:git*' actionformats "(%s|${white}%a${rpscolor}) %12.12i %c%u %b%m"
}
zstyle ':vcs_info:*' stagedstr "$gitstaged●$rpscolor"
zstyle ':vcs_info:*' unstagedstr "$gitdirty●$rpscolor"
# zstyle ':vcs_info:hg:*:-all-' command fakehg
# zstyle ':vcs_info:*+*:*' debug true
zstyle ':vcs_info:hg*+set-hgrev-format:*' hooks hg-hashfallback
zstyle ':vcs_info:hg*+set-message:*' hooks mq-vcs
zstyle ':vcs_info:git*+set-message:*' hooks git-st git-stash
function prompt_char {
git branch >/dev/null 2>/dev/null && echo '±' && return
hg root >/dev/null 2>/dev/null && echo '☿' && return
svn info >/dev/null 2>/dev/null && echo '☣' && return
echo '%#'
}
exitstatus () {
local exitstatus=$?
if [ $exitstatus -ne 0 ] ; then
if [ $exitstatus -gt 128 -a $exitstatus -lt 163 ] ; then
echo "${SIG_PROMPT_PREFIX}SIG$signals[$exitstatus-127]${SIG_PROMPT_SUFFIX}"
else
echo "${SIG_PROMPT_PREFIX}${exitstatus}${SIG_PROMPT_SUFFIX}"
fi
fi
}
### Dynamically set hgrevformat based on if the local rev is available
# We don't always know the local revision, e.g. if use-simple is set
# Truncate long hash to 12-chars but also allow for multiple parents
function +vi-hg-hashfallback() {
if [[ -z ${hook_com[localrev]} ]] ; then
local -a parents
parents=( ${(s:+:)hook_com[hash]} )
parents=( ${(@r:12:)parents} )
hook_com[rev-replace]="${(j:+:)parents}"
ret=1
fi
}
# Show remote ref name and number of commits ahead-of or behind
function +vi-git-st() {
local ahead behind remote
local -a gitstatus
# Are we on a remote-tracking branch?
remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} \
--symbolic-full-name --abbrev-ref 2>/dev/null)}
if [[ -n ${remote} ]] ; then
# for git prior to 1.7
# ahead=$(git rev-list origin/${hook_com[branch]}..HEAD | wc -l)
ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
(( $ahead )) && gitstatus+=( "${gitstaged}+${ahead}${rpscolor}" )
# for git prior to 1.7
# behind=$(git rev-list HEAD..origin/${hook_com[branch]} | wc -l)
behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
(( $behind )) && gitstatus+=( "${gitdirty}-${behind}${rpscolor}" )
hook_com[branch]="${hook_com[branch]} [ ${remote}${gitstatus:+ }${gitstatus} ]"
fi
}
# Show screen STY and tmux number
sty () {
local sty=$?
if [ ! -z "$STY" ] || [ ! -z "$TMUX" ] ; then
echo "${SIG_PROMPT_PREFIX}${STY:+"SCREEN:"}${(S)STY/#*./}${STY+${TMUX+" - "}}${TMUX:+"TMUX:"}${TMUX/*,/}${SIG_PROMPT_SUFFIX}"
fi
}
screennum() {
local att
local det
local dead
if [ -x /usr/bin/screen ]; then
att=`screen -ls | grep Attached | wc -l`
det=`screen -ls | grep Detached | wc -l`
dead=`screen -ls | grep Dead | wc -l`
echo "A:$att|D:$det|?:$dead"
fi
}
# Show count of stashed changes
function +vi-git-stash() {
local -a stashes
if [[ -s ${hook_com[base]}/.git/refs/stash ]] ; then
stashes=$(git stash list 2>/dev/null | wc -l)
hook_com[misc]+=" (${stashes} stashed)"
fi
}
STYINFO=$(sty)
# Executed before each prompt
function precmd {
vcs_info
setprompt
RPS1='$usercolor◀%(?::$exitcolor${PVPREFIX})$(exitstatus)%(?::${PVSUFFIX})${stycolor}${PVPREFIX}$(sty)${rpscolor}${PVSUFFIX}${CORNER_RD}$reset'
}
# Executed after a command has been read and is to be executed.
function preexec {
# if running gnu screen, set the window name to the last run command
# FIXME any way to make this not change certain window titles (by window
# number or if a title isn't already set?)
if [[ "$TERM" =~ "screen" ]]; then
local CMD=${1[(wr)^(*=*|ssh|sudo|-*)]}
echo -ne "\ek$CMD\e\\"
fi
}
function setprompt() {
local -a lines infoline
local x i filler i_width
infoline+=( "${rpscolor}${CORNER_LU}" )
### First, assemble the top line
# Current dir
[[ -w $PWD ]] && infoline+=( ${pathcolor} ) || infoline+=( ${ropathcolor} )
infoline+=( "${PVPREFIX} %~ ${PVSUFFIX}${rpscolor}${PR_HBAR}" )
# Username & host
infoline+=( "${PVPREFIX} ${usercolor}%n${reset}@${hostcolor}%m${rpscolor} ${PVSUFFIX}" )
i_width=${(S)infoline//\%\{*\%\}} # search-and-replace color escapes
i_width=${#${(%)i_width}} # expand all escapes and count the chars
if [[ "$PROMPT_UNICODE" = "yes" ]]; then
filler="${rpscolor}${(l:$(( $COLUMNS - $i_width - 1))::─:)}"
else
filler="${rpscolor}${(l:$(( $COLUMNS - $i_width - 1))::-:)}"
fi
infoline[3]=( "${infoline[3]}${PR_HBAR}${filler}${PR_HBAR}" )
infoline+=( "${rpscolor}${CORNER_RU}" )
### Now, assemble all prompt lines
lines+=( ${(j::)infoline} )
scmline="${rpscolor}${PR_VBAR} ${vcs_info_msg_0_}${reset}"
i_width=${(S)scmline//\%\{*\%\}} # search-and-replace color escapes
i_width=${#${(%)i_width}} # expand all escapes and count the chars
filler="${rpscolor}${(l:$(( $COLUMNS - $i_width - 2)):: :)}${reset}"
[[ -n ${vcs_info_msg_0_} ]] && lines+=( "${scmline}${filler}${rpscolor}${PR_VBAR}" )
lines+=( "${CORNER_LD}${PVPREFIX} %(1j.${rpscolor}%j${reset} .)${usercolor}%%${reset} " )
### Finally, set the prompt
PROMPT=${(F)lines}
}
venv_rprompt () {
if [[ -n $VIRTUAL_ENV ]]; then
RPROMPT="${rpscolor} venv:$(basename $VIRTUAL_ENV)${reset}"
else
RPROMPT=""
fi
}
# function zle-keymap-select {
# VIMODE="${${KEYMAP/vicmd/ M:command}/(main|viins)/}"
# zle reset-prompt
# }
# zle -N zle-keymap-select
#
########## Or this one?:
# function zle-line-init zle-keymap-select {
# RPS1="${${KEYMAP/vicmd/-- NORMAL --}/(main|viins)/-- INSERT --}"
# RPS2=$RPS1
# zle reset-prompt
# }
# zle -N zle-line-init
# zle -N zle-keymap-select

2
zlogin
View file

@ -1,3 +1,3 @@
#fortune -c -s #fortune -c -s
#pal -r 7 #pal -r 7
todo command -v todo >/dev/null && todo

View file

@ -1,14 +1,12 @@
# /etc/zsh/zprofile # gentoo specific
# $Header: /var/cvsroot/gentoo-x86/app-shells/zsh/files/zprofile-1,v 1.1 2010/08/15 12:21:56 tove Exp $
# Load environment settings from profile.env, which is created by
# env-update from the files in /etc/env.d
if [ -e /etc/profile.env ] ; then if [ -e /etc/profile.env ] ; then
. /etc/profile.env . /etc/profile.env
fi fi
# You should override these in your ~/.zprofile (or equivalent) for per-user if [ -e "$HOME/.profile" ]; then
# settings. For system defaults, you can add a new file in /etc/profile.d/. . "$HOME/.profile"
fi
export EDITOR=${EDITOR:-/usr/bin/vim} export EDITOR=${EDITOR:-/usr/bin/vim}
export PAGER=${PAGER:-/usr/bin/less} export PAGER=${PAGER:-/usr/bin/less}
export XDG_CONFIG_HOME="$HOME/.config" export XDG_CONFIG_HOME="$HOME/.config"
@ -16,28 +14,21 @@ export XDG_CONFIG_HOME="$HOME/.config"
# 077 would be more secure, but 022 is generally quite realistic # 077 would be more secure, but 022 is generally quite realistic
umask 022 umask 022
# Set up PATH depending on whether we're root or a normal user. PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${ROOTPATH}:$PATH"
# There's no real reason to exclude sbin paths from the normal user,
# but it can make tab-completion easier when they aren't in the
# user's PATH to pollute the executable namespace.
#
# It is intentional in the following line to use || instead of -o.
# This way the evaluation can be short-circuited and calling whoami is
# avoided.
#if [ "$EUID" = "0" ] || [ "$USER" = "root" ] ; then
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${ROOTPATH}:$PATH"
#else
# PATH="$HOME/.bin:/usr/local/bin:/usr/bin:/bin:${PATH}"
#fi
PATH="/usr/lib/colorgcc/bin/:${PATH}" PATH="/usr/lib/colorgcc/bin/:${PATH}"
export PATH export PATH
unset ROOTPATH unset ROOTPATH
shopts=$- shopts=$-
setopt nullglob setopt nullglob
#more gentoo specific stuff
for sh in /etc/profile.d/*.sh ; do for sh in /etc/profile.d/*.sh ; do
[ -r "$sh" ] && . "$sh" [ -r "$sh" ] && . "$sh"
done done
unsetopt nullglob unsetopt nullglob
set -$shopts set -$shopts
unset sh shopts unset sh shopts

8
zshrc
View file

@ -12,8 +12,8 @@ setopt short_loops
setopt cdable_vars setopt cdable_vars
# autoload completions # autoload completions
fpath+=( "${zcpath:-/etc/zsh}/compdef" ) fpath+=( "${ZDOTDIR:-/etc/zsh}/compdef" )
autoload -U ${zcpath:-/etc/zsh}/compdef/*(:t) autoload -U ${ZDOTDIR:-/etc/zsh}/compdef/*(:t)
bindkey -v bindkey -v
@ -22,13 +22,13 @@ autoload -Uz zmv
zmodload zsh/zftp zmodload zsh/zftp
for i in ${zcpath:-/etc/zsh}/aliases/*~${zcpath:-/etc/zsh}/aliases/*.zwc; do for i in ${ZDOTDIR:-/etc/zsh}/aliases/*~${ZDOTDIR:-/etc/zsh}/aliases/*.zwc; do
. $i . $i
done done
stty -ixon stty -ixon
. ${zcpath:-/etc/zsh}/modules/loader.zsh && mod_init . ${ZDOTDIR:-/etc/zsh}/modules/loader.zsh && mod_init
echo $PATH | grep -q 'local' || . /etc/zsh/zprofile echo $PATH | grep -q 'local' || . /etc/zsh/zprofile
echo $PATH | grep -q 'sbin' || . /etc/zsh/zprofile echo $PATH | grep -q 'sbin' || . /etc/zsh/zprofile