~mclehman/sessions

Convenience layer over tmux sessions written in Raku
5540c70b — 0xFORDCOMMA 10 months ago
Clarify license: Artistic 2.0
6066059e — 0xFORDCOMMA 10 months ago
Rework readme further.
6c9dd57a — 0xFORDCOMMA 10 months ago
Improve readme clarity.

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~mclehman/sessions
read/write
git@git.sr.ht:~mclehman/sessions

You can also use your local clone with git send-email.

Sessions

A convenience layer on top of tmux sessions

This is a simple pair of scripts I use to manage tmux sessions on my server.

The main interface is the session script which creates and switches between sessions.

I expand the idea of a tmux session to categorized sessions: foo/bar and foo/baz are related sessions.

session can be invoked in three ways:

  • session Creates or switches to the default session (currently misc/dev, eventually sourced from an environment variable). This is equivalent to explicitly invoking session misc dev.
  • session <category> <session> Creates or switches to the tmux session <category>/<session>. Roughly equivalent to tmux switch-client -t <category>/<session> \ || tmux attach -t <category>/<session> \ || tmux new -d -s <category>/<session> \ && ( tmux switch-client -t <category>/<session> \ || tmux attach -t <category>/<session>)
  • session <session> Searches for a matching session in all categories. If only one is found, it is switched to. If it is ambiguous, options are presented. If no such session is found, no session is created. No direct tmux analogue, but presumably you wouldn't need to search categories using regular tmux session management.

sessions provides a view of the current categories and sessions. Currently this is done using the unicode box drawing characters but a later version will likely add a user configurable option to control this and default to a more compact layout.

Dependencies

Strictly, only Perl 6 is required. You probably want to install Rakudo Star (https://rakudo.org/), a Perl 6 implementation with a collection of modules, but bare Rakudo could suit your needs. This project has no Perl 6 module dependencies.

If you'd like to install this conveniently, you may want to install Zef (https://github.com/ugexe/zef), the Perl 6 package manager.

Installation

If you have Zef and would like to install without cloning the repo, you can use the following command: zef install https://gitlab.com/0xFORDCOMMA/sessions.git

Otherwise, once you've cloned the repo, either get bin/session and bin/sessions into your path somehow or use Zef: zef install .

Example usage

[ ~/dev/sessions ] on  master
λ | ➜ sessions --usage
Usage:
  sessions [--style=<Style> (boxed compact)] -- Default display style is boxed.

[ ~/dev/sessions ] on  master
λ | ➜ sessions
┌────┐
│misc│
├────┴─┐
│ dev  │
└──────┘

[ ~/dev/sessions ] on  master
λ | ➜ sessions --style=compact
misc
  dev

[ ~/dev/sessions ] on  master
λ | ➜ session --usage
Usage:
  session -- Create or enter default session 'misc/dev'.
  session <category> <session> -- Create or enter session '<category>/<session>'.
  session <session> -- Search all categories for matching session, switch to result if unique.

[ ~/dev/sessions ] on  master
λ | ➜ session foo bar
[detached (from session foo/bar)]

[ ~/dev/sessions ] on  master took 2s
λ | ➜ sessions --style=compact
foo
  bar

misc
  dev


[ ~/dev/sessions ] on  master
λ | ➜ session foo bar

[ ~/dev/sessions ] on  master took 2s
λ | ➜ session bar # equivalent

[ ~/dev/sessions ] on  master took 2s
λ | ➜ session bar bar
[detached (from session bar/bar)]

[ ~/dev/sessions ] on  master took 2s
λ | ➜ sessions --style=compact
bar
  bar

foo
  bar

misc
  dev


[ ~/dev/sessions ] on  master
λ | ➜ session bar
Ambiguous session, choose one of:
bar/bar
foo/bar