mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-11-29 16:23:57 +00:00
On writing fzf-tmux combo
This commit is contained in:
parent
f6b1a6278f
commit
05da892cd2
33
README.md
33
README.md
@ -487,6 +487,39 @@ fzf() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Using fzf with tmux splits
|
||||||
|
|
||||||
|
It isn't too hard to write your own fzf-tmux combo like the default
|
||||||
|
CTRL-T key binding. (Or is it?)
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# This is a helper function that splits the current pane to start the given
|
||||||
|
# command ($1) and sends its output back to the original pane with any number of
|
||||||
|
# optional keys (shift; $*).
|
||||||
|
fzf_tmux_helper() {
|
||||||
|
[ -n "$TMUX_PANE" ] || return
|
||||||
|
local cmd=$1
|
||||||
|
shift
|
||||||
|
tmux split-window -p 40 \
|
||||||
|
"bash -c \"\$(tmux send-keys -t $TMUX_PANE \"\$(source ~/.fzf.bash; $cmd)\" $*)\""
|
||||||
|
}
|
||||||
|
|
||||||
|
# This is the function we are going to run in the split pane.
|
||||||
|
# - "find" to list the directories
|
||||||
|
# - "sed" will escape spaces in the paths.
|
||||||
|
# - "paste" will join the selected paths into a single line
|
||||||
|
fzf_tmux_dir() {
|
||||||
|
fzf_tmux_helper \
|
||||||
|
'find * -path "*/\.*" -prune -o -type d -print 2> /dev/null |
|
||||||
|
fzf --multi |
|
||||||
|
sed "s/ /\\\\ /g" |
|
||||||
|
paste -sd" " -' Space
|
||||||
|
}
|
||||||
|
|
||||||
|
# Bind CTRL-X-CTRL-D to fzf_tmux_dir
|
||||||
|
bind '"\C-x\C-d": "$(fzf_tmux_dir)\e\C-e"'
|
||||||
|
```
|
||||||
|
|
||||||
### Fish shell
|
### Fish shell
|
||||||
|
|
||||||
It's [a known bug of fish](https://github.com/fish-shell/fish-shell/issues/1362)
|
It's [a known bug of fish](https://github.com/fish-shell/fish-shell/issues/1362)
|
||||||
|
Loading…
Reference in New Issue
Block a user