3 ms·
A ‘trick’ for fancy prompts containing information is to give them the form, : all the stuff; As long as ‘all the stuff’ is parseable as shell words (whic
by kps 6y ago
A ‘trick’ for fancy prompts containing information is to give them the form,
: all the stuff;
As long as ‘all the stuff’ is parseable as shell words (which you can ensure by quoting with printf '%q' if there's doubt), then you can copy and paste entire lines.
The trivial copyable prompt would be
:;
- chrisweekly 6y agoThank you for this!! TIL. Immediately adopting. Now wishing everyone else knew this too.
- kps 6y agoI read about this long ago, possibly in the Blit era, possibly in ;login: (other order, other reasons). It's old lore, but not widely known, so I try to mention in when the subject of prompts comes up.
- Arnavion 6y agoNote that this isn't guaranteed to be a no-op for arbitrary "all the stuff". Specifically it won't work for commands involving pipes, or commands involving command substitution / process substitution. That is: : bar "$(foo)" : bar <(foo) : < <(foo) bar : bar | foo will all still execute `foo`
- kps 6y agoThat's why I mentioned quoting.