aboutsummaryrefslogtreecommitdiff
path: root/bbstartup.sh
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-09-30 15:46:24 -0700
committerBruce Hill <bruce@bruce-hill.com>2019-09-30 15:46:24 -0700
commit7a666d519556e9c7bf510d71565793978e7beba0 (patch)
treede0fdab0d45729219e7ba40c0c325df050bd2e83 /bbstartup.sh
parente341f51dc62af41494a8618ad8e8c31632e93053 (diff)
Overhaul of how binding commands works. It's now all handled through
bbstartup.sh, which loads bindings.bb and parses it to +bind:<keys>:<script> commands.
Diffstat (limited to 'bbstartup.sh')
-rwxr-xr-xbbstartup.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/bbstartup.sh b/bbstartup.sh
new file mode 100755
index 0000000..014bad5
--- /dev/null
+++ b/bbstartup.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+# This file contains the script that is run when bb launches
+# See API.md for details on bb's API.
+
+# Default XDG values
+[ ! "$XDG_CONFIG_HOME" ] && XDG_CONFIG_HOME=~/.config
+[ ! "$sysconfdir" ] && sysconfdir=/etc
+
+# Create some default marks:
+mkdir -p "$XDG_CONFIG_HOME/bb/marks"
+mark() {
+ ln -sT "$XDG_CONFIG_HOME/bb/marks/$1" "$2" 2>/dev/null
+}
+mark home ~
+mark root /
+mark config "$XDG_CONFIG_HOME"
+mark marks "$XDG_CONFIG_HOME/bb/marks"
+
+# Set viewing options
+bb +sort:+n
+bb +col:'*smpn'
+
+# Load key bindings
+# first check ~/.config/bb/bindings.bb, then /etc/xdg/bb/bindings.bb, then ./bindings.bb
+if [ -e "$XDG_CONFIG_HOME/bb/bindings.bb" ]; then
+ cat "$XDG_CONFIG_HOME/bb/bindings.bb"
+elif [ -e "$sysconfdir/xdg/bb/bindings.bb" ]; then
+ cat "$sysconfdir/xdg/bb/bindings.bb"
+elif [ -e bindings.bb ]; then
+ cat bindings.bb
+fi | sed -e '/^#/d' -e "s/^[^ ]/$(printf '\034')+bind:\\0/" | tr '\034' '\0' >> "$BBCMD"