Terminal Enhancements
Minimal Command Prompt
This brief tutorial walks through setting up your terminal with a shorter command prompt.
Normally a new terminal will show the following:
hostname:current_directory username$
In my case this looks like this:
rjd:~ rjduran$

What is a hostname and why is my hostname really long?
When you setup a new computer this is automatically assigned a hostname matching your username and computer type. This name identifies your computer on a local area network. For example, rjdurans-macbook-pro or something similar. To change your hostname for your computer goto System Preference > Sharing and enter a different name for the Computer Name. On a local network your computer is identified as hostname.local. In my case it is rjd.local. You can also type hostname into your terminal and see the current hostname.
What's the tilde character "~" mean?
The tilde (~) character is used to indicate your home directory in the terminal. It's a shorthand for /Users/username. For example, to goto your Desktop folder from anywhere on your system you can type in cd ~/Desktop.
How can I shorten the command line prompt?
To understand how this works you need to know that there are hidden configuration files loaded when you start a terminal session. They are located in your home directory and are named .profile, .bash_profile, and .bashrc. It's possible that these files don't exist yet but you can simply create them by using the touch command or with vscode. For instance, touch ~/.bash_profile will create a new hidden file called .bash_profile in your home directory.
After doing this you can edit the file in vscode. Open the file and enter the following line then save to instantly shorten the command prompt next time you open a new terminal. This command simply makes use of the PS1 environment variable to configure the terminal display. Customization of the PS1 variable is a deep topic and you can read more about what's possible starting here and here.
export PS1="\W $ "
Result:
