Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux alias chain commands (can recursion be avoided?)

I've been looking around for ways to alias clear and ls into one command. Currently I've defined command x:

alias x="clear;ls"

Now is there any walkaround to avoid recursion and define:

 alias ls='clear;ls'
like image 345
GoTTimw Avatar asked Oct 10 '11 16:10

GoTTimw


2 Answers

If you put a backslash before the command name, that will disable any aliases.

alias ls='clear;\ls'

Or, like Arnaud said, just use the full path for ls.

like image 174
Jonathan Avatar answered Sep 17 '22 17:09

Jonathan


Another way of doing this would be

alias ls='clear; command ls'

This is different from /usr/bin/ls, as it still searches ls in the $PATH, but will ignore shell functions or aliases.

like image 42
jpalecek Avatar answered Sep 20 '22 17:09

jpalecek