Today I figured out how to implement some shortcuts to use in Terminal. I’ve always found it annoying to move among directories from the command line, and especially getting to my projects folder which is nested pretty deeply. I’ve also seen other people type shorter commands than I was using, and I wanted to do it to! Lots of googling and I came up with a result.
The first step is to make it so that Finder displays hidden files with these two lines in Terminal:
defaults write com.apple.Finder AppleShowAllFiles true
Then open a Finder window and navigate to the root user folder (for me it’s what shows up on the command line before $
). There are three files to open: .gitconfig
, and .bashrc
I started here from some bad googling–the steps below can make this redundant–but here it is anyway. I added the following lines into .gitignore
to simplify my git commands:
So now instead of typing git checkout -b branchName
I can just type git cob branchName
But there is a better way yet…
When a Terminal window opens it uses one of two settings, and the two settings are managed by these two files (explained better in this YouTube video). To make sure the shell sees the shortcuts no matter which way Terminal opens, direct .bash_profile
by adding this line to the file:
if [ -f ~/.bashrc ]; then
First I added a function to change a 2-step process into 1: making a new directory and then changing into it:
# mkdir, cd into it
Then I went a step further and made a specific function to open my dev projects folder from root:
# Go to dev folder & list
I also want to be able to see all of the folders and files in a directory as soon as I cd into it:
# cd, then ls directory
And finally a bunch of shortcuts to make life easier:
So I one-upped my .gitignore shortcut and now type gcob branchName
in the example above. Win!
Most of the time I’d rather not see all of the hidden files in Finder so to wrap up, undo the first step by entering the below in Terminal:
defaults write com.apple.Finder AppleShowAllFiles false
This is the final output, but initially I got some errors from copying other people’s suggestions. Still a lot to learn about shell scripting but I can say for sure that it prefers double quotes " "
to single ' '
! Also there is this great tool which will tell you what the errors are and how to fix them: ShellCheck.
Got started on the big capstone project for my bootcamp class, a Yelp clone showing campgrounds. I’m calling mine FireCamp. Should be fun!
Still pausing on the group Metro project until we figure out our framework so for now working on the bootcamp. Next section is about databases so should be getting into MongoDB.