Monday, January 25, 2010

Command Line Open in UNIX

On OS X I can just "open" any file. On Windows, I can use "start". And on Linux? On modern installations, the "xdg-open" command works just fine. Unfortunately - this is not always the case. And I don't want to remember different commands for different machines. So here is the ultimate open alias setting for bash, for all systems that I use (it can be easily extended for other environments).


 
conditional_alias() {
  UNSET=false
  alias $1 > /dev/null 2>&1 || UNSET=true
  [ x$UNSET = xtrue ] && which $2 > /dev/null 2>&1 && alias $1=$2
}
 
conditional_alias open gvfs-open
conditional_alias open xdg-open
conditional_alias open gnome-open
conditional_alias open exo-open
uname | grep MINGW > /dev/null 2>&1 && alias open=start

2 comments:

  1. Learn to play on line casino games by clicking on the links below. Each link tells 점보카지노 you somewhat in regards to the sport, the principles and provides you an internet video on the game in action. Video Poker gives you the power to compute the probability of acquiring the winning arms as proven on the paytable. Video Poker presents presents variety of the} highest odds of any sport if played appropriately, properly as|in addition to} a low home edge. Every video poker sport is different, but each may have a minimal hand you need to|you should|you have to} make so as to to} win.

    ReplyDelete