You are not logged in.

#1 2022-08-29 05:56:40

cloverskull
Member
Registered: 2015-10-01
Posts: 348

MacOS-like 'open'

Hey friends, I also posted this over at the arch forums but figured I would post here as well. I find this to be pretty handy.

One thing I enjoy on my work Mac is the 'open' command. For the uninitiated, the command is treated similar to xdg-open. This script, saved as /usr/local/bin/open has basically the same outcome as the Mac 'open' command. Try it in a directory, or try using it on some file.

xdg-open "$1" &> /dev/null &

Sometimes the simplest of things become handy. Figured I would share, cheers.

Offline

#2 2022-08-29 11:58:14

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,746

Re: MacOS-like 'open'

I think I used to have 'open' alias just pointing to thunar, why not "$@" instead of "$1"?

Offline

#3 2022-08-29 15:16:44

cloverskull
Member
Registered: 2015-10-01
Posts: 348

Re: MacOS-like 'open'

I use 'open' on a number of things that aren't just directories - like 'open file.txt' opens the text file in whatever xdg-open thinks a text file should be opened with.

As far as $1, it's just based on my MacOS experience. I have only ever passed a single argument so am just doing that smile But I may see what MacOS does with multiple args.

Offline

#4 2022-08-29 15:20:24

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 2,746

Re: MacOS-like 'open'

Actually the direct thunar alias did open text files as well (irc), also coming from macos btw.

Offline

#5 2022-08-30 05:12:34

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 12,652
Website

Re: MacOS-like 'open'

From Debian Buster (ie Beryllium) there is already an "open" command. It's a Debian alternative that points by default to xdg-open, though sysadmins can set the alternative to point anywhere they want.

So you can do 'open <file>' out of the box.

xdg-open doesn't accept more than one argument though. There are various other ***-open utilities available, possibly better.


...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )

Introduction to the Bunsenlabs Boron Desktop

Online

Board footer

Powered by FluxBB