2021-09-24 23:07:17 +08:00
|
|
|
function isolated-tmux-start
|
2021-08-29 15:44:22 +08:00
|
|
|
set -l tmpdir (mktemp -d)
|
|
|
|
cd $tmpdir
|
|
|
|
|
2022-06-13 05:23:52 +08:00
|
|
|
# macOS lacks the tmux-256color terminfo, use screen-256color instead.
|
|
|
|
if test (uname) = Darwin
|
|
|
|
echo 'set -g default-terminal "screen-256color"'
|
|
|
|
end >./.tmux.conf
|
|
|
|
|
2021-08-29 15:44:22 +08:00
|
|
|
function isolated-tmux --inherit-variable tmpdir
|
|
|
|
# tmux can't handle session sockets in paths that are too long, and macOS has a very long
|
|
|
|
# $TMPDIR, so use a relative path - except macOS doesn't have `realpath --relative-to`...
|
|
|
|
# Luckily, we don't need to call tmux from other directories, so just make sure no one
|
|
|
|
# does by accident.
|
|
|
|
if test $PWD != $tmpdir
|
|
|
|
echo "error: isolated-tmux must always be run from the same directory." >&2
|
|
|
|
return 1
|
|
|
|
end
|
2022-06-13 05:23:52 +08:00
|
|
|
tmux -S .tmux-socket -f .tmux.conf $argv
|
2021-08-29 15:44:22 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function isolated-tmux-cleanup --on-event fish_exit --inherit-variable tmpdir
|
|
|
|
isolated-tmux kill-server
|
|
|
|
rm -r $tmpdir
|
|
|
|
end
|
|
|
|
|
2021-09-24 23:07:17 +08:00
|
|
|
function tmux-sleep
|
|
|
|
set -q CI
|
|
|
|
and sleep 1
|
|
|
|
or sleep .1
|
|
|
|
end
|
|
|
|
|
2021-08-29 15:44:22 +08:00
|
|
|
set -l fish (status fish-path)
|
|
|
|
isolated-tmux new-session -x 80 -y 10 -d $fish -C '
|
|
|
|
# This is similar to "tests/interactive.config".
|
|
|
|
function fish_greeting; end
|
|
|
|
function fish_prompt; printf "prompt $status_generation> "; end
|
|
|
|
# No autosuggestion from older history.
|
|
|
|
set fish_history ""
|
|
|
|
' $isolated_tmux_fish_extra_args
|
|
|
|
# Set the correct permissions for the newly created socket to allow future connections.
|
|
|
|
# This is required at least under WSL or else each invocation will return a permissions error.
|
|
|
|
chmod 777 .tmux-socket
|
|
|
|
|
2021-09-24 23:07:17 +08:00
|
|
|
# Loop a bit, until we get an initial prompt.
|
2021-09-25 00:27:14 +08:00
|
|
|
for i in (seq 25)
|
2021-09-24 23:07:17 +08:00
|
|
|
if string match -q '*prompt*' (isolated-tmux capture-pane -p)
|
|
|
|
break
|
|
|
|
end
|
|
|
|
sleep .2
|
2021-08-29 15:44:22 +08:00
|
|
|
end
|
|
|
|
end
|