Hacker News new | past | comments | ask | show | jobs | submit login

I recently stumbled across tmux while trying to provide a more customized UX in a bash script. Tmux and screen seemed a little more powerful than I needed, with lots of ways to accidentally corrupt the terminal. More and less were pretty close to what I wanted, but I could not figure out how to accept arbitrary input from the less prompt, exit, and pass it to bash.

Maybe that's not what less is for. Any tips on how I can create a less UX with custom input handling would be appreciated.




The select builtin might help in your case:

http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_06.htm...


For future reference, if you want to replicate a git-like man page UX (using less as the pager) the trick is defining custom commands with lesskey[0]. You can specify the exit status of the "quit" action to pass the information back to the calling script.

[0] https://www.freebsd.org/cgi/man.cgi?query=lesskey&sektion=1





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: