Category Archives: Tools

Three tips for creating the “best ever” git command line!

As a recovering CVS user turned svn master, and now an aspiring git ninja, I am sharing some of the tips and tricks to make my git environment as enjoyable and effective as possible.  First a little tough love: if you are not using the git command line, then just move along… these aren’t the droids you’re looking for.  But seriously, if you want to learn how to use git better you MUST MUST MUST use the command line. But if you are going to use a GUI, then PLEASE do us all a favor and avoid Github for Mac and instead get a tool like Tower.

So if you are still reading you are in the right place! 🙂

Tip #1:  If you are not using bash-completion, start now! Seriously! Stop reading this post and go install bash-completion immediately! This is the single biggest time saver; period. It provides completions via a deep knowledge of common tools such as git, ssh, jar, java, man, etc. For example:

  1. cd <your favorite git project>
  2. git checkout origin/<TAB><TAB>
  3. You will see all of the branches from the remote repo appear like magic!
  4. The git bash-completion knows about git commands, tags, branches, repositories, etc. So cool!
  5. Now try: git log –<TAB><TAB>
  6. It shows you all of the command line options for git log. With each git command having a wealth of options, this is a huge sanity saver.

Tip #2: Now that you have bash completing your git commands for you, how about we add some color to the results of git commands? Yes, seeing the output of a “git diff” colorized with additions in green and subtractions in red is, well after you get used to it, simply required.

Edit your ~/.gitconfig and add the following section:

[color]
  diff = auto
  status = auto
  branch = auto
  interactive = auto
  ui = auto

And while you are in there add this section to automatically run garbage collection for you!

[gc]
  auto = 1

Tip #3: Tired of typing “git status” to figure out if your branch is clean or dirty? Or if you need to push or pull to get caught up with a remote repo? The next git trick will really knock your socks off! Via the bash prompt, it displays the git branch you are currently on. If the branch is dirty the name of the branch is displayed in red. If the branch is clean the name is displayed in green. For example:

…clean…

    [develop] /Develop/k2/rsmart/nakamura

…dirty…

    [develop] /Develop/k2/rsmart/nakamura

…ahead…

    [develop↑] /Develop/k2/rsmart/nakamura

…behind…

    [develop↓] /Develop/k2/rsmart/nakamura

…branches have diverged…

    [develop↕] /Develop/k2/rsmart/nakamura

Curious yet? Here are the arcane .bash_profile incantations to make this a reality:

c_cyan=`tput setaf 6`
c_red=`tput setaf 1`
c_green=`tput setaf 2`
c_sgr0=`tput sgr0`
parse_git_branch ()
{
    if git rev-parse --git-dir >/dev/null 2>&1
    then
        git_status="$(git status 2> /dev/null)"
        branch_pattern="^# On branch ([^${IFS}]*)"
        remote_pattern="# Your branch is (.*) of"
        diverge_pattern="# Your branch and (.*) have diverged"
        # add an else if or two here if you want to get more specific
        if [[ ${git_status} =~ ${remote_pattern} ]]; then
          if [[ ${BASH_REMATCH[1]} == "ahead" ]]; then
            remote="↑"
          elif [ ${BASH_REMATCH[1]} == "behind" ]]; then
            remote="↓"
          fi
        fi
        if [[ ${git_status} =~ ${diverge_pattern} ]]; then
          remote="↕"
        fi
        if [[ ${git_status} =~ ${branch_pattern} ]]; then
          branch=${BASH_REMATCH[1]}
          echo "${branch}${remote}"
        fi
    else
        return 0
    fi
}
branch_color ()
{
    if git rev-parse --git-dir >/dev/null 2>&1
    then
        git_status="$(git status 2> /dev/null)"
        color=""
        if [[ ${git_status} =~ "working directory clean" ]]; then
            color="${c_green}"
        else
            color=${c_red}
        fi
    else
        return 0
    fi
    echo -ne $color
}
export PS1='[\[$(branch_color)\]$(parse_git_branch)\[${c_sgr0}\]] \w\[${c_sgr0}\]$ '

With this information in hand, you should be well on your way to leveling-up your git ninja (ginja?) skills… 🙂

Advertisements

7 Comments

Filed under Technology, Tools

Tags for OS X Users – Finding Stuff

I have been experimenting with some tools over the past six months to help me get better organized and increase the chances I can actually find something on my computer. I started my exploration with a program called Together from Reinvented Software.  Together was a good place for me to begin exploring the set of tags I would use and to incorporate tagging into my daily work-flows.  The things I liked about Together:

  1. It did not lock my content up into some bizarro binary file that could never be parsed again.  Instead, it neatly organized all of the files you added to Together in your Documents folder.  Seemed like a pretty reasonable thing.
  2. The tagging UI was pretty fast and had auto-complete.

