Each of the two file managers I use — Thunar and Xfe — allows me to open a terminal in a selected directory. In Thunar, I right-click on a directory and choose Open Terminal Here, and in Xfe I use the keyboard shortcut Ctrl + t.
In both cases, though, the terminal window opens right on top of the file manager window. I prefer the "open terminal here" action to open a terminal in a different workspace and to take me to that workspace.
This article explains how I organised that.
A wee little script
First, I installed wmctrl from my distro's repository. It's a handy little utility that can control what workspace you're on and what's in a given workspace.
wmctrl specifies workspaces by number, starting with 0. For example, if I have 3 workspaces on my desktop, the first one is "0", the second is "1" and the third is "2". I'm a creature of habit, and my file manager (either Thunar or Xfe) is always open in workspace 2. If I do the "open terminal here" thing, I want that terminal to open in workspace 3, next door, which wmctrl knows as "2".
My terminal is the Xfce one, and the command I use to launch it is xfce4-terminal --geometry=125x45+70+80. The "geometry" option sizes the terminal window and places it where I prefer on my desktop.
I wrote the following script, called termshift, and put it in my scripts folder, where I made it executable:
#!/bin/bash wmctrl -s 2; wmctrl -R <(xfce4-terminal --geometry=125x45+70+80)
The first wmctrl command in the script moves me to workspace 3 on my desktop. The second wmctrl command launches my terminal in that workspace and raises its focus.
(For a full list of wmctrl options, see its man page.)
In Thunar, I went to the Edit menu and selected Configure custom actions... Here the example given by the Thunar developers is "Open Terminal Here". I selected this example and opened its edit dialog. In the Command section, I replaced the default terminal command with the path to my termshift script. No command parameters (with "%") are necessary after the path, and I left the file pattern as "*" in the Appearance Conditions tab.
When I now right-click on a directory in the tree in Thunar's left-hand pane and choose "Open Terminal Here", I'm moved from workspace 2 to workspace 3 and into an Xfce terminal whose working directory is the one I selected in Thunar.
In Xfe it's both a little easier and a little harder. To make Xfe aware of termshift, I simply copied the script to my /home/bob/.config/xfe/scripts/ folder. To do the "open terminal but on a different workspace" trick, I now right-click on a selected directory either in Xfe's left-hand directory pane, or on any item within that directory in the right-hand pane. On the right-click menu I select Scripts, and termshift appears to the right of that word in a sub-menu. Clicking on termshift runs the script.