Skip to content

Instantly share code, notes, and snippets.

@coderofsalvation
Last active January 4, 2016 18:59
Show Gist options
  • Select an option

  • Save coderofsalvation/8664647 to your computer and use it in GitHub Desktop.

Select an option

Save coderofsalvation/8664647 to your computer and use it in GitHub Desktop.
attempt for universal way of opening a filetype with default application (regardless of windowmanager)
#!/bin/bash
# attempt for universal way of opening a filetype with default application (regardless of windowmanager)
# usage: open my.pdf (HINT: put this in your .bashrc: alias o='launch' )
# @param string (arguments)
function launch(){
if which xdg-open &>/dev/null;
then xdg-open "$@"
elif which gnome-open &>/dev/null;
then gnome-open "$@";
elif which kde-open &>/dev/null;
then kde-open "$@";
elif which open &>/dev/null;
then open "$@"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment