Creating a custom prompt in your terminal can be a great way to improve your productivity and make your work environment more personalised. While there are many pre-configured solutions available, creating your own can be a rewarding experience that allows you to fine-tune your prompt to your specific needs. This can take time and effort, but the result can be a clean, dynamic, and efficient prompt that helps you work more effectively. In this case, the prompt was specifically designed to work well with Apple Terminal, which is a simple and easy-to-use terminal application that comes pre-installed on all Mac computers. This makes it a great choice for users who don't require advanced features or who don't use the terminal frequently. With a customised prompt, even a simple terminal application like Apple Terminal can become a powerful tool for productivity and efficiency.
While the default zsh prompt is functional, it is relatively short and does not provide much information. On the other hand, the default bash prompt on macOS is longer and more informative, displaying the current working directory, the username, the hostname, and more. However, with a few tweaks, you can create a customised zsh prompt that displays the same information as the default bash prompt, along with other useful details.
The customised prompt is designed to provide you with the information that is most relevant and useful to your workflow, while also being visually appealing, easy to read, and user-friendly. Some of the information that the prompt displays includes the current working directory, which can help you keep track of where you are in the file system and navigate between different directories more efficiently.
The prompt also displays the git branch and status, which is particularly useful for developers who work with version control systems like Git. This feature allows you to see at a glance which branch you are currently working on, as well as any changes or updates that have been made to the repository.
In addition, the prompt displays the previous command's exit status using colours to indicate whether the command was successful or not. This feature makes it easier to spot errors and identify potential issues with your commands. For example, if a command fails, the prompt will display the exit status in red, making it easy to see that something went wrong.
Overall, the customised prompt is designed to make your command line experience more efficient and productive by providing you with the information you need in a clear and easy-to-read format.
- Prompt character turns red if the last command didn't exit with
0
. - Shows the git branch and whether it's dirty.
- Indicates when you have unpushed/unpulled git commits with up/down arrows.
- Username and host are only displayed when in an SSH session or a container.
- Shows the current path in the title and the (current folder and command) when a process is running.
- Shows the current git branch in the title.
The following diagram shows the structure of the prompt:
Suggestion: when you open your terminal, you might see a message that displays information such as the version of your operating system or the last time you logged in. While this message can be useful, it can also be distracting and unnecessary for some users. Fortunately, you can suppress this message by creating a file called .hushlogin in your home directory (~). This file will prevent the status message from appearing at the start of each terminal session, regardless of whether you're using zsh, bash, or any other shell. This is a simple and effective way to customise your terminal experience and remove any unwanted distractions.
Here are the two methods you can choose from:
Automatic Download via curl
: Simply execute the following command in your terminal to quickly download and seamlessly install the utility:
zsh -c "$(curl -fsSL https://raw.githubusercontent.com/nicolodiamante/simple/HEAD/bootstrap.zsh)"
Manual Cloning: For those who prefer a hands-on approach, you can manually clone the repository to your desired location:
git clone https://github.com/nicolodiamante/simple.git ~/simple
Directory Navigation & Script Execution: Navigate to the root directory of the repository, and then execute the installation script using the following command:
source utils/install.zsh
Simple Configuration: To streamline the integration process, this script systematically identifies the zshrc
file within the user's environment and appends the simple/script
path to the pivotal fpath
variable.
fpath=(~/simple/script $fpath)
autoload -Uz simple
Install via Oh My Zsh
If you're using Oh My Zsh, you can install simple
as a plugin:
git clone https://github.com/nicolodiamante/simple.git $ZSH_CUSTOM/plugins/simple
Then, add simple
to your .zshrc
plugins array:
plugins=(... simple)
Restart theshell to activate the changes.
Any suggestions or feedback you may have for improvement are welcome. If you encounter any issues or bugs, please report them to the issues page.