1

How do I create a shortcut/alias in fedora? For example this is the path to my netbeans IDE

netbeans-8.2/bin/netbeans

I am a lazy person, and I don't want to type all this out in the terminal, is there a way so I can type something else and it "equals" whatever I want? Example If I type

SOMECOMMAND = netbeans-8.2/bin/netbeans

Whatever somecommand actually is, it will act as though I actually typed out the full

netbeans-8.2/bin/netbeans
Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
bit.con
  • 13
  • 1
  • 3

1 Answers1

1
alias nb='netbeans-8.2/bin/netbeans'

will probably do what you want.

Then nb gets expanded to the full command.

To see all the aliases you have set, type alias. To unset the alias, you want unalias nb.

This alias won't be saved permanently. To do that you will need to edit your shell configuration. For bash, which is the default shell under Fedora, that's .bashrc in your home directory.

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
SauceCode
  • 2,275
  • 4
  • 21
  • 32
  • Unfortunately this does not work – bit.con Feb 07 '17 at 00:14
  • You need to give more information. Does `netbeans-8.2/bin/netbeans` on its own actually do what you want? – SauceCode Feb 07 '17 at 00:16
  • yes, when I type that in the terminal it runs netbeans like it should – bit.con Feb 07 '17 at 00:17
  • And what error message do you get from the suggested commands? – SauceCode Feb 07 '17 at 00:19
  • this is what it outputs: bash: alias: nb: not found bash: alias: =netbeans-8.2/bin/netbeans: not found – bit.con Feb 07 '17 at 00:20
  • 1
    Did you add an extra space by mistake? – SauceCode Feb 07 '17 at 00:24
  • I don't think I've ever face palmed so hard in my life, thank you! – bit.con Feb 07 '17 at 00:26
  • I take it your command was `alias nb ='netbeans-8.2/bin/netbeans'`. If you have an alias set, `alias ` prints what that alias is. And `alias ` prints the value of both aliases. So your shell thought you were trying to print the value of both aliases, instead of assigning an alias. That should help understand your error message. – SauceCode Feb 07 '17 at 00:34
  • 1
    @bit.con Note that this alias will only work in a specific directory, the one containing `netbeans-8.2`. It would probably make more sense to put a full path there. But in fact what would make the most sense would be to [add `…/netbeans-8.2/bin` to your PATH](http://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path). – Gilles 'SO- stop being evil' Feb 07 '17 at 22:47