Not long ago, an IT Admin from Missouri and a Software Engineer from the UK emailed me asking me if I could help them figure out how to get SSH-Agent running in Cmder. Now that I have received two big thumbs up from each of them, it's time for me to share my solution to you.

Meet your new friend: .bash_profile

On Linux systems using the Bourne-Again Shell (BASh), there are various files which can be used to enhance your experience with bash. One such file is .bash_profile which can be found (and if it isn't found, it can be placed in) your ~ (home) directory. Other files have other purposes, such as ~/.bashrc, however due to how Cmder works, we're only going to use ~/.bash_profile, and you can otherwise read about the differences between the two files on Josh Staiger's blog. For other very useful information on bash, check out the StackOverflow Wiki for Bash.

Now, chances are that you do not already have ~/.bash_profile created on your system; To create it, go ahead and open up your git bash profile in Cmder and type the following:

$ touch ~/.bash_profile

The file now exists. To edit it, let's open it in notepad:

$ notepad ~/.bash_profile

Finally, at the top of the file, let's type the following, which informs bash in Cmder that it'll be executing a bash script:

#!/bin/bash

Running Eval on SSH-Agent & Adding Keys

One of the benefits of ~/.bash_profile is automating processes you would otherwise have to manually participate in, such as running an eval on ssh-agent, and adding your ssh keys in ~/.ssh. To do this very thing automatically every time you open Cmder, add the following on a new line in ~/.bash_profile:

Aliases Shortcut Your World

Aliases are the greatest thing since sliced bread. Are you often finding yourself typing git status -s and wished there was a quicker way? Well there is, you could literally alias that string to s and use that instead.

Here are a few of my aliases, which I'll then explain below. Should you like to add these to your ~/.bash_profile, copy and paste them to a new line (and keep the #comment intact).

edprof opens ~/.bash_profile in Sublime Text 3 and once that is saved and closed, sources ~/.bash_profile, running the contents in the current shell (making it so you don't need to restart Cmder or the current bash profile to see changes you made go live);

c clears the screen;

.., ..., and .... navigate you up the folder hierarchy; and

grep is modified to show colors when you run grep.

Wrap-Up

There is a plethora of aliases, functions, and other things you can add to your ~/.bash_profile to make your stay in your bash tab in Cmder far more pleasant and convenient. Googling "bash_profile aliases" will yield many more aliases written by other developers, while "bash_profile ssh" will take you to other simpler and more complex options for adding and managing your ssh-keys. Linux has a rich and well-developed history, and a million other people have probably asked questions for Linux that now apply to Windows (while using something like Cmder), so keep that in mind.

If you have any comments or questions about this article, or are interested in me writing an article about another topic or issue you are curious about or needing help with, feel free to shoot me an email: and...@awmoore.com