Skip to content

Instantly share code, notes, and snippets.

@AlexZ005
Last active October 4, 2021 17:08
Show Gist options
  • Save AlexZ005/2f7bb35d2d98e3e7fc909af3619fc638 to your computer and use it in GitHub Desktop.
Save AlexZ005/2f7bb35d2d98e3e7fc909af3619fc638 to your computer and use it in GitHub Desktop.
ask for a username on login and create a new directory in home folder
#prepare bashrc
read -p 'Pick username: ' user
#[ -d $user ] && echo "WARNING! User already exists!" || mkdir ~/$user
if [[ ! -d $user ]]; then
mkdir $user
else
echo "WARNING! User already exists! Overwrite?"
read -p "" -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
read -p "Are you sure? " -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
fi
cd ~/$user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment