diff options
author | axel <axel@liljencrantz.se> | 2007-02-09 03:01:18 +1000 |
---|---|---|
committer | axel <axel@liljencrantz.se> | 2007-02-09 03:01:18 +1000 |
commit | 7118269e4b3b6714c71f0042f85354eac3c72603 (patch) | |
tree | bd950adc7d804a1401c50b8da4d19f00ceb14f32 /share/functions/vared.fish | |
parent | 100355c3c1e6194c585e0963e2a45173d40e7256 (diff) |
Minor tweaks to vared function
darcs-hash:20070208170118-ac50b-76ea318d47de28a4437ecf0a50daea2c617017ea.gz
Diffstat (limited to 'share/functions/vared.fish')
-rw-r--r-- | share/functions/vared.fish | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/share/functions/vared.fish b/share/functions/vared.fish index 19da02d5..feadaadc 100644 --- a/share/functions/vared.fish +++ b/share/functions/vared.fish @@ -18,25 +18,25 @@ function vared --description "Edit variable value" case '*' if test (count $$argv ) -lt 2 - set init '' + set -l init '' if test $$argv set init $$argv end - set prompt 'set_color green; echo '$argv'; set_color normal; echo "> "' - read -p $prompt -c $init tmp - - # If variable already exists, do not add any - # switches, so we don't change export rules. But - # if it does not exist, we make the variable - # global, so that it will not die when this - # function dies - - if test $$argv - set -- $argv $tmp - else - set -g -- $argv $tmp + set -l prompt 'set_color green; echo '$argv'; set_color normal; echo "> "' + if read -p $prompt -c $init tmp + + # If variable already exists, do not add any + # switches, so we don't change export rules. But + # if it does not exist, we make the variable + # global, so that it will not die when this + # function dies + + if test $$argv + set $argv $tmp + else + set -g $argv $tmp + end end - else printf (_ '%s: %s is an array variable. Use %svared%s %s[n] to edit the n:th element of %s\n') $argv (set_color $fish_color_command) (set_color $fish_color_normal) vared $argv $argv |