These aspects of Together kept me using it for a few months until I discovered:

  1. The tags themselves were locked up in some bizarro binary file format! That did not sit well with me thinking about years and years of collected tags. While the program does have some way to sync those tags to Spotlight comments, the author warns that it will slow the application down and consume huge amounts of resources.
  2. The application became slow and unresponsive – even though I did not have the Spotlight-tag-syncing, resource-sucking option turned on.
  3. The work-flow of drag-and-drop became too cumbersome and I wanted something more streamlined.

I continued trudging through my use of Together, when one day the MacUpdate Promo had an application called Tags by Gravity Applications advertised for steep discount. It sounded like a good fit – maybe too good to be true – but the price was right and was worth trying to see if it met the hype. What I liked:

  1. Your tags are not locked away – they are part of the file’s metadata. This should allow my tags to travel as long as Spotlight is around.
  2. Spotlight can search for the tags – try a search like: tag:receipt apple.
  3. The UI is lightweight and fast. It may feel a bit unprofessional (just a personal opinion), but it cuts mustard.
  4. It is integrated with almost every application I use, and thus knows what file I am trying to tag without some cumbersome drag-and-drop work-flow. Very smart and efficient.

I am glad to say that I am still using Tags on a daily basis and have built some Automator work-flows around it as well. And… They recently provided me with an update to get everything working smoothly with Snow Leopard. Overall, I am very satisfied with this solution – I am able to find things reliably.  And after using this work-flow for awhile, it does strike me that this should be a base capability in OS X. I do find some evidence that Apple is headed down this path if you try the following in Snow Leopard: Print -> Save as PDF -> then play around in the Keywords field. I am seeing auto-complete. Are you?

1 Comment

Filed under Personal, Technology, Tools

Sakai3 tool development; lessons learned from rapid prototyping in jQuery

So this one definitely got me outside of my comfort zone. This is also the first presentation I have given where I did not use even one slide! I seemed to have gotten favorable reactions from the audience – so I am going to share it.

Watch the Screen-cast

Description: Learn how you can use simple HTML, CSS, JavaScript, and jQuery technologies to build rapid prototypes that can be quickly user tested in short iterations. Unlike more traditional prototyping methods, jQuery allows you to build fully functional user interfaces that not only aid in the design process, but then actually become the tool code itself.

Presenters: Lance Speelmon, Indiana University

1 Comment

Filed under Sakai, Technology, Tools

First experiences with ScreenFlow – very positive!

I have to admit, I am smitten with good screen-casts and when I saw the release of a new screen-casting application, ScreenFlow, I had to try it.  In the past, I have used SnapzProX and that tool has served me well.  However, there were a couple of serious limitations that have always left me wanting more:

  1.  WYSIWYG – You must select your capture options, start the recording, and then do not make any mistakes!  Because you will export to a resolution lower than that of your desktop (e.g. 1440×900), you will likely choose options that limit the capture area to something more reasonable (e.g. 640×480).  Because you have to make these decisions before recording your chances of getting it wrong increase substantially.  This is a very unkind WYSIWYG – no undo – you must start your recording over if you make any mistakes.  
  2. Export/Transcoding – You can only make your export selections once and hope you got them right!  You want to get the smallest file size with the highest quality encoding.  Almost certainly you will not get it right the first time.  So now what?  Record again and export again!  Not acceptable.  
I was intrigued when I read TUAW’s blog posting about ScreenFlow.  The approach ScreenFlow takes fundamentally changes the workflow I have come to know.  ScreenFlow captures the entire screen — no more trying to remember if I am in-frame or out-of-frame — just capture the desktop in its entirety and worry about zooming and panning later!  According to their web site: “ScreenFlow can handle everything from capturing DVD video & audio to fast moving Keynote presentations”.  This fundamentally changes the screen capture game and the way I think about it.
 
Okay, so the capture is great (with low CPU overhead), but the real magic happens when you start adding what are known as “actions” to your project.  Actions allow you to manipulate video and audio in post.  Callout actions allow you to draw attention to the mouse or foreground windows.  I cannot do the editing process justice; go watch the company’s screencasts to be wowed.  🙂  IMHO, this application is really top notch and represents what differentiates great Mac software from good: it is fun, easy to use, and it gives me great results.  
 
So how does ScreenFlow directly address my issues with SnapzProX?
  1. WYSIWYG – friendly – because it captures the entire screen during recording, I can worry about panning and zooming in post.  If I do not like the results, undo, and try again; very forgiving.
  2. Export – Since the entire capture and post processing is saved as a project, I can run multiple exports/transcodes until I get it right.  Again, very forgiving.
While I do not claim to be a pro, I submit my first screencast made with ScreenFlow for your review.  I spent about an hour on this total with three takes.  The learning curve for post processing was very low.  ScreenFlow includes screencasts that document the workflow and are very helpful.
 

1 Comment

Filed under Sakai, Technology, Tools