4 ms·
I’ve got a random question for the terminal folk: I’m often testing a web server hosted on a remote server that hot reloads, but I have to wait for it to finish
by asdfman123 4y ago
I’ve got a random question for the terminal folk: I’m often testing a web server hosted on a remote server that hot reloads, but I have to wait for it to finish compiling.
I can tell it’s done if I have a tab open looking at the logs, but ideally I’d like some kind of icon that’s yellow when compiling, green when compiled, etc.
What could I use for that?
- deleted 4y ago[deleted]
- hboon 4y agoIf you mean to mix in GUI, on macOS, there is BitBar and another one (forgot the name) that just puts a big coloured dot in the menubar that you can curl to change its color. Something along that line would work.
- asdfman123 4y agoWhat about Linux?
- akira2501 4y agotmux. If a bell, or ctrl-g, is output on the terminal, the tmux status line will indicate this fact if you are viewing a different terminal. It will stay indicating until you switch back to that terminal. tmux will also show you the name of the command that's currently running, so if it's a make file or other script that finishes, you can observe that on it's own, but if you add an `echo -e "\007"` to the end of your script, you'll get the indicator.
- asdfman123 4y agoNice! I already use tmux. I’m not sure if the log file outputs anything like that though. There’s a way to hook into the build process and run commands after it completes. I’m guessing I might have to do that to get the status line wired in.
- lloeki 4y agothis is not tmux specific, basically every terminal out there would react to the bell char. e.g Terminal.app adds a bell icon to the tab, makes the dock icon bounce, and a badge on it. if you want to hack a bit and have a specific log line outputted yo the terminal you can stuff the bell char right in the string! one could also display notifications, there are more advanced CLI programs but here's a crude way: https://apple.stackexchange.com/questions/238814/send-notification-from-command-line#238820 https://apple.stackexchange.com/questions/238814/send-notifi... These things can also be done on Linux. A bit of web searching should give you ideas. I frequently use them with long running commands or fswatch.
- Galanwe 4y agoIf I understand correctly, you have a remote server with a logfile, and some markers in this log file tells you whether the build is in process or finished. I would suggest you keep it simple and simply poll the logfile for the latest occurrence of either "Build started" or "Build finished" and display a pop-up for each case. Very roughly that would look like: while true do MATCH=$(ssh remote@host 'cat /logfile' | grep -P 'started|finished' | tail -1) case "$MATCH" in *started*) notify-send "Build started" ;; *finished*) notify-send "Build finished" ;; esac sleep 1s done That's dirty bash written in an HN comment on my phone, but the idea is here. It's a bit wasteful to initiate ssh sessions so often, so you could improve it with a single "ssh remote@host tail -f /logfile", pipe that to "grep", then to a while read, but I left that as an exercise. There is some option to notify-send so that pop-ups replace one another instead of creating new ones.
- asdfman123 4y agoI should have clarified I’m usually looking at another tab in tmux. Any way to pop up there?
- jxf 4y agoYou can ask tmux to update the window status — for instance to show red or green based on the exit code of the last command. Example here: https://unix.stackexchange.com/a/597367/63035 https://unix.stackexchange.com/a/597367/63035
- asdfman123 4y agoNice! I was able to do just that, with a solution like the one you wrote, except I'm grepping a local (instead of remote) log, and changing the status bar color based on log output. Was exactly what I wanted, thanks.
- Rebelgecko 4y agoIf you're on a mac that sounds doable with iterm. I have some code in my fish config to bounce the dock icon when a longrunning command ends
- daneel_w 4y agoIn some cases you can get away with simple solutions like just printing the BEL character a few times: make install; printf \\a\\a\\a
- arlort 4y agoI think the bell character suggestion might be the simplest, but depending on how long the build takes you might want to check ntfy.sh I alias the build command to POST a notification using curl and get it on the browser/phone
- mixmastamyk 4y agoYou can change the tab title with ansi escapes. These days you can use Unicode chars as well, and some have colors, say with a emoji font.