2021-07-15 00:22:16 +00:00
|
|
|
function dotfish
|
|
|
|
if test (count $argv) -ge 1
|
|
|
|
set -g TARGET $argv[1]
|
|
|
|
else
|
|
|
|
set -g TARGET (whoami)
|
|
|
|
end
|
|
|
|
|
|
|
|
echo_progress "Updating fish config for: "
|
|
|
|
echo_highlight "$TARGET" \n
|
|
|
|
|
2021-07-15 00:32:00 +00:00
|
|
|
if test -z $TARGET
|
2021-07-15 00:49:45 +00:00
|
|
|
echo_progress "Couldn't detect target, exiting..." \n
|
|
|
|
return 1
|
2021-07-15 00:32:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
set -g FISHCONFIG ~(echo $TARGET)/.config/fish
|
|
|
|
|
|
|
|
echo_progress "Destination directory is: "
|
|
|
|
echo_highlight "$FISHCONFIG" \n
|
|
|
|
|
2021-07-15 00:49:45 +00:00
|
|
|
if not test -e "$FISHCONFIG/.DOTFISHED"
|
|
|
|
echo_progress "Conflicting config detected, confirm deletion?" \n
|
|
|
|
if confirm
|
|
|
|
echo_progress "Deleting old config..." \n
|
|
|
|
rm -rf $FISHCONFIG
|
|
|
|
else
|
|
|
|
echo_progress "Deletion was refused, exiting..." \n
|
|
|
|
return 2
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2021-07-15 00:27:19 +00:00
|
|
|
if test -d $FISHCONFIG
|
2021-07-15 00:49:45 +00:00
|
|
|
echo_progress "Existing config detected, pulling from Git..." \n
|
2021-07-15 00:27:19 +00:00
|
|
|
git -C $FISHCONFIG pull
|
|
|
|
else
|
2021-07-15 00:49:45 +00:00
|
|
|
echo_progress "No config detected, cloning from Git..." \n
|
2021-07-15 00:27:19 +00:00
|
|
|
git clone "https://github.com/Steffo99/.config-fish" $FISHCONFIG
|
|
|
|
end
|
2021-07-15 00:22:16 +00:00
|
|
|
|
|
|
|
echo_progress "Fixing permissions..." \n
|
2021-07-15 00:23:11 +00:00
|
|
|
chown -R "$TARGET:" $FISHCONFIG
|
2021-07-15 00:22:16 +00:00
|
|
|
|
2021-07-15 00:49:45 +00:00
|
|
|
echo_progress "Update complete!" \n
|
2021-07-15 00:22:16 +00:00
|
|
|
end
|