Skip to content
Myr

Allow setting tmux split height in %

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent 995d380 · Browse files · 3 files+42 added−18 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+42 added−18 removed

  • other:+42 added−18 removed

3 files+42 added−18 removed

modified:plugin/fzf.vim+12 added-2 removed
20 unmodified lines
21" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION22" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.2324let s:min_tmux_height = 325let s:default_tmux_height = 1525let s:default_tmux_height = '40%'2627let s:cpo_save = &cpo28set cpo&vim29
83 unmodified lines
113 let command = 'cd '.s:escape(a:dict.dir).' && '.a:command114 else115 let command = a:command116 endif117118 if type(a:dict.tmux) == 1119 if a:dict.tmux =~ '%$'120 let height = screenrow() * str2nr(a:dict.tmux[0:-2]) / 100121 else122 let height = str2nr(a:dict.tmux)123 endif124 else117 let height = a:dict.tmux125 let height = a:dict.tmux126 endif127128 let s:pane = substitute(129 \ system(130 \ printf(131 \ 'tmux split-window -l %d -P -F "#{pane_id}" %s',
67 unmodified lines
modified:install+18 added-4 removed
113 unmodified lines
114 eval "$__fsel"115}116117__fsel_tmux() {118 local height lines119 height=${FZF_TMUX_HEIGHT:-40%}120 lines=${LINES:-40}121 if [[ $height =~ %$ ]]; then122 height=${height:0:${#height}-1}123 height=$(( height * lines / 100 ))124 fi118 tmux split-window -l ${FZF_TMUX_HEIGHT:-15} "tmux send-keys -t $TMUX_PANE \"\$($__fsel)\""125 tmux split-window -l $height "tmux send-keys -t $TMUX_PANE \"\$($__fsel)\""126}127128__fcd() {129 local dir130 dir=$(find ${1:-*} -path '*/\.*' -prune -o -type d -print 2> /dev/null | fzf +m) && printf 'cd %q' "$dir"131}132133__use_tmux=0127[ -n "$TMUX_PANE" -a ${FZF_TMUX:-1} -ne 0 -a ${LINES:-30} -gt 15 ] && __use_tmux=1134[ -n "$TMUX_PANE" -a ${FZF_TMUX:-1} -ne 0 -a ${LINES:-40} -gt 15 ] && __use_tmux=1135136if [ -z "$(set -o | grep '^vi.*on')" ]; then137 # Required to refresh the prompt after fzf138 bind '"\er": redraw-current-line'
47 unmodified lines
186 done187 echo188EOF189183if [ -n "$TMUX_PANE" -a ${FZF_TMUX:-1} -ne 0 -a ${LINES:-30} -gt 15 ]; then190if [ -n "$TMUX_PANE" -a ${FZF_TMUX:-1} -ne 0 -a ${LINES:-40} -gt 15 ]; then191 fzf-file-widget() {192 local height lines193 height=${FZF_TMUX_HEIGHT:-40%}194 lines=${LINES:-40}195 if [[ $height =~ %$ ]]; then196 height=${height:0:${#height}-1}197 height=$(( height * lines / 100 ))198 fi185 tmux split-window -l ${FZF_TMUX_HEIGHT:-15} "tmux send-keys -t $TMUX_PANE \"\$($__fsel)\""199 tmux split-window -l $height "tmux send-keys -t $TMUX_PANE \"\$($__fsel)\""200 }201else202 fzf-file-widget() {203 LBUFFER="${LBUFFER%% #}$(eval "$__fsel")"
54 unmodified lines
modified:README.md+12 added-12 removed
212 unmodified lines
213- `ALT-C` - cd into the selected directory214215If you're on a tmux session, `CTRL-T` will launch fzf in a new split-window. You216may disable this tmux integration by setting `FZF_TMUX` to 0, or change the217height of the window with `FZF_TMUX_HEIGHT`.217height of the window with `FZF_TMUX_HEIGHT` (e.g. `20`, `50%`).218219The source code can be found in `~/.fzf.bash` and in `~/.fzf.zsh`.220221Auto-completion
92 unmodified lines
314Note that the environment variables `FZF_DEFAULT_COMMAND` and `FZF_DEFAULT_OPTS`315also apply here.316317If you're on a tmux session, `:FZF` will launch fzf in a new split-window whose318height can be adjusted with `g:fzf_tmux_height` (default: 15). However, the bang319version (`:FZF!`) will always start in fullscreen.318height can be adjusted with `g:fzf_tmux_height` (default: '40%'). However, the319bang version (`:FZF!`) will always start in fullscreen.320321### `fzf#run([options])`322323For more advanced uses, you can call `fzf#run()` function which returns the list324of the selected items.325326`fzf#run()` may take an options-dictionary:327328| Option name | Type | Description |329| ----------- | ------- | ---------------------------------------------------------- |330| `source` | string | External command to generate input to fzf (e.g. `find .`) |331| `source` | list | Vim list as input to fzf |332| `sink` | string | Vim command to handle the selected item (e.g. `e`, `tabe`) |333| `sink` | funcref | Reference to function to process each selected item |334| `options` | string | Options to fzf |335| `dir` | string | Working directory |336| `tmux` | number | Use tmux split if possible with the given height |328| Option name | Type | Description |329| ----------- | ------------- | ------------------------------------------------------------------- |330| `source` | string | External command to generate input to fzf (e.g. `find .`) |331| `source` | list | Vim list as input to fzf |332| `sink` | string | Vim command to handle the selected item (e.g. `e`, `tabe`) |333| `sink` | funcref | Reference to function to process each selected item |334| `options` | string | Options to fzf |335| `dir` | string | Working directory |336| `tmux` | number/string | Use tmux split if possible with the given height (e.g. `20`, `50%`) |337338#### Examples339340If `sink` option is not given, `fzf#run` will simply return the list.
93 unmodified lines