What shell do you guys use? - BSD
Users browsing this thread: 20 Guest(s)
|
|||
Small tip: the most critical information that is missing from any default shell, in a portable way: the last command error code.
I do it this way: Code: % PS1='%${?#0} ' The magic: $? contains the last error code, but having a "0" displayed all of the time is not nice, so to strip it, the parameter expansion ${var#glob} [1] strips the leading "0", which only appears for one value: 0: it remove the code when it is 0. This is a bit tweaked and not very flexible, but very portable (for sh, no immediate equivalent for rc), and helps with catching "ok, there are error messages, but did 'make' return 1 or 0? Ah shit I did an 'ls', this long compilation exit code is lost forever!". Another extremely useful (at times) feature is showing the date in the prompt: reason: it permits to measure time of execution of commands even when you forgot to run "date" before and after or run the command with a leading "time": "I let the command run the whole night and it worked! but... did it take 5 minutes or 5 hours? No can tell!" Another extremely feature of the terminal st(1) (a bit off-topic, sorry), is the "-o iofile" flag that logs every I/O to a file. Life-saver! I had 5GB of shell logs, but I have 100GB of free disk space, so why bother... On the other hand: "ok, I'm pushing the configuration to the router over ssh, let's review it once *issue a dump conf command on the router* all good, apply, still works... disconnect from router and call it a day! *client calls angry telling the network is dead* what? wait a minute... uh oh, no more ssh access, and I closed the terminal with the backlog, I do not know what went wrong, time to drive for 2h to the client's place with a new router at hand! Ah, no I do have the terminal I/O recording the conf dump command I did, and the exact sequence of commands I entered, including those of 5 days ago for fixing the same problem." [1]: https://pubs.opengroup.org/onlinepubs/96...g_18_06_02 |
|||