3 ms·
Bash users: FYI you can bind shortcuts like this, too. I have my right hand home row keys bound to __bash_ctrl_n() (for e.g.), and various tools in my dotfiles
by 000ooo000 2y ago
Bash users: FYI you can bind shortcuts like this, too. I have my right hand home row keys bound to __bash_ctrl_n() (for e.g.), and various tools in my dotfiles override these functions (git, if installed, sets up __bash_ctrl_e() to run git status and git log).
- jmholla 2y agoNeat. Can you share the source of any of the functions you've bound to some of your keys?
- 000ooo000 2y agoApologies for the slow response. They're not really interesting: - ctrl+j => equivalent of 'ls -la' using exa/eza - ctrl+k => git status followed by git log showing only current branch's commits (vs. tracked) - ctrl+l => sometimes I'll manually bind this to 'git reset @~' - ctrl+; => thinking I'll use this for calling fzf through my wrapper which sets up hotkeys for either `cd`/`$EDITOR`-ing the selected item Point is to reduce typing of the commonly-used commands. Somewhere in my shell profile/rc setup (I'm on Workman, not Qwerty, hence NEOK instead of JKL;): bash_functions=( "__bash_ctrl_n" "__bash_ctrl_e" "__bash_ctrl_o" "__bash_ctrl_k" ) for bash_function in "${bash_functions[@]}" do if ! type -t "$bash_function" 1> /dev/null then eval "$bash_function() { echo \"$bash_function(): This function should be overridden/aliased\"; }" fi done Then in my .bashrc (Note the leading space prior to `__bash_ctrl_x` - with Bash's `HISTCONTROL=ignorespace`, these keybinds won't pollute your history): bind '"\C-n": "\C-u __bash_ctrl_n\C-j"' bind '"\C-e": "\C-u __bash_ctrl_e\C-j"' bind '"\C-o": "\C-u __bash_ctrl_o\C-j"' bind '"\C-k": "\C-u __bash_ctrl_k\C-j"' Then in my app-specific configs/dotfiles: __bash_ctrl_n() { git status; git log ..; } Bonus: these Bash bindings can be cool for little QoL tricks, e.g. Ctrl+Y to rerun the last command with sudo. bind '"\e\C-y": "\C-usudo !! \C-j"' Other good ones: - Append `--help | $PAGER` and run - Rerun last command and pipe into $PAGER (some terminals support viewing last command output in a pager without re-running it, e.g. Kitty) Hope that helps.