Detach Attach Manager for tmux (local and remote) sessions, with autocompletion, running in the BASH shell.
source the dam.sh file into your shell to make the dam function useable:
$source dam.sh
The dam function interacts with your bash
1 environment; the files ~/.ssh/config
2 and ~/.ssh/known_hosts
3 along with the commands ssh
4 and tmux
5 to make your command line terminal a more stateful place to be productive.
The simplest invocation is:
$dam
which attaches to the tmux session named mine on your current host. If the mine session does not exist it will be created, if it already exists dam
will detach the session from any other terminal before attaching to it.
Should you want to create additional sessions (and you should) with meaningful names, simply append the session name to the dam
command, as in:
$dam work
note, dam
does not support multi-word session names at this time. If you can't remember what session names you had, simply hit the tab key after the dam
command:
$dam <tab>
which gives you a shi^wboat load more than you expected... at least, if you are a regular ssh
4 user with at least a few entries in your ~/.ssh/known_hosts
3 file, this is because dam
also knows about ssh
4 and will create / connect to tmux
5 sessions on remote hosts. Since were on the topic of remote hosts; how do you use dam
to connect to a remote host??? well, I am glad you asked. Any argument to dam
that contains a forward slash (or solidus, for you UTF-8 nomenclature geeks) will have the pre-slash portion treated as a hostname, including your current host environment. Even an argument which is a lone slash works to connect to you local tmux session via ssh (assuming your localhost is running the sshd6 service), I am not sure there is much use for that, but there it is...
$dam /
or, more likely, something similar to
$dam somehost.example.com/
you can still attach to distinct sessions on the remote host by postpending the session name, as in
$dam somehost.example.com/base
NB completing remote session names requires an ssh
4 connection, which can be annoying unless you have identity keys setup.
Thats mostly it, the real convenience starts when you load your ssh-agent
7 with an identity key and you can then <tab>
complete your way to a host/session, because hey, who wants to memorize and type all that every time you need to connect?!?
1: https://linux.die.net/man/1/bash
2: https://man.openbsd.org/ssh_config
3: https://man.openbsd.org/sshd#SSH_KNOWN_HOSTS_FILE_FORMAT
4: https://man.openbsd.org/ssh
5: https://man.openbsd.org/tmux
6: https://man.openbsd.org/sshd
7: https://man.openbsd.org/ssh-agent