X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=dot-files%2F_zshrc;h=11755ad6400f255839747cdea7f9caa34a33230e;hb=e6b82167f7bd95ded853c326d4efb90e622c3ad9;hp=710f2590c1fcf04ef13e734d4e8df127cfdc3242;hpb=8f28435a1f0bd37793ee2d90de8436e386e5b20e;p=sugar.git diff --git a/dot-files/_zshrc b/dot-files/_zshrc index 710f259..11755ad 100644 --- a/dot-files/_zshrc +++ b/dot-files/_zshrc @@ -53,7 +53,11 @@ setopt inc_append_history setopt share_history function _we_are_in_gnu_screen () { - [[ "$WINDOW" != "" ]] + [[ -n "$WINDOW" ]] +} + +function _we_are_in_ssh_session () { + [[ -n "$SSH_CONNECTION" ]] } _prompt_base='%B[%n@%m] %{%(?.$fg[green].$fg[red])%}%#%{$reset_color%}%b ' @@ -95,7 +99,12 @@ function print_directory_info() { elif [[ -r $absdir/.hg/branch ]] then # Hg - cat $absdir/.hg/branch + local hgbranch=`cat $absdir/.hg/branch` + if [[ -e $absdir/.hg/unpushed ]] then + echo "*${hgbranch}*" + else + echo "$hgbranch" + fi elif [[ -d $absdir/_darcs ]] then # Darcs @@ -126,6 +135,7 @@ alias -g L="| $PAGER" alias -g G="| grep" alias -g H="| head" alias -g T="| tail" +alias -g X="| hexdump -C" alias ..='cd ..' alias cd..='cd ..' @@ -159,9 +169,10 @@ if [ $(hostname) = "aria.cielonegro.org" ]; then alias pa='open -a NiseRingo.app' alias heboris='open /Applications/HeborisUEMac/exe/Heboris\ OpenGL.app' alias hengband='open ~/Applications/hengband*/Hengband*' + alias syssleep='sudo shutdown -s now' fi -if [ $(uname) = "Darwin" ]; then +if [[ $(uname) = "Darwin" ]]; then alias ldd="otool -L" alias ls='ls -Fw' @@ -177,6 +188,26 @@ else alias lls='ls -la' fi +function osname () { + case $(uname) in + "Darwin" | "FreeBSD" | "NetBSD") + uname -v;; + "Linux") + if [[ -f "/etc/redhat-release" ]]; then + cat "/etc/redhat-release" + elif [[ -f "/etc/SuSE-release" ]]; then + cat "/etc/SuSE-release" + else + echo -n "$0: I know this is "$(uname -o)" but " >&2 + echo "have no idea about its distribution." >&2 + return 1 + fi;; + *) + echo "$0: Failed to detect the OS name." >&2 + return 1 + esac +} + # The following lines were added by compinstall zstyle :compinstall filename "$HOME/.zshrc" @@ -185,16 +216,24 @@ autoload -U compinit compinit # End of lines added by compinstall -if [ "x$WINDOW" = "x" ]; then +if ( _we_are_in_gnu_screen ); then + # When we are in a GNU Screen session... + + if ( _we_are_in_ssh_session ); then + # Propagate remote session's bells to the local one. + screen -X vbell off + fi +else + if [ -e ".motd" ]; then + cat ".motd" + fi + + # Run "fortune" if we aren't in a GNU Screen session. if which fortune 2>&1 >/dev/null; then fortune fi fi -if [ -e ".motd" ]; then - cat .motd -fi - if which ssh-agent-manager 2>&1 >/dev/null; then eval `ssh-agent-manager -s` fi