Gopher Menu

       How I make sure my burrow phlog posts are not too wide
       January 25th, 2019
       Here's a nifty one, sometimes when making phlog posts, I run into GNU 
       nano doing a very bad job word wrapping, which results in the phlog 
       looking bad in say lynx on a standard 80x25 terminal.  No biggie, I 
       setup a function to give me a hand.
       Software used:
       * GNU bash 4.4.23 in POSIX mode
       * tmux-SIXEL ( )
       * burrow ( )
       * GNU nano 2.9.6
       My function is placed into ~/.bashrc, here's what it does:
       * Checks to see if it's being called from a running tmux (case $TERM)
       * Saves tmux window title from before burrow running
       * Renames current tmux window to "burrow"
       * Sets current tomux window to 73 characters wide
       * Traps ctrl+c to restore window title if interrupted
       * Tells nano to try to wrap at 72 characters and runs burrow
       * Renames window back to its original name when burrow is done
       * Restores tmux to default window width
       * Sets return code in case running from another script
       Here's the condensed code I am using in ~/.bashrc:
       case $TERM in
           burrow() {
             local code=0
             local ancien
             ancien=$(tmux display-message -p '#W')
             tmux rename-window "burrow"
             tmux setw force-width 73
             trap "{tmux rename-window $ancien ; tmux setw force-width 0 }" INT
             env EDITOR="/usr/bin/nano -r72" burrow $@
             tmux rename-window $ancien
             tmux setw force-width 0
             return $code;
 (DIR) Back to phlog index
 (DIR) gopher root
       This phlog entry has been read 429 times.
  (?)  Comments have been enabled for this post, select here to leave yours
       Comments have been left on this post:
       Good post! It is very helpful
       Posted Mon Jan 27 22:22:53 UTC 2020 by