2020-05-23 04:31:00 +03:00
|
|
|
function tide_install
|
2020-06-07 07:23:56 +03:00
|
|
|
# If git isn't installed, there's nothing we can do
|
|
|
|
if not command -q git
|
|
|
|
printf '%s\n' 'Git must be installed to download Tide.'
|
|
|
|
return 1
|
|
|
|
end
|
|
|
|
|
2020-05-23 04:31:00 +03:00
|
|
|
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
|
|
|
|
2020-05-23 04:31:00 +03:00
|
|
|
# -----------------Download Files-----------------
|
2020-06-16 21:28:16 +03:00
|
|
|
set -g tempDir '/tmp/tide_theme'
|
2020-04-03 02:30:40 +03:00
|
|
|
|
2020-05-23 04:31:00 +03:00
|
|
|
# Copy/clone repository into $tempDir
|
2020-04-20 21:12:57 +03:00
|
|
|
if test -e $tempDir
|
|
|
|
rm -rf $tempDir
|
|
|
|
end
|
2020-05-23 04:31:00 +03:00
|
|
|
if set -q _flag_local
|
|
|
|
cp -rf "$location" "$tempDir"
|
|
|
|
else
|
2020-06-16 20:19:45 +03:00
|
|
|
git clone -q --depth 1 -b $location https://github.com/IlanCosman/tide.git $tempDir
|
2020-05-23 04:31:00 +03:00
|
|
|
end
|
2020-04-20 21:12:57 +03:00
|
|
|
|
2020-05-25 01:37:09 +03:00
|
|
|
cp -r "$tempDir/completions" $__fish_config_dir
|
2020-05-23 04:31:00 +03:00
|
|
|
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
|
|
|
|
2020-05-23 04:31:00 +03:00
|
|
|
# --------------------Set Defaults--------------------
|
2020-06-14 07:29:21 +03:00
|
|
|
_set_immutables
|
|
|
|
|
2020-06-16 21:28:16 +03:00
|
|
|
set -U _tide_var_list
|
2020-06-16 02:23:45 +03:00
|
|
|
source "$_tide_dir/configure/configs/lean.fish"
|
|
|
|
for fakeVar in $fake_tide_var_list
|
|
|
|
set -l normalVar (string replace 'fake_' '' $fakeVar)
|
|
|
|
set -U $normalVar $$fakeVar
|
|
|
|
set -a _tide_var_list $normalVar
|
|
|
|
set -e $fakeVar
|
|
|
|
end
|
2020-05-13 23:08:37 +03:00
|
|
|
|
|
|
|
# -----------------------Finish-----------------------
|
2020-06-03 01:10:18 +03:00
|
|
|
for file in $_tide_file_list
|
|
|
|
source "$__fish_config_dir/$file"
|
|
|
|
end
|
|
|
|
source "$__fish_config_dir/functions/fish_prompt.fish"
|
2020-05-13 23:08:37 +03:00
|
|
|
|
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-13 23:08:37 +03:00
|
|
|
|
2020-05-19 06:03:25 +03:00
|
|
|
if _user_confirm_defaultYes 'Configure tide prompt?'
|
|
|
|
tide configure
|
2020-05-13 23:08:37 +03:00
|
|
|
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.'
|
2020-05-13 23:08:37 +03:00
|
|
|
end
|
2020-05-23 04:31:00 +03:00
|
|
|
|
|
|
|
rm -rf $tempDir
|
2020-06-16 21:28:16 +03:00
|
|
|
set -e tempDir
|
2020-05-13 23:08:37 +03:00
|
|
|
end
|
|
|
|
|
2020-06-14 07:29:21 +03:00
|
|
|
function _set_immutables
|
|
|
|
set -U _tide_var_immutable_list
|
2020-06-16 21:28:16 +03:00
|
|
|
|
|
|
|
_set_immutable _tide_file_list
|
|
|
|
for file in $tempDir/{completions/*, conf.d/*, functions/*}
|
|
|
|
set -a _tide_file_list (string replace "$tempDir/" '' $file)
|
|
|
|
end
|
2020-06-14 07:29:21 +03:00
|
|
|
|
2020-06-17 18:57:08 +03:00
|
|
|
_set_immutable _tide_version 1.4.0
|
2020-06-14 07:29:21 +03:00
|
|
|
_set_immutable _tide_dir "$__fish_config_dir/tide_theme"
|
|
|
|
# --------------Colors--------------
|
|
|
|
_set_immutable _tide_color_green 5FD700
|
|
|
|
_set_immutable _tide_color_light_blue 00AFFF
|
|
|
|
_set_immutable _tide_color_dark_blue 0087AF
|
|
|
|
_set_immutable _tide_color_normal (set_color normal)
|
|
|
|
end
|
|
|
|
|
|
|
|
function _set_immutable -a var_name
|
|
|
|
set -U $var_name $argv[2..-1]
|
|
|
|
set -a _tide_var_immutable_list $var_name
|
|
|
|
end
|
|
|
|
|
2020-04-26 00:52:39 +03:00
|
|
|
function _user_confirm_defaultYes -a question
|
2020-04-22 06:06:05 +03:00
|
|
|
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 ''
|
2020-04-22 06:06:05 +03:00
|
|
|
return 0
|
|
|
|
end
|
|
|
|
end
|
2020-04-20 21:12:57 +03:00
|
|
|
end
|