From 032c04ef08d8749e241b2a0c3b07824bb56b057d Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 15 Jul 2021 03:04:22 +0200 Subject: [PATCH] Allow multiple users --- functions/dotfish.fish | 82 +++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/functions/dotfish.fish b/functions/dotfish.fish index a336d30..89a64f8 100644 --- a/functions/dotfish.fish +++ b/functions/dotfish.fish @@ -1,48 +1,48 @@ 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 - - if test -z $TARGET - echo_progress "Couldn't detect target, exiting..." \n - return 1 + if test (count $argv) -eq 0 + set -g argv (whoami) end - set -g FISHCONFIG ~(echo $TARGET)/.config/fish + for TARGET in $argv + echo_progress "Updating fish config for: " + echo_highlight "$TARGET" \n - echo_progress "Destination directory is: " - echo_highlight "$FISHCONFIG" \n - - 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 + if test -z $TARGET + echo_progress "Couldn't detect target, exiting..." \n + return 1 end + + set -g FISHCONFIG ~(echo $TARGET)/.config/fish + + echo_progress "Destination directory is: " + echo_highlight "$FISHCONFIG" \n + + 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 + + + if test -d "$FISHCONFIG" + echo_progress "Existing config detected, pulling from Git..." \n + git -C "$FISHCONFIG" pull + else + echo_progress "No config detected, cloning from Git..." \n + git clone "https://github.com/Steffo99/.config-fish" "$FISHCONFIG" + end + + echo_progress "Fixing permissions..." \n + chown -R "$TARGET:" "$FISHCONFIG" + + echo_progress "Changing login shell..." \n + chsh -s "/usr/bin/fish" "$TARGET" + + echo_progress "Update complete!" \n end - - - if test -d "$FISHCONFIG" - echo_progress "Existing config detected, pulling from Git..." \n - git -C "$FISHCONFIG" pull - else - echo_progress "No config detected, cloning from Git..." \n - git clone "https://github.com/Steffo99/.config-fish" "$FISHCONFIG" - end - - echo_progress "Fixing permissions..." \n - chown -R "$TARGET:" "$FISHCONFIG" - - echo_progress "Changing login shell..." \n - chsh -s "/usr/bin/fish" "$TARGET" - - echo_progress "Update complete!" \n end \ No newline at end of file