Allow for installation into non-standard locations (#65)

* Allow for installation into non-standard locations

This is useful when installed via fisher, if the user has set up
$fisher_path to be something other than ~/.config/fish

* Use simpler regex

Co-authored-by: Ilan Cosman <ilancosman@gmail.com>
This commit is contained in:
Varun Madiath 2021-01-01 00:07:13 -05:00 committed by GitHub
parent fb22b3bec9
commit 95b0d7802b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 12 additions and 11 deletions

View File

@ -45,7 +45,7 @@ Anything exposed to the shell or user--functions, global/universal variables, an
You can quickly install the necessary dependencies using `tide test -i`. You can quickly install the necessary dependencies using `tide test -i`.
`tide test` runs tests from the `$_tide_dir/tests` directory. `tide test` runs tests from the `$_tide_root/functions/tide/tests` directory.
Example: Example:

View File

@ -10,6 +10,6 @@ complete -c tide -x -n '__fish_seen_subcommand_from test' -a --help -d "Print he
complete -c tide -x -n '__fish_seen_subcommand_from test' -a --install -d "Install testing dependencies" complete -c tide -x -n '__fish_seen_subcommand_from test' -a --install -d "Install testing dependencies"
complete -c tide -x -n '__fish_seen_subcommand_from test' -a --verbose -d "Display test output even if passed" complete -c tide -x -n '__fish_seen_subcommand_from test' -a --verbose -d "Display test output even if passed"
for file in (string replace --all --regex '^.*/|\.fish$' '' $_tide_dir/tests/*.fish) for file in (string replace --all --regex '^.*/|\.fish$' '' $_tide_root/functions/tide/tests/*.fish)
complete -c tide -x -n "__fish_seen_subcommand_from test" -a $file complete -c tide -x -n "__fish_seen_subcommand_from test" -a $file
end end

View File

@ -5,13 +5,14 @@ function _tide_init_install --on-event _tide_init_install
_set_immutable _tide_color_green 5FD700 _set_immutable _tide_color_green 5FD700
_set_immutable _tide_color_light_blue 00AFFF _set_immutable _tide_color_light_blue 00AFFF
_set_immutable _tide_dir "$__fish_config_dir/functions/tide" # Each string replace is the regex equivalent of dirname
_set_immutable _tide_root (status current-filename | string replace --regex '/[^/]+$' '' | string replace --regex '/[^/]+$' '')
_set_immutable VIRTUAL_ENV_DISABLE_PROMPT true _set_immutable VIRTUAL_ENV_DISABLE_PROMPT true
set -U _tide_var_list set -U _tide_var_list
source $__fish_config_dir/functions/_tide_sub_configure.fish source $_tide_root/functions/_tide_sub_configure.fish
_load_config 'lean' _load_config 'lean'
_tide_finish _tide_finish

View File

@ -4,7 +4,7 @@ for func in _fake(functions --all | string match --entire _tide_item)
end end
end end
for file in $_tide_dir/configure/{choices, functions, prompt_items}/**.fish for file in $_tide_root/functions/tide/configure/{choices, functions, prompt_items}/**.fish
source "$file" source "$file"
end end
@ -82,4 +82,4 @@ end
function _find_and_remove -a name list --no-scope-shadowing function _find_and_remove -a name list --no-scope-shadowing
set -e "$list"[(contains --index $name $$list)] 2>/dev/null # Ignore error if $list doesn't contain $name set -e "$list"[(contains --index $name $$list)] 2>/dev/null # Ignore error if $list doesn't contain $name
end end

View File

@ -17,7 +17,7 @@ function _tide_sub_test
set -lx TERM xterm # Ensures color codes are printed set -lx TERM xterm # Ensures color codes are printed
set -l testsDir "$_tide_dir/tests" set -l testsDir "$_tide_root/functions/tide/tests"
set -q _flag_all && set argv (string replace --all --regex '^.*/|\.fish$' '' $testsDir/*.fish) set -q _flag_all && set argv (string replace --all --regex '^.*/|\.fish$' '' $testsDir/*.fish)
set -q _flag_CI && set -a argv 'CI/'(string replace --all --regex '^.*/|\.fish$' '' $testsDir/CI/*.fish) set -q _flag_CI && set -a argv 'CI/'(string replace --all --regex '^.*/|\.fish$' '' $testsDir/CI/*.fish)

View File

@ -44,4 +44,4 @@ function _tide_finish
end end
set _tide_var_list $incomingVarList set _tide_var_list $incomingVarList
end end

View File

@ -40,7 +40,7 @@ function _load_config -a name
end end
set -g fake__tide_var_list set -g fake__tide_var_list
for line in fake_(cat "$_tide_dir/configure/configs/$name.fish") for line in fake_(cat "$_tide_root/functions/tide/configure/configs/$name.fish")
set -a fake__tide_var_list (string split --max 1 ' ' $line)[1] set -a fake__tide_var_list (string split --max 1 ' ' $line)[1]
eval set -g $line eval set -g $line
end end

View File

@ -1,6 +1,6 @@
@mesg '-----------context-----------' @mesg '-----------context-----------'
set -l sourceFile "$__fish_config_dir/functions/_tide_item_context.fish" set -l sourceFile "$_tide_root/functions/_tide_item_context.fish"
function _context function _context
_tide_decolor (_tide_item_context) _tide_decolor (_tide_item_context)
@ -9,4 +9,4 @@ end
@test 'None' -z (set -lx tide_context_always_display false; _context) @test 'None' -z (set -lx tide_context_always_display false; _context)
@test 'Default' (set -lx tide_context_always_display true; _context ) = $USER'@'$hostname @test 'Default' (set -lx tide_context_always_display true; _context ) = $USER'@'$hostname
@test 'SSH' (set -g SSH_TTY /dev/pts/0; _context) = $USER'@'$hostname @test 'SSH' (set -g SSH_TTY /dev/pts/0; _context) = $USER'@'$hostname
@test 'Root' (_tide_decolor (sudo fish --command="source $sourceFile;_tide_item_context")) = 'root@'$hostname @test 'Root' (_tide_decolor (sudo fish --command="source $sourceFile;_tide_item_context")) = 'root@'$hostname