0

Is there any possibility to put some lines of code automatically to the terminal?

E.g. when I want to start Hamachi through the terminal and don't want to write long expressions every time.

Maybe this problem is easy to solve, but I am a beginner and would be thankful for help.

Braiam
  • 67,791
  • 32
  • 179
  • 269

1 Answers1

2

ah.. jeah, I take it you want to execute a command, not just put text into the terminal ;-)

In your home directory you find a hidden file named .bashrc This file holds a list of commands that are execute whenever you start a shell. You could append your command there...

But...

If you do this with complex stuff, this stuff will always execute when you open your shell. Depending on what it is this may make your shell unusable.. you don't want that.

What you want is an alias.

append to your .bashrc

alias i_can_remember_that="long and strenuous command"

everytime you type now i_can_remember_that into your shell, the long command gets executed. You can even pass additional parameters to the alias:

i_can_remember_that foo will in fact run long and strenuous command foo

The name of the alias can be choosen freely of course. Sometimes you even want to override another command that way. i.e. a common alias is:

alias ls='ls --color=auto -B' which replaces ls with a more complex call of itself.

Paul Hänsch
  • 3,197