Some file managers, such as pcmanfm
or pcmanfm-qt
, open terminals in the current directory by setting $PWD
before opening the terminal. Most terminals behave as expected. This includes xterm
, gnome-terminal
, and xfce4-terminal
. However, konsole
always opens in a pre-specified directory (usually $HOME
).
How can konsole
be made to respect $PWD
as other terminals do?
This is a long-standing issue that has been around since at least 2010.
Previous solutions required patching the source code. Apparently a patch was submitted, but never accepted.
For several years, there has been no setting to make
konsole
respect$PWD
. However, there is a command-line option--workdir
that can be exploited by a script to makekonsole
function as desired.Check the path to locate a user-accessible location that takes precedence over
/usr/bin
by examining the output ofecho $PATH
. Typical options include~/bin/
and~/.local/bin/
.Create a file named
~/bin/konsole
(or~/.local/bin/konsole
) with the following contents:Give the new script execute permissions.
Now, whenever this script is run, it will process
$PWD
and execute/usr/bin/konsole --workdir "$PWD"
. If put in the right folder, it will have priority over the realkonsole
and usage will be transparent. Similar scripts can be created for other programs that do not behave as desired.