Add status messages to shell init files

Mostly for profiling, but I think it's cool to have status occasionally. In the
process, I also did some clean up, moving some stuff between profile, rc, and
env.
This commit is contained in:
Eryn Wells 2012-08-07 11:19:43 -07:00
parent 7b2074e292
commit 1400941de1
6 changed files with 49 additions and 40 deletions

8
env
View file

@ -8,8 +8,13 @@
#
# Eryn Wells <eryn@erynwells.me>
export SYS=`uname -s | tr A-Z a-z`
[ -e $HOME/.shell-functions ] && source $HOME/.shell-functions
export SYS=`uname -s | tr A-Z a-z`
# Set this to a non-zero integer to see startup messages
export NOISY=0
print_info_noisy 1 "Initializing environment for $SYS system"
PAGER="less"
MANPAGER=$PAGER
EDITOR="vim"
@ -33,7 +38,6 @@ PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
export PATH
# System specific environment settings
case $SYS in
darwin)
export PATH=$HOME/Library/Python/2.7/bin:$PATH

28
profile
View file

@ -2,33 +2,9 @@
# vim: ft=zsh
# Eryn Wells <eryn@erynwells.me>
# Gotta do some machine specific setup
arch=`uname -s`
case $arch in
Linux)
alias iptls='sudo iptables --line-numbers -nv -L'
alias ip6tls='sudo ip6tables --line-numbers -nv -L'
alias rlx="xrdb $HOME/.Xdefaults"
;;
Darwin)
alias indent='gnuindent'
alias acls='/bin/ls -le'
;;
esac
# NetHack options
# use color in the terminal
export NETHACKOPTIONS="color"
[ -e $HOME/.profile-local ] && source $HOME/.profile-local
# Start SSH agent for password-less logins
if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]
then
if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then
print_info_noisy 1 'Starting ssh-agent'
eval `ssh-agent -s`
trap "kill $SSH_AGENT_PID" 0
fi
LEDGER_FILE=$HOME/Documents/Financial/personal.ledger
export LEDGER_FILE PATH

25
rc
View file

@ -3,8 +3,9 @@
# Generic interactive shell setup
# Eryn Wells <eryn@erynwells.me>
. $HOME/.shell-functions
print_info_noisy 1 'Initializing interactive shell'
print_info_sub_noisy 2 'Creating aliases'
alias j='jobs'
alias h='history'
alias df='df -h'
@ -37,16 +38,38 @@ case $SYS in
alias la="$ls -A $ls_options"
alias ll="$ls -l $ls_options"
binary_exists gdircolors && alias dircolors='gdircolors'
alias indent='gnuindent'
alias acls='/bin/ls -le'
;;
linux)
alias ls="ls --color=auto"
alias la="ls -A --color=auto"
alias ll="ls -l --color=auto"
alias l.="ls -d --color=auto .*"
# iptables aliases
alias iptls='sudo iptables --line-numbers -nv -L'
alias ip6tls='sudo ip6tables --line-numbers -nv -L'
alias rlx="xrdb $HOME/.Xdefaults"
;;
*)
print_error "What system %Bis%b this, anyway?"
;;
esac
# Set up dircolors
if [ -e $HOME/.dircolors/$SYS.cfg ]; then
dircolors=$HOME/.dircolors/$SYS.cfg
else
dircolors=$HOME/.dircolors/default.cfg
fi
eval `dircolors $dircolors`
# NetHack options
# use color in the terminal
export NETHACKOPTIONS="color"
# Default ledger file
[ -e "$HOME/Documents/Financial/personal.ledger" ] && \
LEDGER_FILE=$HOME/Documents/Financial/personal.ledger
[ -e $HOME/.rc.local ] && source $HOME/.rc.local

View file

@ -9,5 +9,16 @@ function print_msg { print -P "%F{$1}==>%f $2" }
function print_info { print_msg 'blue' "$@" }
function print_error { print_msg 'red' "$@" }
function print_msg_sub { print -P " %F{$1}*%f $2" }
function print_info_sub { print_msg_sub 'blue' "$@" }
function print_error_sub { print_msg_sub 'error' "$@" }
# Print if $NOISY is set
function print_info_noisy { [ ${NOISY:-0} -ge $1 ] && print_info $@[2,-1] }
function print_error_noisy { [ ${NOISY:-0} -ge $1 ] && print_error $@[2,-1] }
function print_info_sub_noisy { [ ${NOISY:-0} -ge $1 ] && print_info_sub $@[2,-1] }
function print_error_sub_noisy { [ ${NOISY:-0} -ge $1 ] && print_error_sub $@[2,-1] }
# Return 1 if the binary exists (according to hash); 0 otherwise.
function binary_exists { return $(hash $1 1>/dev/null 2>&1) }

View file

@ -5,6 +5,8 @@
#
# Eryn Wells <eryn@erynwells.me>
print_info_noisy 1 'Initializing login shell'
[ -e $HOME/.profile ] && source $HOME/.profile
# Any ZSH stuff goes here.

15
zshrc
View file

@ -25,6 +25,7 @@ else
isroot="%(!.%{$fg_bold[red]%}%#%{$reset_color%}.%#)"
fi
print_info_sub_noisy 2 'Setting prompt'
PROMPT=" $hist $bgjob$isroot "
@ -72,6 +73,7 @@ precmd_git_rprompt()
precmd_functions=(precmd_xterm_title precmd_separator_info precmd_git_rprompt)
print_info_sub_noisy 2 'Initializing ZSH'
# Shell options
setopt \
TRANSIENT_RPROMPT \
@ -106,17 +108,6 @@ HISTSIZE=1000000
SAVEHIST=1000000
HISTFILE="$HOME/.zhistory"
#[ -n "$DISPLAY" ] && alias -s pdf='evince'
#[ -n "$DISPLAY" ] && alias -s dvi='evince'
# Set up dircolors
if [ -e $HOME/.dircolors/$SYS.cfg ]; then
dircolors=$HOME/.dircolors/$SYS.cfg
else
dircolors=$HOME/.dircolors/default.cfg
fi
eval `dircolors $dircolors`
# emacs command line editing
bindkey -v
@ -125,6 +116,8 @@ bindkey -v
# Completion
###
print_info_sub_noisy 2 'Initializing completion'
# load completion system
autoload -U compinit
compinit