expand and xclip
Posted: Tue Aug 12, 2025 1:22 am
Continual learning: even though I knew about expand, xclip was a useful discovery.
I wanted to copy & paste a multi-screen script into LibreOffice for pretty printing and documentation purposes and used these two commands as follows:
I generally write my scripts in "vim", where I have set tabs to be four spaces, as the default eight assumes at least one of a really wide screen or a tiny font or very few levels of indentation, so when I paste code into a document where the font is mono-spaced, I want to replace the tabs in the source properly. That is what "expand -t 4" does.
Since I'm already at the CLI to do the tab expansion, I might as well use the X clipboard to paste the result into my document so that I don't have to fiddle around with temporary files that I must remember to delete in order to avoid future confusion.
So, running the above intelligently [!] expands the tabs in the "consume-lists" script and puts the result in the clipboard, allowing me to Alt+TAB to LibreOffice, where I simply paste it.
I wanted to copy & paste a multi-screen script into LibreOffice for pretty printing and documentation purposes and used these two commands as follows:
Code: Select all
expand -t4 consume-lists | xclip -selection clipboard
Since I'm already at the CLI to do the tab expansion, I might as well use the X clipboard to paste the result into my document so that I don't have to fiddle around with temporary files that I must remember to delete in order to avoid future confusion.
So, running the above intelligently [!] expands the tabs in the "consume-lists" script and puts the result in the clipboard, allowing me to Alt+TAB to LibreOffice, where I simply paste it.