Last active
October 4, 2021 17:08
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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