AfricanMatt
AfricanMatt

Reputation: 145

From Gitbash to Ubuntu terminal

I have a function in my .bashrc file on Win7 that looks like this:

function gi() {
    npm install --save-dev grunt-"$@"
}

It allows me to type "gi (grunt plugin)" to quickly install a plugin.

I copied this .bashrc file over to Ubuntu and opening the terminal gives the following error:

syntax error near unexpected token `$'{\r''

What is the correct syntax for this function in Ubuntu?

Upvotes: 2

Views: 67

Answers (2)

Jordan Kasper
Jordan Kasper

Reputation: 13273

You have a carriage return (\r) somewhere in there. Try simply retyping the whole thing in Ubuntu. Alternatively, you could just use delete or backspace to make it all one line, then hit "enter" a few times to make it look pretty in Ubuntu. The trick is to do that "enter" typing IN Ubuntu so you get Unix line feeds, not Windows ones.

Upvotes: 1

Graham Savage
Graham Savage

Reputation: 1164

You don't need to use function with bash, so in your bashrc file, simply remove that word:

gi() {
    echo npm install --save-dev grunt-"$@"
}

Upvotes: 2

Related Questions