How to scroll in tmux?

How to scroll in tmux?

Asenqua Tech is reader-supported. When you buy through links on our site, we may earn an affiliate commission.

It can be annoying to not be able to scroll back in tmux and if you do it wrong, the whole app and the server might hang. 

There are 2 ways using which you can scroll in tmux: using the mouse and using keyboard shortcuts. They can be used together and you can easily configure them in your .tmux.conf.

Before we get to the core of the article, let us first understand how you can issue commands to tmux.

How to issue commands to tmux?

To issue commands, you can use the following three methods enlisted below:

shortcuts: tmux uses a prefix key to issue commands. This prefix key is CTRL+b by default and tmux interprets the keystroke following the prefix as a tmux shortcut. 

For example, if you wish to detach from a session in tmux using shortcuts to issue a command (the detaching), you should press the prefix key, i.e., CTRL+b simultaneously and then press d to detach.

command mode: To enter the command mode in tmux, the user has to press the prefix key or CTRL+b, followed by :. This, in turn, will open a command prompt that will accept tmux commands. The command prompt appears at the bottom of the screen.

command line: If you are currently using a tmux session, you can directly issue commands to the command lines within the sessions. These commands are usually prefaced by tmux. A good example of issuing commands in tmux in command lines would be how we used a command line to detach from a tmux session previously.

 

How to scroll in tmux?

Aforementioned, there are 2 ways of scrolling in Tmux. You can configure them in your .tmux.conf and they can be used together.

With your mouse

Initially you would not be able to scroll back in tmux using your mouse (that’s why you are reading this post, anyway). The thing is, you will need to enable scrolling back with the mouse in tmux using commands.

Almost every setting in tmux can be applied through the .tmux.conf config file, while you are running tmux. To enable scrolling back with mouse in tmux, here is what you need to do:

  • Firstly press the prefix key or CTRL+b
  • Next, type in the following command:

:set -g mouse on

This should enable scrolling using the mouse. If you wish to make this setting permanent, you will need to add it to your config without the colon before the config file. 

Since tmux has two config files, namely ~/.tmux.conf  and /etc/tmux.conf, the former that is located in your home directory for adding personal settings and the latter for the system wide config file, we recommend making changes to only the personal file (~/.tmux.conf).

Making changes to the personal config file has an added convenience of overriding any setting changes made in the system wide config.

With keyboard shortcuts

tmux , by default, enables scrolling with keys. All you need to do is press the prefix key and then the arrow keys, depending on how you wish to move around in your session. 

Since tmux (or linux, in general) has two text editors, namely emacs and vi, the keyboard shortcuts to scroll back or scroll in different directions differ slightly on both these editors. 

To tests vim-keys or emacs keys in tmux on your Macbook (given that it comes equipped with tiny unusable arrow keys), use the following:

:setw mode-keys emacs (for emacs)

or,

:setw mode-keys vi (for vim)

As it is with making changes to the config file, in order to enable scrolling with mouse permanent, the same goes for enabling permanent scrolling with keyboard. To make scrolling with your keyboard permanent, use set-window-option instead of setw in your personal config file, i.e., ~/.tmux.conf. 

If your server is outputting a lot of data, and you want to scroll back down to the extreme end, all you need to do is press Enter. Unlike other times, this shall stop your app from hanging while the server is processing a lot of data.

Key Combinations for vi in tmux:

Moving around in tmux, when in vi mode, can be done using certain shortcut keys once scrolling using the keyboard is enabled (and made permanent). 

Note: When we mention C+(some key), you are supposed to press and hold the C key and press the other key at the same time. You are not supposed to be pressing C and the plus (+) key as well as the other key mentioned. 

For example, when we say C+b, you should press and hold the C key and the b key at the same time (without pressing the plus key which is only used for reference).

To scroll half a page down, use C+d. In contrast, if you wish to scroll half a page up, press C+u. To move to the next page in tmux, while using vi, press C+f. To go back to the previous page, press C+b.

To scroll down, use C+Down or C+e, while to scroll up use C+Up or C+y.

In order to search again in tmux, press n, and to search again in reverse, use N (in Caps, of course). To search backward in tmux, while in vi mode, press ? and to search forward use /.

Key Combinations for emacs in tmux:

