Terminal: Opening the current path in a window?

Viewed 29055

Often times, I find myself navigating very deep into a directory and wanting to open the graphical window (nautilus) for various reasons. So the question is simple:

After doing,

cd sampledirectory  
cd sampledirectory2 

How can I open this location in a GUI?

6 Answers

I assume Gnome with Nautilus:

nautilus .

To open in the current directory.

Replace nautilus with whichever File Manager you use (Dolphin, etc).

The most portable way should be using freedesktop's xdg-utils xdg-open. For example

   $ xdg-open .

this has the advantage of choosing from your desktop preferences the tool to open different file types, like for example

   $ xdg-open ~/Documents/mypresentation.odp

or

   $ xdg-open ~/Pictures/mypic.png

nautilus .


I've done this a zillion times.

Here is how I do it on every system:

Mac:

#!/bin/sh
open /System/Library/CoreServices/Finder.app ${1:-.}

Linux / BSD, if Gnome:

#!/bin/sh
nautilus ${1:-.}

Windows ... Cygwin ...

#!/bin/sh
[ $# -eq 1 ] && exec explorer "$(cygpath -w "$1")"

Similar to DigitalRoss' comment, on a Mac you can add the following to your ~/.bash_profile:

alias finder="open /System/Library/CoreServices/Finder.app ${1:-.}"

then, from any Terminal window session, you can simply type:

finder

to launch the Finder at your current location.

Related