summaryrefslogtreecommitdiffstats
path: root/plugin
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2016-12-03 01:08:09 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2016-12-03 01:13:56 +0900
commitab9ae4f643ed47538bae6cebddc4c529f8700b45 (patch)
tree2faecf5efafccbccdea230e824d42604529fc981 /plugin
parentd9a51030eaeb601edb0a7d9673655a216045046d (diff)
[vim] Fix path display in FZF when cwd is ~
Diffstat (limited to 'plugin')
-rw-r--r--plugin/fzf.vim7
1 files changed, 6 insertions, 1 deletions
diff --git a/plugin/fzf.vim b/plugin/fzf.vim
index 49dc1924..09999649 100644
--- a/plugin/fzf.vim
+++ b/plugin/fzf.vim
@@ -581,6 +581,11 @@ let s:default_action = {
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
+function! s:shortpath()
+ let short = pathshorten(fnamemodify(getcwd(), ':~:.'))
+ return empty(short) ? '~/' : short . (short =~ '/$' ? '' : '/')
+endfunction
+
function! s:cmd(bang, ...) abort
let args = copy(a:000)
let opts = { 'options': '--multi ' }
@@ -588,7 +593,7 @@ function! s:cmd(bang, ...) abort
let opts.dir = substitute(substitute(remove(args, -1), '\\\(["'']\)', '\1', 'g'), '/*$', '/', '')
let opts.options .= ' --prompt '.shellescape(opts.dir)
else
- let opts.options .= ' --prompt '.shellescape(pathshorten(fnamemodify(getcwd(), ':~:.')).'/')
+ let opts.options .= ' --prompt '.shellescape(s:shortpath())
endif
let opts.options .= ' '.join(args)
call fzf#run(fzf#wrap('FZF', opts, a:bang))