How to open new terminal in current directory?
When in a directory, I sometimes want another terminal to be opened in the same directory.
For example, I'm in ~/code/someproject/src/
, and I open a new terminal, by default, it opens in ~
, how do I launch a new terminal in the current directory?
I'm running Arch Linux with urxvt as my terminal and i3 as my window manager.
There is a very informative thread over in the i3-faq forum that has various scripts/programs that tackle this very issue.
https://faq.i3wm.org/question/150/how-to-launch-a-terminal-from-here/
I went for the c program xcwd which really does a great job. It also works from within GUI programs.
when you launch a terminal from within a existing terminal, the original terminal's environment will be preserved including current working directory and any other environment variables that you have set. This is why urxvt &
works
Somewhat similar to simotek's answer:
I use st, which, like many other terminal emulators opens a new terminal in the current working directory if run from command line.
An alias like: alias opennewterm="st >/dev/null 2>&1 & disown"
opens a terminal in the current directory and doesn't block the terminal.
If you're using zsh
, you can bind that to a keyboard shortcut by putting the following in your .zshrc
:
bindkey -s "^[n" "opennewterm\n"
which types opennewterm
and a newline when Alt+n
is pressed.