Skip to content

Commit

Permalink
🔨 select-shell: clearer outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Apr 10, 2022
1 parent 134fd58 commit 22e3d7a
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions commands/select-shell
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,21 @@ function select-shell() (
fi

# log
echo-segment --h1="Selected the shell [$shell] at [$path]"
echo-segment --h1="Selected [$shell] at [$path]"

# add the shell to the system whitelist
echo-segment --h2="Whitelisting as a login shell"
# update system whitelist
echo-segment --h2="Update system whitelist"
if contains-line "$path" </etc/shells; then
echo-segment --green="Already within the system whitelist [/etc/shells]"
else
echo-segment --h3="Add to system whitelist [/etc/shells]"
echo "$path" | sudo tee -a /etc/shells
echo-segment --g3="Add to system whitelist [/etc/shells]"
fi
echo-segment --g2="Whitelisting as a login shell"
echo-segment --g2="Update system whitelist"

echo-segment --h2="Set as the login shell for [$USER]"
# update system selection
echo-segment --h2="Update login shell for [$USER]"
if command-exists chpass; then
echo-style --dim="You can ignore [chpass: no changes made] warnings."
# mac
Expand All @@ -89,14 +90,14 @@ function select-shell() (
chsh -s "$path" "$USER"
else
# unknown fail
echo-style --error="Unable to apply the shell on this system, as neither of the tools to do it [chpass] nor [chsh] exist on this sytem." >/dev/stderr
echo-segment --e2="Set as the login shell for [$USER]"
echo-style --error="Unable to update the login shell on this system, as neither of the tools to do it [chpass] nor [chsh] exist on this sytem." >/dev/stderr
echo-segment --e2="Update login shell for [$USER]"
return 19 # ENODEV 19 Operation not supported by device
fi
echo-segment --g2="Set as the login shell for [$USER]"
echo-segment --g2="Update login shell for [$USER]"

# success case
echo-segment --g1="Selected the shell [$shell] at [$path]"
echo-segment --g1="Selected [$shell] at [$path]"
echo-style --notice="Restart your terminal, or open a new one, for the change to take effect."
}
function use_first_available {
Expand Down

0 comments on commit 22e3d7a

Please sign in to comment.