Use C-o as your prefix in tmux instead of C-a, because C-a allows you to move your cursor to the beginning of the line. Read on if you don't understand what I mean.
I've heard it said that the C-a prefix is one of the things gnu screen "got right." Usually this is said during a conversation about changing the default configuration of tmux, which uses C-b as the prefix. Here's a quick explanation and why I disagree.
Anyone who does any amount of typing knows that B is one of the "inconvenient" keys. Take a quick look at the B key on your keyboard. Two issues should stand out: 1) it's the furthest letter key from your fingers, and 2) it sits an equal distance from each of your index fingers. Issue #2 will stand out if you strike the B key with your right index finger and have worked on a split keyboard. This is because split keyboards put the B key with the left hand. These issues combine to make C-b a poor choice for a prefix, but what about C-a? First, a quick digression.
I program in vim, but let’s talk about emacs. We spend a lot of time manipulating text. Our editors like vim and emacs do everything they can to allow us to do our text manipulations at or near home row. What a lot of people don’t realize is that the important text manipulation techniques from emacs are available in every textfield you interact with (except those in the Adobe Flash Player.) Here are a few key combinations I use multiple times a minute:
- C-f Move cursor forward one character
- C-b Move cursor backward one character
- C-n Move cursor down one line
- C-p Move cursor up one line
- C-k Kill all characters to the right of the cursor on the same line
- C-y Put whatever was killed last where the cursor is
- C-d Kill character to right of cursor
- C-h Kill character to left of cursor
- C-e Move cursor to the end of a line
- C-a Move cursor to the beginning of a line
Look at that last one. Anywhere that you are typing text you can strike C-a (control+a) to quickly move the cursor to the beginning of the line. Even when you're typing at a terminal. Give it a try. Open a terminal, type some text (without tmux open), and strike C-a to move the cursor to the beginning of the line. All of this works in instant messengers, browser address bars, word processors, html forms, etc.
Now, if you remap tmux from C-b to C-a you can no longer use C-a to move to the beginning of a line. But what else can you do? I use C-o as my tmux prefix. It's just as convenient as C-a! Try it and let me know what you think.
set -g prefix C-o