prefer own environment variables over those of `sd`
2 files changed, 38 insertions(+), 26 deletions(-)
changed files
M completions/scriptura.fish → completions/scriptura.fish
@@ -1,41 +1,41 @@ -set --query SD_ROOT or set --local SD_ROOT "~/sd" +set --query SCRIPTURA_ROOT or set --local SCRIPTURA_ROOT "~/sd" complete --command scriptura --no-files complete --command scriptura \ - --condition 'not __fish_seen_subcommand_from $(__scriptura_print $SD_ROOT)' \ + --condition 'not __fish_seen_subcommand_from $(__scriptura_print $SCRIPTURA_ROOT)' \ --short-option h --long-option help \ --description 'Display help information' complete --command scriptura \ - --condition 'not __fish_seen_subcommand_from $(__scriptura_print $SD_ROOT)' \ + --condition 'not __fish_seen_subcommand_from $(__scriptura_print $SCRIPTURA_ROOT)' \ --short-option n --long-option new \ --description 'Create new script' complete --command scriptura \ - --condition 'not __fish_seen_subcommand_from $(__scriptura_print $SD_ROOT)' \ + --condition 'not __fish_seen_subcommand_from $(__scriptura_print $SCRIPTURA_ROOT)' \ --short-option e --long-option edit \ --description 'Edit existing script' complete --command scriptura \ - --condition 'not __fish_seen_subcommand_from $(__scriptura_print $SD_ROOT)' \ + --condition 'not __fish_seen_subcommand_from $(__scriptura_print $SCRIPTURA_ROOT)' \ --short-option c --long-option cat \ --description 'Display script content' complete --command scriptura \ - --condition 'not __fish_seen_subcommand_from $(__scriptura_print $SD_ROOT)' \ + --condition 'not __fish_seen_subcommand_from $(__scriptura_print $SCRIPTURA_ROOT)' \ --short-option w --long-option which \ --description 'Display script path' complete --command scriptura \ - --condition 'not __fish_seen_subcommand_from $(__scriptura_print $SD_ROOT)' \ - --arguments '$(__scriptura_complete $SD_ROOT)' + --condition 'not __fish_seen_subcommand_from $(__scriptura_print $SCRIPTURA_ROOT)' \ + --arguments '$(__scriptura_complete $SCRIPTURA_ROOT)' complete --command scriptura \ - --condition '__fish_seen_subcommand_from $(__scriptura_print $SD_ROOT)' \ + --condition '__fish_seen_subcommand_from $(__scriptura_print $SCRIPTURA_ROOT)' \ --condition 'not __scriptura_seen_script $(commandline -xpc)' \ --condition 'not __fish_seen_argument --short n --long new' \ - --arguments '$(__scriptura_complete $SD_ROOT/$(commandline -xpc)[-1])' + --arguments '$(__scriptura_complete $SCRIPTURA_ROOT/$(commandline -xpc)[-1])' complete --command scriptura \ --condition '__scriptura_seen_script $(commandline -xpc)' \@@ -53,7 +53,7 @@ end function __scriptura_seen_script set --function argv $argv[2..-1] - set --function target $SD_ROOT + set --function target $SCRIPTURA_ROOT if not set --query argv[1] return 1
M functions/scriptura.fish → functions/scriptura.fish
@@ -1,14 +1,20 @@ -set --query SD_ROOT or set --local SD_ROOT "$HOME/sd" +if not set --query SCRIPTURA_ROOT + if set --query SD_ROOT + set --function SCRIPTURA_ROOT $SD_ROOT + else + set --function SCRIPTURA_ROOT "$HOME/sd" + end +end function scriptura argparse --stop-nonopt h/help n/new e/edit w/which c/cat -- $argv or return - if not path is $SD_ROOT + if not path is $SCRIPTURA_ROOT if set --query _flag_new - mkdir $SD_ROOT + mkdir $SCRIPTURA_ROOT else - echo \$SD_ROOT $SD_ROOT does not exist, use `$(status function) --new` to create it + echo \$SCRIPTURA_ROOT $SCRIPTURA_ROOT does not exist, use `$(status function) --new` to create it return 1 end end@@ -18,7 +24,7 @@ __scriptura_usage return 0 end - set --function target $SD_ROOT + set --function target $SCRIPTURA_ROOT for i in (seq 1 (count $argv)) if test "$argv[$i]" = --@@ -77,9 +83,9 @@ end function __scriptura_usage echo "Usage: scriptura [script_name]" - echo "SD_ROOT: $SD_ROOT" + echo "SCRIPTURA_ROOT: $SCRIPTURA_ROOT" echo "" - __scriptura_list $SD_ROOT + __scriptura_list $SCRIPTURA_ROOT end function __scriptura_list --argument-names from@@ -134,9 +140,11 @@ __scriptura_edit $target end function __scriptura_edit --argument-names script_path - if not set --query SD_EDITOR - set --function SD_EDITOR $( - if set --query VISUAL + if not set --query SCRIPTURA_EDITOR + set --function SCRIPTURA_EDITOR $( + if set --query SD_EDITOR + echo $SD_EDITOR + else if set --query VISUAL echo $VISUAL else if set --query EDITOR echo $EDITOR@@ -147,21 +155,25 @@ echo nano else if command --query vi echo vi else - echo "Don't know which editor to use, set \$SD_EDITOR, \$VISUAL or \$EDITOR!" >& 2 + echo "Don't know which editor to use, set \$SCRIPTURA_EDITOR, \$VISUAL or \$EDITOR!" >& 2 return 1 end ) end - eval $SD_EDITOR $script_path + eval $SCRIPTURA_EDITOR $script_path end function __scriptura_cat --argument-names script_path - if not set --query SD_CAT - set --function SD_CAT cat + if not set --query SCRIPTURA_CAT + if set --query SD_CAT + set --function SCRIPTURA_CAT $SD_CAT + else + set --function SCRIPTURA_CAT cat + end end - eval $SD_CAT $script_path + eval $SCRIPTURA_CAT $script_path end function __scriptura_which --argument-names script_path