radtrio.blogg.se

Tmux bind mac command key
Tmux bind mac command key






tmux bind mac command key
  1. #TMUX BIND MAC COMMAND KEY HOW TO#
  2. #TMUX BIND MAC COMMAND KEY FULL#

Otherwise it uses the copy-mode table.īut this doesn’t really matter, to us. If it contains the string “ vi,” then it uses the copy-mode-vi table. To decide which key table to use when you enter copy mode, tmux checks the value of the $EDITOR environment variable.

tmux bind mac command key

There are two “key tables” in tmux for copy mode, one which by default contains emacs-style keybindings (called copy-mode) and one that contains vi-style keybindings (called copy-mode-vi). But before we can bind keys for it, we have to learn a little bit of trivia. That’s nice and all, but what we really care about here is tmux’s “copy mode:” its text selection feature.

#TMUX BIND MAC COMMAND KEY FULL#

I point this out because it’s a bit easier to get to the relevant section of man tmux if you search the full name of a command.īut okay. Just a little gotcha to watch out for.Īlso note that bind is short for bind-key. I point this out because if you add a line to your config, source it, then remove that line from your config, and source it again, the effect of that command will probably stick around (unless it was a keybinding, in which case it will be unbound). Note that this behaves just like source ~/.bash_profile: it just re-executes every command it doesn’t “reset” anything to its initial state. I find it easier to press M-w M-r than to press M-w r, since you don’t need to time the release of the modifier. Now we can press M-w M-r (our prefix, followed by option-r) to reload the config – no more killing tmux and re-starting it every time something changes. The first keybinding I’m going to add is a very useful: $ cat ~/.nf There are a lot! ( -f /dev/null just causes tmux to ignore our ~/.nf.)Īnyway, now we have a tmux that really doesn’t do anything. You can see the all of the “default” keybindings. Meanwhile, if we run: $ tmux -f /dev/null list-keys You can stop tmux and all sessions by running tmux kill-server, and then that should work. If it did print something, you probably have a tmux server running, and tmux is listing the keys for an existing session – which hasn’t reloaded your ~/.nf. Is that everything? How can we be sure? We can run this: $ tmux list-keys I also switched to the shorter unbind instead of unbind-key. By default, we were only unbinding the “ prefix” table. The -T specifies which “key table” we’re using. Because tmux actually has multiple “keymaps.” We cleared the “normal” one we cleared the keys that you press after pressing the prefix.

tmux bind mac command key

$ cat ~/.nfĪnd now I’m still lying to you, a little bit. So we’re going to use that for the rest of this explanation. Set-option is very common, and has a short alias that is just set. Set-option does what it says, and -g makes the change “globally.” You can also change options on a “per-session” basis, but you know what? We’re not using sessions. But the choice of prefix key is deeply personal: you should pick what feels right to you. I picked M-w for this example, which means “alt-w” or “option-w,” because it’s easy (for me) to press using only my left hand. You press the prefix, and then the next key you press determines the command you want to run.īy default the prefix key is C-b, or “control-b.” I think this is a particularly bad keybinding – not only is b is one of the hardest to reach keys on your entire keyboard, but C-b is a fairly commonly used shortcut already – it moves your cursor back one character, in bash and zsh and any other readline-y thing you’re using. The prefix key works like a “leader key” in vim. For starters, there is one obvious key that is still bound, and that’s the “prefix key.” Now I’m lying a little bit, for rhetorical effect. Don’t want splits? Now the only way to get one is to run tmux split exsplitcitly. We have made tmux into a blank slate, and we can now cherry-pick exactly what features we want it to have.

tmux bind mac command key

I unbind all the keys, and then bind exactly the ones I want.Īll it takes is one magical line: $ cat ~/.nf That feature is “unbind all the keys.” That’s how I start my tmux config. Tmux has a very neat feature that I love. I don’t need to remember any tmux defaults I don’t need anything except my little file.

#TMUX BIND MAC COMMAND KEY HOW TO#

If I forget how to do something, I can just look at that file. If something isn’t in that file, it doesn’t exist. I like this, because it turns my ~/.nf into documentation about what my tmux can do, and how it works. It’s mostly an excuse to demonstrate a simple ~/.nf, and to explain how you can set up tmux to do exactly what you want it to, and nothing more. This is a very long guide about setting up tmux “from scratch,” which is to say without any of the default keybindings or any default behavior.








Tmux bind mac command key