Skip to content
Snippets Groups Projects
Commit 22960131 authored by Junegunn Choi's avatar Junegunn Choi
Browse files

Add ALT-C keybinding for bash

parent 8a3e8c2d
No related branches found
No related tags found
No related merge requests found
......@@ -162,20 +162,13 @@ Key bindings for command line
The install script will setup the following key bindings.
### bash
- `CTRL-T` - Paste the selected file path(s) into the command line
- `CTRL-R` - Paste the selected command from history into the command line
The source code can be found in `~/.fzf.bash`.
### zsh
### bash/zsh
- `CTRL-T` - Paste the selected file path(s) into the command line
- `CTRL-R` - Paste the selected command from history into the command line
- `ALT-C` - cd into the selected directory
The source code can be found in `~/.fzf.zsh`.
The source code can be found in `~/.fzf.bash` and in `~/.fzf.zsh`.
Auto-completion
---------------
......
......@@ -110,6 +110,10 @@ __fsel() {
echo
}
__fcd() {
DIR=$(find ${1:-*} -path '*/\.*' -prune -o -type d -print 2> /dev/null | fzf) && printf 'cd %q' "$DIR"
}
if [ -z "$(set -o | grep '^vi.*on')" ]; then
# Required to refresh the prompt after fzf
bind '"\er": redraw-current-line'
......@@ -119,6 +123,9 @@ if [ -z "$(set -o | grep '^vi.*on')" ]; then
# CTRL-R - Paste the selected command from history into the command line
bind '"\C-r": " \C-e\C-u$(HISTTIMEFORMAT= history | fzf +s | sed \"s/ *[0-9]* *//\")\e\C-e\er"'
# ALT-C - cd into the selected directory
bind '"\ec": " \C-e\C-u$(__fcd)\e\C-e\er\C-m"'
else
bind '"\C-x\C-e": shell-expand-line'
bind '"\C-x\C-r": redraw-current-line'
......@@ -129,6 +136,9 @@ else
# CTRL-R - Paste the selected command from history into the command line
bind '"\C-r": "\eddi$(HISTTIMEFORMAT= history | fzf +s | sed \"s/ *[0-9]* *//\")\C-x\C-e\e$a\C-x\C-r"'
# ALT-C - cd into the selected directory
bind '"\ec": "\eddi$(__fcd)\C-x\C-e\C-x\C-r\C-m"'
fi
fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment