Commit d3777dbb authored by nimrod's avatar nimrod
Browse files

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.
parent 023ca7d1
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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 () {
+1 −0
Original line number Diff line number Diff line
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)
+8 −3
Original line number Diff line number Diff line
@@ -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