Strawberry
Strawberry

Reputation: 67868

Can I make an alias with a parameter?

So i want to run a script that requires me to input the name of a file.

For example: /userthatisnotme/bin/move filename

So I want to make it easier for me to remember, so I can just type move filename instead of that whole path.

How can I do this?

Upvotes: 0

Views: 520

Answers (2)

ghostdog74
ghostdog74

Reputation: 342273

use a sub routine.

mymove(){
 /userthatisnotme/bin/move "$1"
}

save this in your library eg mylibrary. when you want to use it, just source it. . mylibrary or source mylibrary

Upvotes: 1

Adam Vandenberg
Adam Vandenberg

Reputation: 20641

In your bash_profile (or other shell profile script):

alias my_move="/userthatisnotme/bin/move"

Examples of aliases for ls here: http://github.com/adamv/dotfiles/blob/master/bashrc#L45

The "parameters" get placed after the alias name. For more complicated situations, you could make a shell function instead of an alias.

Upvotes: 3

Related Questions