using alias ccat='pygmentize -g -O style=colorful,linenos=1' with line numbers

276 Views Asked by At

I'm using this alias to color my cat results. However, I want to add line numbers to the output, but using ccat -n <filename> is not working.

I can achieve it by ccat <filename> | cat -n but I can't create an alias for that (I expect an alias such as ccatn which I could use like ccatn <filename>)

What can I do to get this functionality (meaning, type in a command and a file name and get the same result as typing ccat <filename> | cat -n)?

1

There are 1 best solutions below

0
On

Use a function instead:

ccatn() {
    pygmentize -g -O style=colorful,linenos=1 "$1" | cat -n
}