-
Notifications
You must be signed in to change notification settings - Fork 35
Description
I love this. shpool is simple and really close to what I've been looking for.
Quite often however, I want something simple to prefix my commands with so I can reattach to it should I lose my connection or by accident close/crash the terminal emulator. With this in mind I find that shpool has two shortcomings:
-
--cmdonly accepts a single string and not a list of strings, meaning the caller has to escape their command.Tools like
xargsandpueueaccept a list of strings which it simply joins with a space, optionally escaping each part first. -
shpoolruns the command without inheriting the current working directory nor the runtime environment variables, meaning such has to be re-established before the command can be run.
This is my current workaround in bash:
run_in_shpool() (
TMP_ENV_FILE="$(mktemp)"
{
declare -p # this one is overkill. Remove it if you don't need support for local bash variables, arrays and functions
export -p
} >"$TMP_ENV_FILE"
local uid="$(date '+%Y-%m-%d-%H:%M:%S')"
set -x
shpool attach "session-$uid" -c "bash -ilc \"source ${TMP_ENV_FILE%Q} 2>/dev/null; cd ${PWD%Q}; ${*@Q}\""
)
run_in_shpool echo foo bar bazrelated:
- shpool session creates with pwd as home directory not on curent path #47 (touches on half of shortcoming
#2)