How do I open a file my script generated with the default GUI editor with bash?
On OS X there is the command open
, but as far as I know that doesn't exist on linux. What is a good cross-platform alternative?
(executing open somefile.ext
on OS X does the same as if I double clicked the file in Finder).
Mostly close to this is xdg-open
:
$ xdg-open somefile.ext
On linux you have kde-open
and gnome-open
for specific desktop environments, and xdg-open
is more generic but must still be run from a DE.
On windows, (obviously not bash
but cmd.exe
), I believe the similar command is start
.
With bash a cross-platform code could be:
if which xdg-open &> /dev/null; then
xdg-open $file # linux
else
open $file # mac
fi
On your .profile
export EDITOR='~/bin/mate -w'
and your bash use this editor
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With