1
Fork 0
mirror of https://github.com/Steffo99/config-fish.git synced 2024-10-16 14:27:34 +00:00
config-fish/functions/dotfish.fish

42 lines
1.2 KiB
Fish
Raw Normal View History

2021-07-15 00:22:16 +00:00
function dotfish
2024-08-21 19:59:02 +00:00
log-i "Running" "dotfish" "update..."
if test (count $argv) -eq 0
set -g argv (whoami)
log-d "No users specified, running on" "$argv" ""
end
for TARGET in $argv
log-d "Updating fish config for:" "$TARGET" ""
set -g FISHCONFIG ~(echo $TARGET)/.config/fish
log-t "Destination directory is:" "$FISHCONFIG" ""
if not test -e "$FISHCONFIG/.DOTFISHED"
log-w "Conflicting config detected" "$FISHCONFIG" ", delete?"
if confirm
log-t "Deleting old config at" "$FISHCONFIG" "..."
command rm -rf "$FISHCONFIG"
else
log-t "Deletion rejected, not touching" "$FISHCONFIG" "."
continue
end
2024-09-02 23:38:16 +00:00
end
log-t "Fixing permissions at" "$FISHCONFIG" "..."
command chown -R "$TARGET:" "$FISHCONFIG"
2024-08-21 19:59:02 +00:00
if test -d "$FISHCONFIG"
log-t "Existing config detected at" "$FISHCONFIG" "pulling from Git..."
2024-09-02 23:38:16 +00:00
command sudo -u "$TARGET" -- git -C "$FISHCONFIG" pull
2024-08-21 19:59:02 +00:00
else
log-t "No config detected, cloning from Git into" "$FISHCONFIG" "..."
2024-09-02 23:38:16 +00:00
command sudo -u "$TARGET" -- git clone "https://github.com/Steffo99/.config-fish" "$FISHCONFIG"
2024-08-21 19:59:02 +00:00
end
log-t "Changing login shell to" "/usr/bin/fish" "..."
command chsh -s "/usr/bin/fish" "$TARGET"
end
log-s "Dotfish updated successfully for" "$argv" "!"
2021-07-15 00:22:16 +00:00
end