From 65146e772d1b77908995cf3e3bea0dc4afd8838c Mon Sep 17 00:00:00 2001 From: Alexander Kobjolke Date: Sun, 24 Oct 2021 21:26:30 +0200 Subject: [PATCH] state Sun Oct 24 09:26:30 PM CEST 2021 --- home/cli.nix | 12 +++++++++--- kill-old-mosh | 16 ++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100755 kill-old-mosh diff --git a/home/cli.nix b/home/cli.nix index ee2e2c3..07fc433 100644 --- a/home/cli.nix +++ b/home/cli.nix @@ -29,10 +29,16 @@ gotop gnumake ripgrep # better grep + sqlite + pass + pandoc # editors emacs-nox + # c/c++ + clang_12 + # haskell cabal2nix nix-prefetch-git @@ -43,9 +49,9 @@ home.extraOutputsToInstall = [ "doc" "info" "devdoc" ]; xdg.enable = true; - xdg.configFile = { - "emacs".source = config.lib.file.mkOutOfStoreSymlink ./emacs.d; - }; + # xdg.configFile = { + # "emacs".source = ./emacs.d; + # }; programs = { direnv = { diff --git a/kill-old-mosh b/kill-old-mosh new file mode 100755 index 0000000..52e5a2e --- /dev/null +++ b/kill-old-mosh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +mysession=$(cat /proc/self/sessionid) +count=0 +while read pid _; do + session=$(cat /proc/$pid/sessionid) + if [ "$mysession" != "$session" ]; then + kill $pid + count=$((count + 1)) + fi +done <<<$(ps -C mosh-server -o pid=,etimes= | sort -k 2 -r) + +if [[ $count -eq 0 ]]; then + echo 2>&1 "No stale mosh session found" +else + echo 2>&1 "$count stale mosh session(s) killed" +fi