migrate to dotter
This commit is contained in:
parent
c5618f2f2c
commit
23b6c0a596
265 changed files with 62 additions and 3125 deletions
38
configs/fish/functions/split_run.fish
Normal file
38
configs/fish/functions/split_run.fish
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
function split_run
|
||||
argparse mask r/restart -- $argv
|
||||
or return
|
||||
|
||||
if not set -qg MPROCS_PORT
|
||||
set -gx MPROCS_PORT $(random 1024 2048)
|
||||
kitten @ env "MPROCS_PORT=$MPROCS_PORT"
|
||||
end
|
||||
|
||||
if set -ql _flag_restart
|
||||
# Send commands to server
|
||||
mprocs --server "127.0.0.1:$MPROCS_PORT" --ctl "{c: restart-proc}"
|
||||
return 0
|
||||
end
|
||||
|
||||
|
||||
if set -ql _flag_mask
|
||||
set -l cmd "$(mask --introspect | jq ".commands[] | [.name, .description] | @tsv" -r | fzf --accept-nth=1)"
|
||||
|
||||
if test -z $cmd
|
||||
return 1
|
||||
end
|
||||
|
||||
set -l cmd "mask $cmd"
|
||||
|
||||
# check if server is running
|
||||
if nc -w 1 -zv 127.0.0.1 $MPROCS_PORT &>/dev/null
|
||||
mprocs --server "127.0.0.1:$MPROCS_PORT" --ctl "{c: add-proc, cmd: \"$cmd\"}"
|
||||
mprocs --server "127.0.0.1:$MPROCS_PORT" --ctl "{c: select-proc, index: 0}"
|
||||
mprocs --server "127.0.0.1:$MPROCS_PORT" --ctl "{c: prev-proc}"
|
||||
else
|
||||
# Start server
|
||||
kitten @ launch --cwd=current --location last --dont-take-focus mprocs --server "127.0.0.1:$MPROCS_PORT" "$cmd"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue