diff --git a/bashrc b/bashrc index 27a08f3..6ab0fc6 100755 --- a/bashrc +++ b/bashrc @@ -202,6 +202,11 @@ then || complete -o default -o nospace -F _git g fi +scr(){ + _time="%Y-%m-%dT%H:%M:%S%z" + script `date +${_time}`.script "$@" +} + netwait(){ while ! ping example.com -c 1 do @@ -555,7 +560,8 @@ __my_ps1_scale(){ } __my_ps1_tmux(){ local last=$? - local tmuxc="$(__try_exec tmux display -p '#S:#I:#W.#P' 2>/dev/null)" + null type tmux || return $last + local tmuxc="$(tmux display -p '#S:#I:#W.#P' 2>/dev/null)" test -n "$TMUX" && echo "[TMUX:$tmuxc]" return $last } @@ -565,12 +571,13 @@ __my_ps1_moc(){ return $last } test -r /usr/share/git/git-prompt.sh && . /usr/share/git/git-prompt.sh +GIT_PS1_SHOWDIRTYSTATE=t +GIT_PS1_SHOWUPSTREAM=t __my_ps1_git(){ local last=$? null type __git_ps1 || return $last - null git status || return $last - test -n "`git status -s -uno`" && local star=\* - __git_ps1 "[GIT:$(__try_exec git config --get user.name):%s${star}]" + null __gitdir || return $last + __git_ps1 "[GIT:$(__try_exec git config --get user.name):%s]" return $last } __my_ps1_ipaddr(){ @@ -608,9 +615,8 @@ then __my_cdef="\[\e[0m\]" fi _PS1="\ -${__my_c4}:: ${__my_cdef}[${__my_c1}\w/${__my_cdef}<${__my_c3}\${OLDPWD}${__my_cdef}]\$(__my_ps1_scale)\$(__my_ps1_tmux)\$(__my_ps1_git)\$(__my_ps1_bttry)\$(__my_ps1_ipaddr)\$(__my_ps1_moc)\n\ -${__my_c4}:: ${__my_c2}\u@\H${__my_cdef} \D{%a, %d %b %Y %T %z} ${SHELL} \V\n\ -${__my_c4}:: ${__my_cdef}shlv:${SHLVL} cnum:\# jobs:\j last:\$? \$ " +${__my_c4}:: ${__my_cdef}[${__my_c2}\u@\H${__my_cdef}:${__my_c1}\w/${__my_cdef}]\$(__my_ps1_scale)\$(__my_ps1_tmux)\$(__my_ps1_git)\$(__my_ps1_bttry)\$(__my_ps1_ipaddr)\$(__my_ps1_moc)\n\ +${__my_c4}:: ${__my_cdef}l${SHLVL}n\#j\js\$? \D{%T} \$ " PS1=$_PS1 __my_set_title(){ diff --git a/setup.sh b/setup.sh index 513bda4..384ad1a 100755 --- a/setup.sh +++ b/setup.sh @@ -3,6 +3,14 @@ mkdir -p ~/.my/log mkdir -p ~/.local/bin +_iswindows(){ + case `uname` in + (CYGWIN*) return 0;; + (MINGW*) return 0;; + esac + return 1 +} + gen_source_script(){ # _gen_source_script file lines test $# -eq 2 || return 1 @@ -48,9 +56,10 @@ git_config(){ git config --global status.relativePaths false git config --global status.showUntrackedFiles normal git config --global log.date iso - git config --global alias.graph "log --graph --date-order -C -M --pretty=tformat:\"<%h> %ad [%an] %Cgreen%d%Creset %s\" --all --date=iso" + git config --global alias.graph "log --graph --date-order -C -M --pretty=tformat:\"<%h> %ad [%an] %Cgreen%d%Creset %s\" --all --date=iso -n 500" git config --global alias.st "status -s -b" git config --global alias.b "branch" + git config --global alias.sb "show-branch" git config --global alias.ci "commit --verbose" git config --global alias.co "checkout" git config --global alias.cim "commit --verbose -m" @@ -62,7 +71,7 @@ git_config(){ # git config --global alias.ll "!git ls-files | xargs ls -l -CFG --color=auto --time-style=long-iso" git config --global alias.addi "add -i" git config --global alias.clean-p "!test -z \"\$(git status -s -uno)\"" - if false iswindows; then + if _iswindows; then git config --global core.fileMode false fi } @@ -89,7 +98,8 @@ mac_start_daemon(){ sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist } -get_install_script http://www.frexx.de/xterm-256-notes/data/colortable16.sh http://www.frexx.de/xterm-256-notes/data/256colors2.pl +get_install_script http://www.frexx.de/xterm-256-notes/data/colortable16.sh \ + http://www.frexx.de/xterm-256-notes/data/256colors2.pl git_config