Skip to content

Instantly share code, notes, and snippets.

@brysgo
Last active April 27, 2018 19:53
Show Gist options
  • Save brysgo/70def356e3603b0bb3e75f68628fe66f to your computer and use it in GitHub Desktop.
Save brysgo/70def356e3603b0bb3e75f68628fe66f to your computer and use it in GitHub Desktop.
Use alias for home directory (if username has a space)

Usage

  1. Run sudo ln -s $HOME /Users/myshortname
  2. Add profile script to the top of your /etc/profile
  3. Create ~/.useralias file with the name of your alias (myshortname in this case)
  4. Use $ORIG_HOME for things like your NVM_DIR that doesn't like aliases
if [ -f "$HOME/.useralias" ]; then
export ORIG_USER=$USER
export USER=`cat "$HOME/.useralias"`
export ORIG_LOGNAME=$LOGNAME
export LOGNAME=$USER
export ORIG_HOME=$HOME
export HOME="/Users/$USER"
fi
if [ "$PWD" = "$ORIG_HOME" ]; then
cd ~
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment