tide/install.fish

87 lines
2.4 KiB
Fish
Raw Normal View History

function tide_install
argparse 'l/local' 'd/dev' -- $argv
set -l location $argv[1]
if test -z "$location"
set location 'master'
2020-05-20 22:33:41 +03:00
end
2020-05-20 00:10:19 +03:00
printf '%s\n' 'Installing tide theme...'
2020-04-03 03:12:55 +03:00
# -----------------Download Files-----------------
2020-05-19 06:03:25 +03:00
set -l tempDir '/tmp/tide_theme'
2020-04-03 02:30:40 +03:00
# Copy/clone repository into $tempDir
if test -e $tempDir
rm -rf $tempDir
end
if set -q _flag_local
cp -rf "$location" "$tempDir"
else
git clone -q --depth=1 -b $location https://github.com/IlanCosman/tide.git $tempDir
end
cp -r "$tempDir/conf.d" $__fish_config_dir
cp -r "$tempDir/functions" $__fish_config_dir
cp -r "$tempDir/tide_theme" $__fish_config_dir
if set -q _flag_dev
cp -r "$tempDir/tests" $__fish_config_dir
cp -r "$tempDir/dev/." "$__fish_config_dir/functions"
2020-05-23 04:34:38 +03:00
# Install fisher and fishtape for testing
curl https://git.io/fisher --create-dirs -sLo ~/.config/fish/functions/fisher.fish
fisher add jorgebucaran/fishtape
2020-05-10 02:41:29 +03:00
end
2020-04-16 11:48:40 +03:00
# --------------------Set Defaults--------------------
2020-05-22 08:11:20 +03:00
# Add contents of conf.d and functions to a list for uninstallation
set -U _tide_file_list
for file in $tempDir/{conf.d/*, functions/*}
2020-05-22 08:11:20 +03:00
if test "$file" != "$tempDir/functions/fish_prompt.fish"
set -a _tide_file_list (string replace "$tempDir/" '' $file)
end
end
source "$__fish_config_dir/tide_theme/configure/functions/_set_tide_defaults.fish"
2020-05-19 06:03:25 +03:00
_set_tide_defaults
# -----------------------Finish-----------------------
2020-05-19 06:03:25 +03:00
_source_tide_functions
2020-05-20 20:39:44 +03:00
set_color $_tide_color_green
2020-05-20 00:10:19 +03:00
printf '%s\n' 'Tide theme installed!'
2020-05-22 05:28:50 +03:00
set_color normal
printf '%s\n'
2020-05-19 06:03:25 +03:00
if _user_confirm_defaultYes 'Configure tide prompt?'
tide configure
else
2020-05-20 00:10:19 +03:00
printf '%s\n'
2020-05-22 05:28:50 +03:00
printf '%s\n' 'Run tide configure to customize your prompt.'
end
rm -rf $tempDir
end
2020-05-19 06:03:25 +03:00
function _source_tide_functions
for file in $_tide_file_list
source "$__fish_config_dir/$file"
end
2020-05-17 20:01:17 +03:00
source "$__fish_config_dir/functions/fish_prompt.fish"
end
function _user_confirm_defaultYes -a question
while true
read -P "$question [Y/n] " input
switch $input
case y Y yes Yes
return 0
case n N no No
return 1
2020-04-30 00:52:58 +03:00
case ''
return 0
end
end
end