Skip to content

Commit d0a3940

Browse files
committed
Expand environment variables in command arguments (issue #20)
Issue #20 on GitHub: #20
1 parent 64f3cac commit d0a3940

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ Unzip the most recent [ZIP archive](http://peterodding.com/code/vim/downloads/se
2424

2525
## Commands
2626

27+
Note that environment variables inside command arguments are expanded by the plug-in.
28+
2729
### The `:SaveSession` command
2830

2931
This command saves your current editing session just like Vim's built-in [:mksession][mksession] command does. The difference is that you don't pass a full pathname as argument but just a name, any name really. Press `<Tab>` to get completion of existing session names. If you don't provide an argument the name 'default' is used, unless an existing session is open in which case the name of that session will be used.

autoload/xolox/session.vim

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
" Vim script
22
" Author: Peter Odding
3-
" Last Change: April 30, 2013
3+
" Last Change: May 2, 2013
44
" URL: http://peterodding.com/code/vim/session/
55

6-
let g:xolox#session#version = '1.5.13'
6+
let g:xolox#session#version = '1.6'
77

88
call xolox#misc#compat#check('session', 2)
99

@@ -482,7 +482,11 @@ endfunction
482482
" Miscellaneous functions. {{{1
483483

484484
function! s:unescape(s) " {{{2
485-
return substitute(a:s, '\\\(.\)', '\1', 'g')
485+
" Undo escaping of special characters (preceded by a backslash).
486+
let s = substitute(a:s, '\\\(.\)', '\1', 'g')
487+
" Expand any environment variables in the user input.
488+
let s = substitute(s, '\(\$[A-Za-z0-9_]\+\)', '\=expand(submatch(1))', 'g')
489+
return s
486490
endfunction
487491

488492
function! s:select_name(name, action) " {{{2

doc/session.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ commands will be available to you:
8383
*session-commands*
8484
Commands ~
8585

86+
Note that environment variables inside command arguments are expanded by the
87+
plug-in.
88+
8689
-------------------------------------------------------------------------------
8790
The *:SaveSession* command
8891

0 commit comments

Comments
 (0)