Command Line Productivity (Part 3)

Here are links to Part 1 and Part 2 of this series.

OK, back to productivity post. I wanted to make my command line work more efficient and streamlined. Even with wonderful zsh autocomplete of remote ssh server paths, git branches etc, there is a lot of typing going on and not all is necessary.

One big annoyance for me is that I have several projects, and often I need to get from one to the other quickly. Often I would have several tabs open in iTerm2 and each would be for some context, and within that context that window would be split further. Often I would keep those for several days, just to avoid having to type all of this again.

This is all fine, but I started using sometime 2+ years ago aliases for projects and spaces I go frequently. As long as I have similar file organization on all my machines, and that aliases file is kept on Dropbox, things are great. Dropbox is awesome :), just saying.

Back to my aliases file which I mentioned in Part 2 of this series.

# apps
alias reload=”source ~/.zshrc”
alias be=”bundle exec”
alias cuke=”bundle exec cucumber”
alias rs=”bundle exec rspec”

# locations
alias work=”cd ~/work”
alias fit=”cd ~/work/fitclub”
alias zelio=”cd ~/work/zelio”
alias home=”cd ~”
alias aliases=”mvim ~/Dropbox/Apps/aliases”
alias web=”cd /Library/WebServer/Documents/”

I removed several projects from this, as I feel exposed by having all my aliases here.

First part shortens long app related commands, obviously I do a lot of rails, if you use different tools, it pays to shorten them. Other part is for different location on my machine I feel like I like to have their locations.

This all works really well. However recently I came across … bash script I can’t find source to properly attribute credits… well here it is, it is very short and uses symlinks to remember folders aliases. Just include this in your .bashrc or .profile or .zshrc

# JUMPEROO
export MARKPATH=$HOME/.marks
function jump {
cd -P $MARKPATH/$1 2>/dev/null || echo “No such mark: $1”
}

function j {
cd -P $MARKPATH/$1 2>/dev/null || echo “No such mark: $1”
}

function mark {
mkdir -p $MARKPATH; ln -s $(pwd) $MARKPATH/$1
}
function unmark {
rm -i $MARKPATH/$1
}
function marks {
ls -l $MARKPATH | sed ‘s/  / /g’ | cut -d’ ‘ -f9- | sed ‘s/ -/\t-/g’ && echo
}

It usage is to cd into folder let’s say ~/work/my_awesome_code, then say ‘mark awesome’ and in future, if you say ‘jump awesome’ you will be there. If you say ‘marks’ it will list all remembered locations. Very simple, awesome.

While my aliases served me well for years, this solution is very elegant and I really like how it is done.

This is pretty much what I had so far. There some smaller tricks I like to do, like creating todo.txt in folder and in .rvmrc or some other file to add ‘cat todo.txt’, so each time I open a folder, it will tell me what next it is supposed to happen in that project. This obviosly can be done in .zshrc as independent function, I just didn’t spend time on it.

Also,  whenever I notice I am typing same command over and over, I will make an alias for duration of project if nothing else, to save me from typing.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s