Utility Git Bash Shortcuts

Big hat tip to sartorial exemplar John Fair for putting me on to this idea and sharing his set of default aliases.

If you use git bash for your typical interaction with git (and probably you should if you don’t because it behaves the same on all git platforms), adding a few shortcuts can dramatically cut down on the typing you need to do.

Open a git bash prompt.  From the prompt, open ~/.bashrc in your favorite editor.  Then paste these aliases into that file.

alias st2='/c/progra~1/sublim~1/sublime_text.exe'
alias fsi='/c/progra~2/mid3a6~1/v4.0/fsi.exe'
alias s='start '

#Change to base directory
alias ctb='cd /c/mysandbox'

#Git status--use this one all the time
alias gs='git status'

#Git checkout -- another one I use all the time
alias gche='git checkout'

alias ls='ls -alp '
alias ga='git add '
alias gb='git branch '
alias gche='git checkout '
alias gcom='git commit '
alias gcam='git commit -am '
alias gl='git log '
alias gpl='git pull '
alias gm='git merge '
alias gd='git diff '

You may notice that I have a shortcut for my favorite editor (Sublime Text 2) as well as an alias to bring up a F# Repl too.  I also have a utility alias to change to the root directory of my current development work.

Configuring Sublime Text 2 To Work With FSharp

I like working with the Sublime Text 2 editor and I surely like to work with FSharp so I’ve been trying to find ways to make life easier for myself.  A few tips to pass along:

  1. Get the F# Textmate Bundle. Once you get it, unzip it into the ~\Application Data\Sublime Text 2\Packages directory.  In my case I created a F# directory under the Packages directory.
  2. Add the following settings via the File Settings-User menu
    	"tab_size": 4,
    	"translate_tabs_to_spaces": true
  3. To make it easier to compile and build your app, create a couple of environment variables: MSBuildBin and FSBin. In my case I set the MSBuildBin to the directory where the MSBuild.exe is located and I set FSBin to the directory where Fsc.exe is located.

Under the ~\Application Data\Sublime Text 2\Packages\User directory, create a file called msbuild.sublime-build and put the following in it:

    "path": "%FSBin%;%MSBuildBin%",
    "cmd": ["msbuild"]

Once you do this, on the Tools->Build System menu, you should have an msbuild option.  If you select the msbuild option from the build system you should be able to build your FSharp app with an msbuild *.proj file.  You can grab the lines from the output via a Perl RegEx if you want but I’ve not done anything so complex up to this point.

I’m working on adding the ability to shell out to the fsi.exe utility.  If I make any progress with that, I’ll post on it here.

UPDATE: See Leaf’s comment below for information on adding a REPL to Sublime Text 2. Great many thanks Leaf.

Also, here is a Gist of a small, modest F# shell script to kick off Sublime Text 2 adding git into the path for the ST2 git plug-in.

UPDATE 2:  The eminent F# developer, PaulMichael Blasucci has created a new Sublime Text 2 plug-in for F# developers.

Technorati Tags: ,,