diff options
Diffstat (limited to 'sh')
-rw-r--r-- | sh/profile.d/visual.sh | 10 | ||||
-rw-r--r-- | sh/shrc | 6 | ||||
-rw-r--r-- | sh/shrc.d/sd.sh | 16 |
3 files changed, 27 insertions, 5 deletions
diff --git a/sh/profile.d/visual.sh b/sh/profile.d/visual.sh index 119d81c7..94aee963 100644 --- a/sh/profile.d/visual.sh +++ b/sh/profile.d/visual.sh @@ -1,3 +1,9 @@ -# Use first found implementation of vi(1) -VISUAL='vi' +# If emacs is installed, and ~/.emacs exists, use emacs as the visual editor; +# otherwise, use the system's vi +if command -v emacs >/dev/null 2>&1 && + [ -f "$HOME"/.emacs ] ; then + VISUAL=emacs +else + VISUAL=vi +fi export VISUAL @@ -8,13 +8,15 @@ command -p stty -ixon -ctlecho 2>/dev/null HISTSIZE=$((1 << 12)) # If HOSTNAME isn't set by this shell, we'll do it -[ -n "$HOSTNAME" ] || HOSTNAME=$(uname -n) +if [ -z "$HOSTNAME" ] ; then + HOSTNAME=$(uname -n) +fi # Don't warn me about new mail unset -v MAILCHECK # Load all the POSIX-compatible functions from ~/.shrc.d; more advanced shells -# like bash will have their own functions +# like bash will have their own functions in addition to these for sh in "$HOME"/.shrc.d/*.sh ; do [ -e "$sh" ] || continue . "$sh" diff --git a/sh/shrc.d/sd.sh b/sh/shrc.d/sd.sh index 04b50f6d..10597832 100644 --- a/sh/shrc.d/sd.sh +++ b/sh/shrc.d/sd.sh @@ -38,12 +38,26 @@ sd() { return 2 fi + # Strip trailing slashes + while : ; do + case $1 in + *?/) set -- "${1%/}" ;; + *) break ;; + esac + done + # Read sole optional argument case $1 in + # Root has no siblings + /) + printf >&2 'sd(): Radical misunderstanding\n' + return 2 + ;; + # Slashes aren't allowed */*) - printf >&2 'bd(): Illegal slash\n' + printf >&2 'sd(): Illegal slash\n' return 2 ;; |