AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Mac screen commander1/7/2023 Once you have split panes, you can easily switch between them using Ctrl-a. To do this, split the terminal window using Ctrl-a S. You can also have more than one terminal window open at the same time. For instance, to navigate to Terminal 9 that we created earlier, you can simply type Ctrl-a 9. This simply switches between the previous and next window. One simple way is using Ctrl-a n and Ctrl-a p. There are a number of different methods for navigating between windows. I will show you why this can be useful in the next section. For instance, screen -t "Terminal 9" 9 will create a new terminal window called Terminal 9 with a terminal number of 9. You can also use the -t flag to provide a number for the terminal window. This will create another terminal named Terminal 3. You can do this by typing screen -t "Terminal 3". Now let's create one more terminal and name it at the same time. You can use the up and down arrow keys or j/k to move between them. You should now be able to type Ctrl-a " again and see both terminals. Rename it one more time by typing Ctrl-a A and calling it Terminal 2. The first way to create a new terminal is by typing Ctrl-A c. Now, let's create two more terminals and give them different names. If you press Ctrl-a " again, you should see the terminal listed by the title we gave it. You should see a prompt appear at the bottom asking you to give the window a title. Currently, you should only have one terminal open, with the number 0 and a default name of the shell you are using. While in screen, type the command Ctrl-a " to see a list of open terminals. Screen provides a couple useful ways of managing multiple terminal windows. To see a list, you can view the help by pressing Ctrl-a ? (control-a followed by a question mark). However, you now have many different options that weren't available before. It's the same exact terminal you're already familiar with. What you see afterwards should look very familiar. I explain how to disable this screen later in the article. The first thing you will see is the startup screen, which you can dismiss by pressing either space or return. Is Screen right for you? Here is a simple guide to get you started quickly and help you decide if it fits your workflow. Now, if I ever accidentally close the Terminal application or get disconnected over SSH, the state of all my windows and processes will remain the same. Screen is able to solve both of these problems simply and elegantly. What if you could start the script once and know it's still running in the background even if you've opened and closed the Terminal application many times since the script was started? If you simply ran the script from the terminal, the script would need to be restarted every time you closed the terminal window. Suppose you're running a script in the background that monitors a folder and compiles CoffeeScript files into JavaScript as the files change. Here's a similar scenario that I ran into recently. Wouldn't it be great if you could just reconnect later and not only check on the progress, but also have all of your terminal windows in the same state as how you left them? Suppose you want to SSH to a computer, start some long-running process, and not have to worry about keeping the connection open for that process to finish. Although there is a slight learning curve with Screen, there is one major advantage that more than makes up for the extra effort. For the last week, I have been using GNU Screen to help me manage my terminal windows.
0 Comments
Read More
Leave a Reply. |