fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
3dc36f74b
master
1function isolated-tmux-start --wraps fish 2set -l tmpdir( mktemp -d) 3cd $tmpdir 4 5echo 'set -g mode-keys emacs' > .tmux.conf 6 7function isolated-tmux --inherit-variable tmpdir --wraps tmux 8# tmux can't handle session sockets in paths that are too long, and macOS has a very long 9# $TMPDIR, so use a relative path - except macOS doesn't have `realpath --relative-to`... 10# Luckily, we don't need to call tmux from other directories, so just make sure no one 11# does by accident. 12if test $PWD != $tmpdir 13echo "error: isolated-tmux must always be run from the same directory." >&2 14return 1 15end 16tmux -S .tmux-socket -f .tmux.conf$argv 17end 18 19function isolated-tmux-cleanup --on-event fish_exit --inherit-variable tmpdir 20isolated-tmux kill-server 21rm -r$tmpdir 22end 23 24function tmux-sleep 25set -q CI&& sleep 1 26or sleep 0.3 27end 28 29function sleep-until 30set -l cmd$argv [ 1 ] 31set -l i0 32while [ $i -lt 100 ] && not eval " $cmd " > /dev/null 33tmux-sleep 34set i( math $i +1 ) 35end 36if [ $i -eq 100 ] 37printf '%s\n' "timeout waiting for $cmd " >&2 38exit 1 39end 40end 41 42set -l fish( status fish-path) 43set -l size -x80 -y10 44set -l greeting_file 45if not test -f $greeting_file 46printf > $__fish_config_dir /functions/fish_greeting.fish %s\ 47'function fish_greeting; end' 2> /dev/null 48end 49isolated-tmux new-session$size -d$fish -C' 50# This is similar to "tests/interactive.config". 51function fish_prompt; printf "prompt $status_generation> "; end 52# No autosuggestion from older history. 53set fish_history "" 54# No transient prompt. 55set fish_transient_prompt 0 56set -g CDPATH 57' $argv 58# Set the correct permissions for the newly created socket to allow future connections. 59# This is required at least under WSL or else each invocation will return a permissions error. 60chmod 777 .tmux-socket 61 62# Resize window so we can attach to tmux session without changing panel size. 63isolated-tmux resize-window$size 64 65if test " $tmux_wait " = false 66return 67end 68 69# Loop a bit, until we get an initial prompt. 70for iin ( seq 50 ) 71if test -n "$ ( isolated-tmux capture-pane -p ) " 72return 73end 74sleep .2 75end 76echo "error: isolated-tmux-start timed out waiting for non-empty first prompt" >&2 77end