Customizing TextMate Next- and Previous-Tab Keyboard Shortcuts

I was kind of surprised to find that TextMate (at least TextMate 2) doesn’t allow you to edit keyboard shortcuts. I found myself repeatedly trying to use the next- and previous-tab shortcuts I use in Chrome while in TextMate, which… didn’t work. A “good” user would probably learn the right shortcuts, but I wanted the software to change, not my brain.

I found most of the solution on Jason Seifer’s blog (thanks!). I never realized you can set application-specific keyboard shortcuts in OS X, and that’s exactly what I needed. Unfortunately, since his post (or maybe between TextMate and TextMate 2), the menu text has changed.

Here’s what I ended up having to do (TextMate 2.0-beta.6 on OS X Yosemite):

  • Open System Preferences / Keyboard
  • Select ‘Shortcuts’ tab
  • Select ‘App Shortcuts’ in the list on the left
  • Add an entry for TextMate
  • Populate it like so:

Screen Shot 2014-12-15 at 5.16.38 PM

And now, viola! Ctrl+Tab advances to the next tab, and Ctrl+Shift+Tab goes to the previous tab—just like in my web browser!

bashrc vs bash_profile

On the subject of bashrc

I’ve always been confounded by the presence of both .bashrc and .bash_profile and how they related.

It turns out to be simple, but 0% intuitive:

  • .bashrc is invoked for non-login, interactive shells
  • .bash_profile is invoked for login shells

The difference is powerful, surely, but also annoying. Most of the time, you just want something to always run in bash, and you don’t care about login vs. non-login.

Which is why it’s recommended to have .bash_profile merely source .bashrc.

My .bashrc

Not that this is terribly enthralling, but I figured I’d post some of the more useful parts of my .bashrc file.

Colorized prompt: starting with a newline

export PS1='\n[\e[0;32m]\u[\e[m] [\e[1;34m]\w[\e[m] [\e[1;32m]\$[\e[m] '

Putting a newline at the front of your prompt is possibly the best idea I have ever had. It creates just enough room between commands to know what’s what. Seriously, you don’t know what you’re missing.

When it comes to figuring out colors for a prompt, Arch Linux’s Color Bash Prompt wiki page is the most helpful I’ve ever seen.

Keep lots of history

I complained one day to someone that commands I use occasionally would fall out of my bash history. I’d use Ctrl+R to search for them, and when they fell out of history, I was lost.

He pointed out that it’s easy to increase the size of your history. You might as well make it huge:


I think those values are maybe a bit mismatched; see this explanation. HISTSIZE probably doesn’t need to be 800,000 larger than allowed on-disk.

It’s a small text file. There’s really not a compelling reason to keep the file tiny. It’s possible that 200,000 lines on disk is too high, but it’s guaranteed that 1,000 is too small.

BTW, another tip: if you often rely on history search, you can add a comment on the end to aid in your search. E.g.,

git rebase -p --onto ddc4a6102051^ ddc4a6102051 # remove commit from history

If you can’t remember the command, now I can try to Ctrl+R “remove commit” or the like.

Some simple aliases

alias be='bundle exec'
alias gb='git rev-parse --abbrev-ref HEAD'
alias gpcm='git pull company master'
alias gpom='git push origin master'

gb is a handy trick to show only the current git branch name.

An alias with arguments

You can’t (to my knowledge) pass arguments to an alias. But what you can do is define a function.

For example, in the above example where I use a comment on the end to aid in searching history, because I could never remember what the thing was called?

I made it a function:

git-toss() {
git rebase -p --onto $1^ $1

Now git-toss d34db33f will expand to git rebase -p --onto d34db33f^ d34db33f, removing d34db33f from my git history. (I will note that this is probably not a common git task.)

What else am I missing?

How to telnet to port 443 to test HTTPS sites

Testing websites, it’s sometimes beneficial to just telnet 80 and speak HTTP. But, of course, that won’t work for HTTPS sites, because you’re expected to set up an SSL connection, not send HTTP commands.

It turns out you have two options (at least), but neither involves using telnet.

Use openssl

This is the more common one: use the s_client option on the OpenSSL CLI tool.

Matthew.Wagner ~ $ openssl s_client -connect
depth=1 /C=BE/O=GlobalSign nv-sa/CN=GlobalSign Organization Validation CA - G2
verify error:num=20:unable to get local issuer certificate
verify return:0
Certificate chain

This will output a ton of SSL information, but then you’re in the equivalent of a telnet session, tunneled through a secure connection. You can use your classic dialog, e.g.,

GET / HTTP/1.1

And you’ll get the expected response.

Use gnutls-cli

Thanks to a fellow Matt, at, for this great suggestion. If you’ve got gnutls installed, it’s even easier:

Matthew.Wagner ~ $ gnutls-cli
Processed 237 CA certificate(s).
Resolving ''...
Connecting to ''...
Cannot connect to Operation timed out

(The “Cannot connect” error is not erroneous. I was confirming that my browser wasn’t insane, and that really was down at the time.)

gnutls-cli is present on my Mac, but not on a CentOS box. There, it’s provided by gnutls-utils.