From d3777dbbfa703db1f9ab1c2c7338f0b9e9b56ee7 Mon Sep 17 00:00:00 2001 From: Adar Nimrod <nimrod@shore.co.il> Date: Thu, 19 Aug 2021 23:09:29 +0300 Subject: [PATCH] Workbench improvements. - Use a specific Tmux socket for the session in the container, seperate it from other sessions. Easier to kill in update-wb. - Name the session as well and display it properly. - Better session creation or attachment. - Better image pruning when updating. - Don't allow running update-wb from inside the container, killing Tmux stops the script and it doesn't work. --- .bashrc | 4 ++-- .tmux.conf | 1 + Documents/bin/update-wb | 11 ++++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.bashrc b/.bashrc index 3cea620..2e252c6 100644 --- a/.bashrc +++ b/.bashrc @@ -265,11 +265,11 @@ toux () { } wb () { - toolbox run --container workbench -- /bin/sh -ic 'if tmux ls >/dev/null 2>&1; then tmux a; else tmux; fi;' + toolbox run --container workbench -- tmux -L workbench new-session -As workbench } wbr () { - ssh -t ns4.shore.co.il toolbox run --container workbench -- /bin/sh -ic "'if tmux ls >/dev/null 2>&1; then tmux a; else tmux; fi;'" + ssh -t ns4.shore.co.il toolbox run --container workbench -- tmux -L workbench new-session -As workbench } __prompt () { diff --git a/.tmux.conf b/.tmux.conf index 5fa2a04..ad05793 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -1,6 +1,7 @@ bind-key b send-prefix set -g set-titles on set -g set-titles-string '#T' +set -g status-left-length 12 # Copied from https://github.com/seebi/tmux-colors-solarized/blob/master/tmuxcolors-dark.conf #### COLOUR (Solarized dark) diff --git a/Documents/bin/update-wb b/Documents/bin/update-wb index a2bc386..9d79d01 100755 --- a/Documents/bin/update-wb +++ b/Documents/bin/update-wb @@ -14,15 +14,20 @@ is_latest() { } update() { + if [ -S "/tmp/tmux-$(id -u)/workbench" ] + then + toolbox run --container workbench -- tmux -L workbench kill-server + fi toolbox rm --force "$CONTAINER" 2>/dev/null || true - yes | podman image prune --filter 'label=com.github.containers.toolbox=true' - killall tmux || true + podman image prune --filter 'label=com.github.containers.toolbox=true' --force toolbox create --image "$IMAGE" } if [ "$(hostname)" = 'toolbox' ] then - /usr/libexec/flatpak-xdg-utils/flatpak-spawn --host "$0" "$@" + printf '\e[1;91m%s\e[0m\n' \ + 'Cannot update the workbench container from inside the workbench container.' >&2 + exit 1 elif [ "${1:-}" = "-d" ] || [ "${1:-}" = "--dry-run" ] || [ -n "${DRY_RUN:-}" ] then podman image pull "$IMAGE" > /dev/null -- GitLab