1
Fork 0
mirror of https://github.com/Steffo99/config-fish.git synced 2024-12-22 23:04:22 +00:00
config-fish/functions/dotfish.fish

43 lines
1.3 KiB
Fish
Raw Normal View History

2021-07-15 00:22:16 +00:00
function dotfish
2021-07-15 01:04:22 +00:00
if test (count $argv) -eq 0
set -g argv (whoami)
2021-07-15 00:22:16 +00:00
end
2021-07-15 01:04:22 +00:00
for TARGET in $argv
echo_progress "Updating fish config for: "
echo_highlight "$TARGET" \n
set -g FISHCONFIG ~(echo $TARGET)/.config/fish
2021-07-15 00:32:00 +00:00
2021-07-15 01:04:22 +00:00
echo_progress "Destination directory is: "
echo_highlight "$FISHCONFIG" \n
2021-07-15 00:32:00 +00:00
2021-07-15 01:04:22 +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
2021-07-15 01:05:17 +00:00
echo_progress "Deletion was refused, skipping..." \n
continue
2021-07-15 01:04:22 +00:00
end
end
2021-07-15 00:32:00 +00:00
2021-07-15 01:04:22 +00:00
if test -d "$FISHCONFIG"
echo_progress "Existing config detected, pulling from Git..." \n
git -C "$FISHCONFIG" pull
2021-07-15 00:49:45 +00:00
else
2021-07-15 01:04:22 +00:00
echo_progress "No config detected, cloning from Git..." \n
git clone "https://github.com/Steffo99/.config-fish" "$FISHCONFIG"
2021-07-15 00:49:45 +00:00
end
2021-07-15 00:22:16 +00:00
2021-07-15 01:04:22 +00:00
echo_progress "Fixing permissions..." \n
chown -R "$TARGET:" "$FISHCONFIG"
2021-07-15 01:02:47 +00:00
2021-07-15 01:04:22 +00:00
echo_progress "Changing login shell..." \n
chsh -s "/usr/bin/fish" "$TARGET"
2021-07-15 00:22:16 +00:00
2021-07-15 01:04:22 +00:00
echo_progress "Update complete!" \n
end
2021-07-15 00:22:16 +00:00
end