How can I save the current working directory in different tabs in a gnome-terminal? I am looking for a script or a command, that will save the working directory of each open tab, without having to manually go through all tabs and type pwd
in the terminal window..
I am using Ubuntu 14.04, and gnome-terminal version 3.6.2.
I tried to save the current state using gnome-terminal --save-config=conf.cfg
The file conf.cfg
will in some cases contain an entry like:
WorkingDirectory=/home/hakon/mydir
. However, that directory is not necessarily the current working directory of the terminal window. It seems it is related to the command line option --working-directory
.. so it will only represent the working directory if I do not change it after the terminal window has opened..
Best Answer
This can be done by changing the custom command of gnome-terminal to
then each time you open a new tab the title of the terminal window will be set to the current working directory of the tab.
Then, to save the current working directory of all tabs, you must determine the number of currently opened tabs. This can be done with
and inspecting the saved file
config.cfg
. Then iterate through all tabs usingand save the window title (which is equal to the current working directory) with