Command-line Fu


As developers, we’re constantly tinkering and refactoring code to arrive at the tidiest and most maintainable piece of software. I’m still often surprised by how few of us optimize our working environments via shortcuts, aliases, and habits - especially considering the large time investment we often commit as software engineers.

Inspired by @hmason's Command-line Fu session at OrdCamp, I realized that there’s a lot of snippets I’ve written and accumulated over the years that could be useful to a young developer.

So without further adieu, I’ll try to post some of my more useful snippets at least once or twice a month beginning with one of my personal favs: tmux

function tm() {
if [ -n "$1" ]; then
tmux attach -t $1 2>/dev/null || tmux new -s $1
else
tmux list-sessions 2> >(grep -q 'failed')
if [ "$?" -eq 1 ]; then
echo "No available tmux sessions. Please create one."
fi
fi
}
view raw tmux-helper hosted with ❤ by GitHub

Can you figure out what it’s doing? :)