When you define a bash function you can call bash commands with command command.
function ls() {
clear
command ls "$@"
}
How would you pipe commands in bash function?
e.g.
function ls() {
clear
command ls "$@" | head
}
EDIT: The output would be OK, but there is --color=auto. Look here
Try this in your
~/.bashrcIt’s similar to the function you have already but with the inclusion of
builtin, it guarantees not to get stuck in a loop calling itself. Hope this works!EDIT: It should be noted that any colour information produced by
lswith the--color=autooption won’t be carried through the pipe to head.