5

I search everywhere and almost everyone was suggesting to open the ~/.bashrc or ~/.bash_aliases, then put the alias command there, I created a function name palias as permanent alias function and put it in ~/.bashrc:

function palias(){ echo "alias $1='$2'" >> /home/User/.bashrc;}

So now if I want to permanently alias some command I just :

palias update "sudo apt-get update"

I wonder if there is a built in command like this function, or anything like this to install from repositories?

Eliah Kagan
  • 117,780
Arsinux
  • 73
  • 1
  • 6
  • 2
  • You can find a complete list with all builtin commands only by typing helpin your terminal; you will not find nothing appropriate to your function. 2) Do you really need a special package to install it for such a small function? It is probably more quickly to write it than to install it...
  • – Radu Rădeanu Aug 05 '14 at 07:36
  • 3
    as a side note, you should add grep $1 /home/User/.bashrc right before you modify your .bashrc, to at least notify the user that there is already an existing alias with this name – Aserre Aug 05 '14 at 09:27
  • @RaduRădeanu I was just curious – Arsinux Aug 05 '14 at 13:48
  • 1
    @Pandya I believe OP used this line as an example. With his function he can add any other command as an alias without editing bashrc – Aserre Aug 05 '14 at 14:08
  • IMO this question contains the answer. This is probably the easiest way to do it. – Sparhawk Aug 14 '14 at 07:44
  • 1
    @EliahKagan OP already knows how to create an alias (witness the function OP has shown us). The question is: is there an app/builtin which does what the function does? – muru Oct 06 '14 at 15:51
  • 1
    @muru You're right--while I think How do I create a permanent Bash alias? does offer insight into this problem beyond what the OP has demonstrated in the question, I was quite wrong to think of this as the same question, or of the answers there as answering this. – Eliah Kagan Oct 06 '14 at 17:56