Bash – Is it possible to prepend all terminal output with a certain character

bashrxvtterminal

For example, say I want to run the command ll:

My output would look something like this:

josh@zeitgeist ~ ll
total 41148
drwxr-xr-x 42 josh josh     4096 Aug  4 22:52 ./
drwxr-xr-x  4 root root     4096 Jul  9 21:18 ../
-rw-rw-r--  1 josh josh  3523718 Jul 11 00:17 2017-07-11-001710_3840x2160_scrot.png

but I want it to look like this:

josh@zeitgeist ~ ll
   total 41148
   drwxr-xr-x 42 josh josh     4096 Aug  4 22:52 ./
   drwxr-xr-x  4 root root     4096 Jul  9 21:18 ../
   -rw-rw-r--  1 josh josh  3523718 Jul 11 00:17 2017-07-11- 001710_3840x2160_scrot.png

I already know about using PS1='XXX' to change the prompt; is there a way to change every line of the output that gets displayed, for every command, specifically in the terminal(not changing the output and putting it in a file)?

I would like to do this to have an indentation line of characters going down the left side of my terminal. I'm currently wokring on creating a sci-fi inspired desktop, and one of the things I'm doing is creating a unique, irregular border around my titleless, borderless urxvt terminal windows by using a terminal background image. The only issue is I cannot figure out how to prepend spacing to the beginning of all output, because the output hugs the left edge of the window, which covers the paret of the background I want visible. I tried using URxvt internalBorder and externalBorder, but they cover the background image on the bottom and right edges of the terminal.

Best Answer

How about this. Starts a new bash process that is piped into awk, where every line piped in gets a couple of spaces printed before $0 (the input line)

$ bash | awk '{print "  " $0}'
$ id
  uid=500(ec2-user) gid=500(ec2-user) groups=500(ec2-user),10(wheel)
$ uname -a
  Linux ip-172-31-37-61 4.9.38-16.33.amzn1.x86_64 #1 SMP Thu Jul 20 01:31:29 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
$
Related Question