aboutsummaryrefslogtreecommitdiff
path: root/ksh
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2017-01-06 20:10:01 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-01-06 20:10:01 +1300
commit94331ff4049628e696d733420232d5b0cfef1919 (patch)
tree960c8ee85e03183022eb54e236745d4126fd1322 /ksh
parentMerge branch 'master' into port/bsd/netbsd (diff)
parentRename keyboard trap func less ambiguously (diff)
downloaddotfiles-94331ff4049628e696d733420232d5b0cfef1919.tar.gz
dotfiles-94331ff4049628e696d733420232d5b0cfef1919.zip
Merge branch 'master' into port/bsd/netbsd
Diffstat (limited to 'ksh')
-rw-r--r--ksh/kshrc16
-rw-r--r--ksh/kshrc.d/bind.ksh28
2 files changed, 43 insertions, 1 deletions
diff --git a/ksh/kshrc b/ksh/kshrc
index cf7812d6..5d481bb4 100644
--- a/ksh/kshrc
+++ b/ksh/kshrc
@@ -1,7 +1,21 @@
-# Emacs-style key bindings
+# Emacs-style key bindings; these are present in ksh88 and pdksh
set -o braceexpand
set -o emacs
+# Track locations of binaries
+set -o trackall
+
+# Use subshells to test these newer options, as ksh93 seems to get very upset
+# if you try to set an option and it doesn't exist
+
+# Try to get "**" as a recursive glob
+(set -o globstar) 2>/dev/null &&
+ set -o globstar
+
+# Try to get !-style history expansion
+(set -o histexpand) 2>/dev/null &&
+ set -o histexpand
+
# Save history
HISTFILE=$HOME/.ksh_history
HISTSIZE=$((1 << 10))
diff --git a/ksh/kshrc.d/bind.ksh b/ksh/kshrc.d/bind.ksh
new file mode 100644
index 00000000..34cb5f5a
--- /dev/null
+++ b/ksh/kshrc.d/bind.ksh
@@ -0,0 +1,28 @@
+# Try to bind ^I to complete words and ^L to clear the screen
+case $KSH_VERSION in
+
+ # ksh93 is lovely, but complex; rebind ^L so it does the same as Alt-^L
+ *'93'*)
+ keybd_trap() {
+ # shellcheck disable=SC2154
+ case ${.sh.edchar} in
+ $'\f') .sh.edchar=$'\e\f' ;;
+ esac
+ }
+ trap keybd_trap KEYBD
+ ;;
+
+ # More straightforward with mksh; bind keys to the appropriate emacs mode
+ # editing commands
+ *'MIRBSD KSH'*)
+ bind '^I'='complete'
+ bind '^L'='clear-screen'
+ ;;
+
+ # Similar with pdksh; there's a "complete" command, but not a "clear" one,
+ # so we fake it with clear(1) and some yanking
+ *'PD KSH'*)
+ bind '^I'='complete'
+ bind -m '^L'='^Uclear^J^Y'
+ ;;
+esac