Last active
October 17, 2025 17:46
-
Star
(189)
You must be signed in to star a gist -
Fork
(25)
You must be signed in to fork a gist
-
-
Save sdondley/b01cc5bb1169c8c83401e438a652b84e to your computer and use it in GitHub Desktop.
Revisions
-
sdondley revised this gist
May 30, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ tmux, like other great software, is deceptive. On the one hand, it's fairly easy to get set up and start using right away. On the other hand, it's difficult to take advantage of tmux's adanced features without spending some quality alone time with the manual. But the problem with manuals is that they aren't geared toward beginners. They are geared toward helping seasoned developers and computer enthusiasts quickly obtain the -
sdondley revised this gist
Jan 16, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1183,7 +1183,7 @@ later. Go ahead and copy and paste the following few lines the file and save it: **`bind -T split % splitw -hd`** **`bind -T root C-\\ switch-client -T split`** **`bind -T split t splitw -f man tmux`** -
sdondley revised this gist
Jul 10, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -161,7 +161,7 @@ as horizontal splits in poorly researched blog posts across the web. At any rate, The `C-b "` keystroke combination is one of the many default key bindings that tmux provides for you out of the box. Key bindings are similar to "hot keys" or "shortcut keys" you may be familiar with in other applications (e.g., control-s for "save document"). Key bindings are great for issuing frequently used commands very quickly. In tmux, key bindings are a bit more flexible and powerful than typical hot keys. We will learn more about them in more detail later in the guide. -
sdondley revised this gist
Jul 10, 2020 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -98,16 +98,16 @@ pseudo-terminals containing the processes within each pane. And so if you take the time to become proficient with tmux, you will be duly rewarded. The first step in that journey is to learn the `split-window` command well because it is the key to unlocking the most important feature of tmux. The `split-window` subcommand creates more panes so you can have more applications visible at once. Of course, you only have so much screen real estate and so there is a practical limitation for how many panes you can have open in a single window. Working around that limitation is a topic for another time. Our focus is on how to master this one single command to get you off to a good start toward achieving mastery with tmux. Before getting started, we should point out that one potentially confusing aspect of the `split-window` command is its name is slightly misleading. If you split a rock in half, you expect to get two rocks, right? But `split-window` doesn't split a window into two windows. Instead, it splits the **current active pane** of the current window into **two panes.** So it might be helpful to think of the -
sdondley revised this gist
Jul 10, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -70,7 +70,7 @@ window up into rectangular-shaped subunits, called **panes,** as in a window pane. If there is more than one pane in a tmux window, they are visually delineated from one another with a thin, single pixel-wide border. Each pane can have a different height and width so a tmux window with many panes can start to resemble [a window designed by the famous 20th century architect Frank Lloyd Wright](http://www.glass-by-design.com/images7/flw_abstract_stained_glass_1x.jpg) more than the neat, symmetrical arrangement found on a French door. Panes have one of two states: "active" and "inactive." Active panes will have a -
sdondley revised this gist
Jul 10, 2020 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -69,9 +69,9 @@ be seen inside of the visible window that tmux opens. `split-window` splits this window up into rectangular-shaped subunits, called **panes,** as in a window pane. If there is more than one pane in a tmux window, they are visually delineated from one another with a thin, single pixel-wide border. Each pane can have a different height and width so a tmux window with many panes can start to resemble a window designed by the famous 20th century architect [Frank Lloyd Wright](http://www.glass-by-design.com/images7/flw_abstract_stained_glass_1x.jpg) more than the neat, symmetrical arrangement found on a French door. Panes have one of two states: "active" and "inactive." Active panes will have a brighter border color than the "inactive" ones. There can be only one active -
sdondley revised this gist
Jul 10, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ tmux, like other great software, is deceptive. On the one hand, it's fairly easy to get set up and start using right away. On the other hand, it's difficult to take advantage of tmux's adanced power features without spending some quality alone time with the manual. But the problem with manuals is that they aren't geared toward beginners. They are geared toward helping seasoned developers and computer enthusiasts quickly obtain the -
sdondley revised this gist
Jul 10, 2020 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,9 +3,9 @@ ## Guide overview tmux, like other great software, is deceptive. On the one hand, it's fairly easy to get set up and start using right away. On the other hand, it's difficult to take advantage of tmux's adanced power features you without spending some quality alone time with the manual. But the problem with manuals is that they aren't geared toward beginners. They are geared toward helping seasoned developers and computer enthusiasts quickly obtain the information they need so they can get back to real work. As a result, man pages -
sdondley revised this gist
Jul 6, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1403,7 +1403,7 @@ tmux and what it can do. Of course, you also want to use it to get real work done. Unless you aspire to be a professional tmux trainer, learning tmux should not be your full time job. So our best advice is to go ahead an start using tmux. Use it all the time. Program your terminal to automatically attach to a tmux session when you open it. But be sure to keep things simple at first. Get comfortable working with just one window with multiple panes. When that starts to feel too limiting, -
sdondley revised this gist
Apr 18, 2019 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1403,7 +1403,7 @@ tmux and what it can do. Of course, you also want to use it to get real work done. Unless you aspire to be a professional tmux trainer, learning tmux should not be your full time job. So our best advices is to go ahead an start using tmux. Use it all the time. Program your terminal to automatically attach to a tmux session when you open it. But be sure to keep things simple at first. Get comfortable working with just one window with multiple panes. When that starts to feel too limiting, @@ -1425,10 +1425,10 @@ closely at the subcommands the plugin adds to your configuration file. A good rule of thumb is that if you can't figure out what the plugin's subcommands do, don't add them to your configuration. Finally, we covered only one subcommand in depth today and a few options. There are hundreds, if not thousands of different subcommands and settings for you to explore. Treat tmux like a musical instrument and try to set aside 15 or 20 minutes each day praciting and experimenting with new commands and options. A great place to find other important subcommands to study is right there in your prefix table. Take some time see which subcommands tmux is using for the -
sdondley revised this gist
Apr 18, 2019 . 1 changed file with 29 additions and 18 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1404,34 +1404,45 @@ done. Unless you aspire to be a professional tmux trainer, learning tmux should not be your full time job. So our recommendation is to go ahead an start using tmux. Use it all time. Program your terminal to automatically attach to a tmux session when you open it. But be sure to keep things simple at first. Get comfortable working with just one window with multiple panes. When that starts to feel too limiting, start learning how to create new windows. When you get comfortable working with many windows in a single session, begin learn about running multiple tmux sessions. When you're starting to feel like a real pro, see if there are any advantages to running multiple tmux servers. There will be things that will frustrate you or confuse you about tmux and things that will feel very restrictive and limiting at first. You will be tempted to turn to plugins to "fix" tmux's perceived limitations. We don't want to discourage you from installing plugins, but we encourage you to be very selective. Carefully research what each plugin does and how it does it because the plugins may just add to your confusion and provide capabilities you aren't ready to take advantage of. They will also hide which features are native to tmux and which ones are provided by the plugins. So as much as possible, keep your use of plugins limited until you gain a lot more confidence with tmux. Look closely at the subcommands the plugin adds to your configuration file. A good rule of thumb is that if you can't figure out what the plugin's subcommands do, don't add them to your configuration. Finally, we covered only one single subcommand today and a few options today. There are hundreds, if not thousands of different settings for you to explore. Treat tmux like a musical instrument and try to set aside 15 or 20 minutes each day praciting and experimenting with new commands and options. A great place to find other important subcommands to study is right there in your prefix table. Take some time see which subcommands tmux is using for the default key bindings. Try each of them out and see what happens. Figure out which key bindings are useful to you. Get rid of the ones you'll rarely need and replace them with your own. Then create your own key table and start adding your own custom key bindings. Be sure to add the good ones to your configuration file. There's no better way to learn tmux quickly than by experimenting with it. When you experiment, be sure to run them in a "clean" tmux environment without any configuration file (or at least a very limited one) so you can be sure it is working as the developers intended. Feel free to take notes and cheatsheets to help you remember all that you learn. If you follow this advice diligently, you will be a master tmuxer in no time. Oh yeah, and one more thing... -
sdondley revised this gist
Apr 17, 2019 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -135,11 +135,11 @@ overview to this guide above. ### Using key binding to execute the `split-window` subcommand There are two different types of tmux splits: vertical and horizontal. Each of these two splits has a **key binding** dedicated to it that can be executed by you. To execute the key binding for the **vertical split,** which splits the current pane of the current window into a top and bottom pane, you type in the following keys from inside an active terminal window running a tmux session: **`C-b "`** -
sdondley revised this gist
Apr 17, 2019 . 1 changed file with 10 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,16 +18,16 @@ tmux that can't be easily gleaned by typing `man tmux` into the terminal. It assumes the user is new to tmux and even fairly new to the world of command line-based computing. The only requirement for using this guide assumes is that you have tmux installed and have figured out how to launch a tmux session from the shell with **`tmux new -s <session_name>`** and that you have at least a day or two's worth of experience getting around a command line. Though this guide will be accessible to new users, many fairly experienced users can benefit from it, too. The guide might start with an excessive amount of hand holding, but it eventually goes into fairly good detail on many tmux features and configuration options. So unless you have spent many hours reading the tmux manual, don't be surprised if you pick up quite a few tips and tricks even if you've been using tmux for years but never took the time to truly ***grok*** it. So this guide's goals are two-fold: 1) help newbies get over the hump of confusion that often accompanies new software by giving them enough experience -
sdondley revised this gist
Apr 17, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -61,8 +61,8 @@ or docker image you can call your own. ## What does the `split-window` subcommand do for you? We'll begin our guide with a big picture overview of what the `split-window` subcommand does. When a new tmux session or window is created in tmux, only one application can be seen inside of the visible window that tmux opens. `split-window` splits this -
sdondley revised this gist
Apr 17, 2019 . 1 changed file with 60 additions and 16 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -383,9 +383,8 @@ use the full `split-window` command because no other commands begin with "sp". If you have tab completion on, you will see "sp" expand into `split-window`. So now we have gone form 12 keystrokes to just three. Very nice. Setting up command completion is not covered by this guide. You should consult with your local computer expert or search engine or man page for guidance. ## More basic `splitw` options @@ -590,15 +589,20 @@ OK! This covers all the basic options for the `splitw` command. Actually, there one more basic option: `-v`, which does a vertical split. But since `-v` is already the default, there is no reason to use it. There are a couple of advanced options available with `splitw`, the `-P` and the `-F` options. These options are useful for doing advanced automation of tmux. But to try to keep this guide at a somewhat reasonable length and stay focused on the basics, they are not covered by this guide. So now that we've covered all the basic options, it's time to turn our attention to passing a shell command to the `splitw` subcommand. ## Passing shell commands to `splitw` Options are cool and give us fine-tuned control over how panes are split, but the real power of `splitw` is realized when we pass shell commands to it. Learning this simple aspect of `splitw` is the first step to unlocking all kinds of great ways to automate tmux, saving you a lot of tedious keystroke entry. ### A simple, but very fleeting example @@ -765,12 +769,11 @@ on: ## Using the `bind-key` subcommand to perform advanced splits Now that you know most of basic features of the `splitw` subcommand and some related subcommands, we'll look at some more advanced type of splits using key bindings. As we saw, tmux offers only two default key bindings for splits, one for a vertical split and one for a horizontal split. We are going to improve on this by learning how to use the `bind-key` subcommand, or `bind` for short. But before we get there, we have to lay a little more groundwork and get up to speed on the inner workings of key bindings if we want to get the most out of @@ -903,7 +906,7 @@ key commands we just set up. What should we use? We're already using `C-b` for the prefix table so that's out. Whatever we decide, we need to very careful with our selection. We don't want to use a key that is useful to any of our apps we might run inside tmux or those apps will no longer be able to no longer respond to it because tmux hijackis it. Overrding another application's functionaity would be like Alexa cutting the power to your HomePod and then giving you a weather report @@ -1035,11 +1038,11 @@ familiar `splitw` command. The second subcommand is `send-keys` or just `send`. "What's that?" you say. Well, you don't have to ask us anymore, now you can find out for yourself with `C-\ m`! We will say that if you are interested in automating your applications, `send` is definitey a subcommand you will want to master. Like `splitw`, learning the ins and outs of `send` will unlock a lot of power for you. We highly recommend spending some time practicing with it. #### Getting you ready to stand on your own As we start telling you to go RTFM, now would be a good opportunity to talk about how to actually RTFM. But there are lots of great tutorials on this topic @@ -1392,3 +1395,44 @@ This can be faster than the previous solution especially if you are jumping across several panes. Though you will still need a key command to activate your custom key table before you can access the key commands listed above. We'll leave setting up that key command as an exercise for you. ## Next steps in your tmux adventures You should now know just enough to bootstrap your way to learning more about tmux and what it can do. Of course, you also want to use it to get real work done. Unless you aspire to be a professional tmux trainer, learning tmux should not be your full time job. So our recommendation is to go ahead an start using tmux. Use it all time. Refuse to open a terminal without first attaching it to a tmux session on your local machine. But be sure to keep things simple at first. Get comfortable working with just one window with multiple panes. When that starts to feel too limiting, start learning how to create new windows. When you get comfortable working with many windows in a single session, begin learn about running multiple tmux sessions. When you're starting to feel like a real pro, see if there are any advantages to running multiple tmux servers. There will be things that will frustrate you or confuse you about tmux and things that will feel very restrictive and limiting at first. You will be tempted to turn to plugins to "fix" tmux's perceived limitations. We don't want to discourage you from installing plugins, but we encourage you to do so very selectively. Carefully research what each plugin does and how it does it because the plugins may just add to your confusion and provide capabilities you aren't ready to take advantage of. They will also hide which features are native to tmux and which ones are provided by the plugins. So as much as possible, keep your use of plugins limited until you gain a lot more confidence with tmux. Look closely at the subcommands the plugin adds to your configuration file. A good rule of thumb is that if you can't figure out what the plugin's subcommands do, don't add them to your configuration. Finally, we covered only one single subcommand today and a few options today. There are dozens of others. Set aside 15 or 20 minutes each day praciting and experimenting with new commands and options. When you experiment, be sure to run them in a "clean" tmux environment without any configuration file (or at least a very limited one) so you can be sure it is working as the developers intended. Feel free to take notes and cheatsheets to help you remember all that you learn. If you follow this advice diligently, you will be a master tmuxer in no time. Oh yeah, and one more thing... # RTFM! -
sdondley revised this gist
Apr 17, 2019 . 1 changed file with 8 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -307,12 +307,14 @@ action becomes instinctual. If you start running out of space in your window, practice using the **`C-b :kill-pane -a`** command to close all the open panes except the active one. Or, if you want to kill just the pane you are currently in, do **`C-b x`** and answer "y" when asked if you are sure you want to kill the pane. As you create new panes, you'll notice each pane you created gets progressively smaller. The first new pane you create is half the size of the window. The second pane created is half the size of the first pane. The third pane is half the size of the second, and so on, until we run out of room and can't create any more panes. Don't worry about resizing the panes or moving between panes. We will cover all that later. The next several sections of this guide will show you how to override tmux's default settings by using the `split-window` **options** to get it to respond -
sdondley revised this gist
Apr 17, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -184,7 +184,7 @@ it ready to listen for your next keystroke. `C-b` tells tmux, "Listen up! I want to give you a command," much like the talking speakers on your kitchen counter. You wouldn't like it if those devices piped up during dinner conversation with your friends and family. That's why you're required to "prefix" your commands with some attention-grabbing statement like "Hey Siri!" or "Alexa." tmux works the same way. It's there listening for the special prefix command but it shuts up and stays out of the way until it gets it. -
sdondley revised this gist
Apr 17, 2019 . 1 changed file with 15 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -176,23 +176,25 @@ split command in this case is `C-b "`. tmux refers to the key after the prefix key as the **key command**. In this case the key command is the `"` character which, by default, is associated with the `split-window` command. The prefix key prevents they key commands from activating while you work on the applications running inside the panes. For example, if you want to type the `"` character into a text document, it would be annoying if tmux started splitting panes on you. The `C-b` prefix is a magic keystroke that wakes tmux up and gets it ready to listen for your next keystroke. `C-b` tells tmux, "Listen up! I want to give you a command," much like the talking speakers on your kitchen counter. You wouldn't like it if those devices piped up during dinner conversation with your friends and family. That's why you're required to "prefix" your subcommands with some attention-grabbing statement like "Hey Siri!" or "Alexa." tmux works the same way. It's there listening for the special prefix command but it shuts up and stays out of the way until it gets it. Key bindings can be customized to your liking. You will learn how to do this later. For now, the only other useful thing to know about key bindings is that if you hit `C-b` and and then want to back out of giving a key command, you can hit **`Esc`** (the escape key). This will get tmux back out of the way so you can continue interacting with the application you have open in your active pane. A different key binding is used to perform a **horizontal split.** In tmux, horizontal splits place the new pane on the right side of the current active -
sdondley revised this gist
Apr 17, 2019 . 1 changed file with 11 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -176,16 +176,17 @@ split command in this case is `C-b "`. tmux refers to the key after the prefix key as the **key command**. In this case the key command is the `"` character which, by default, is associated with the `split-window` command. The reason for a prefix key is that it ensures that the key commands are not activated while you work on the applications running inside tmux. If you want to type `"` into a text document, it would be very annoying if tmux started splitting panes on you. Think of `C-b` as a magic keystroke that wakes tmux up and gets it ready to listen for your next keystroke. `C-b` tells tmux, "Listen up! I want to give you a command," much like the talking speakers on your kitchen counter. You wouldn't like it if those devices piped up during dinner conversation with your friends and family. That's why they require you to "prefix" your subcommands with some attention-grabbing statement like "Hey Siri!" or "Alexa." tmux works the same way. It's there listening for the special prefix command but it shuts up and gets out of the way until it gets it. Key bindings can be customized to your liking. You will learn how to do this later. For now, the only thing you should keep in mind is that if you hit `C-b` -
sdondley revised this gist
Apr 17, 2019 . 1 changed file with 58 additions and 44 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -839,7 +839,7 @@ character is generated! The first time we hit `C-b` we entered the prefix key table as usual. But because we obliterated the `C-b` key command from the prefix table, tmux no longer ran the `send-prefix` command when we hit `C-b`. Instead it did nothing. After doing literally nothing, exactly what we told it to do while switched to the prefix table. After doing nothing as instructed, it interpreted the next `%` as a literal percent sign. If you're paying attention, the next question you'll ask is, so what *does* tell @@ -871,8 +871,13 @@ our "split" key table with the `bind` subcommand: **`C-b :bind -T split '"' splitw -d`** Notice we have to place the double quotes inside of a set of single quotes or you will confuse poor tmux. By default, tmux expects the `"` character to be paired with another `"` character and gives special meaning to all the characters in between them (this is why `"` is known as a "delimiter"). To make sure tmux undertands what we want, we have to "delimit the delimiter" with single quotes. OK, while we're at it, let's create a second key binding: **`C-b :bind -T split % splitw -hd`** @@ -892,21 +897,19 @@ command should load the custom "split" key table so we can actually access the key commands we just set up. What should we use? We're already using `C-b` for the prefix table so that's out. Whatever we decide, we need to very careful with our selection. We don't want to use a key that is useful to any of our apps we might might run inside tmux or those apps will no longer be able to no longer respond to it because tmux hijackis it. Overrding another application's functionaity would be like Alexa cutting the power to your HomePod and then giving you a weather report whenever you asked Siri to to play music. One possible workaround to the problem is to find a way to reprogram your HomePod to play music with a completely different command. This would be the equivalent of changing the hot key in your application. We'll leave these hard decisions up to you when they arise. Anyway, we will choose `C-\` because it is unlikely that another app uses it. Here's subcommand to run to activate the "split" key table when we hit `C-\`, the `switch-client` (`switchc`) subcommand: **`C-b :bind -T root C-\ switch-client -T split`** @@ -919,8 +922,8 @@ The `-T`, as we have already seen, is the option for naming a key table. And Like the "prefix" table, the "root" table is a special table built into tmux. The significant thing about key commands in root is that they don't require us to type a key combination before they can be activated. It's a lot like being able to issue a subcommand to our favorite digital assistant without first saying "Hey Siri," "Alexa," or "Ok Google." So we have to be very careful about what goes in the root table. We don't want to put common, everyday keystrokes in there because we don't want tmux piping up all the time when we are trying to get work done in our applications. Therefore, placing key commands in the root @@ -935,19 +938,29 @@ At any rate, go ahead and take a peek at the root key table with: As you might surmise from this list, the root table is used by tmux to interact with mouse commands. You should also see the new `C-\` key command we just minted. The mouse commands we see don't actually do anything because we haven't activated the special `mouse` option tmux supplies (tmux assumes you are hard core and don't need no stinkin' mouse). If you're not averse to indulging in a little mouse activity from time to time, you can get tmux to respond to your mouse by turning on the `mouse` option: **C-b :set -g mouse on** With this option turned on, tmux panes should now be able to respond to scrolls, clicks, and drags on the pane border so you can quickly resize them. You can see we are setting this command with the global option with `-g` which essentially means we are changing this everywhere (it's a bit more complicated than that but that is a topic of another guide). Another note of interest is that instead of using `setw`, we use `set` to indicate that we are changing a session option not a window option. We will leave it up to you investigate the different kinds of options and what they mean on your own as they aren't directly related to the `splitw` command. But you should at least be aware that there are different kinds of options. Alright, let's get back to the business at hand and see if our new key binding works: **`C-\ %`** @@ -965,8 +978,8 @@ with our newfound abilities. So we've created some key bindings to see how we can use them to add additional options to the `splitw` command. Now let's show some more creative and useful `splitw` subcommands that use shell commands to help you see some of the real power of using tmux. First, let's say you are learning tmux and you want to be able to quickly pop open its man page. Add this key binding: @@ -994,8 +1007,8 @@ page. This can be accommodated with the `command-prompt` subcommand: Now try `C-\ m` and you'll see a prompt, "man page name:". Type in the name of the man page and a new pane will pop open with any man page you desire. Super cool! Be aware, however, if you make a typo in your man page name and the man page doesn't exist, man will immediately exit with an error, the pane will die, and you'll be left wondering why your man page isn't showing up. We aren't going to break down the above command for you. Instead, we are going to do you a bigger favor and show you a neat trick for quickly looking it up @@ -1006,12 +1019,12 @@ yourself in the tmux man page. Add this monster command: Now do `C-\ s` to execute this command. At the first prompt, type in `tmux`. At the second prompt, type in `command-prompt`. When the man page opens now, the man page will move down to the first mention of "command-prompt" for you. Super duper! We do want to point out a couple of significant points from that last command. First, look closely at the command sent to the `command-prompt` subcommand and you'll see there are actually two different subcommands in there separated by a semicolon: `splitw -f man '%%'` and `send-keys / %2 Enter`. The first command is our familiar `splitw` command. The second subcommand is `send-keys` or just `send`. "What's that?" you @@ -1023,22 +1036,23 @@ you. So definitely spend some time practicing with it. #### Getting ready to stand on your own As we start telling you to go RTFM, now would be a good opportunity to talk about how to actually RTFM. But there are lots of great tutorials on this topic already. If you are new to man pages, or you still find them intimidating, we'd like just suggest a video which we think is an excellent introduction to them: https://youtu.be/jyo0TwmON4A. It's slightly on the long side (is that such a bad thing?), so consider bumping the speed setting up to 1.5 or even higher if you want. Once you are done with that video, spend at least 10 to 15 minutes browsing through the tmux man page. You don't have to understand all of it, but you should at least get familiar with how it's laid out and what the major sections of the page are. This will help you find things much more quickly when you need them. The more familiar you get with the tmux manual and how to read it, the more pleasant learning tmux will be for you. One tip for getting around the tmux man page quickly is to search by a subcommand aliases to help find what you need more more quickly. ### "Chaining" key tables -
sdondley revised this gist
Apr 17, 2019 . 1 changed file with 8 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -769,7 +769,7 @@ or `bind` for short. But before we get there, we have to lay a little more groundwork and get up to speed on the inner workings of key bindings if we want to get the most out of them. As we mentioned earlier, there is a lot more to tmux's key bindings than what you get with your average hot key. ### Introducing key tables @@ -834,10 +834,13 @@ from the prefix key table. For all other key tables, we must specify the table. OK, so what do you think will happen now when we run `C-b %`? Will it work? Try it and you'll see that it does, in fact, still work and will create a horizontal split. But now try hitting `C-b C-b` (two times) and then `%`. Now a literal `%` character is generated! The first time we hit `C-b` we entered the prefix key table as usual. But because we obliterated the `C-b` key command from the prefix table, tmux no longer ran the `send-prefix` command when we hit `C-b`. Instead it did nothing. After doing literally nothing, exactly what we told it to do while switched to the prefix table. After doing nothing as it was told to, it interpreted the next `%` as a literal percent sign. If you're paying attention, the next question you'll ask is, so what *does* tell tmux that `C-b` should load the prefix key table? To answer that question -
sdondley revised this gist
Apr 17, 2019 . 1 changed file with 10 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -124,9 +124,9 @@ command. There are a few different ways to execute the subcommands. You can access them with a couple of keystrokes inside a tmux window using what tmux calls **key bindings.** You can also type the subcommands in directly to the tmux command line. You can also place the subcommand inside a tmux configuration file. Finally, you can run them from a shell command line or script. Each of these ways is discussed next. **Note:** This guide assumes you have not customized your key bindings. If you haven't already done so, make sure you have removed all tmux customizations as @@ -138,8 +138,8 @@ overview to this guide above. There are two different types of tmux splits: vertical and horizontal. Each has what's called a **key binding** dedicated to it. To perform a **vertical split,** which splits the current pane of the current window into a top and bottom pane, you execute the following key binding from inside an active terminal window running a tmux session: **`C-b "`** @@ -272,9 +272,9 @@ Running the `split-window` subcommand works even if it is executed from outside of a tmux session. That's because the command ultimately gets passed to the tmux server running on our machine which processes it and takes the appropriate action. As a result, we can run tmux commands from inside shell scripts and functions, and perform all kinds advanced automation tricks that can make working with tmux a real joy. Unfortunately, this is not a guide on shell scripting and that will be left to the reader to explore. Now that we know all the different ways to execute the split command, let's take a closer look at what it actually does and then later, how we can change its @@ -295,7 +295,8 @@ This default command does quite a bit of work. It: * Sizes the new pane to be exactly half the height of the current pane * Launches the default shell in the new pane * Deactivates the old pane and makes the new pane active. As a result, your cursor is now at the command line prompt of the shell the opens up inside the new pane. As already mentioned, you can use the `C-b "` key binding to do this same action. Go ahead and practice issuing this key binding enough times so that the -
sdondley revised this gist
Apr 17, 2019 . 1 changed file with 52 additions and 51 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -98,13 +98,13 @@ pseudo-terminals containing the processes within each pane. And so if you take the time to become proficient with tmux, you will be duly rewarded. The first step in that journey is to learn the `split-window` command well because it is the key to unlocking the most important feature of tmux. You use the `split-window` subcommand to create more panes so you can have more applications visible at once. Of course, you only have so much screen real estate and so there is a practical limitation for how many panes you can have open in a single window. But working around that limitation is a topic for another time. Our focus today is on how to master this one single command to get you off to a good start toward achieving mastery with tmux. Before we get started, we should point out that one potentially confusing aspect of the `split-window` command is that it has a misleading name. If you split a @@ -136,10 +136,10 @@ overview to this guide above. ### Using key binding to execute the `split-window` subcommand There are two different types of tmux splits: vertical and horizontal. Each has what's called a **key binding** dedicated to it. To perform a **vertical split,** which splits the current pane of the current window into a top and bottom pane, you execute the following key binding a terminal window with an active tmux session: **`C-b "`** @@ -607,12 +607,12 @@ from the tmux command line history to save you some typing. So what happened here? In the command above we passed the `ls` shell command to the `splitw` command. tmux then ran the command in a new pane. When the command finished executing, tmux killed the pane for us. This is the default behavior of tmux. So why, you may ask, do the other panes stay open and not close immediately? It's because they have a running process in them, an interactive shell that never stops running until we command it. To prove this to yourself, create a new split with `C-b "`. After the new pane opens, type `exit` at the shell prompt. The pane vanishes! That's because we @@ -622,7 +622,7 @@ by leaving it. Unlike a shell process, the `ls` command doesn't hang around waiting for us to tell it what to do. It does its job and bails. When `ls` finished printing out its list of files to the pane it exited and tmux dutifully killed the pane. ### Keeping panes open @@ -687,8 +687,8 @@ to update the contents of our new pane with something else. So we do: This command definitely needs a little explaining. It starts out with our usual key binding to get us to the command line and then we see the subcommand, `respawnp`. Next we see two options, `-k`, and then a `-t`, which has an argument supplied to it, `!`. Lastly, we pass in the shell command. The `-k` options tells our subcommand to kill the existing command running in a pane. So in other words, we kill the first `ls | less` command which effectively @@ -705,9 +705,9 @@ pane." We normally supply this option with an integer argument that represents the index number of the pane we are going to kill. However, instead of a number we have an exclamation point. The exclamation point is what's called a **token**. In the context of the `respawnp` command, it represents the last active pane. Note that we could have just as easily replaced the token with the actual index number of the pane. But the token conveniently saves us from having to do that. There are many other tokens available and we'll see one ore two more later in the guide. ### Attack of the zombie panes @@ -775,7 +775,7 @@ what you get with your average hot key. The first concept we need to introduce are **key tables**. A key table is nothing more than a listing of key commands. A key command, as you may recall, is the key followed by the prefix key, `C-b`. Each of the key commands in a key table are bound to a specific tmux subcommand. So far, all the key bindings we've used required us to type in the default @@ -789,10 +789,10 @@ key table: **`C-b :lsk -T prefix`** Now we see a long list of all the key commands that belong to the prefix key table. The `-T` option, for "table," tells `lsk` to show us key commands only for the tables we request. If we leave the `-T` option off, `lsk`shows us all the key commands from all the different key tables. Look closely toward the top of the list, a few rows down. You should see a familiar face: @@ -826,10 +826,10 @@ key binding with the `unbind-key` (alias: `unbind`) command: **`C-b :unbind -T prefix C-b`** This removes the `C-b` key command from the prefix table. Technically, we didn't have to bother to tell `unbind` which key table to remove the key command from. That's because if no `-T` option is supplied, it assumes we want to remove it from the prefix key table. For all other key tables, we must specify the table. OK, so what do you think will happen now when we run `C-b %`? Will it work? Try it and you'll see that it does, in fact, still work and will create a horizontal @@ -885,19 +885,20 @@ This should output: Beautiful! There is just one thing more to do. We need to tell tmux which key command should load the custom "split" key table so we can actually access the key commands we just set up. What should we use? We're already using `C-b` for the prefix table so that's out. Whatever we decide, we need to very careful with our selection. We have to careful it's not a useful key for any of the apps we might be running or those apps will no longer be able to no longer respond to it because tmux has hijacked it. Overrding another application's functionaity would be like Alexa cutting power to your HomePod and then giving you a weather report whenever you asked Siri to to play music. One possible workaround to the problem is to find a way to reprogram your HomePod to play music with a completely different command. This would be the equivalent of changing the hot key in your application. We'll leave these hard decisions up to you when they arise. Anyway, we will choose `C-\` because it is generally a safe combination to use, so we'll use that. Let's now the run subcommand that will activate the "split" @@ -911,18 +912,18 @@ command which we pass the "split" table to. But what is the `-T root` stuff? The `-T`, as we have already seen, is the option for naming a key table. And "root" is just the name of the table we are adding our new key command to. Like the "prefix" table, the "root" table is a special table built into tmux. The significant thing about key commands in root is that they don't require us to type a key combination before they can be activated. It's a lot like being able to program you favorite digital assistant to wake up to something other than "Hey Siri," "Alexa," or "Ok Google." So we have to be very careful about what goes in the root table. We don't want to put common, everyday keystrokes in there because we don't want tmux piping up all the time when we are trying to get work done in our applications. Therefore, placing key commands in the root key table should be done sparingly and reserved only for key combinations that activate tables or for key combinations that are extremely useful. For example, many tmux users map the pane navigation keys to C-h, C-j, C-k and C-l and place them in the root key table to let them move between panes much more quickly. At any rate, go ahead and take a peek at the root key table with: @@ -1005,7 +1006,7 @@ Duper! We do want to point out a couple of significant points from that last command. First, look closely at the command sent to the `command-prompt` subcommand and to see there are actually two different subcommands in there separated by a semicolon: `splitw -f man '%%'; send-keys / %2 Enter`. The first command is our familiar `splitw` command. @@ -1261,7 +1262,7 @@ you first big step toward mastering tmux. ## One More Thing: Navigating panes Alright, alright. We're throwing in a little bonus material for you: some suggestions for making it easier to navigate tmux panes. The easiest way tmux provides to move between split panes that's built into tmux is: -
sdondley revised this gist
Apr 17, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1320,8 +1320,8 @@ key bindings, which we will now cover. ### Setting up key binding for more convenient pane navigation So, out of the box, tmux doesn't give provide great options for moving between panes. Let's see how we can improve the situation. There are a couple of things we can do. One common practice is to add the following key bindings to the root key table: -
sdondley revised this gist
Apr 17, 2019 . No changes.There are no files selected for viewing
-
sdondley revised this gist
Apr 17, 2019 . 1 changed file with 18 additions and 17 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -177,7 +177,7 @@ key as the **key command**. In this case the key command is the `"` character which, by default, is associated with the `split-window` command. The big reason for having a prefix key is that it ensures that the key commands are not activated while you work on the applications running inside tmux. If you want to type `"` into a text document, it would be very annoying if tmux started splitting panes on you. Think of `C-b` as a magic keystroke that wakes tmux up and gets it ready to listen for your next keystroke. `C-b` tells tmux, @@ -246,35 +246,35 @@ appropriately named `run-shell` command which is not covered in this guide. ### Creating splits from a tmux configuration file The `split-window` command, along with other subcommands, can also be placed inside of a tmux configuration file. These configuration files can run every time you start tmux. You can also run them manually while inside tmux. You can use configuration files to help you automate your window splits and get them set up just the way you like when a new tmux session is launched. All this will be covered later in the guide. ### Executing `split-window` from a shell The `split-window` can also be directly run right from a shell command line: **`tmux split-window`** Note that this way of executing `split-window` is the same as executing it from tmux's command prompt except we precede the subcommand with the `tmux` shell command. Our shell has no knowledge of what `split-window` is, so we have to type `tmux` first so it knows to pass the subcommand along to tmux which will know how to respond. The other difference is that there is no need to type a colon, of course, because we aren't trying to get to the tmux command prompt, we are passing the subcommand directly to tmux via the shell. If we do put a colon there, tmux will think the colon is part of an unreognized command and throw an error. Running the `split-window` subcommand works even if it is executed from outside of a tmux session. That's because the command ultimately gets passed to the tmux server running on our machine which processes it and takes the appropriate action. As a result, we can run tmux commands from inside shell scripts and functions, and do kinds of advanced automation tricks that will make working with tmux a real joy. Unfortunately, as this is not a guide on shell scripting and that will be left to the reader to explore. Now that we know all the different ways to execute the split command, let's take a closer look at what it actually does and then later, how we can change its @@ -307,19 +307,20 @@ the pane. You'll notice that each pane you create gets progressively smaller. The first new pane you create is half the size of the window. The second pane created is half the size of the first pane. The third pane is half the size of the second, and so on, until we run out of room and can't create any more panes. Don't worry about resizing the panes or moving between panes. We will cover all that later. The next several sections of this guide will show you how to override tmux's default settings by using the `split-window` **options** to get it to respond with in more precise and desired behaviors. ## Basic `split-window` options ### Horizontal splits When you get bored creating vertical splits and are ready to inject some excitement into your life, create a horizontal split with the following command: **`C-b :split-window -h`** This is the same command as the vertical split except we've added an `h`, -
sdondley revised this gist
Apr 16, 2019 . No changes.There are no files selected for viewing
-
sdondley revised this gist
Apr 16, 2019 . 1 changed file with 11 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -173,7 +173,7 @@ for you to enter the next key to see what tmux command you want to perform. In this way, specific tmux commands are **bound** to certain keys and keystroke combinations, hence the phrase "key binding." The key combination bound to our split command in this case is `C-b "`. tmux refers to the key after the prefix key as the **key command**. In this case the key command is the `"` character which, by default, is associated with the `split-window` command. The big reason for having a prefix key is that it ensures that the key commands @@ -778,7 +778,7 @@ is the key follows the prefix key, `C-b`. Each of the key commands in a key table are bound to a specific tmux subcommand. So far, all the key bindings we've used required us to type in the default prefix key, `C-b`, before hitting our key command. What we didn't mention before is that `C-b` tells tmux which key table to use. Each table has a name. In the case of `C-b`, the key table name is, appropriately, "prefix." The table contains a list of all the key commands that can be run after hitting the @@ -883,8 +883,8 @@ This should output: **`bind-key -T split % split-window -hd`** Beautiful! There is just one thing more to do. We need to tell tmux which key command should load the custom "split" key table so we can actually access the key command we just set up. What should we use? We're already using `C-b` for the prefix table so that's out. Whatever we decide, need to very careful with our selection. We have to be @@ -911,8 +911,8 @@ The `-T`, as we have already seen, is the option for naming a key table. And "root" is just the name of the table we are adding our new key command to. Like the "prefix" table, "root" table is a special table built into tmux. The significant thing about key commands in root is that they don't require us to type a key combination before they can be activated. It's a lot like being able to program you favorite digital assistant to wake up to something other than "Hey Siri," "Alexa," or "Ok Google." So we have to be very careful about what goes in the root table. We don't want to put common, everyday keystrokes in @@ -928,7 +928,7 @@ At any rate, go ahead and take a peek at the root key table with: **`C-b :lsk -T root`** As you might surmise from this list, the root table is used by tmux to interact with mouse commands. You should also see the new `C-\` key command we just minted. Note that mouse command don't yet work because we haven't activated the `mouse on` option. So let's change that while we are thinking of it: @@ -1334,7 +1334,7 @@ One common practice is to add the following key bindings to the root key table: **`bind -T root C-l selectp -R`** Since we're adding this key command to the root key table, there is no need to type in the prefix key. What's equally great about this solution is your right hand never has to move off the home row and so this is very fast. The downside to this is that it may interfere with the shortcut keys in your applications. But having such a convenient way to navigate panes might be worth @@ -1364,5 +1364,6 @@ number in a new prefix table. **`bind -T your_key_table 9 selectp -t 9`** This can be faster than the previous solution especially if you are jumping across several panes. Though you will still need a key command to activate your custom key table before you can access the key commands listed above. We'll leave setting up that key command as an exercise for you. -
sdondley revised this gist
Apr 16, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -156,7 +156,7 @@ horizontal line appears across your screen, tmux considers this to be a "vertical" split because the new pane is aligned vertically with the old pane. This often confuses seasoned vim users where a "horizontal" split looks like tmux's vertical split. You'll frequently see tmux's vertical split referred to as horizontal splits in poorly researched blog posts across the web. At any rate, The `C-b "` keystroke combination is one of the many default key bindings that tmux provides for you out of the box. Key bindings are similar to -
sdondley revised this gist
Apr 16, 2019 . 1 changed file with 16 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1319,20 +1319,23 @@ key bindings, which we will now cover. ### Setting up key binding for more convenient pane navigation So, out of the box, tmux doesn't give us the greatest options for moving between panes. Let's see how we can improve the situation. There are a couple of things we can do. One common practice is to add the following key bindings to the root key table: **`bind -T root C-h selectp -L`** **`bind -T root C-j selectp -D`** **`bind -T root C-k selectp -U`** **`bind -T root C-l selectp -R`** Since we're adding this key command to the root key table, there is no need to type in the prefix key combination. What's equally great about this solution is your right hand never has to move off the home row and so this is very fast. The downside to this is that it may interfere with the shortcut keys in your applications. But having such a convenient way to navigate panes might be worth it for you. @@ -1341,14 +1344,23 @@ Another possibility is to set up key bindings that will jump to a pane's index number in a new prefix table. **`bind -T your_key_table 0 selectp -t 0`** **`bind -T your_key_table 1 selectp -t 1`** **`bind -T your_key_table 2 selectp -t 2`** **`bind -T your_key_table 3 selectp -t 3`** **`bind -T your_key_table 4 selectp -t 4`** **`bind -T your_key_table 5 selectp -t 5`** **`bind -T your_key_table 6 selectp -t 6`** **`bind -T your_key_table 7 selectp -t 7`** **`bind -T your_key_table 8 selectp -t 8`** **`bind -T your_key_table 9 selectp -t 9`** This can be faster than the previous solution especially if you are jumping
NewerOlder