3

Is there a way to change the command xdg-open to the more simple open? Including the ability to pass a path to it? For example, instead of typing xdg-open ., I'd like to simply type open ..

5

You can alias anything you like (but check that the command you want to use doesn't already exist first: type open should tell you not found) Make a backup of your ~/.bashrc and define the alias:

cp .bashrc bashrc-bak
nano .bashrc

Add at the end

alias open='xdg-open'

Or if you want to avoid seeing any warnings from the program that is called, discard output with a redirection as suggested by TalkLittle:

alias open='xdg-open &>/dev/null'

Save and exit, then type source .bashrc to use the alias immediately. The alias will take arguments just like the full command, of course.

  • Thanks! I'm not terribly great with bash commands just yet, so I appreciate the help :) – JacobTheDev Aug 4 '16 at 13:30
  • @Rev more than welcome :) – Zanna Aug 4 '16 at 13:38
  • 2
    Use alias open='xdg-open &>/dev/null' to hide Nautilus errors when typing open . – TalkLittle Nov 19 '16 at 21:25
  • @zanna could you integrate TalkLittle's tip in your answer ? It makes for an even cleaner solution and this is what I was looking for that drove me to this thread. Anyways thanks to both of you ! – Nicolas Marshall Jun 21 '17 at 16:43
  • @NicolasMarshall done, thank you for the suggestion :) – Zanna Jun 21 '17 at 16:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.