From 95b0d7802be22a907e40c6d27baea4b6259b8693 Mon Sep 17 00:00:00 2001 From: Varun Madiath Date: Fri, 1 Jan 2021 00:07:13 -0500 Subject: [PATCH] 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 --- CONTRIBUTING.md | 2 +- completions/tide.fish | 2 +- conf.d/_tide_init.fish | 5 +++-- functions/_tide_sub_configure.fish | 4 ++-- functions/_tide_sub_test.fish | 2 +- functions/tide/configure/choices/all/finish.fish | 2 +- functions/tide/configure/choices/all/style.fish | 2 +- functions/tide/tests/context.fish | 4 ++-- 8 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index be93bab..8a6db5f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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`. -`tide test` runs tests from the `$_tide_dir/tests` directory. +`tide test` runs tests from the `$_tide_root/functions/tide/tests` directory. Example: diff --git a/completions/tide.fish b/completions/tide.fish index da853d9..ad9376f 100644 --- a/completions/tide.fish +++ b/completions/tide.fish @@ -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 --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 end \ No newline at end of file diff --git a/conf.d/_tide_init.fish b/conf.d/_tide_init.fish index ac00d26..60b3152 100644 --- a/conf.d/_tide_init.fish +++ b/conf.d/_tide_init.fish @@ -5,13 +5,14 @@ function _tide_init_install --on-event _tide_init_install _set_immutable _tide_color_green 5FD700 _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 -U _tide_var_list - source $__fish_config_dir/functions/_tide_sub_configure.fish + source $_tide_root/functions/_tide_sub_configure.fish _load_config 'lean' _tide_finish diff --git a/functions/_tide_sub_configure.fish b/functions/_tide_sub_configure.fish index ceafcb9..3689458 100644 --- a/functions/_tide_sub_configure.fish +++ b/functions/_tide_sub_configure.fish @@ -4,7 +4,7 @@ for func in _fake(functions --all | string match --entire _tide_item) 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" end @@ -82,4 +82,4 @@ end 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 -end \ No newline at end of file +end diff --git a/functions/_tide_sub_test.fish b/functions/_tide_sub_test.fish index bdbcec2..3c18d2e 100644 --- a/functions/_tide_sub_test.fish +++ b/functions/_tide_sub_test.fish @@ -17,7 +17,7 @@ function _tide_sub_test 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_CI && set -a argv 'CI/'(string replace --all --regex '^.*/|\.fish$' '' $testsDir/CI/*.fish) diff --git a/functions/tide/configure/choices/all/finish.fish b/functions/tide/configure/choices/all/finish.fish index 512eabd..08d91a3 100644 --- a/functions/tide/configure/choices/all/finish.fish +++ b/functions/tide/configure/choices/all/finish.fish @@ -44,4 +44,4 @@ function _tide_finish end set _tide_var_list $incomingVarList -end \ No newline at end of file +end diff --git a/functions/tide/configure/choices/all/style.fish b/functions/tide/configure/choices/all/style.fish index 8d376ab..59d5a1c 100644 --- a/functions/tide/configure/choices/all/style.fish +++ b/functions/tide/configure/choices/all/style.fish @@ -40,7 +40,7 @@ function _load_config -a name end 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] eval set -g $line end diff --git a/functions/tide/tests/context.fish b/functions/tide/tests/context.fish index a8783f0..313957e 100644 --- a/functions/tide/tests/context.fish +++ b/functions/tide/tests/context.fish @@ -1,6 +1,6 @@ @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 _tide_decolor (_tide_item_context) @@ -9,4 +9,4 @@ end @test 'None' -z (set -lx tide_context_always_display false; _context) @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 'Root' (_tide_decolor (sudo fish --command="source $sourceFile;_tide_item_context")) = 'root@'$hostname \ No newline at end of file +@test 'Root' (_tide_decolor (sudo fish --command="source $sourceFile;_tide_item_context")) = 'root@'$hostname