Moving around in tmux, when in emacs mode, can be done using certain shortcut keys once scrolling using the keyboard is enabled. 

To scroll half a page down, use M+Down. In contrast, if you wish to scroll half a page up, press M+up. To move to the next page in tmux, while using emacs, simply press Page down. To go back to the previous page, press Page up.

To scroll down, use C+Down, while to scroll up use C+Up.

In order to search again in tmux, press n, and to search again in reverse, use N (in Caps, of course). To search backward in tmux, while in emacs mode, press C+r and to search forward use C+s.

 

How to manage panes in tmux?

Once you have created a session in tmux, you will be presented with a single window with one panel inside. 

To split the panel into two, press the prefix key and % key. Pressing Ctrl+b % will split a single pane into two in tmux and it can be more feasible to put into use when you want outputs from multiple processes visible within a single window. Using the % key with the prefix key splits the pane vertically, while using the prefix key + “, splits the pane horizontally.

Now, you have split panes in tmux. How do you manage them? Apart from splitting, you can also resize, switch, zoom, force kill and do a lot more with the panes inside the window created in tmux.

To switch to another pane, press prefix + arrow key. To resize the active pane, press prefix + ALT+arrow, while to zoom in on the active pane press Prefix + z. To zoom out and exit the zoom mode, press Prefix + z again. Use exit to close the active pane. To move the pane above and below, use Prefix + k and Prefix + j respectively. 

If there is an unresponsive process in a pane, and you wish to kill it, use Prefix + x. To move the left pane, use Prefix + h, while to move the right pane in your window in tmux, use Prefix + l. Using Prefix + q will display pane numbers while using Prefix + o will allow you to jump or toggle to the other pane in the window in tmux. 

To move all panes, rotating the window up, press Prefix + C-o, while to move all panes, rotating the window down, use Prefix + M-o. To switch to the next layout from a predefined layout, press Prefix + space. To switch to the main horizontal layout from predefined layout, use Prefix + M-3. On the other hand, to switch to the main vertical layout from the predefined layout, use Prefix + M-2. To switch to main vertical layout from predefined layout, use Prefix + M-4, while to switch to a tiled layout from a predefined layout, press Prefix + M-5. To switch to an even-horizontal layout, use Prefix + M-1

To move the divider up i lines (for horizontal divider), use tmux bind-key k resize-pane -U [i]. To move the divider left i columns (for vertical divider), use tmux bind-key k resize-pane -R [i]. In order to move the divider down i lines (for horizontal divider), press tmux bind-key k resize-pane -D [i]

Use C-a C-up, C-a C-down, C-a C-left, C-a C-right to resize panes by 1 row/column. On the other hand, to resize panes by 5 rows/columns, C-a M-up, C-a M-down, C-a M-left, C-a M-right

