From: Iain Patterson Date: Thu, 23 Apr 2009 21:13:15 +0000 (+0100) Subject: Separate aliases and variables. X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=b82d709dee82b7e05ae8b9fa87e0eea488da6a3d;p=profile.git Separate aliases and variables. Moved grep, ls and screen aliases and variables into their own files. These are grep.bashrc, ls.bashrc and screen.bashrc. --- diff --git a/.profile.d/aliases.bashrc b/.profile.d/aliases.bashrc index 4c424d4..943f879 100644 --- a/.profile.d/aliases.bashrc +++ b/.profile.d/aliases.bashrc @@ -1,16 +1,7 @@ -grep -V 2>/dev/null | grep GNU >/dev/null && alias grep='grep --color=auto' alias knh='kill_known_host' -alias l='ls' -alias ls='/bin/ls $LS_OPTIONS' if which vim 2>/dev/null | grep ^/ >/dev/null; then alias vim='vim +syn\ on' alias vi='vim' fi -if which krenew 2>/dev/null | grep ^/ >/dev/null; then - alias kscreen='krenew --' -else - alias kscreen='' -fi alias debug='valgrind --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=5 --verbose --time-stamp=yes --track-fds=yes' -alias session='bigscreen -rx -S session || kscreen bigscreen -S session' alias svnfind='find . -type f ! -path "*/.svn/*"' diff --git a/.profile.d/grep.bashrc b/.profile.d/grep.bashrc new file mode 100644 index 0000000..0872828 --- /dev/null +++ b/.profile.d/grep.bashrc @@ -0,0 +1,19 @@ +# Use colours for grep if possible. +if grep -V 2>/dev/null | grep GNU >/dev/null; then + alias grep='grep --color=auto' + + # Old versions of grep understand GREP_COLOR. + export GREP_COLOR='0;33' + + # Newer versions allow setting colours based on context, using GREP_COLORS. + # cx: Lines of context; sl: Matching lines; mt: Search string; fn: Filename + # ln: Line number; bn: Byte offset; se: Separators. + colours=$(tput colors 2>/dev/null) + if [ $colours = 256 ]; then + export GREP_COLORS='cx=38;5;246:sl=:mt=33:fn=38;5;25:ln=38;5;82:bn=33:se=38;5;246' + elif [ $colours -gt 88 ]; then + export GREP_COLORS='cx=38;5;84:sl=:mt=33:fn=38;5;22:ln=38;5;44:bn=33:se=38;5;84' + else + export GREP_COLORS='cx=31:sl=:mt=33:fn=36:ln=34:bn=33:se=31' + fi +fi diff --git a/.profile.d/ls.bashrc b/.profile.d/ls.bashrc new file mode 100644 index 0000000..88e76e0 --- /dev/null +++ b/.profile.d/ls.bashrc @@ -0,0 +1,17 @@ +alias l='ls' +alias ls='/bin/ls $LS_OPTIONS' + +# Check for GNU ls and add colour and ISO8601 dates if available. +ls=$(ls --help 2>/dev/null) +if echo "$ls" | grep gnu.org >/dev/null; then + eval `dircolors 2>/dev/null` 2>/dev/null + + LS_OPTIONS="--color=auto -F -b" + if echo $ls | grep -- --time-style >/dev/null; then + LS_OPTIONS="$LS_OPTIONS --time-style=long-iso" + fi + export LS_OPTIONS +elif [ "$SYSTEM" = "Darwin" ]; then + export LS_OPTIONS="-G -F -b" +fi +unset ls diff --git a/.profile.d/screen.bashrc b/.profile.d/screen.bashrc new file mode 100644 index 0000000..90b3707 --- /dev/null +++ b/.profile.d/screen.bashrc @@ -0,0 +1,17 @@ +# Fixup screen and define ``session'' if available. +screen=$(which screen 2>/dev/null) +if [ ! -z "$screen" ]; then + # Override SCREENDIR iff screen is not setuid. + if ! ls -l "$screen" | cut -d ' ' -f 1 | grep s >/dev/null; then + export SCREENDIR="$HOME/.screen/$HOSTNAME" + fi + + if which krenew 2>/dev/null | grep ^/ >/dev/null; then + alias kscreen='krenew --' + else + alias kscreen='' + fi + + alias session='bigscreen -rx -S session || kscreen bigscreen -S session' +fi +unset screen diff --git a/.profile.d/variables.bashrc b/.profile.d/variables.bashrc index a4fda1e..e3d8f04 100644 --- a/.profile.d/variables.bashrc +++ b/.profile.d/variables.bashrc @@ -2,35 +2,8 @@ export SSHTERM=urxvtc export SSHTERM_TITLE=-title export SSHTERM_EXEC=-e unset LANG -if ls --help 2>/dev/null | grep gnu.org >/dev/null; then - export LS_OPTIONS="--color=auto -F -b --time-style=long-iso" -elif [ "$SYSTEM" = "Darwin" ]; then - export LS_OPTIONS="-G -F -b" -fi export VISUAL=vim -eval `dircolors 2>/dev/null` 2>/dev/null unset XMODIFIERS #:-( export SSHTERM="urxvt" export SSHTERM_TITLE="-title" export SSHTERM_EXEC="-e" -export GREP_COLOR='0;33' -# cx: Lines of context; sl: Matching lines; mt: Search string; fn: Filename -# ln: Line number; bn: Byte offset; se: Separators. -colours=$(tput colors) -if [ $colours = 256 ]; then - export GREP_COLORS='cx=38;5;246:sl=:mt=33:fn=38;5;25:ln=38;5;82:bn=33:se=38;5;246' -elif [ $colours -gt 88 ]; then - export GREP_COLORS='cx=38;5;84:sl=:mt=33:fn=38;5;22:ln=38;5;44:bn=33:se=38;5;84' -else - export GREP_COLORS='cx=31:sl=:mt=33:fn=36:ln=34:bn=33:se=31' -fi - -# Override SCREENDIR iff screen is not setuid. -screen=$(which screen &>/dev/null) -if [ ! -z "$screen" ]; then - if ! ls -l "$screen" | cut -d ' ' -f 1 | grep s >/dev/null; then - export SCREENDIR="$HOME/.screen/$HOSTNAME" - fi -fi -unset screen -#mkdir -p "$SCREENDIR"