15

Is there a feasible solution than combines the advantages of a command-line and a graphical file browser?

For example, the command-line is good to change the directory and execute commands but can't show thumbnails and the file browser is intuitive, gives a good overview on where you are in the tree but you can't "talk" to the computer like in a command-line.

EDIT: for me, as a command-line user, its more like needing a command-line with additional file-browser capabilities than having a file browser with some command-line features.

9

Dolphin looks like what you are looking for:

But the terminal is a slave of its directory navigation (if you change the directory in the GUI, it changes in the terminal, but not the other way around).

To change the application directory when you change the current directory in the terminal, you can make your shell send a message to Dolphin to update its view. Add this to your shell rc files (Warning: not thoroughly tested, but works here for the most common situations, use at your own risk):

Bash:

if [ -n "$KONSOLE_DBUS_SERVICE" ]; then
  if qdbus "$KONSOLE_DBUS_SERVICE" /dolphin >/dev/null 2>&1; then
    cd() {
      builtin cd "$@"
      qdbus "$KONSOLE_DBUS_SERVICE" /dolphin/MainWindow0 org.kde.dolphin.MainWindow.changeUrl "$PWD" >/dev/null
    }
  fi
fi

Zsh:

if [ -n "$KONSOLE_DBUS_SERVICE" ]; then
  if qdbus "$KONSOLE_DBUS_SERVICE" /dolphin >/dev/null 2>&1; then
    chpwd() {
      qdbus "$KONSOLE_DBUS_SERVICE" /dolphin/MainWindow0 org.kde.dolphin.MainWindow.changeUrl "$PWD" >/dev/null
    }
  fi
fi

There is an issue with this. When the Dolphin window changes the current directory, the terminal loses focus. You may want to ask for a bugfix (or even complete native support for this feature) to the developers, if you like it.

6
  • Unfortunately changing directories from the command-line is one of the important features for me.
    – dStulle
    Nov 12 '10 at 20:57
  • @dStulle: If you just want to use the keyboard to change the directory, you can type Ctrl-L in Dolphin to make the cursor jump to the address bar, where you can type the address of the new directory and press Enter to navigate to it. If you really want to type cd in the command-line, you should be able to make a hack that executes qdbus to send the message org.kde.dolphin.MainWindow.changeUrl($PWD) back to Dolphin. But I think you should give it a try, it is mostly getting used to a new paradigm of GUI-Terminal integration.
    – Juliano
    Nov 12 '10 at 21:04
  • it is not about to "type" the location but to "be" in the command-line. qdbus is very nice and could work for this, but could not find how to link the the Terminal to its dolphin instance. if there are more than one Dolphin windows open it seems you could not determine which one to changeUrl on and I also could not find a way either alias, script or function to also change current command-line directory. EDIT: looks like someone else did while I was trying…
    – dStulle
    Nov 12 '10 at 22:30
  • The Dolphin service can be seen in the terminal from the $KONSOLE_DBUS_SERVICE env variable. It is a real problem if you have two windows open of the same instance of Dolphin. I really don't know how to distinguish between them. There is a $KONSOLE_DBUS_SESSION, but it links only to the konsole session, not the dolphin window. Anyways, you should suggest this feature to Dolphin developers, half of it is implemented above.
    – Juliano
    Nov 12 '10 at 22:41
  • 1
    I have dolphin 4.14.2 in debian. It now changes gui directory when you change in cli. Jun 17 '16 at 7:03
4

Gnome Commander is a file manager with a shell command line line at the bottom. Midnight Commander (mc) is similar, but in text mode. (Both get their inspiration from Norton Commander.)

2
  • unfortunately it seems to lack the important [tab]-auto-complete function for the command-line and a real file-thumbnail-preview.
    – dStulle
    Nov 12 '10 at 21:13
  • Ctrl-O will drop you to a shell in Midnight Commander and Ctrl-Enter will place the name of whatever item is selected into the command line. Not quite the same as [tab] auto-complete but pretty close.
    – user7136
    May 14 '11 at 20:07
4

Nautilus Terminal is a plugin for Nautilus (Gnome's file manager).

The directories don't follow the command line, but it's reasonably quick to do pwd | xclip, <Ctrl> +<l>, <Ctrl>+<v>

1
  • Also nice but as mentioned, file-browser also doesn't follow the command-line. It also seems to not "cd" into the new directory but starts a complete new bash instance. And some shortcuts like "ctrl-a" don't affect in the command-line but the file-browser.
    – dStulle
    Nov 12 '10 at 22:53
1

Konqueror http://www.konqueror.org/ has easy ways of going back and forth between terminal windows and file manager. See the forum discussion at: http://www.knoppix.net/forum/threads/3838-How-to-Open-Konqueror-in-the-Directory-as-Your-Current-Shell In konqueror typing ctrl-t gets you a terminal in the current directory, and in the shell kfmclient exec . opens konqueror at the current directory.

0

Below is a variation of the answer by @Juliano using dolphin + qdbus + terminal (added here as an answer instead of a comment so as to format the code snippet.) This variation also has limitations, and is definitely a hack.

This also assumes "dolphin" is running an attached terminal (view > panels > terminal; or, press "F4"). Just like the other proposal it sends a command to dolphin to update the path in the gui to match the PWD in the console. To force the terminal to retain focus, it sends a close/open (f4 + f4) to the terminal window using xte (xautomation): i.e., automatically closing and immediately re-opening the terminal so that it regains focus.

if [ -n "$KONSOLE_DBUS_SERVICE" ]; then
  if qdbus "$KONSOLE_DBUS_SERVICE" /dolphin >/dev/null 2>&1; then
    cd() {
      [ "$1" != "$PWD" ] && do_send=true || do_send=false;
      builtin cd "$@"
      if $do_send ; then
        qdbus "$KONSOLE_DBUS_SERVICE" /dolphin/MainWindow0 org.kde.dolphin.MainWindow.changeUrl "$PWD" >/dev/null 2>&1
        xte 'key F4' >/dev/null > /dev/null 2>&1 
        xte 'key F4' >/dev/null > /dev/null 2>&1 
      fi
    }
  fi
fi

The main issue (besides the slight flicker as the terminal closes/re-opens) is that dolphin (for some reason) inserts a "control+c" plus "cd {dir}" (where "dir" is the path of the file manager) into the terminal every time the terminal re-opens, interfering with the other commands that are being typed. (Edit: to add hack upon hack, as another workaround for this: just alias ccd=cd since the "c" character of this control+c always seems to be inserted in front of a cd {path}...)

Of course it would be better to have a proper fix in dolphin, to have the terminal retain focus and/or have this whole feature built into dolphin.

0

Paste an alias into your .bashrc (another appropriate config file):

alias revealAndJumpIntoYourFileManager ='pwd| xargs -0 io.elementary.files'
alias justReveal='pwd| xargs -0 io.elementary.files && jumpapp io.elementary.terminal'

Replace io.elementary.files and io.elementary.termianal by your file manager and console app.

Obviously you can shorten your alias naming as you see fit like reveal or even shorter and more reasonalbe ( make sure to not shadow your existing/future programs though! ) So whenever you want to look at what is going on in your current directory instead of a raw ls output into your terminal you can just invoke reveal and observe it directly from a file manger.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.