To swap the current pane with the pane from the left, use Prefix + }, while to swap current pane with the pane from the right, use Prefix + {. To go to the last used pane, use Prefix + ; and in order to move the pane out of the current window you are using in tmux, use Prefix + !

 

How to handle sessions in tmux?

Once you have completed your work with the session you had been using in tmux, you can get rid of it by exiting all the panes created inside or by keeping the session in background so you can use it later if you want to.

To detach from your current session use the prefix key + d. If you want tmux to give you options from which you can choose which sessions you would like to detach, use the prefix key + D (note the Caps Lock). What this does is keep your session running in the background while you are detached from it. 

You can re-attach a session and pick up where you left at any point in time, later. However, to re-attach to a session, you will need to figure out which session you want to attach to, first. To get a list of all the sessions running in the background, use tmux ls. Use Prefix + s to display an interactive session list.

To switch to a previous session use Prefix + (, while to switch to the next session, use Prefix + ). To name your sessions, in order to make them more meaningful, you can create your next session using tmux new -s database. This will create a new session with the name “database”.

To rename your current session in tmux, use Prefix + $. To select the last session or the most recently used session in tmux, use Prefix + L. Finally, to destroy all sessions and kill all processes, use tmux kill-server.

 

How to manage windows in tmux?

Upon the starting of a tmux session, a single window is created automatically. Now, you can attach multiple windows to the same session and switch between these windows whenever required using various commands. 

This can come in handy if you are multitasking and running multiple jobs simultaneously in parallel. To create a new window, use Prefix + c, while to switch to the previous window use Prefix + p, and to switch to the next window, use Prefix + n

If you want to switch to a different window in tmux using its index number, use Prefix + 0-9. For example, if you want to switch to the window with index number 5, use Prefix + 5. To close a window, you simply need to press exit. In order to choose a window from an interactive list, use Prefix + w.

If you are facing an unresponsive window and want to force kill all processes in that window, use Prefix + &

To split windows horizontally, use Prefix + % while to split windows vertically, use Prefix + “

If a window has a content alert, an activity, or a bell, switching between the windows requires, presing Prefix + M-n. To switch back to a previous window that has a content alert, an activity or a bell, use Prefix + M-p.

By default, tmux names windows according to the process that spawned it, thus, to rename a window use Prefix + ,.

Similar Posts

1,167 Comments

  1. canadian discount drugs [url=http://canadadrugs.pro/#]certified canadian online pharmacy[/url] canadian prescription pharmacy

  2. cytotec pills buy online [url=http://cytotec24.com/#]purchase cytotec[/url] purchase cytotec

  3. Level design brings together all elements of the game to shape the player experience: game mechanics, gameplay, obstacles, story, and so on. Its objective is to create interactive situations or events within the game environment to challenge the player and keep them engaged and immersed. Elise has taught in higher education since 2012 and holds an Associate Fellowship with Advance HE. Her research focuses on adaptive music and how it can be used in apps, installations, and video games to create immersive and engaging experiences. Her work has garnered attention from the sonic arts community, including commissions and funding from Sound and Music through the Sonic Arts Network and the Francis Chagrin Award. Game making is central to this course, pushing students to develop their own practice in a supportive and critical environment. Working both independently and collaboratively, you will learn industry level skillsets in game engine technologies, games culture and game design fundamentals.
    http://www.progettokublai.net/forums/users/eleanorsmith174
    Find centralized, trusted content and collaborate around the technologies you use most. VFX artist Ian Mac ” href= videogameschronicle platforms pc mac >Maclure made the claim on Twitter in response to a comment from veteran games journalist Jeff Gerstmann, who said he thinks the whole ‘Series S is holding back next-gen games’ argument doesn’t hold up. Gamers Nexus, a prolific tech YouTuber, recently purchased an Xbox Developer Kit — a special version of the Xbox Series X console studios use for game development. As it turned out, the XDK for the current generation of Xbox consoles comes with a whopping 40GB of GDDR6 memory (please, no jokes about Chrome) and a hardware ban from Microsoft (if obtained illegally). These tools have already shown results in a small pilot test with a handful of studios, Microsoft says. At Halo maker 343 Industries, for instance, testing found that the game’s pause screen still rendered a 4K image that was invisible to the player. Simply changing this unseen issue reduced the game’s energy usage by 15 percent “with no negative impact to the player experience,” Microsoft says (a Microsoft spokesperson confirmed this savings only applies to the pause screen energy usage).

  4. تقدم شركة كايرو هايتس مجموعة من أكبر المشروعات السكنية المتميزة وشقق للبيع بالقاهرة الجديدة والتجمع الخامس والعديد من الوحدات السكنية الراقية بعقارات بيت الوطن والتى تتميز بالخصوصية والهدوء والإطلالة الفريدة على حدائق ومساحات خضراء.
    تختار كايرو هايتس بالقاهرة الجديدة مشروعاتها بعناية وبمواقع استراتيجية بحيث تكون قريبة من مناطق الخدمات والمراكز الترفيهية وأشهر النوادى والمؤسسات التعليمية الهامة.
    عقارات للبيع فى بيت الوطن بالتقسيط

  5. Bitcoin (BTC) might just be the golden opportunity of our era, poised to skyrocket to $200,000 in the upcoming year or the one following. In the past year alone, BTC has witnessed a staggering 20-fold increase, while other cryptocurrencies have surged by an astounding 800 times! Consider this: a mere few years ago, Bitcoin was valued at just $2. Now is the time to seize this unparalleled chance in life.
    Join Binance, the world’s largest and most secure digital currency exchange, and unlock free rewards. Don’t let this pivotal moment slip through your fingers!
    Click the link below to enjoy a lifetime 10% discount on all your trades.
    https://swiy.co/LgSv

Leave a Reply

Your email address will not be published. Required fields are marked *