aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authormyrrlyn2016-11-06 20:59:12 -0500
committermyrrlyn2016-11-06 21:01:56 -0500
commit77579fdf1506317b7b4542589b1788f118267084 (patch)
treeea79b539c9bb38d1e81cda57a34ae7cd21cdfac1
downloadaur-77579fdf1506317b7b4542589b1788f118267084.tar.gz
Package up the tmix script from the wiki
-rw-r--r--.SRCINFO21
-rw-r--r--PKGBUILD54
-rw-r--r--README.md27
-rw-r--r--tmix.install3
-rw-r--r--tmix.sh37
-rw-r--r--tmix.sh.sigbin0 -> 287 bytes
-rw-r--r--tmux.service13
-rw-r--r--tmux.service.sigbin0 -> 287 bytes
8 files changed, 155 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..6e60e0d14c69
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,21 @@
+pkgbase = tmix
+ pkgdesc = Tmux service and mixer
+ pkgver = 0.1.0
+ pkgrel = 1
+ url = https://wiki.archlinux.org/index.php/Tmux#Clients_simultaneously_interacting_with_various_windows_of_a_session
+ arch = x86_64
+ arch = i686
+ license = GPL
+ depends = tmux
+ source = tmix.sh
+ source = tmix.sh.sig
+ source = tmux.service
+ source = tmux.service.sig
+ validpgpkeys = 8710F6CEE12649E205BA39E67D4C5DFC6C76C13E
+ md5sums = fdf7137b780205312e35ea7e5b450df4
+ md5sums = 0afd81e7dbd77327a88fd32b1fd3d3c5
+ md5sums = 2387d9b98aada06e24050438f8f1c7aa
+ md5sums = bfd88c60618a6808308a20dcbe7bf823
+
+pkgname = tmix
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..0dbf4ca883ea
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,54 @@
+# This is an example PKGBUILD file. Use this as a start to creating your own,
+# and remove these comments. For more information, see 'man PKGBUILD'.
+# NOTE: Please fill out the license field for your package! If it is unknown,
+# then please put 'unknown'.
+
+# Maintainer: Your Name <youremail@domain.com>
+pkgname="tmix"
+pkgver="0.1.0"
+pkgrel=1
+epoch=
+pkgdesc="Tmux service and mixer"
+arch=(
+ "any"
+)
+url="https://wiki.archlinux.org/index.php/Tmux#Clients_simultaneously_interacting_with_various_windows_of_a_session"
+license=('GPL')
+groups=()
+depends=(
+ "tmux"
+)
+makedepends=()
+checkdepends=()
+optdepends=()
+provides=()
+conflicts=()
+replaces=()
+backup=()
+options=()
+install=
+changelog=
+source=(
+ "tmix.sh"
+ "tmix.sh.sig"
+ "tmux.service"
+ "tmux.service.sig"
+)
+noextract=()
+md5sums=(
+ 'dac6d14cb5d026be0bc9525f443eda27'
+ 'cd0aa7a6e61ed48f178f8cbfa719f4c1'
+ '2387d9b98aada06e24050438f8f1c7aa'
+ 'bfd88c60618a6808308a20dcbe7bf823'
+)
+validpgpkeys=(
+ "8710F6CEE12649E205BA39E67D4C5DFC6C76C13E"
+)
+
+package() {
+ mkdir -p "${pkgdir}/etc/profile.d"
+ install -m 755 tmix.sh "${pkgdir}/etc/profile.d/tmix.sh"
+
+ mkdir -p "${pkgdir}/etc/systemd/user"
+ install -m 644 tmux.service "${pkgdir}/etc/systemd/user/tmux.service"
+}
diff --git a/README.md b/README.md
new file mode 100644
index 000000000000..e09987694c08
--- /dev/null
+++ b/README.md
@@ -0,0 +1,27 @@
+# tmix
+
+This is simply a packaged implementation of the script on the Arch wiki [tmux
+page][src].
+
+It provides a systemd user service which runs a tmux base session, and a shell
+script for allowing parallel access to the base session.
+
+Enable the systemd unit with `systemd --user enable tmux`. It does not seem to
+automatically run the service on login over SSH, so it may be useful to add
+`systemctl --user start tmux` to your shell login file. This is a no-op if the
+service is already running, so multiple login shells will not cause an issue.
+
+Attach to the base session with `tmix [$(whoami) [SESSION_NAME [WINDOW_NAME]]]`.
+
+When called with no arguments, tmix connects to the session named after the user
+and makes a new clone session named with the timestamp. tmix can also connect to
+other base sessions, and will take either a given name or fall back to the
+timestamp for the cloned session. If a third argument is given, a new window is
+spawned with that name.
+
+I'm not entirely sure how to get my pubkey someplace `gpg --recv-keys` can get
+it. My key is available at [keybase.io/myrrlyn] or [myrrlyn.net/myrrlyn.asc].
+
+[src]: https://wiki.archlinux.org/index.php/Tmux#Clients_simultaneously_interacting_with_various_windows_of_a_session
+[keybase.io/myrrlyn]: https://keybase.io/myrrlyn
+[myrrlyn.net/myrrlyn.asc]: https://myrrlyn.net/myrrlyn.asc
diff --git a/tmix.install b/tmix.install
new file mode 100644
index 000000000000..3a364c73d8ce
--- /dev/null
+++ b/tmix.install
@@ -0,0 +1,3 @@
+post_install() {
+ source /etc/profile
+}
diff --git a/tmix.sh b/tmix.sh
new file mode 100644
index 000000000000..7d99e483ce2f
--- /dev/null
+++ b/tmix.sh
@@ -0,0 +1,37 @@
+function tmix () {
+ trim () { echo $1; }
+
+# Permit running tmix, no arguments, as a shorthand for attaching to the user
+# session. `tmix self ...` also works.
+ if [[ -z "$1" || "$1" == "self" ]] ; then
+ tmux_base="$(whoami)"
+# Also permit using tmix for tmux ls. I and U are right next to each other after
+# all.
+ elif [[ "$1" == "ls" ]] ; then
+ pgrep tmux > /dev/null && tmux ls || echo "No tmux server running!"
+ exit 0
+ else
+ tmux_base="$1"
+ fi
+
+# Check if the specified base session is running, and if not, make it so.
+ tmux_nb=$(trim `tmux ls | grep "^${tmux_base}" | wc -l`)
+ if [[ "${tmux_nb}" == "0" ]] ; then
+ echo "Launching tmux base session ${tmux_base} ..."
+ tmux new-session -s "${tmux_base}" -d
+ fi
+# Don't attach to a tmux session from inside a tmux session. That's a recipe for
+# disaster.
+ if [[ ! -z "${TMUX}" ]] ; then
+ echo "Connecting to a tmux session from inside a tmux session is a BAD CALL"
+ exit 1
+ fi
+ echo "Launching copy of base session ${tmux_base} ..."
+ [[ ! -z "$2" ]] && tmux_sesh="$2" || tmux_sesh="$(date +%Y%m%d%H%M%S)"
+ tmux new-session -d -t "${tmux_base}" -s "${tmux_sesh}"
+# Spawn a new window, if the user asked for one.
+ if [[ "$3" ]] ; then
+ tmux new-window -n "$3"
+ fi
+ tmux attach-session -t "${tmux_sesh}" \; set-option destroy-unattached
+}
diff --git a/tmix.sh.sig b/tmix.sh.sig
new file mode 100644
index 000000000000..172fc78ee007
--- /dev/null
+++ b/tmix.sh.sig
Binary files differ
diff --git a/tmux.service b/tmux.service
new file mode 100644
index 000000000000..4dc3f056a777
--- /dev/null
+++ b/tmux.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Dedicated tmux server for a user
+Documentation=man:tmux(1)
+
+[Service]
+Type=forking
+WorkingDirectory=%h
+ExecStart=/usr/bin/tmux -2u new-session -s %u -d
+ExecStop=/usr/bin/tmux kill-session -t %u
+Restart=always
+
+[Install]
+WantedBy=multi-user.target
diff --git a/tmux.service.sig b/tmux.service.sig
new file mode 100644
index 000000000000..2c945746cae3
--- /dev/null
+++ b/tmux.service.sig
Binary files differ