pyratelog

personal blog
git clone git://git.pyratebeard.net/pyratelog.git
Log | Files | Refs | README

commit f2621de9f0656387f3e21a39b58d6cc448bd723f
parent b9fd087199be5ff818506b12d63ea2e434fd13b9
Author: pyratebeard <root@pyratebeard.net>
Date:   Thu, 31 Mar 2022 21:19:39 +0100

this_ssux

Diffstat:
Mentry/this_ssux.md | 18+++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/entry/this_ssux.md b/entry/this_ssux.md @@ -1,21 +1,21 @@ -Two of the commands I use the most on a daily basis are `tmux` and `ssh`. +Two of the commands I use the most on a daily basis are [tmux](https://github.com/tmux/tmux/wiki) and ssh. -If you haven't heard of `tmux` it is a terminal multiplexer similar to `screen`, but with loads of extra functionality. My normal workflow sees me mostly in one or more `tmux` sessions. +If you haven't heard of tmux it is a terminal multiplexer similar to screen, but with loads of extra functionality. My normal workflow sees me mostly in one or more tmux sessions. -As a sysadmin I rely heavily on `ssh`. Even with moving a lot of my work to Infrastructure-as-Code with tools like Ansible, there is still many times throughout a given week when I have to `ssh`onto a system. +As a sysadmin I rely heavily on ssh. Even with moving a lot of my work to Infrastructure-as-Code with tools like Ansible, there is still many times throughout a given week when I have to ssh onto a system. -A long time I was in the habit of starting a `screen` when I logged onto a system so that if my connection dropped I didn't lose what I was doing, as well as being able to open new shells within the same session. +A long time I was in the habit of starting a screen when I logged onto a system so that if my connection dropped I didn't lose what I was doing, as well as being able to open new shells within the same session. -Then I moved to installing `tmux` on my systems and started a `tmux` session when I logged on. After a while this became an function in my `zsh` [alias file](https://git.pyratebeard.net/dotfiles/file/zsh/.zsh/aliases.zsh.html#l181){target="_blank" rel="noreferrer"}, which I use in place of `ssh` +Then I moved to installing tmux on my systems and started a tmux session when I logged on. After a while this became an function in my `zsh` [alias file](https://git.pyratebeard.net/dotfiles/file/zsh/.zsh/aliases.zsh.html#l181){target="_blank" rel="noreferrer"}, which I use in place of ssh ``` ssux () { TERM=screen ssh -t "$@" 'tmux attach || tmux new' || ssh "$@" } ``` -The function opens an `ssh` connection to the server specified then attempts to attach an existing `tmux` session. If this fails it will try to start a new session. If both of those commands fail, if `tmux` isn't installed for example, then it falls back to normal `ssh` +The function opens an ssh connection to the server specified then attempts to attach an existing tmux session. If this fails it will try to start a new session. If both of those commands fail, if tmux isn't installed for example, then it falls back to normal ssh -Running it is as simple as replacing `ssh` +Running it is as simple as replacing ssh ``` ssux hostname ``` @@ -24,7 +24,7 @@ I have seen a couple of different methods of doing something similar using setti I was using this a lot in work and decided to add hostname autocompletion to make my life easier. You can see the completion script in my [dotfiles](https://git.pyratebeard.net/dotfiles/file/zsh/.zsh/completion/_ssux.html){target="_blank" rel="noreferrer"}. -Living inside a `tmux` session then using `tmux` over `ssh` meant I had to use two different prefix options. I didn't like this. I use the backtick as my prefix in `tmux` because I am lazy. I wanted to use the same backtick prefix on my remote sessions. This worked if I hit backtick twice before the command I wanted to send to the remote, or "second" session. +Living inside a tmux session then using tmux over ssh meant I had to use two different prefix options. I didn't like this. I use the backtick (```) as my prefix in tmux, I find it to be really convenient. I wanted to use the same backtick prefix on my remote sessions. This worked if I hit backtick twice before the command I wanted to send to the remote, or "second" session. With a bit of internet searching I found a discussion on the [tmux Github page](https://github.com/tmux/tmux/issues/237){target="_blank" rel="noreferrer"} regarding a toggle option. I also came across [bnorick's tmux.conf](https://github.com/bnorick/tmux-config/blob/master/tmux/tmux.conf#L368){target="_blank" rel="noreferrer"} with a toggle for nested sessions. @@ -46,4 +46,4 @@ bind-key -T root F11 \ When I hit F12 the prefix in my local session is set to None, then I change the colour of the active window tab in the status bar so I remember it is disabled. I can now use the backtick prefix freely in my remote session. To enable the local session again I hit F11. -<img src="/img/ssux.mp4" class="fitwidth" alt="ssux demo" /> +<img src="img/ssux.mp4" class="fitwidth" alt="ssux demo" />