
Now all you have to do to edit those files is type the alias command aliases or bashprofile. ~/.aliases" alias bashprofile="nano ~/.bash_profile &. If you’re going to be doing a lot of dotfile editing like we are, set some aliases like this: # EASIER DOTFILE EDITING alias aliases="nano ~/.aliases &. Now you can simply type in any of those aliases and the corresponding command will execute! /./." # COMMON DIRECTORIES alias dl="cd ~/Downloads" alias dt="cd ~/Desktop" alias dc="cd ~/Documents" alias p="cd ~/Documents/projects" alias home="cd ~" # GIT alias g="git" alias gs="git status" alias gd="git diff" alias gb="git branch" alias gm="git checkout master" # SHOW/HIDE HIDDEN FILES alias showhidden="defaults write AppleShowAllFiles -bool true & killall Finder alias hidehidden="defaults write AppleShowAllFiles -bool false & killall Finder # SHOW/HIDE DESKTOP ICONS alias hidedesktop="defaults write CreateDesktop -bool false & killall Finder alias showdesktop="defaults write CreateDesktop -bool true & killall Finder There are plenty of great examples online, so make sure to do a little searching.

I’ll just list out some basic aliases that I use. If there are common commands you find yourself using, setup an alias for them! These are the aliases I like to use, but you can set anything you can think of. We’re going to set up some useful aliases, which are just shortcuts for commands. Now that our prompt is all set up, let’s make our Terminal experience a little better. You won’t notice anything immediately, but if you navigate to a git repository, your prompt should be finished and look something like this:

There are plenty of ways to achieve this, but this works for me: # GIT FUNCTIONS git_branch() # TERMINAL PROMPT PS1="\\u\" # username PS1+=" " # space PS1+="\\W\" # current directory PS1+="\\$(git_branch)\" # current branch PS1+=" " # space PS1+="> " # end prompt export PS1 export CLICOLOR=1 export LSCOLORS=ExFxBxDxCxegedabagacad Above your PS1 configuration, we’ll add in a little function to get the current working branch. However, if you’re like me and often working in a git repository, it’s nice to have your current branch displayed in your prompt. bash_prompt.Īt this point, your Terminal should look something like this: To apply your changes, simply execute the command. Remember, to exit and save your file, press Ctrl+X, then Y, then the Return key. Add this under your PS1 line: export PS1 Let’s export that and see what it looks like. The syntax might seem a bit weird, but it’s interesting to learn about if you’re curious! Basically, we’re getting the current username with \u, wrapping that in a specific colour, 0 93m, and adding in the proper escape sequences. bash_prompt file: # TERMINAL PROMPT PS1="\\u\" # username PS1 is the primary prompt displayed in the Terminal before each command. Let’s start setting up our prompt.There are a few different prompts you can customize, but we’ll stick to PS1 for this tutorial. Now, we’re going to want to make sure colours are enabled so our prompt looks nice! Add these 2 lines to do that: export CLICOLOR=1 export LSCOLORS=ExFxBxDxCxegedabagacadĬLICOLOR turns colours on, and LSCOLORS customizes them. Add this line to the top of your file: #!/usr/bin/env bash The layout I like for my prompt is - name directory (git-branch) > |įirst, let’s put a shebang at the top of our file so our system knows it’s bash. Now open up the file in the nano editor: nano. This is definitely a personal preference, so make sure to customize it to your liking!įirst, create your. bash_prompt file is going to contain the commands to set a custom bash prompt. That’s it! To save, simply press Ctrl+X, then Y, then the Return key, then apply your changes with the command. With the nano editor open, add these lines: source ~/.bash_prompt source ~/.aliases bash_profile for is to source the other dotfiles. You could add all the configuration information in this file if you wanted, but I like to split it up for better maintainability. The nano editor should open with your new. To edit your file, run the command: nano. bash_profile file, run the command: touch. Let’s make sure we’re in the home directory.

This is the first file that is read and executed when you open up your Terminal, so it’s important!
Os x open terminal here free#
Feel free to use vim, emacs, or whatever editor you’re most comfortable with!

To edit these files, we’ll just be using the nano editor as we only need to add and save a few lines. Over the next few steps, we’ll be creating some dotfiles to configure our Terminal experience. If you want to improve it even more though, keep following along! Step 3: Configuring. If you wanted to leave it here, you definitely could! It looks a bit better than the default.
