Compare commits

..

3 Commits

Author SHA1 Message Date
daniil-berg 7166d9196a fix(shell): bind arrows directly for bash history search
The macro form `"\e[A": "\C-x\C-p\C-e"` ran history-search-backward then
end-of-line to mimic zsh's cursor-at-end. But history-search-* takes its
prefix from start-of-line to point, and `\C-e` moves point to the end, so
the next Up searched for the whole recalled line, found nothing, and left
Up/Down dead after one press. Bind arrows straight to the search functions;
pure readline has no history-search-end widget, so cursor lands at the
prefix boundary.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-09 15:07:12 +02:00
daniil-berg 61de00137c shell: jump cursor to line end on bash history search
history-search-* leaves the cursor at the prefix boundary, not the end,
unlike zsh's history-search-end widget. Bind the search functions to
throwaway keys and map the arrows to a macro that runs the search then
end-of-line, so prefix recall lands the cursor at EOL like zsh.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 12:10:51 +02:00
daniil-berg ad5a6c98ea shell: centralize history config and create history dir
Move HISTFILE/HISTSIZE/SAVEHIST/HISTFILESIZE/HISTCONTROL into the shared
shell/exports as env vars; each shell ignores the other's name-specific
ones. Dedup that can't be an env var stays per-shell: HISTCONTROL=ignoreboth
for bash, setopt hist_ignore_all_dups/hist_ignore_space for zsh.

Also mkdir -p the HISTFILE parent in shell/interactive, so a fresh host
doesn't silently drop history when ~/.cache/shell is absent.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 11:49:55 +02:00
5 changed files with 24 additions and 6 deletions
+2 -1
View File
@@ -10,7 +10,8 @@
# Case-insensitive globbing (used in pathname expansion)
shopt -s nocaseglob;
# Append to the Bash history file, rather than overwriting it
# Append to the Bash history file, rather than overwriting it.
# (HISTFILE/HISTSIZE/HISTFILESIZE/HISTCONTROL come from ~/.config/shell/exports.)
shopt -s histappend;
# Autocorrect typos in path names when using `cd`
+8 -1
View File
@@ -6,7 +6,14 @@
$include /etc/inputrc
# zsh-style prefix history search: type a prefix, Up/Down walk matching
# history entries with cursor at end of line. Empty prefix = previous/next.
# history entries. Empty prefix = previous/next.
#
# Bind arrows straight to the search functions. Do NOT wrap in a macro that
# appends end-of-line (\C-e) to mimic zsh's cursor-at-end: \C-e moves point to
# the line end, and history-search-* takes its prefix from start-of-line to
# point -- so the next press searches for the whole recalled line, finds
# nothing, and Up/Down go dead. Pure readline has no history-search-end widget;
# cursor lands at the prefix boundary, which is readline's intended behavior.
"\e[A": history-search-backward
"\e[B": history-search-forward
"\eOA": history-search-backward
+7 -1
View File
@@ -7,8 +7,14 @@ export XDG_CACHE_HOME="$HOME/.cache"
# Default editor
export EDITOR='vim'
# Shell history file
# Shell history (env vars both shells read; each ignores the other's by name —
# zsh uses SAVEHIST, bash uses HISTFILESIZE/HISTCONTROL. zsh dedup is a setopt,
# not an env var, so it stays in .zshrc).
export HISTFILE="${XDG_CACHE_HOME:-$HOME/.cache}/shell/history"
export HISTSIZE=1000000 # commands kept in memory (both shells)
export SAVEHIST=1000000 # zsh: lines written to $HISTFILE
export HISTFILESIZE=1000000 # bash: lines written to $HISTFILE
export HISTCONTROL=ignoreboth # bash: drop dups + space-prefixed
# Global git config file
export GIT_CONFIG_GLOBAL="${XDG_CONFIG_HOME:-$HOME/.config}/git/config"
+4
View File
@@ -8,5 +8,9 @@ for _file in "${XDG_CONFIG_HOME:-$HOME/.config}"/shell/{aliases,functions,extra}
done
unset _file
# Ensure the history dir exists; neither shell mkdir's it, so without this
# $HISTFILE writes fail silently on a fresh host.
[ -n "$HISTFILE" ] && mkdir -p "$(dirname "$HISTFILE")"
# pyenv interactive shims (pyenv init - autodetects the running shell):
command -v pyenv >/dev/null 2>&1 && eval "$(pyenv init -)"
+3 -3
View File
@@ -12,9 +12,9 @@ setopt autocd # Automatically cd into typed directory.
stty stop undef # Disable ctrl-s to freeze terminal.
setopt interactive_comments
# History in cache directory:
HISTSIZE=10000000
SAVEHIST=10000000
# HISTFILE/HISTSIZE/SAVEHIST come from ~/.config/shell/exports (shared).
# Dedup is a setopt, not an env var (bash's HISTCONTROL=ignoreboth equivalent):
setopt hist_ignore_all_dups hist_ignore_space
# Basic auto/tab complete:
autoload -U compinit