aboutsummaryrefslogtreecommitdiff
path: root/sh
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-05-19 20:35:26 +1200
committerTom Ryder <tom@sanctum.geek.nz>2017-05-19 20:35:26 +1200
commita3ddf9e5799a4727625c0676d6e32c055640b9c5 (patch)
tree3e22a57ea4ae600cf9ec39b521b4b7cc7c407a46 /sh
parentMerge branch 'master' into port/bsd/freebsd (diff)
parentJust use whichever vi(1) we need as VISUAL (diff)
downloaddotfiles-a3ddf9e5799a4727625c0676d6e32c055640b9c5.tar.gz
dotfiles-a3ddf9e5799a4727625c0676d6e32c055640b9c5.zip
Merge branch 'master' into port/bsd/freebsd
Diffstat (limited to 'sh')
-rw-r--r--sh/profile.d/editor.sh17
-rw-r--r--sh/profile.d/options.sh2
-rw-r--r--sh/profile.d/visual.sh8
-rw-r--r--sh/shrc.d/bc.sh4
-rw-r--r--sh/shrc.d/ed.sh2
-rw-r--r--sh/shrc.d/grep.sh14
-rw-r--r--sh/shrc.d/la.sh2
-rw-r--r--sh/shrc.d/ll.sh2
-rw-r--r--sh/shrc.d/ls.sh8
9 files changed, 32 insertions, 27 deletions
diff --git a/sh/profile.d/editor.sh b/sh/profile.d/editor.sh
index 307879fe..debb93b6 100644
--- a/sh/profile.d/editor.sh
+++ b/sh/profile.d/editor.sh
@@ -3,12 +3,21 @@
if command -v ed >/dev/null 2>&1 ; then
EDITOR=ed
-# Failing that, if we have both vim(1) and exm(1df) in our $PATH, use the
-# latter to work around Vim's ex mode screen-clearing
-elif { command -v vim && command -v exm ; } >/dev/null 2>&1 ; then
+# Failing that, if the system's implementation of ex(1) looks like Vim and we
+# have exm(1df) in our $PATH, use the latter to work around Vim's ex mode
+# screen-clearing
+elif (
+ command -v ex >/dev/null 2>&1 || exit 1
+ command -v exm >/dev/null 2>&1 || exit 1
+ ver=$(ex --version 2>/dev/null | awk 'NR==1{print $1;exit}')
+ case $ver in
+ (VIM) exit 0 ;;
+ (*) exit 1 ;;
+ esac
+) >/dev/null 2>&1 ; then
EDITOR=exm
-# Otherwise, just call ex(1) directly
+# Otherwise, we can just call ex(1) directly
else
EDITOR=ex
fi
diff --git a/sh/profile.d/options.sh b/sh/profile.d/options.sh
index 1a511d75..89b5d245 100644
--- a/sh/profile.d/options.sh
+++ b/sh/profile.d/options.sh
@@ -5,7 +5,7 @@ options() {
# Check or create the directory to cache the options
# Shift the program name off; remaining arguments are the options to check
- dir=$HOME/.cache/$1
+ dir=$HOME/.cache/sh/opt/$1
prog=$1
shift
diff --git a/sh/profile.d/visual.sh b/sh/profile.d/visual.sh
index d03da255..38ab9893 100644
--- a/sh/profile.d/visual.sh
+++ b/sh/profile.d/visual.sh
@@ -1,7 +1,3 @@
-# Set visual editor; vim if we've got it, but vi will do fine
-if command -v vim >/dev/null 2>&1 ; then
- VISUAL=vim
-else
- VISUAL=vi
-fi
+# Use first found implementation of vi(1)
+VISUAL=vi
export VISUAL
diff --git a/sh/shrc.d/bc.sh b/sh/shrc.d/bc.sh
index 41331ff9..aee88e09 100644
--- a/sh/shrc.d/bc.sh
+++ b/sh/shrc.d/bc.sh
@@ -1,12 +1,12 @@
# Our ~/.profile should already have made a directory with the supported
# options for us; if not, we won't be wrapping bc(1) with a function at all
-[ -d "$HOME"/.cache/bc ] || return
+[ -d "$HOME"/.cache/sh/opt/bc ] || return
# Define function proper
bc() {
# Add --quiet to stop the annoying welcome banner
- [ -e "$HOME"/.cache/bc/quiet ] &&
+ [ -e "$HOME"/.cache/sh/opt/bc/quiet ] &&
set -- --quiet "$@"
# Run bc(1) with the concluded arguments
diff --git a/sh/shrc.d/ed.sh b/sh/shrc.d/ed.sh
index d7d3fa2f..a2b7818e 100644
--- a/sh/shrc.d/ed.sh
+++ b/sh/shrc.d/ed.sh
@@ -8,7 +8,7 @@ ed() {
fi
# Add --verbose to explain errors
- [ -e "$HOME"/.cache/ed/verbose ] &&
+ [ -e "$HOME"/.cache/sh/opt/ed/verbose ] &&
set -- --verbose "$@"
# Add an asterisk prompt (POSIX feature)
diff --git a/sh/shrc.d/grep.sh b/sh/shrc.d/grep.sh
index fc8f62c0..dd85a198 100644
--- a/sh/shrc.d/grep.sh
+++ b/sh/shrc.d/grep.sh
@@ -1,6 +1,6 @@
# Our ~/.profile should already have made a directory with the supported
# options for us; if not, we won't be wrapping grep(1) with a function at all
-[ -d "$HOME"/.cache/grep ] || return
+[ -d "$HOME"/.cache/sh/opt/grep ] || return
# Discard GNU grep(1) environment variables if the environment set them
unset -v GREP_OPTIONS
@@ -9,31 +9,31 @@ unset -v GREP_OPTIONS
grep() {
# Add --binary-files=without-match to gracefully skip binary files
- [ -e "$HOME"/.cache/grep/binary-files ] &&
+ [ -e "$HOME"/.cache/sh/opt/grep/binary-files ] &&
set -- --binary-files=without-match "$@"
# Add --color=auto if the terminal has at least 8 colors
- [ -e "$HOME"/.cache/grep/color ] &&
+ [ -e "$HOME"/.cache/sh/opt/grep/color ] &&
[ "$({ tput colors || tput Co ; } 2>/dev/null)" -ge 8 ] &&
set -- --color=auto "$@"
# Add --devices=skip to gracefully skip devices
- [ -e "$HOME"/.cache/grep/devices ] &&
+ [ -e "$HOME"/.cache/sh/opt/grep/devices ] &&
set -- --devices=skip "$@"
# Add --directories=skip to gracefully skip directories
- [ -e "$HOME"/.cache/grep/directories ] &&
+ [ -e "$HOME"/.cache/sh/opt/grep/directories ] &&
set -- --directories=skip "$@"
# Add --exclude to ignore .gitignore and .gitmodules files
- [ -e "$HOME"/.cache/grep/exclude ] &&
+ [ -e "$HOME"/.cache/sh/opt/grep/exclude ] &&
set -- \
--exclude=.gitignore \
--exclude=.gitmodules \
"$@"
# Add --exclude-dir to ignore version control dot-directories
- [ -e "$HOME"/.cache/grep/exclude-dir ] &&
+ [ -e "$HOME"/.cache/sh/opt/grep/exclude-dir ] &&
set -- \
--exclude-dir=.cvs \
--exclude-dir=.git \
diff --git a/sh/shrc.d/la.sh b/sh/shrc.d/la.sh
index e21ad8fb..1ac44b8e 100644
--- a/sh/shrc.d/la.sh
+++ b/sh/shrc.d/la.sh
@@ -1,7 +1,7 @@
# Run ls -A if we can (-A is not POSIX), ls -a otherwise
la() {
# Prefer --almost-all (exclude "." and "..") if available
- if [ -e "$HOME"/.cache/ls/almost-all ] ; then
+ if [ -e "$HOME"/.cache/sh/opt/ls/almost-all ] ; then
set -- -A "$@"
else
set -- -a "$@"
diff --git a/sh/shrc.d/ll.sh b/sh/shrc.d/ll.sh
index c8c95d3b..e9737c62 100644
--- a/sh/shrc.d/ll.sh
+++ b/sh/shrc.d/ll.sh
@@ -1,7 +1,7 @@
# Run ls -Al if we can (-A is not POSIX), ls -al otherwise
ll() {
# Prefer -A/--almost-all (exclude "." and "..") if available
- if [ -e "$HOME"/.cache/ls/almost-all ] ; then
+ if [ -e "$HOME"/.cache/sh/opt/ls/almost-all ] ; then
set -- -Al "$@"
else
set -- -al "$@"
diff --git a/sh/shrc.d/ls.sh b/sh/shrc.d/ls.sh
index 05e7a06c..40a0a5ce 100644
--- a/sh/shrc.d/ls.sh
+++ b/sh/shrc.d/ls.sh
@@ -1,6 +1,6 @@
# Our ~/.profile should already have made a directory with the supported
# options for us; if not, we won't be wrapping ls(1) with a function at all
-[ -d "$HOME"/.cache/ls ] || return
+[ -d "$HOME"/.cache/sh/opt/ls ] || return
# If the system has already aliased ls(1) for us, like Slackware or OpenBSD
# does, just get rid of it
@@ -20,17 +20,17 @@ ls() {
[ -t 1 ] && set -- -x "$@"
# Add --block-size=K to always show the filesize in kibibytes
- [ -e "$HOME"/.cache/ls/block-size ] &&
+ [ -e "$HOME"/.cache/sh/opt/ls/block-size ] &&
set -- --block-size=1024 "$@"
# Add --color if the terminal has at least 8 colors
- [ -e "$HOME"/.cache/ls/color ] &&
+ [ -e "$HOME"/.cache/sh/opt/ls/color ] &&
[ "$({ tput colors || tput Co ; } 2>/dev/null)" -ge 8 ] &&
set -- --color=auto "$@"
# Add --time-style='+%Y-%m-%d %H:%M:%S' to show the date in my preferred
# (fixed) format
- [ -e "$HOME"/.cache/ls/time-style ] &&
+ [ -e "$HOME"/.cache/sh/opt/ls/time-style ] &&
set -- --time-style='+%Y-%m-%d %H:%M:%S' "$@"
# If the operating system is FreeBSD, there are some specific options we