mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2025-01-23 07:08:27 +00:00
Allow setting tmux split height in %
This commit is contained in:
parent
995d380200
commit
cf8dbf8047
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
|
||||
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`.
|
||||
|
||||
@ -315,8 +315,8 @@ Note that the environment variables `FZF_DEFAULT_COMMAND` and `FZF_DEFAULT_OPTS`
|
||||
also apply here.
|
||||
|
||||
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
|
||||
version (`:FZF!`) will always start in fullscreen.
|
||||
height can be adjusted with `g:fzf_tmux_height` (default: '40%'). However, the
|
||||
bang version (`:FZF!`) will always start in fullscreen.
|
||||
|
||||
### `fzf#run([options])`
|
||||
|
||||
@ -325,15 +325,15 @@ of the selected items.
|
||||
|
||||
`fzf#run()` may take an options-dictionary:
|
||||
|
||||
| Option name | Type | Description |
|
||||
| ----------- | ------- | ---------------------------------------------------------- |
|
||||
| `source` | string | External command to generate input to fzf (e.g. `find .`) |
|
||||
| `source` | list | Vim list as input to fzf |
|
||||
| `sink` | string | Vim command to handle the selected item (e.g. `e`, `tabe`) |
|
||||
| `sink` | funcref | Reference to function to process each selected item |
|
||||
| `options` | string | Options to fzf |
|
||||
| `dir` | string | Working directory |
|
||||
| `tmux` | number | Use tmux split if possible with the given height |
|
||||
| Option name | Type | Description |
|
||||
| ----------- | ------------- | ------------------------------------------------------------------- |
|
||||
| `source` | string | External command to generate input to fzf (e.g. `find .`) |
|
||||
| `source` | list | Vim list as input to fzf |
|
||||
| `sink` | string | Vim command to handle the selected item (e.g. `e`, `tabe`) |
|
||||
| `sink` | funcref | Reference to function to process each selected item |
|
||||
| `options` | string | Options to fzf |
|
||||
| `dir` | string | Working directory |
|
||||
| `tmux` | number/string | Use tmux split if possible with the given height (e.g. `20`, `50%`) |
|
||||
|
||||
#### Examples
|
||||
|
||||
|
22
install
22
install
@ -115,7 +115,14 @@ __fsel() {
|
||||
}
|
||||
|
||||
__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() {
|
||||
@ -124,7 +131,7 @@ __fcd() {
|
||||
}
|
||||
|
||||
__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
|
||||
# Required to refresh the prompt after fzf
|
||||
@ -180,9 +187,16 @@ read -r -d '' __fsel <<'EOF'
|
||||
echo
|
||||
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() {
|
||||
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
|
||||
fzf-file-widget() {
|
||||
|
@ -22,7 +22,7 @@
|
||||
" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
let s:min_tmux_height = 3
|
||||
let s:default_tmux_height = 15
|
||||
let s:default_tmux_height = '40%'
|
||||
|
||||
let s:cpo_save = &cpo
|
||||
set cpo&vim
|
||||
@ -114,7 +114,17 @@ function! s:execute_tmux(dict, command, temps)
|
||||
else
|
||||
let command = a:command
|
||||
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(
|
||||
\ system(
|
||||
\ printf(
|
||||
|
Loading…
x
Reference in New Issue
Block a user