Added --hist-readline that works without tty injection master
authorFrançois Fleuret <fleuret@meta.com>
Mon, 26 Jan 2026 16:20:45 +0000 (17:20 +0100)
committerFrançois Fleuret <fleuret@meta.com>
Mon, 26 Jan 2026 16:20:45 +0000 (17:20 +0100)
bash-selector.sh

index 63d3081..9416da5 100755 (executable)
@@ -43,6 +43,12 @@ function selector-history () {
     selector --bash -j -y -u -c 7,4,0,3 -q <(history)
 }
 
+function selector-history-readline () {
+    selector --bash -j -y -u -c 7,4,0,3 -q <(history) -o /tmp/selector-cmd
+    READLINE_LINE=$(echo /tmp/selector-cmd)
+    READLINE_POINT="${#READLINE_LINE}"
+}
+
 ######################################################################
 # Selector-based directory history
 ######################################################################
@@ -119,6 +125,11 @@ if [[ "$1" ]]; then
                 bind '"\C-[r":"\C-a\C-k selector-history\C-m"'
                 ;;
 
+            --hist-readline)
+                # M-r puts the selected history line in place of the current one
+                bind '"\C-[r":"\C-a\C-k selector-history-readline\C-m"'
+                ;;
+
             --cd)
                 # M-c provides a dynamic list of directories to cd into
                 bind '"\C-[c":"\C-a\C-k selector-cd-search\C-m"'