[vim] Options to xterm command

This commit is contained in:
Junegunn Choi 2014-06-15 03:18:29 +09:00
parent 0b43f988c7
commit 65c1b53275
2 changed files with 26 additions and 15 deletions

View File

@ -287,7 +287,7 @@ TODO :smiley:
Usage as Vim plugin Usage as Vim plugin
------------------- -------------------
Note: To use fzf in GVim, bash and xterm are required. (Note: To use fzf in GVim, bash and xterm are required.)
### `:FZF[!]` ### `:FZF[!]`
@ -311,6 +311,13 @@ 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: '40%'). However, the height can be adjusted with `g:fzf_tmux_height` (default: '40%'). However, the
bang version (`:FZF!`) will always start in fullscreen. bang version (`:FZF!`) will always start in fullscreen.
In GVim, `xterm` command will be used to launch fzf. You can set options to
`xterm` command with `g:fzf_xterm_options`. For example,
```vim
let g:fzf_xterm_options = '-geometry 120x30'
```
### `fzf#run([options])` ### `fzf#run([options])`
For more advanced uses, you can call `fzf#run()` function which returns the list For more advanced uses, you can call `fzf#run()` function which returns the list
@ -318,16 +325,17 @@ 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_width` | number/string | Use tmux vertical split with the given height (e.g. `20`, `50%`) | | `tmux_width` | number/string | Use tmux vertical split with the given height (e.g. `20`, `50%`) |
| `tmux_height` | number/string | Use tmux horizontal split with the given height (e.g. `20`, `50%`) | | `tmux_height` | number/string | Use tmux horizontal split with the given height (e.g. `20`, `50%`) |
| `xterm_options` | string | Options to `xterm` command (Only used in GVim) |
#### Examples #### Examples
@ -353,9 +361,10 @@ nnoremap <silent> <Leader>C :call fzf#run({
\ 'source': \ 'source':
\ map(split(globpath(&rtp, "colors/*.vim"), "\n"), \ map(split(globpath(&rtp, "colors/*.vim"), "\n"),
\ "substitute(fnamemodify(v:val, ':t'), '\\..\\{-}$', '', '')"), \ "substitute(fnamemodify(v:val, ':t'), '\\..\\{-}$', '', '')"),
\ 'sink': 'colo', \ 'sink': 'colo',
\ 'options': '+m', \ 'options': '+m',
\ 'tmux_width': 20 \ 'tmux_width': 20,
\ 'xterm_options': '-geometry 20x30'
\ })<CR> \ })<CR>
``` ```

View File

@ -125,7 +125,9 @@ function! s:execute(dict, command, temps)
call s:pushd(a:dict) call s:pushd(a:dict)
silent !clear silent !clear
if has('gui_running') if has('gui_running')
execute "silent !xterm -e bash -ic '".substitute(a:command, "'", "'\"'\"'", 'g')."'" let xterm_options = get(a:dict, 'xterm_options', get(g:, 'fzf_xterm_options', ''))
execute "silent !xterm ".xterm_options.
\ " -e bash -ic '".substitute(a:command, "'", "'\"'\"'", 'g')."'"
else else
execute 'silent !'.a:command execute 'silent !'.a:command
endif endif