mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-04 22:22:10 -07:00
Allow setting tmux split height in %
This commit is contained in:
24
README.md
24
README.md
@@ -214,7 +214,7 @@ The install script will setup the following key bindings.
|
|||||||
|
|
||||||
If you're on a tmux session, `CTRL-T` will launch fzf in a new split-window. You
|
If you're on a tmux session, `CTRL-T` will launch fzf in a new split-window. You
|
||||||
may disable this tmux integration by setting `FZF_TMUX` to 0, or change the
|
may disable this tmux integration by setting `FZF_TMUX` to 0, or change the
|
||||||
height of the window with `FZF_TMUX_HEIGHT`.
|
height of the window with `FZF_TMUX_HEIGHT` (e.g. `20`, `50%`).
|
||||||
|
|
||||||
The source code can be found in `~/.fzf.bash` and in `~/.fzf.zsh`.
|
The source code can be found in `~/.fzf.bash` and in `~/.fzf.zsh`.
|
||||||
|
|
||||||
@@ -315,8 +315,8 @@ Note that the environment variables `FZF_DEFAULT_COMMAND` and `FZF_DEFAULT_OPTS`
|
|||||||
also apply here.
|
also apply here.
|
||||||
|
|
||||||
If you're on a tmux session, `:FZF` will launch fzf in a new split-window whose
|
If you're on a tmux session, `:FZF` will launch fzf in a new split-window whose
|
||||||
height can be adjusted with `g:fzf_tmux_height` (default: 15). However, the bang
|
height can be adjusted with `g:fzf_tmux_height` (default: '40%'). However, the
|
||||||
version (`:FZF!`) will always start in fullscreen.
|
bang version (`:FZF!`) will always start in fullscreen.
|
||||||
|
|
||||||
### `fzf#run([options])`
|
### `fzf#run([options])`
|
||||||
|
|
||||||
@@ -325,15 +325,15 @@ of the selected items.
|
|||||||
|
|
||||||
`fzf#run()` may take an options-dictionary:
|
`fzf#run()` may take an options-dictionary:
|
||||||
|
|
||||||
| Option name | Type | Description |
|
| Option name | Type | Description |
|
||||||
| ----------- | ------- | ---------------------------------------------------------- |
|
| ----------- | ------------- | ------------------------------------------------------------------- |
|
||||||
| `source` | string | External command to generate input to fzf (e.g. `find .`) |
|
| `source` | string | External command to generate input to fzf (e.g. `find .`) |
|
||||||
| `source` | list | Vim list as input to fzf |
|
| `source` | list | Vim list as input to fzf |
|
||||||
| `sink` | string | Vim command to handle the selected item (e.g. `e`, `tabe`) |
|
| `sink` | string | Vim command to handle the selected item (e.g. `e`, `tabe`) |
|
||||||
| `sink` | funcref | Reference to function to process each selected item |
|
| `sink` | funcref | Reference to function to process each selected item |
|
||||||
| `options` | string | Options to fzf |
|
| `options` | string | Options to fzf |
|
||||||
| `dir` | string | Working directory |
|
| `dir` | string | Working directory |
|
||||||
| `tmux` | number | Use tmux split if possible with the given height |
|
| `tmux` | number/string | Use tmux split if possible with the given height (e.g. `20`, `50%`) |
|
||||||
|
|
||||||
#### Examples
|
#### Examples
|
||||||
|
|
||||||
|
22
install
22
install
@@ -115,7 +115,14 @@ __fsel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
__fsel_tmux() {
|
__fsel_tmux() {
|
||||||
tmux split-window -l ${FZF_TMUX_HEIGHT:-15} "tmux send-keys -t $TMUX_PANE \"\$($__fsel)\""
|
local height lines
|
||||||
|
height=${FZF_TMUX_HEIGHT:-40%}
|
||||||
|
lines=${LINES:-40}
|
||||||
|
if [[ $height =~ %$ ]]; then
|
||||||
|
height=${height:0:${#height}-1}
|
||||||
|
height=$(( height * lines / 100 ))
|
||||||
|
fi
|
||||||
|
tmux split-window -l $height "tmux send-keys -t $TMUX_PANE \"\$($__fsel)\""
|
||||||
}
|
}
|
||||||
|
|
||||||
__fcd() {
|
__fcd() {
|
||||||
@@ -124,7 +131,7 @@ __fcd() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
__use_tmux=0
|
__use_tmux=0
|
||||||
[ -n "$TMUX_PANE" -a ${FZF_TMUX:-1} -ne 0 -a ${LINES:-30} -gt 15 ] && __use_tmux=1
|
[ -n "$TMUX_PANE" -a ${FZF_TMUX:-1} -ne 0 -a ${LINES:-40} -gt 15 ] && __use_tmux=1
|
||||||
|
|
||||||
if [ -z "$(set -o | grep '^vi.*on')" ]; then
|
if [ -z "$(set -o | grep '^vi.*on')" ]; then
|
||||||
# Required to refresh the prompt after fzf
|
# Required to refresh the prompt after fzf
|
||||||
@@ -180,9 +187,16 @@ read -r -d '' __fsel <<'EOF'
|
|||||||
echo
|
echo
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if [ -n "$TMUX_PANE" -a ${FZF_TMUX:-1} -ne 0 -a ${LINES:-30} -gt 15 ]; then
|
if [ -n "$TMUX_PANE" -a ${FZF_TMUX:-1} -ne 0 -a ${LINES:-40} -gt 15 ]; then
|
||||||
fzf-file-widget() {
|
fzf-file-widget() {
|
||||||
tmux split-window -l ${FZF_TMUX_HEIGHT:-15} "tmux send-keys -t $TMUX_PANE \"\$($__fsel)\""
|
local height lines
|
||||||
|
height=${FZF_TMUX_HEIGHT:-40%}
|
||||||
|
lines=${LINES:-40}
|
||||||
|
if [[ $height =~ %$ ]]; then
|
||||||
|
height=${height:0:${#height}-1}
|
||||||
|
height=$(( height * lines / 100 ))
|
||||||
|
fi
|
||||||
|
tmux split-window -l $height "tmux send-keys -t $TMUX_PANE \"\$($__fsel)\""
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fzf-file-widget() {
|
fzf-file-widget() {
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
let s:min_tmux_height = 3
|
let s:min_tmux_height = 3
|
||||||
let s:default_tmux_height = 15
|
let s:default_tmux_height = '40%'
|
||||||
|
|
||||||
let s:cpo_save = &cpo
|
let s:cpo_save = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
@@ -114,7 +114,17 @@ function! s:execute_tmux(dict, command, temps)
|
|||||||
else
|
else
|
||||||
let command = a:command
|
let command = a:command
|
||||||
endif
|
endif
|
||||||
let height = a:dict.tmux
|
|
||||||
|
if type(a:dict.tmux) == 1
|
||||||
|
if a:dict.tmux =~ '%$'
|
||||||
|
let height = screenrow() * str2nr(a:dict.tmux[0:-2]) / 100
|
||||||
|
else
|
||||||
|
let height = str2nr(a:dict.tmux)
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
let height = a:dict.tmux
|
||||||
|
endif
|
||||||
|
|
||||||
let s:pane = substitute(
|
let s:pane = substitute(
|
||||||
\ system(
|
\ system(
|
||||||
\ printf(
|
\ printf(
|
||||||
|
Reference in New Issue
Block a user