官术网_书友最值得收藏!

Explaining tmux commands

Now you may notice that attach-session sounds like a pretty long command. It's the same as list-sessions, and there are many others in the lexicon of tmux commands that seem rather verbose.

Tab completion

There is less complexity to the long commands than it may seem because most of them can be tab-completed. Try going to your command prompt and typing the following:

$ tmux list-se

Next, hit the Tab key. You should see it fill out to this:

$ tmux list-sessions

So thankfully, due to tab completion, there is little need to remember these long commands.

Note that tab completion will only work in certain shells with certain configurations, so if the tab completion trick doesn't work, you may want to search the Web and find a way to enable tab completion for tmux.

Aliases

Most of the commands have an alias, which is a shorter form of each command that can be used. For example, the alias of list-sessions is ls. The alias of new-session is new.

You can see them all readily by running the tmux command list-commands (alias lscm), as used in the following code snippet:

$ tmux list-commands

This will show you a list of all the tmux commands along with their aliases in parenthesis after the full name.

Throughout this text, we will always use the full form for clarity, but you could just as easily use the alias (or just tab complete of course).

One thing you'll most likely notice is that only the last few lines are visible in your terminal. If you go for your mouse and try to scroll up, that won't work either! How can you view the text that is placed above? We will need to move into something called the Copy mode that has its own chapter later in this text (See Chapter 4, Manipulating Text).

Renaming windows

Let's say you want to give a more descriptive name to a window. If you had three different windows, each with the nano editor open, seeing nano for each window wouldn't be all that helpful.

Thankfully, it's very easy to rename a window. Just switch to the window you'd like to rename. Then <Prefix>, , will prompt you for a new name. Let's rename the nano window to masterpiece .

See how the status line has been updated and now shows window 0 with the masterpiece title as shown in the following screenshot. Thankfully, tmux is not smart enough to check the contents of your window; otherwise, we're not sure whether the masterpiece title would make it through.

Killing windows

As the last stop on our virtual tour, let's kill a window we no longer need. Switch to window 1 with our find-window trick by entering <Prefix>, f, cat test, Enter or of course we could use the less exciting <Prefix>, l command to move to the last opened window.

Now let's say goodbye to this window. Press <Prefix>, & to kill it. You will receive a prompt to which you have to confirm that you want to kill it.

This is a destructive process, unlike detaching, so be sure anything you care about has been saved.

Once you confirm it, window 1 will be gone. Poor window 1! You will see that now there are only window 0 and window 2 left:

You will also see that now <Prefix>, f, cat test, Enter no longer loads window 1 but rather says No windows matching: cat test. So, window 1 is really no longer with us.

Whenever we create a new window, it will take the lowest available index, which in this case will be 1. So window 1 can rise again, but this time as a new and different window with little memory of its past. We can also renumber windows as we'll see later, so if window 1 being missing is offensive to your sense of aesthetics, fear not, it can be remedied!

主站蜘蛛池模板: 马尔康县| 通海县| 高邮市| 北碚区| 福鼎市| 临西县| 林周县| 安徽省| 高雄县| 明水县| 盐池县| 名山县| 上犹县| 元谋县| 舒兰市| 贵州省| 句容市| 澄迈县| 聂荣县| 榆社县| 常熟市| 年辖:市辖区| 九江市| 恩施市| 天柱县| 旬阳县| 苍梧县| 丰都县| 确山县| 梁山县| 灯塔市| 合作市| 奎屯市| 福贡县| 营山县| 乡城县| 蒙阴县| 道真| 八宿县| 嘉定区| 岐山县|