aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-03-09 10:03:33 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-03-09 10:03:33 +1300
commitc3d4f097a7282f81d4c0efc702efdb6e99cb218c (patch)
tree14487758fd655d5c09a910ab1908bf1a29cd03bc
parentb5c783b95140f3fbd40c4e1cd73649c8bdc323dd (diff)
downloaddotfiles-c3d4f097a7282f81d4c0efc702efdb6e99cb218c.tar.gz
dotfiles-c3d4f097a7282f81d4c0efc702efdb6e99cb218c.zip
Use env vars not shell funcs for vim check
Set EDITOR and VISUAL appropriately based on what's on the system. We can't assume ed(1) unfortunately, but ex(1) should be there.
-rw-r--r--README.markdown2
-rw-r--r--sh/profile.d/editor.sh8
-rw-r--r--sh/profile.d/visual.sh8
-rw-r--r--sh/shrc.d/vim.sh13
4 files changed, 12 insertions, 19 deletions
diff --git a/README.markdown b/README.markdown
index 05d53270..4cd4820c 100644
--- a/README.markdown
+++ b/README.markdown
@@ -217,8 +217,6 @@ in `sh/shrc.d` to be loaded by any POSIX interactive shell. Those include:
preserved; I hate having `root`-owned files in my home directory.
* `tree()` colorizes GNU `tree(1)` output if possible (without having
`LS_COLORS` set).
-* `vim()` defines three functions to always use `vim(1)` as my `ex(1)`,
- `vi(1)` and `view(1)` implementation if it's available.
* `x()` is a one-key shortcut for `exec startx`.
There are a few other little tricks defined for other shells providing
diff --git a/sh/profile.d/editor.sh b/sh/profile.d/editor.sh
index ee0da70b..5d6b249e 100644
--- a/sh/profile.d/editor.sh
+++ b/sh/profile.d/editor.sh
@@ -1,3 +1,7 @@
-# Set command-line editor
-EDITOR=ed
+# Set command-line editor; ed if we've got it (!), but ex will do fine
+if command -v ed >/dev/null 2>&1 ; then
+ EDITOR=ed
+else
+ EDITOR=ex
+fi
export EDITOR
diff --git a/sh/profile.d/visual.sh b/sh/profile.d/visual.sh
index 95eb1d5d..d03da255 100644
--- a/sh/profile.d/visual.sh
+++ b/sh/profile.d/visual.sh
@@ -1,3 +1,7 @@
-# Set visual editor
-VISUAL=vi
+# 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
export VISUAL
diff --git a/sh/shrc.d/vim.sh b/sh/shrc.d/vim.sh
deleted file mode 100644
index e9174082..00000000
--- a/sh/shrc.d/vim.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-# If Vim exists on the system, use it instead of ex, vi, and view
-command -v vim >/dev/null 2>&1 || return
-
-# Define functions proper
-ex() {
- vim -e "$@"
-}
-vi() {
- vim "$@"
-}
-view() {
- vim -R "$@"
-}