| ---------------------------------------- | |
| 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 ( https://github.com/saitoha/tmux-SIXEL ) | |
| * burrow ( https://github.com/jamestomasino/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 | |
| tmux*) | |
| 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 $@ | |
| code=$? | |
| tmux rename-window $ancien | |
| tmux setw force-width 0 | |
| return $code; | |
| } | |
| :;; | |
| *) | |
| :;; | |
| esac | |
| ---------------------------------------- | |
| Back to phlog index | |
| gopher.zcrayfish.soy gopher root | |
| This phlog entry has been read 3146 times. | |
| Future direct comment submission has been disabled for this phlog entry. | |
| Comments are still accepted by email, please send to: | |
| [email protected] | |
| Be sure to include the post title in the subject line! Thanks! | |
| Comments have been left on this post: | |
| noremap <leader>8 :set colorcolumn=80<CR>:set tw=80<CR>:set fo+=t<CR> | |
| --- for vim users | |
| Posted Fri May 15 10:04:47 UTC 2020 by 85.211.103.186 | |
| ------------------------------------------------------------------------ |