Skip to content

Commit

Permalink
Add tide completions
Browse files Browse the repository at this point in the history
  • Loading branch information
IlanCosman committed May 24, 2020
1 parent 4f535e6 commit 643bce7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
7 changes: 7 additions & 0 deletions completions/tide.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
set -l subcommands (printf '%s ' (basename -a -s '.fish' $_tide_dir/functions/*))

# Disable file completions for the entire command
complete -c tide -f

# Offer subcommands if no subcommand has been given so far
complete -c tide -n "not __fish_seen_subcommand_from $subcommands" -a $subcommands
2 changes: 1 addition & 1 deletion functions/tide.fish
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function tide -a subcommand
set -l tideSubcommand "tide_$subcommand"
set -l tideCommands 'configure' 'uninstall' 'help'
set -l tideCommands (basename -a -s '.fish' $_tide_dir/functions/*)

if contains $subcommand $tideCommands
source "$_tide_dir/functions/$subcommand.fish"
Expand Down
8 changes: 3 additions & 5 deletions install.fish
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function tide_install
git clone -q --depth=1 -b $location https://github.com/IlanCosman/tide.git $tempDir
end

cp -r "$tempDir/completions" $__fish_config_dir
cp -r "$tempDir/conf.d" $__fish_config_dir
cp -r "$tempDir/functions" $__fish_config_dir
cp -r "$tempDir/tide_theme" $__fish_config_dir
Expand All @@ -35,12 +36,9 @@ function tide_install
end

# --------------------Set Defaults--------------------
# Add contents of conf.d and functions to a list for uninstallation
set -U _tide_file_list
for file in $tempDir/{conf.d/*, functions/*}
if test "$file" != "$tempDir/functions/fish_prompt.fish"
set -a _tide_file_list (string replace "$tempDir/" '' $file)
end
for file in $tempDir/{completions/*, conf.d/*, functions/*}
set -a _tide_file_list (string replace "$tempDir/" '' $file)
end

source "$__fish_config_dir/tide_theme/configure/functions/_set_tide_defaults.fish"
Expand Down
2 changes: 1 addition & 1 deletion tide_theme/functions/uninstall.fish
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function tide_uninstall
end

for file in $_tide_file_list
rm "$__fish_config_dir/$file"
rm -f "$__fish_config_dir/$file"
end

# -----------------------------Erase Theme Variables------------------------------
Expand Down

0 comments on commit 643bce7

Please sign in to comment.