Last active
August 28, 2021 19:26
-
-
Save josezy/3d8c04b6890d8062a2b37bf5424cda1e to your computer and use it in GitHub Desktop.
Fish config for auto-attaching to tmux session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if status --is-login | |
set PPID (echo (ps --pid %self -o ppid --no-headers) | xargs) | |
if ps --pid $PPID | grep ssh | |
tmux has-session -t remote; and tmux attach-session -t remote; or tmux new-session -s remote; and kill %self | |
echo "tmux failed to start; using plain fish shell" | |
end | |
end | |
cd /opt/ | |
function supctl | |
# highlight service names in purple | |
# highlight RUNNING services in green, all others in red | |
# highlight services with >1 day uptimes in blue (considered stable) | |
# highlight services with <5min uptimes in flashing yellow (considered unstable) | |
# highlight success log messages in green | |
set subcommand $argv[1] "status" | |
supervisorctl $subcommand[1] $argv[2..-1] \ | |
| env GREP_COLORS='ms=01;35' grep -E --color=always '^[a-Z0-9:-]+|$' \ | |
| env GREP_COLORS='ms=01;32' grep -E --color=always 'RUNNING|$' \ | |
| env GREP_COLORS='ms=01,05' grep -E --color=always 'STARTING|STOPPED|STOPPING|BACKOFF|EXITED|FATAL|UNKNOWN|$' \ | |
| env GREP_COLORS='ms=01;36' grep -E --color=always 'uptime .+ day.?,|$' \ | |
| env GREP_COLORS='ms=05;33' grep -E --color=always 'uptime 0:0[0-5]:[0-9][0-9]|$' \ | |
| env GREP_COLORS='ms=01;32' grep -E --color=always 'success|$' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment