In my fish shell, I am using fish command timer to automatically show the duration of each command after it has been executed. This is a neat feature, which I recommend.
Now I want something similar in addition to that: The number of lines, i.e. after each command line I execute, the number of lines printed to stdout and/or stderr should be printed to stdout, too.
Example:
Instead of
> cat /etc/mpd.conf
pid_file "/run/mpd/mpd.pid"
db_file "/var/lib/mpd/mpd.db"
state_file "/var/lib/mpd/mpdstate"
playlist_directory "/var/lib/mpd/playlists"
I want to see
> cat /etc/mpd.conf
pid_file "/run/mpd/mpd.pid"
db_file "/var/lib/mpd/mpd.db"
state_file "/var/lib/mpd/mpdstate"
playlist_directory "/var/lib/mpd/playlists"
[ 4 lines ]
Some notes:
- There are some manual solutions to print the number of output lines of a command here, but I want this to be a permanent feature implemented in my fish config.
- I don't want to execute the command twice (for obvious reasons like the lack of idempotency etc.)
- A solution for bash (instead of fish) may point in the right direction.
The command timer works with a postexec event that is fired after executing a command line, but that does not exactly solve my problem, so I am in need of an approach.