You are not logged in.

#1 2009-05-13 09:46:15

chrispoole
Member
Registered: 2008-12-30
Posts: 121

[SOLVED] Mac OS X-like 'view' CLI command for Linux?

On the Mac, you can type 'view example.doc' to have OpenOffice open it, or 'view image.png' to have the image viewer open it, etc.

Is there something similar on Linux?

(I've searched but can't find anything.)

Last edited by chrispoole (2009-05-13 11:52:19)

Offline

#2 2009-05-13 09:53:07

HashBox
Member
Registered: 2009-01-22
Posts: 271

Re: [SOLVED] Mac OS X-like 'view' CLI command for Linux?

I think this depends greatly on what desktop environment you're running, the only one I can help with off hand is Xfce, in which case 'exo-open' I think does this.

Offline

#3 2009-05-13 10:28:44

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: [SOLVED] Mac OS X-like 'view' CLI command for Linux?

Have a look at /usr/bin/xdg-open script. It probably provides the mechanism you need.

Last edited by bernarcher (2009-05-13 10:30:22)


To know or not to know ...
... the questions remain forever.

Offline

#4 2009-05-13 10:56:28

chimeric
Member
From: Munich, Germany
Registered: 2007-10-07
Posts: 254
Website

Re: [SOLVED] Mac OS X-like 'view' CLI command for Linux?

In case you're using zsh as your shell of choice you could also use alias -s style aliases:

alias -s doc=openoffice
alias -s cpp=gvim

Typing the filename and hitting enter should then open it in the defined application.

Offline

#5 2009-05-13 11:05:52

chrispoole
Member
Registered: 2008-12-30
Posts: 121

Re: [SOLVED] Mac OS X-like 'view' CLI command for Linux?

HashBox wrote:

I think this depends greatly on what desktop environment you're running, the only one I can help with off hand is Xfce, in which case 'exo-open' I think does this.

Thanks; I'm a GNOME user.

@chimeric I do use zsh, and didn't know about that feature, thanks.

@bernarcher I'll look into that too.

Offline

#6 2009-05-13 11:26:13

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: [SOLVED] Mac OS X-like 'view' CLI command for Linux?

gnome-open works as well.

Offline

#7 2009-05-13 11:52:02

chrispoole
Member
Registered: 2008-12-30
Posts: 121

Re: [SOLVED] Mac OS X-like 'view' CLI command for Linux?

Peasantoid wrote:

gnome-open works as well.

Thanks, just what I was after.

Offline

#8 2009-05-13 15:54:48

Agent69
Member
Registered: 2006-05-26
Posts: 189

Re: [SOLVED] Mac OS X-like 'view' CLI command for Linux?

Is the command really called "view"? I ask because when I used Mac OS X (10.4), it was "open", which would open the file with whatever application was associated with it. Or did that change with 10.5?

http://www.ss64.com/osx/open.html

Offline

#9 2009-05-13 16:05:20

Agent69
Member
Registered: 2006-05-26
Posts: 189

Re: [SOLVED] Mac OS X-like 'view' CLI command for Linux?

chimeric wrote:

In case you're using zsh as your shell of choice you could also use alias -s style aliases:

alias -s doc=openoffice
alias -s cpp=gvim

Typing the filename and hitting enter should then open it in the defined application.

Damn that's slick. I've always stuck with Bash but I might have to reconsider (unless Bash 4 has this feature).

Offline

#10 2009-05-13 20:17:25

Aprz
Member
From: Newark
Registered: 2008-05-28
Posts: 277

Re: [SOLVED] Mac OS X-like 'view' CLI command for Linux?

Agent69 wrote:
chimeric wrote:

In case you're using zsh as your shell of choice you could also use alias -s style aliases:

alias -s doc=openoffice
alias -s cpp=gvim

Typing the filename and hitting enter should then open it in the defined application.

Damn that's slick. I've always stuck with Bash but I might have to reconsider (unless Bash 4 has this feature).

It does except without the "-s". :s By default, in your ~/.bashrc, it already has "alias ls='ls --color=auto'".

Last edited by Aprz (2009-05-13 20:17:59)

Offline

#11 2009-05-13 21:11:58

chrispoole
Member
Registered: 2008-12-30
Posts: 121

Re: [SOLVED] Mac OS X-like 'view' CLI command for Linux?

Agent69 wrote:

Is the command really called "view"? I ask because when I used Mac OS X (10.4), it was "open", which would open the file with whatever application was associated with it. Or did that change with 10.5?

http://www.ss64.com/osx/open.html

You're correct. It's still 'open'. I wasn't at my Mac OS X machine at the time and couldn't remember when I asked the question.

Offline

#12 2009-05-13 23:23:40

Trent
Member
From: Baltimore, MD (US)
Registered: 2009-04-16
Posts: 990

Re: [SOLVED] Mac OS X-like 'view' CLI command for Linux?

Aprz wrote:
Agent69 wrote:
chimeric wrote:

In case you're using zsh as your shell of choice you could also use alias -s style aliases:

alias -s doc=openoffice
alias -s cpp=gvim

Typing the filename and hitting enter should then open it in the defined application.

Damn that's slick. I've always stuck with Bash but I might have to reconsider (unless Bash 4 has this feature).

It does except without the "-s". :s By default, in your ~/.bashrc, it already has "alias ls='ls --color=auto'".

Read it again.  These aren't ordinary aliases.  I interpret chimeric as saying that  in zsh the -s option allows you to associate file extensions with commands, not simple text replacement like your example.

Offline

#13 2009-05-14 04:29:13

Aprz
Member
From: Newark
Registered: 2008-05-28
Posts: 277

Re: [SOLVED] Mac OS X-like 'view' CLI command for Linux?

Trent wrote:

Read it again.  These aren't ordinary aliases.  I interpret chimeric as saying that  in zsh the -s option allows you to associate file extensions with commands, not simple text replacement like your example.

Ah, I missed that. That is pretty sick. tongue

Offline

Board footer

Powered by FluxBB