[bin] Let `em` handle existing tmux sessions more gracefully
This commit is contained in:
parent
3d277673fd
commit
c4efc214f8
|
@ -3,9 +3,17 @@ PARENT_COMMAND=$(ps -o comm= $PPID)
|
|||
TTY=""
|
||||
export TTY
|
||||
export TERM=xterm-24bit
|
||||
declare name
|
||||
raw_name=$(basename $(realpath $(pwd)/../))/$(basename $PWD)
|
||||
name="${raw_name//./_}"
|
||||
|
||||
if [ "${PARENT_COMMAND}" == "$(basename "$SHELL")" ] || [ "${PARENT_COMMAND}" == "tmux: server" ]; then
|
||||
exec emacsclient -s comacs --create-frame --tty "$@"
|
||||
if [[ $(tmux display-message -p '#S' | grep -E "^\w+/\w+$") == "${name}" ]] && [[ -z ${1} ]]; then
|
||||
echo "Detected tmux project session. (Re)-attaching";
|
||||
exec emacsclient -s comacs --create-frame --tty -e "(bascht/switch-to-or-load-workspace \"${name}\" \"${PWD}\")"
|
||||
else
|
||||
exec emacsclient -s comacs --create-frame --tty "$@"
|
||||
fi;
|
||||
else
|
||||
exec emacsclient --create-frame "$@"
|
||||
fi;
|
||||
|
|
Loading…
Reference in New Issue