diff options
Diffstat (limited to 'fedora/.config/bash/keymaps.bash')
| -rw-r--r-- | fedora/.config/bash/keymaps.bash | 38 |
1 files changed, 12 insertions, 26 deletions
diff --git a/fedora/.config/bash/keymaps.bash b/fedora/.config/bash/keymaps.bash index 8335f3e..15bd7e2 100644 --- a/fedora/.config/bash/keymaps.bash +++ b/fedora/.config/bash/keymaps.bash @@ -11,15 +11,13 @@ PROMPT_COMMAND='echo -ne "\e[5 q"' # ---------- helper: pre_cmd ---------- pre_cmd() { - local txt="$1" - if [[ -z "${READLINE_LINE+set}" ]]; then - printf '%s ' "$txt" - return + local last_cmd + last_cmd=$(history 1 | sed 's/^[ ]*[0-9]*[ ]*//') + + if [[ $last_cmd != sudo* ]]; then + READLINE_LINE="sudo $last_cmd" + READLINE_POINT=${#READLINE_LINE} fi - local left=${READLINE_LINE:0:READLINE_POINT} - local right=${READLINE_LINE:READLINE_POINT} - READLINE_LINE="${left}${txt} ${right}" - READLINE_POINT=$((READLINE_POINT + ${#txt} + 1)) } # ---------- Clipboard detection ---------- @@ -146,15 +144,14 @@ sudo_command_line() { pre_cmd "sudo"; } # ---------- wrappers (u-prefix REMOVED) ---------- bc() { command -v bc >/dev/null 2>&1 && /usr/bin/env bc "$@" || printf 'bc: not found\n' >&2; } cdi() { command -v cdi >/dev/null 2>&1 && cdi "$@" || printf 'cdi: not found\n' >&2; } -lastvim() { command -v lastvim >/dev/null 2>&1 && lastvim "$@" || printf 'lastvim: not found\n' >&2; } +lastfiles() { command -v lastfiles >/dev/null 2>&1 && lastfiles "$@" || printf 'lastfiles: not found\n' >&2; } htop() { command -v htop >/dev/null 2>&1 && htop "$@" || printf 'htop: not found\n' >&2; } sessionizer() { command -v sessionizer >/dev/null 2>&1 && sessionizer "$@" || printf 'sessionizer: not found\n' >&2; } upd() { command -v upd >/dev/null 2>&1 && upd "$@" || printf 'upd: not found\n' >&2; } cht() { command -v cht >/dev/null 2>&1 && cht "$@" || printf 'cht: not found\n' >&2; } # from '^ucht' -> 'cht' ali() { command -v ali >/dev/null 2>&1 && ali "$@" || printf 'ali: not found\n' >&2; } fD() { command -v fD >/dev/null 2>&1 && fD "$@" || printf 'fD: not found\n' >&2; } -rgafiles() { command -v rgafiles >/dev/null 2>&1 && rgafiles "$@" || printf 'rgafiles: not found\n' >&2; } -lastvim_l() { command -v lastvim >/dev/null 2>&1 && lastvim -l || printf 'lastvim: not found\n' >&2; } +lastfiles_l() { command -v lastfiles >/dev/null 2>&1 && lastfiles -l || printf 'lastfiles: not found\n' >&2; } # ---------- Readline key bindings (bind -x) ---------- # basic movement @@ -193,7 +190,7 @@ stty -ixon 2>/dev/null || true bind -x '"\C-s":sudo_command_line' # ^S (stty -ixon to avoid flow control) # tmux left pane (bind ESC + backslash) -bind -x $'\e\\':tmux_left_pane +#bind -x '\e\\':tmux_left_pane # ---------- mappings of the original bindkey -s lines (u removed) ---------- bind -x '"\C-b":__bc' # will call function __bc below @@ -201,32 +198,21 @@ __bc() { bc -lq "$@"; } bind -x '"\C-d":cdi' bind -x '"\C-f":fzffiles' -bind -x '"\C-g":lf' -bind -x '"\C-n":lastvim' +bind -x '"\C-n":lastfiles' bind -x '"\C-o":tmo' bind -x '"\C-p":fzfpass' bind -x '"\C-q":htop' bind -x '"\C-t":sessionizer' -bind -x '"\C-y":lfcd' -bind -x '"\C-z":upd' +bind -x '"\C-z":pd' # ^_ (Ctrl-_) mapped to cht (from '^ucht' -> 'cht') bind -x $'"\C-_":cht' # ^X^... sequences (Ctrl-X then key) bind -x '"\C-x\C-a":ali' -bind -x '"\C-x\C-b":gitopenbranch' bind -x '"\C-x\C-d":fD' bind -x '"\C-x\C-f":gitfiles' bind -x '"\C-x\C-g":rgafiles' bind -x '"\C-x\C-l":gloac' -bind -x '"\C-x\C-n":lastvim_l' +bind -x '"\C-x\C-n":lastfiles_l' bind -x '"\C-x\C-q":fpkill' -bind -x '"\C-x\C-r":fgst' -bind -x '"\C-x\C-t":gitstagedfiles' -bind -x '"\C-x\C-u":gitupdate' bind -x '"\C-x\C-_":fzffns' # ^X^_ -bind -x '"\C-x\C-x\C-b":rbackup' -bind -x '"\C-x\C-x\C-p":pcyr' -bind -x '"\C-x\C-x\C-r":rbackup' # rbackup -r not directly supported via bind -x args; call rbackup then ask user for flags if needed -bind -x '"\C-x\C-x\C-s":sshadd' -bind -x '"\C-x\C-x\C-y":yay_remaps' |
