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.

  • 1
    When one right-clicks in a folder in Dolphin, and chooses Actions > Open Terminal Here, konsole opens in that folder. Could you please explain the context/usage you are referring to?
    – DK Bose
    May 11, 2018 at 10:57
  • Context is in the question -- using konsole with pcmanfm. This question is not about Dolphin.
    – xiota
    Aug 5, 2018 at 9:01

1 Answer 1


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 make konsole function as desired.

  1. Check the path to locate a user-accessible location that takes precedence over /usr/bin by examining the output of echo $PATH. Typical options include ~/bin/ and ~/.local/bin/.

  2. Create a file named ~/bin/konsole (or ~/.local/bin/konsole) with the following contents:

    #!/usr/bin/env bash
    # make konsole respect $PWD, as other terminals do
    # save as ~/bin/konsole or ~/.local/bin/konsole
    # catch unset or mis-set PWD
    [[ -z $PWD ]] && PWD="$HOME"
    [[ "$PWD" == '/' ]] && PWD="$HOME"
    term_cls='konsole'      # window class needed for xdotool to activate window
    term_bin=`type -a -p konsole | tail -n 1`    # location of original `konsole`
    term_cmd=( "$term_bin" )
    [[ $PWD ]] && term_cmd+=( --workdir "$PWD" )
    term_tab=( "${term_cmd[@]}" --new-tab )
    case $1 in
        "$term_bin" "$1"
        echo 'cannot change profile properties at this time'
        find_app=( xdotool search --onlyvisible --class "$term_cls" windowactivate exec "${term_tab[@]}" )
        "${find_app[@]}" || xdotool exec "${term_cmd[@]}"
  3. Give the new script execute permissions.

    chmod +x ~/bin/konsole

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 real konsole and usage will be transparent. Similar scripts can be created for other programs that do not behave as desired.


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.