From b3c9a9c6e9bd1baf28dcb76cb347cf8f589bbd12 Mon Sep 17 00:00:00 2001 From: David Alexander Majnemer Date: Sat, 3 Jan 2009 14:15:00 -0600 Subject: [PATCH 01/18] - fixed a bug here and there - made it fully sh compliant (works even with solaris sh) --- commonsh/01_ports | 16 +++++++++------- commonsh/02_term | 32 ++++++++++++++++++++++---------- commonsh/10_alias | 22 ++++++++++++---------- commonsh/10_git | 14 ++++++++------ commonsh/10_pager | 11 ++++++----- commonsh/10_rlwrap | 3 ++- commonsh/10_utility | 21 ++++++++++----------- lessfilter | 2 +- 8 files changed, 70 insertions(+), 51 deletions(-) diff --git a/commonsh/01_ports b/commonsh/01_ports index bd443dd..d7ca964 100755 --- a/commonsh/01_ports +++ b/commonsh/01_ports @@ -1,25 +1,27 @@ -if [[ -d /opt/local/man ]] ; then - if [[ -z "${MANPATH}" ]] ; then - MANPATH="/opt/local/man":$(manpath) +#! /bin/sh + +if [ -d /opt/local/man ] ; then + if [ -z "${MANPATH}" ] ; then + MANPATH="/opt/local/man":`manpath` else MANPATH="/opt/local/man:${MANPATH}" fi export MANPATH fi -if [[ -d /opt/local/bin ]] ; then - if [[ -z "${PATH}" ]] ; then +if [ -d /opt/local/bin ] ; then + if [ -z "${PATH}" ] ; then PATH="/opt/local/bin" else PATH="/opt/local/bin:${PATH}" fi fi -if [[ -d /opt/local/sbin ]] ; then +if [ -d /opt/local/sbin ] ; then PATH="/opt/local/sbin:${PATH}" fi -if [[ -d /opt/local/libexec ]] ; then +if [ -d /opt/local/libexec ] ; then PATH="/opt/local/libexec:${PATH}" fi diff --git a/commonsh/02_term b/commonsh/02_term index ef28517..df6ed0c 100755 --- a/commonsh/02_term +++ b/commonsh/02_term @@ -1,7 +1,9 @@ +#! /bin/sh + # terminal fallback stuff -function fix_term () +fix_term () { - if (infocmp $1 &> /dev/null) ; then + if (infocmp $1 > /dev/null 2>&1) ; then echo $1 else case $1 in @@ -28,12 +30,14 @@ function fix_term () } # sorta hacky, but I cannot find a better way to do this :/ -function fix_terminfo_db () +fix_terminfo_db () { - if [[ `type -p infocmp` = "$1/bin/infocmp" ]] ; then - export TERMINFO="$1/share/terminfo" + if [ `command -v infocmp` = "$1/bin/infocmp" ] ; then + TERMINFO="$1/share/terminfo" + export TERMINFO fi } + # terminal surgery case `uname -s` in Interix) @@ -42,11 +46,19 @@ case `uname -s` in SunOS) fix_terminfo_db "/opt/csw" ;; + Darwin) + fix_terminfo_db "/opt/local" + ;; esac -export TERM=$(fix_term $TERM) - -if [[ $TERM == *256* ]] && (infocmp screen-256color-bce &> /dev/null) ; then - export SCREEN_COLOR="-256color" -fi +TERM=`fix_term $TERM` +export TERM +case $TERM in + *256*) + if (infocmp screen-256color-bce > /dev/null 2>&1) ; then + SCREEN_COLOR="-256color" + export SCREEN_COLOR + fi + ;; +esac diff --git a/commonsh/10_alias b/commonsh/10_alias index 5bdc09e..7915526 100755 --- a/commonsh/10_alias +++ b/commonsh/10_alias @@ -1,15 +1,16 @@ +#! /bin/sh # colors for dircolors in gdircolors dircolors ; do - if (type -p $dircolors &> /dev/null) ; then - [ -f /etc/DIR_COLORS ] && eval $($dircolors -b /etc/DIR_COLORS) && break - [ -f "${HOME}/.dir_colors" ] && eval $($dircolors -b "${HOME}/.dir_colors") && break - eval $($dircolors -b) && break + if (command -v $dircolors > /dev/null 2>&1) ; then + [ -f /etc/DIR_COLORS ] && eval `$dircolors -b /etc/DIR_COLORS` && break + [ -f "${HOME}/.dir_colors" ] && eval `$dircolors -b "${HOME}/.dir_colors"` && break + eval `$dircolors -b` && break fi done # gimmie an editor, make it a nice vi clone for EDITOR in vim elvis vile nvi vi ; do - (type -p $EDITOR &> /dev/null) && break + (command -v $EDITOR > /dev/null 2>&1) && break done export EDITOR @@ -23,7 +24,8 @@ case `uname -s` in alias grep='grep -d skip --color=auto' ;; FreeBSD|Darwin|DragonFly) - export LSCOLORS=ExGxFxDxCxDxDxHbaDacec + LSCOLORS=ExGxFxDxCxDxDxHbaDacec + export LSCOLORS alias ls="ls -Gh" alias grep='grep -d skip --color=auto' ;; @@ -31,18 +33,18 @@ case `uname -s` in alias ls="ls --color" ;; SunOS) - if (type -p gls &> /dev/null) ; then + if (command -v gls > /dev/null 2>&1) ; then alias ls="gls -h --color=auto" else alias ls="ls -h" fi - if (type -p ggrep &> /dev/null) ; then + if (command -v ggrep > /dev/null 2>&1) ; then alias grep='ggrep -d skip --color=auto' fi for locate in glocate slocate ; do - (type -p $locate &> /dev/null) && alias locate=$locate + (command -v $locate > /dev/null 2>&1) && alias locate=$locate done ;; esac @@ -52,4 +54,4 @@ alias du='du -h' alias ping='ping -c4' -(type -p time &> /dev/null) && alias time='command time' +(command -v time > /dev/null 2>&1) && alias time='command time' diff --git a/commonsh/10_git b/commonsh/10_git index 12e0d87..2bad1c5 100755 --- a/commonsh/10_git +++ b/commonsh/10_git @@ -1,21 +1,23 @@ -if [[ -d /usr/local/git/man ]] ; then - if [[ -z "${MANPATH}" ]] ; then - MANPATH="/usr/local/git/man":$(manpath) +#! /bin/sh + +if [ -d /usr/local/git/man ] ; then + if [ -z "${MANPATH}" ] ; then + MANPATH="/usr/local/git/man":`manpath` else MANPATH="/usr/local/git/man:${MANPATH}" fi export MANPATH fi -if [[ -d /usr/local/git/bin ]] ; then - if [[ -z "${PATH}" ]] ; then +if [ -d /usr/local/git/bin ] ; then + if [ -z "${PATH}" ] ; then PATH="/usr/local/git/bin" else PATH="/usr/local/git/bin:${PATH}" fi fi -if [[ -d /usr/local/git/libexec/git-core ]] ; then +if [ -d /usr/local/git/libexec/git-core ] ; then PATH="/usr/local/git/libexec/git-core:${PATH}" fi diff --git a/commonsh/10_pager b/commonsh/10_pager index 8f38326..b2ba957 100755 --- a/commonsh/10_pager +++ b/commonsh/10_pager @@ -1,17 +1,18 @@ for PAGER in less more pg ; do - (type -p $PAGER &> /dev/null) && break + (command -v $PAGER > /dev/null 2>&1) && break done export PAGER # if we are in less, we can set some options and use lesspipe -if [[ $PAGER = "less" ]] ; then +if [ $PAGER = less ] ; then # lesspipe can go by either lesspipe or lesspipe.sh for lesspipe in lesspipe lesspipe.sh ; do - if (type -p $lesspipe &> /dev/null) ; then - eval $(SHELL=/bin/sh $lesspipe) && break + if (command -v $lesspipe > /dev/null 2>&1) ; then + eval `SHELL=/bin/sh $lesspipe` && break fi done # let less be case insensitive - export LESS='-i -R -M' + LESS='-R -M' + export LESS fi diff --git a/commonsh/10_rlwrap b/commonsh/10_rlwrap index 5adb507..7627bac 100755 --- a/commonsh/10_rlwrap +++ b/commonsh/10_rlwrap @@ -1,3 +1,4 @@ +#! /bin/sh for wrap in rlwrap rlfe cle ; do - (type -p $wrap &> /dev/null) && alias ocaml="$wrap ocaml" && break + (command -v $wrap > /dev/null 2>&1) && alias ocaml="$wrap ocaml" && break done diff --git a/commonsh/10_utility b/commonsh/10_utility index 7455b1f..faa5942 100755 --- a/commonsh/10_utility +++ b/commonsh/10_utility @@ -1,15 +1,16 @@ +#! /bin/sh # utility.sh # Miscellaneous Utility Functions -function unkey-host () +unkey_host () { [ ${#} -ne 1 ] && return 1 sed -i -e "/$1/d" $HOME/.ssh/known_hosts } -function mkcd () +mkcd () { - if [[ -d "$1" ]] ; then + if [ -d "$1" ] ; then cd "$1" return fi @@ -17,16 +18,14 @@ function mkcd () mkdir -p "$1" && cd "$1" } -function extract () +extract () { - if [[ ! -f "$1" ]] ; then + if [ ! -f "$1" ] ; then echo "The file ("$1") does not exist!" return fi - local filename - - filename=$(echo "$1" | tr '[:upper:]' '[:lower:]') + filename=`echo "$1" | tr '[:upper:]' '[:lower:]'` case "$filename" in *.tar) @@ -42,10 +41,10 @@ function extract () unzip -qo "${1}" ;; *.gz|*.z) - gzip -dc "${1}" > $(basename "${1%.*}") + gzip -dc "${1}" > `basename "${1%.*}"` ;; *.bz2) - bzip2 -dc "${1}" > $(basename "${1%.*}") + bzip2 -dc "${1}" > `basename "${1%.*}"` ;; *.rar) unrar x -idq "${1}" @@ -60,7 +59,7 @@ function extract () lzma -dc "${1}" | tar xf ;; *.lzma) - lzma -dc "${1}" > $(basename "${1%.*}") + lzma -dc "${1}" > `basename "${1%.*}"` ;; *) echo "Unable to extract '"$1"'" diff --git a/lessfilter b/lessfilter index 3458743..08b6b51 100755 --- a/lessfilter +++ b/lessfilter @@ -1,4 +1,4 @@ -#!/bin/sh +#! /bin/sh # Decode file for less case `echo "$1" | tr '[:upper:]' '[:lower:]'` in # we don't handle archives, we let the big guy do it From cf7d1321d504a924b00bbde29f1d161f0ca52f4d Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Wed, 7 Jan 2009 00:54:32 -0500 Subject: [PATCH 02/18] reorder, prefer dir_colors in the home directory over global dir colors --- commonsh/10_alias | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commonsh/10_alias b/commonsh/10_alias index 7915526..f88ccaa 100755 --- a/commonsh/10_alias +++ b/commonsh/10_alias @@ -2,8 +2,8 @@ # colors for dircolors in gdircolors dircolors ; do if (command -v $dircolors > /dev/null 2>&1) ; then - [ -f /etc/DIR_COLORS ] && eval `$dircolors -b /etc/DIR_COLORS` && break [ -f "${HOME}/.dir_colors" ] && eval `$dircolors -b "${HOME}/.dir_colors"` && break + [ -f /etc/DIR_COLORS ] && eval `$dircolors -b /etc/DIR_COLORS` && break eval `$dircolors -b` && break fi done From 475fa8d51e0913b69774d78fff4fda12a72558f9 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Wed, 7 Jan 2009 00:57:27 -0500 Subject: [PATCH 03/18] cleaned up xmonad.hs nicely --- xmonad.hs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/xmonad.hs b/xmonad.hs index 93d87e2..701865b 100644 --- a/xmonad.hs +++ b/xmonad.hs @@ -1,8 +1,7 @@ import XMonad -import XMonad.Layout import XMonad.Layout.Grid -import XMonad.Layout.NoBorders +import XMonad.Layout.NoBorders(smartBorders) import XMonad.Hooks.DynamicLog import XMonad.Hooks.ManageDocks @@ -11,10 +10,9 @@ import XMonad.Util.Run(spawnPipe) import XMonad.Util.EZConfig(additionalKeys) import XMonad.Prompt -import XMonad.Prompt.Shell -import XMonad.Prompt.Ssh +import XMonad.Prompt.Shell(shellPrompt) -import System.IO +import System.IO(hPutStrLn) myLayoutHook = tiled ||| Mirror tiled ||| Grid ||| Full where @@ -30,6 +28,8 @@ myLayoutHook = tiled ||| Mirror tiled ||| Grid ||| Full -- Percent of screen to increment by when resizing panes delta = 3/100 +myModMask = mod1Mask + main = do xmproc <- spawnPipe "xmobar" xmonad $ defaultConfig { @@ -38,9 +38,10 @@ main = do logHook = dynamicLogWithPP $ xmobarPP { ppOutput = hPutStrLn xmproc, ppTitle = xmobarColor "green" "" - } - } `additionalKeys` + }, + modMask = myModMask + } `additionalKeys` [ - ((mod1Mask, xK_o), shellPrompt defaultXPConfig { position = Top }), - ((mod1Mask, xK_b), sendMessage ToggleStruts) + ((myModMask, xK_o), shellPrompt defaultXPConfig { position = Top }), + ((myModMask, xK_b), sendMessage ToggleStruts) ] From a81da747518d3dec522b5b6bcf0febf291035419 Mon Sep 17 00:00:00 2001 From: David Alexander Majnemer Date: Tue, 13 Jan 2009 01:31:32 -0600 Subject: [PATCH 04/18] add support for ksh-like shells --- install.pl | 4 ++++ ksh/options | 4 ++++ ksh/prompt | 9 +++++++++ kshrc | 11 +++++++++++ mkshrc | 1 + 5 files changed, 29 insertions(+) create mode 100755 ksh/options create mode 100755 ksh/prompt create mode 100644 kshrc create mode 120000 mkshrc diff --git a/install.pl b/install.pl index 71fa68f..370587d 100755 --- a/install.pl +++ b/install.pl @@ -56,6 +56,10 @@ my %links = ( zsh => '.zsh', zshrc => '.zshrc', + ksh => '.ksh', + kshrc => '.kshrc', + mkshrc => '.mkshrc', + Xdefaults => '.Xdefaults', Xresources => '.Xresources', diff --git a/ksh/options b/ksh/options new file mode 100755 index 0000000..409795c --- /dev/null +++ b/ksh/options @@ -0,0 +1,4 @@ +set -o emacs + +HISTSIZE=1000 +export HISTSIZE diff --git a/ksh/prompt b/ksh/prompt new file mode 100755 index 0000000..739815f --- /dev/null +++ b/ksh/prompt @@ -0,0 +1,9 @@ +if [ $USER = root ] ; then + BASE="#" +else + BASE="$" +fi + + +PS1=$'\E[01;32m'"${USER} "$'\E[01;34m''$PWD'" ${BASE} "$'\E[0m' +export PS1 diff --git a/kshrc b/kshrc new file mode 100644 index 0000000..68467b0 --- /dev/null +++ b/kshrc @@ -0,0 +1,11 @@ +if [ -d "${HOME}/.commonsh" ] ; then + for file in "${HOME}"/.commonsh/* ; do + . $file + done +fi + +if [ -d "${HOME}/.ksh" ] ; then + for file in "${HOME}"/.ksh/* ; do + . $file + done +fi diff --git a/mkshrc b/mkshrc new file mode 120000 index 0000000..6324cbf --- /dev/null +++ b/mkshrc @@ -0,0 +1 @@ +kshrc \ No newline at end of file From 73028838e887cb470241ced77547f40473b93e38 Mon Sep 17 00:00:00 2001 From: David Alexander Majnemer Date: Tue, 13 Jan 2009 01:33:19 -0600 Subject: [PATCH 05/18] bug fix for title_prompt in bash, use proper globs --- bash/title_prompt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bash/title_prompt b/bash/title_prompt index ee37db7..d8987b3 100755 --- a/bash/title_prompt +++ b/bash/title_prompt @@ -12,12 +12,12 @@ function do_prompt () fi export PS1="\[\033[01;32m\]\u@\h \[\033[01;34m\]\w ${ERROR_PROMPT}${BASE} \[\033[00m\]" - [[ $TERM != "cons*" ]] && [[ $TERM != "linux" ]] && + [[ $TERM != cons* ]] && [ $TERM != linux ] && echo -ne "\033]0;${USER}@${HOSTNAME}\007" } PROMPT_COMMAND=do_prompt -[[ $TERM != "cons*" ]] && [[ $TERM != "linux" ]] && +[[ $TERM != cons* ]] && [ $TERM != linux ] && trap 'echo -e "\e]1;${USER}@${HOSTNAME}: $BASH_COMMAND\007\c"' DEBUG From 6e08a71d6923741e9a4d70d256c71c51de477a3d Mon Sep 17 00:00:00 2001 From: David Alexander Majnemer Date: Tue, 13 Jan 2009 01:34:24 -0600 Subject: [PATCH 06/18] properly handle the case where there is no infocmp --- commonsh/02_term | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commonsh/02_term b/commonsh/02_term index df6ed0c..b6284ca 100755 --- a/commonsh/02_term +++ b/commonsh/02_term @@ -32,7 +32,7 @@ fix_term () # sorta hacky, but I cannot find a better way to do this :/ fix_terminfo_db () { - if [ `command -v infocmp` = "$1/bin/infocmp" ] ; then + if [ `command -v infocmp 2>/dev/null` = "$1/bin/infocmp" ] ; then TERMINFO="$1/share/terminfo" export TERMINFO fi From ca85e83f9e1fff912ef7dee55ffddc3ccb12fee3 Mon Sep 17 00:00:00 2001 From: David Alexander Majnemer Date: Tue, 13 Jan 2009 01:34:56 -0600 Subject: [PATCH 07/18] remove debug info from shinit --- shinit | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 shinit diff --git a/shinit b/shinit new file mode 100644 index 0000000..28cf231 --- /dev/null +++ b/shinit @@ -0,0 +1,11 @@ +if [ -d "${HOME}/.commonsh" ] ; then + for file in "${HOME}"/.commonsh/* ; do + . $file + done +fi + +if [ -d "${HOME}/.sh" ] ; then + for file in "${HOME}"/.sh/* ; do + . $file + done +fi From cb467422ab5f0b0f039beff94d428b5f41d204cf Mon Sep 17 00:00:00 2001 From: David Alexander Majnemer Date: Tue, 13 Jan 2009 01:36:03 -0600 Subject: [PATCH 08/18] add support for sh in the install.pl script --- install.pl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/install.pl b/install.pl index 370587d..f183ed0 100755 --- a/install.pl +++ b/install.pl @@ -60,6 +60,9 @@ my %links = ( kshrc => '.kshrc', mkshrc => '.mkshrc', + sh => '.sh', + shinit => '.shinit', + Xdefaults => '.Xdefaults', Xresources => '.Xresources', From 6b5159f65e68c5ba55c6cf26c547583bcb6d4445 Mon Sep 17 00:00:00 2001 From: David Alexander Majnemer Date: Tue, 13 Jan 2009 01:36:27 -0600 Subject: [PATCH 09/18] add support for FCEDIT, this makes sure that history is modified with EDITOR in zsh, bash and ksh --- commonsh/10_alias | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/commonsh/10_alias b/commonsh/10_alias index 7915526..3f7c204 100755 --- a/commonsh/10_alias +++ b/commonsh/10_alias @@ -14,6 +14,10 @@ for EDITOR in vim elvis vile nvi vi ; do done export EDITOR +# make the history editor the editor we want +FCEDIT=$EDITOR +export $FCEDIT + # aliases alias cd..='cd ..' From 9ed92223897b050adc244dbb6b5f12d36be9b675 Mon Sep 17 00:00:00 2001 From: David Alexander Majnemer Date: Tue, 13 Jan 2009 01:37:29 -0600 Subject: [PATCH 10/18] remove implicit bashism from lesspipe, it only works with bash! shell emulation should work around this now --- commonsh/10_pager | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/commonsh/10_pager b/commonsh/10_pager index b2ba957..6e3a508 100755 --- a/commonsh/10_pager +++ b/commonsh/10_pager @@ -5,12 +5,17 @@ export PAGER # if we are in less, we can set some options and use lesspipe if [ $PAGER = less ] ; then - # lesspipe can go by either lesspipe or lesspipe.sh for lesspipe in lesspipe lesspipe.sh ; do - if (command -v $lesspipe > /dev/null 2>&1) ; then - eval `SHELL=/bin/sh $lesspipe` && break + lesspipe_test=`command -v ${lesspipe} 2>/dev/null` + if [ -n $lesspipe_test ] ; then + LESSOPEN="| ${lesspipe_test} %s" && break + export LESSOPEN fi done + if [ $lesspipe = lesspipe ] ; then + LESSCLOSE="${lesspipe_test} %s %s" + export LESSCLOSE + fi # let less be case insensitive LESS='-R -M' From ef9da6dbac2b7788a3da71fd008b87d4754ff1e1 Mon Sep 17 00:00:00 2001 From: David Alexander Majnemer Date: Tue, 13 Jan 2009 01:39:40 -0600 Subject: [PATCH 11/18] remove three bashism, over-use of [[ ]], $() and source --- bash/completion | 2 +- bash/git | 2 +- bashrc | 8 ++++---- zsh/icc | 8 ++++---- zsh/options | 1 - zsh/prompt | 2 +- zsh/title | 4 ++-- zshrc | 14 +++++++------- 8 files changed, 20 insertions(+), 21 deletions(-) diff --git a/bash/completion b/bash/completion index 162d7c6..883b676 100755 --- a/bash/completion +++ b/bash/completion @@ -1,3 +1,3 @@ for file in /etc/bash_completion /opt/local/etc/bash_completion ; do - [ -f ${file} ] && source $file && break + [ -f ${file} ] && . $file && break done diff --git a/bash/git b/bash/git index 8a47fe0..a7edcf1 100755 --- a/bash/git +++ b/bash/git @@ -1,3 +1,3 @@ if [ -x /usr/local/git/contrib/completion/git-completion.bash ]; then - source /usr/local/git/contrib/completion/git-completion.bash + . /usr/local/git/contrib/completion/git-completion.bash fi diff --git a/bashrc b/bashrc index 3569802..2d6a468 100644 --- a/bashrc +++ b/bashrc @@ -18,14 +18,14 @@ shopt -s histappend # update the values of LINES and COLUMNS. shopt -s checkwinsize -if [[ -d "${HOME}/.commonsh" ]] ; then +if [ -d "${HOME}/.commonsh" ] ; then for file in "${HOME}"/.commonsh/* ; do - source $file + . $file done fi -if [[ -d "${HOME}/.bash" ]] ; then +if [ -d "${HOME}/.bash" ] ; then for file in "${HOME}"/.bash/* ; do - source $file + . $file done fi diff --git a/zsh/icc b/zsh/icc index a796a54..92a299d 100755 --- a/zsh/icc +++ b/zsh/icc @@ -1,7 +1,7 @@ local iccvars_path; -if [[ -d "/opt/intel/Compiler" ]] ; then +if [ -d "/opt/intel/Compiler" ] ; then iccvars_path=$(echo /opt/intel/Compiler/11.*/*/bin/iccvars.sh(On[1])) - if [[ -r $iccvars_path ]] ; then + if [ -r $iccvars_path ] ; then case `uname -m` in x86_64) source $iccvars_path intel64 @@ -14,9 +14,9 @@ if [[ -d "/opt/intel/Compiler" ]] ; then ;; esac fi -elif [[ -d "/opt/intel/cc" ]] || [[ -d "/opt/intel/cce" ]] ; then +elif [ -d "/opt/intel/cc" ] || [ -d "/opt/intel/cce" ] ; then iccvars_path=$(echo /opt/intel/cc*/(10|9).*/bin/iccvars.sh(On[1])) - if [[ -r $iccvars_path ]] ; then + if [ -r $iccvars_path ] ; then source $iccvars_path fi fi diff --git a/zsh/options b/zsh/options index 9741a2a..f5b1bae 100755 --- a/zsh/options +++ b/zsh/options @@ -41,4 +41,3 @@ setopt HIST_IGNORE_ALL_DUPS unsetopt HIST_BEEP unsetopt EXTENDED_HISTORY - diff --git a/zsh/prompt b/zsh/prompt index 28415ae..de19ff7 100755 --- a/zsh/prompt +++ b/zsh/prompt @@ -1,5 +1,5 @@ # prompt -if [[ -z ${SSH_TTY} ]] ; then +if [ -z ${SSH_TTY} ] ; then PROMPT=$'%{\e[01;32m%}%n@%m %{\e[01;34m%}%~ %(?..%{\e[01;31m%})%(!.#.$) %{\e[00;00m%}' RPROMPT=$'%1(j.%{\e[00;36m%}[%j].)%{\e[01;33m%}[%t]%{\e[00;00m%}' else diff --git a/zsh/title b/zsh/title index 5a010ae..4c2bc07 100755 --- a/zsh/title +++ b/zsh/title @@ -3,7 +3,7 @@ precmd() { local termtitle - termtitle=$(print -P "%n@%m") + termtitle=`print -P "%n@%m"` title zsh "$termtitle" } @@ -16,7 +16,7 @@ preexec() # Prepend this string to the title. # termtitle=$(print -P "%(!.-=*[ROOT]*=- | .)%n@%m:") - termtitle=$(print -P "%n@%m:") + termtitle=`print -P "%n@%m:"` case $cmd[1] in fg) diff --git a/zshrc b/zshrc index ff17fbd..b6cb29c 100644 --- a/zshrc +++ b/zshrc @@ -8,7 +8,7 @@ autoload -U compinit; compinit -d "${HOME}/.zsh/.zcompdump" autoload -U age autoload -U zmv -if [[ ${ZSH_VERSION//.} -gt 420 ]] ; then +if [ ${ZSH_VERSION//.} -gt 420 ] ; then autoload -U url-quote-magic zle -N self-insert url-quote-magic fi @@ -22,11 +22,11 @@ export LOGCHECK=30 export WATCHFMT=$'\e[01;36m'" -- %n@%m has %(a.Logged In.Logged out) --"$'\e[00;00m' # directory hashes -if [[ -d "${HOME}/sandbox" ]] ; then +if [ -d "${HOME}/sandbox" ] ; then hash -d sandbox="${HOME}/sandbox" fi -if [[ -d "${HOME}/work" ]] ; then +if [ -d "${HOME}/work" ] ; then hash -d work="${HOME}/work" for dir in "${HOME}"/work/*(N-/) ; do @@ -35,15 +35,15 @@ if [[ -d "${HOME}/work" ]] ; then fi # common shell utils -if [[ -d "${HOME}/.commonsh" ]] ; then +if [ -d "${HOME}/.commonsh" ] ; then for file in "${HOME}"/.commonsh/*(N.x:t) ; do - source "${HOME}/.commonsh/${file}" + . "${HOME}/.commonsh/${file}" done fi # extras -if [[ -d "${HOME}/.zsh" ]] ; then +if [ -d "${HOME}/.zsh" ] ; then for file in "${HOME}"/.zsh/*(N.x:t) ; do - source "${HOME}/.zsh/${file}" + . "${HOME}/.zsh/${file}" done fi From 550c3e7e7934236b5b13875a4a75ac50c5765799 Mon Sep 17 00:00:00 2001 From: David Alexander Majnemer Date: Tue, 13 Jan 2009 01:40:46 -0600 Subject: [PATCH 12/18] add generic title support for a very basic sh --- sh/title | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 sh/title diff --git a/sh/title b/sh/title new file mode 100644 index 0000000..a0d90df --- /dev/null +++ b/sh/title @@ -0,0 +1,8 @@ +if [ $USER = root ] ; then + BASE="#" +else + BASE="$" +fi + +PS1="${USER} ${BASE} " +export PS1 From 5c749def3cc315c31a7154ddcb2015e51941052a Mon Sep 17 00:00:00 2001 From: David Alexander Majnemer Date: Tue, 13 Jan 2009 01:41:04 -0600 Subject: [PATCH 13/18] nicer way to handle OS X for kill completion --- zsh/completion | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zsh/completion b/zsh/completion index 3693bf3..05b91b0 100755 --- a/zsh/completion +++ b/zsh/completion @@ -44,7 +44,7 @@ case `uname -s` in zstyle ':completion:*:processes-names' command 'ps -e -o args | awk "NR != 1"' ;; Darwin) - if [[ $(sw_vers -productVersion) > 10.4 ]] ; then + if [[ `sw_vers -productVersion` = 10<5->.<-> ]] ; then zstyle ':completion:*:processes-names' command 'ps -e -o command | awk "NR != 1"' else zstyle ':completion:*:processes-names' command 'ps -A -o command | awk "NR != 1"' @@ -81,7 +81,7 @@ case `uname -s` in zstyle ':completion:*:*:killall:*:processes-names' command "ps -u '${USERNAME}' -s" ;; Darwin) - if [[ $(sw_vers -productVersion) > 10.4 ]] ; then + if [[ `sw_vers -productVersion` = 10<5->.<-> ]] ; then zstyle ':completion:*:*:killall:*:processes-names' command "ps -U '${USERNAME}' -o comm" else zstyle ':completion:*:*:killall:*:processes-names' command "ps -U '${USERNAME}' -o command" From 258d4b41505863f5ff7f5daa2aa024acf64e58f2 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Tue, 13 Jan 2009 02:51:57 -0500 Subject: [PATCH 14/18] make mkshrc a sh instead of a ksh --- mkshrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkshrc b/mkshrc index 6324cbf..68a689f 120000 --- a/mkshrc +++ b/mkshrc @@ -1 +1 @@ -kshrc \ No newline at end of file +shinit \ No newline at end of file From bcd389c0f1302a2f4a004dcc2b969d0d9f1f359b Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Tue, 13 Jan 2009 02:55:13 -0500 Subject: [PATCH 15/18] add basic support for dir_colors --- dir_colors | 170 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 dir_colors diff --git a/dir_colors b/dir_colors new file mode 100644 index 0000000..5dd0f52 --- /dev/null +++ b/dir_colors @@ -0,0 +1,170 @@ +# Configuration file for dircolors, a utility to help you set the +# LS_COLORS environment variable used by GNU ls with the --color option. +# Copyright (C) 1996, 1999-2008 +# Free Software Foundation, Inc. +# Copying and distribution of this file, with or without modification, +# are permitted provided the copyright notice and this notice are preserved. +# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the +# slackware version of dircolors) are recognized but ignored. +# Below, there should be one TERM entry for each termtype that is colorizable +TERM Eterm +TERM ansi +TERM color-xterm +TERM con132x25 +TERM con132x30 +TERM con132x43 +TERM con132x60 +TERM con80x25 +TERM con80x28 +TERM con80x30 +TERM con80x43 +TERM con80x50 +TERM con80x60 +TERM cons25 +TERM console +TERM cygwin +TERM dtterm +TERM eterm-color +TERM gnome +TERM gnome-256color +TERM konsole +TERM kterm +TERM linux +TERM linux-c +TERM mach-color +TERM mlterm +TERM putty +TERM rxvt +TERM rxvt-cygwin +TERM rxvt-cygwin-native +TERM rxvt-unicode +TERM screen +TERM screen-256color +TERM screen-bce +TERM screen-w +TERM screen.linux +TERM vt100 +TERM xterm +TERM xterm-16color +TERM xterm-256color +TERM xterm-88color +TERM xterm-color +TERM xterm-debian +# Below are the color init strings for the basic file types. A color init +# string consists of one or more of the following numeric codes: +# Attribute codes: +# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed +# Text color codes: +# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white +# Background color codes: +# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white +NORMAL 00 # global default, although everything should be something. +FILE 00 # normal file +DIR 01;34 # directory +LINK 01;36 # symbolic link. (If you set this to 'target' instead of a + # numerical value, the color is as for the file pointed to.) +FIFO 40;33 # pipe +SOCK 01;35 # socket +DOOR 01;35 # door +BLK 40;33;01 # block device driver +CHR 40;33;01 # character device driver +ORPHAN 40;31;01 # symlink to nonexistent file, or non-stat'able file +SETUID 37;41 # file that is setuid (u+s) +SETGID 30;43 # file that is setgid (g+s) +STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w) +OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky +STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable +# This is for files with execute permission: +EXEC 01;32 +# List any file extensions like '.gz' or '.tar' that you would like ls +# to colorize below. Put the extension, a space, and the color init string. +# (and any comments you want to add after a '#') +# If you use DOS-style suffixes, you may want to uncomment the following: +#.cmd 01;32 # executables (bright green) +#.exe 01;32 +#.com 01;32 +#.btm 01;32 +#.bat 01;32 +# Or if you want to colorize scripts even if they do not have the +# executable bit actually set. +#.sh 01;32 +#.csh 01;32 + # archives or compressed (bright red) +.tar 01;31 +.tgz 01;31 +.svgz 01;31 +.arj 01;31 +.taz 01;31 +.lzh 01;31 +.lzma 01;31 +.zip 01;31 +.z 01;31 +.Z 01;31 +.dz 01;31 +.gz 01;31 +.bz2 01;31 +.bz 01;31 +.tbz2 01;31 +.tz 01;31 +.deb 01;31 +.rpm 01;31 +.jar 01;31 +.rar 01;31 +.ace 01;31 +.zoo 01;31 +.cpio 01;31 +.7z 01;31 +.rz 01;31 +# image formats +.jpg 01;35 +.jpeg 01;35 +.gif 01;35 +.bmp 01;35 +.pbm 01;35 +.pgm 01;35 +.ppm 01;35 +.tga 01;35 +.xbm 01;35 +.xpm 01;35 +.tif 01;35 +.tiff 01;35 +.png 01;35 +.svg 01;35 +.mng 01;35 +.pcx 01;35 +.mov 01;35 +.mpg 01;35 +.mpeg 01;35 +.m2v 01;35 +.mkv 01;35 +.ogm 01;35 +.mp4 01;35 +.m4v 01;35 +.mp4v 01;35 +.vob 01;35 +.qt 01;35 +.nuv 01;35 +.wmv 01;35 +.asf 01;35 +.rm 01;35 +.rmvb 01;35 +.flc 01;35 +.avi 01;35 +.fli 01;35 +.gl 01;35 +.dl 01;35 +.xcf 01;35 +.xwd 01;35 +.yuv 01;35 +# audio formats +.aac 00;36 +.au 00;36 +.flac 00;36 +.mid 00;36 +.midi 00;36 +.mka 00;36 +.mp3 00;36 +.mpc 00;36 +.ogg 00;36 +.ra 00;36 +.wav 00;36 From 46bc836858c21c7346e249921845851925ee5007 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Tue, 13 Jan 2009 03:00:02 -0500 Subject: [PATCH 16/18] add support to install dir_colors --- install.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/install.pl b/install.pl index f183ed0..19b9d50 100755 --- a/install.pl +++ b/install.pl @@ -39,6 +39,7 @@ unless(eval {symlink('', ''); 1;}) { my %links = ( screenrc => '.screenrc', toprc => '.toprc', + dir_colors => '.dir_colors', lessfilter => '.lessfilter', vim => '.vim', From 7b54c43263a78c49c75aefb31d04b84d794f2663 Mon Sep 17 00:00:00 2001 From: David Alexander Majnemer Date: Tue, 13 Jan 2009 02:09:07 -0600 Subject: [PATCH 17/18] add support for solaris and zsh --- dir_colors | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/dir_colors b/dir_colors index 5dd0f52..c812869 100644 --- a/dir_colors +++ b/dir_colors @@ -69,22 +69,22 @@ DOOR 01;35 # door BLK 40;33;01 # block device driver CHR 40;33;01 # character device driver ORPHAN 40;31;01 # symlink to nonexistent file, or non-stat'able file -SETUID 37;41 # file that is setuid (u+s) -SETGID 30;43 # file that is setgid (g+s) -STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w) -OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky -STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable +# SETUID 37;41 # file that is setuid (u+s) +# SETGID 30;43 # file that is setgid (g+s) +# STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w) +# OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky +# STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable # This is for files with execute permission: EXEC 01;32 # List any file extensions like '.gz' or '.tar' that you would like ls # to colorize below. Put the extension, a space, and the color init string. # (and any comments you want to add after a '#') # If you use DOS-style suffixes, you may want to uncomment the following: -#.cmd 01;32 # executables (bright green) -#.exe 01;32 -#.com 01;32 -#.btm 01;32 -#.bat 01;32 +.cmd 01;32 # executables (bright green) +.exe 01;32 +.com 01;32 +.btm 01;32 +.bat 01;32 # Or if you want to colorize scripts even if they do not have the # executable bit actually set. #.sh 01;32 From 9c219d3d970926f7cc5a7d665f80b7fa380172cd Mon Sep 17 00:00:00 2001 From: David Alexander Majnemer Date: Tue, 13 Jan 2009 15:17:11 -0600 Subject: [PATCH 18/18] add support for really old xterm, try to swap with xterm-color --- commonsh/02_term | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/commonsh/02_term b/commonsh/02_term index b6284ca..ef6b1a2 100755 --- a/commonsh/02_term +++ b/commonsh/02_term @@ -52,6 +52,14 @@ case `uname -s` in esac TERM=`fix_term $TERM` + +# I am sorry to hear that you are running an +# xterm that has no colors (I am looking at you solaris) +if [ $TERM = xterm ] && (type -p tput > /dev/null 2>&1) && [ `tput -T xterm colors` = -1 ] ; then + # lets see what we can do about your terrible term + TERM=`fix_term xterm-color` +fi + export TERM case $TERM in