Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

working directory feature is broken #760

Open
tomatac opened this issue May 11, 2023 · 16 comments
Open

working directory feature is broken #760

tomatac opened this issue May 11, 2023 · 16 comments

Comments

@tomatac
Copy link

tomatac commented May 11, 2023

Directory feature per terminal is ignored loading the config file and cannot be set using the UI.
Tested on Ubuntu 22.04.
This used to work in older versions.

The only reasonable workaround, until this gets fixed, is to use the custom commands plugin and setup there cd custom commands.

config.txt

@vssdeo
Copy link
Contributor

vssdeo commented Jul 28, 2023

Hi @tomatac

This issue is on terminator 2.1.3 ? You mention that it used to work on earlier versions ? Can you please let me know what was the flow like and on which version of terminator ?

So there is a plugin SaveLastSessionLayout, if enabled it will save your session as per the last window closed. On launch, you can Right Click->Layouts->SaveSessionLayout and restore that one. I have commented out the provision for auto loading as it wasn't sure how users would like to use it and if it was ok to override "default" so "SaveSessionLayout" was used. May be auto-restore should be a selectable option.

@tomatac
Copy link
Author

tomatac commented Jul 30, 2023

The issue is in version 2.1.3.
The feature is there in the UI. We can set a default folder per terminal. It is very useful especially when we test different microservices. We ran terminator configured with the correct folder for each service and is super useful to start multiple windows with everything ready to run.
The issue is that it used to work and does not work anymore.
Right click and go in "Preferences", then "Layouts" and select a terminal. There is an option to set a custom command and a working directory for each terminal. You can go through each terminal and add working directories and custom commands and it looks like they are retained but as soon as we press the "Save" button at the bottom left they are gone. I also tried to configure these settings in the config file but they get ignored.
I used these features before and they used to work.
SaveLastSessionLayout did not seam to preserve the last folder for each terminal window.
image

@vssdeo
Copy link
Contributor

vssdeo commented Aug 5, 2023

Thanks for a detailed reply, Ok I think I get it, for 2.1.3, for "default" session

  1. It seems that if you close the window without pressing "save", the directory is saved and restored in next launch.
  2. If you do press "save" then it does not save the directory.

For SaveLastSession. It works for me. One has to ensure that the window with tabs and working dir be closed last. Then on next launch right click->layout->SaveLastSession would open. May be it should be more intutive and by default should open last session when enabled.

@vssdeo
Copy link
Contributor

vssdeo commented Aug 6, 2023

@tomatac I have made a patch with does fix it and have shared it for more testing and observations with regard to "command" setting and behavior, meanwhile pls test it out and see if it works. Ref: https://github.com/vssdeo/terminator/tree/760-working-directory-feature-is-broken

@tomatac
Copy link
Author

tomatac commented Aug 7, 2023

@vssdeo, How can we test this patch?

@vssdeo
Copy link
Contributor

vssdeo commented Aug 7, 2023

git clone https://github.com/vssdeo/terminator.git
cd terminator
git pull origin 760-working-directory-feature-is-broken
./terminator

for running of command, the terminator exits, since I am not sure of this behavior I am checking with others.

@tomatac
Copy link
Author

tomatac commented Aug 18, 2023

@vssdeo, I tested the patch but it only works partially for me.
The "working directory" setting is saved correctly but at startup the terminal window does not go to that specific folder.
Does terminator work with pyhon3 or it needs python2?
I am on Ubuntu 23.04 and it does not have python2 installed by default.

@vssdeo
Copy link
Contributor

vssdeo commented Aug 20, 2023

@tomatac thanks for the feedback, even I am trying to wrap my head around why its not working for you ?
For python I have python3 installed only so that should not be an issue.

  1. Could sent me a a zip of your terminator code and I could take a diff and see if there are any differences. [email protected]

  2. Also a copy of ~/.config/terminator/config would be helpful

@tomatac
Copy link
Author

tomatac commented Sep 15, 2023

@vssdeo, I believe that the issue is related to ability of program to run a command at startup because the custom command feature for each window does not work either.
It may not be related to the config file.
I also sent you an email with the files you requested.

@vssdeo
Copy link
Contributor

vssdeo commented Sep 15, 2023

Thanks for your reply @tomatac for config and code sharing and patience. It could be error on my part in understanding your usage so pls hold on a bit more.

  1. So first thing we are looking at same code base so thats good.
  2. I took you config and copied over mine with min changes in command and dir. After running terminator the command and directory change were as per the screenshot.
  3. I then changes the directory and removed the command, and it gets changed

Are you using multiple windows ? because in his case I used your config with diff as below (screenshot) attached.

diff -u  ~/Downloads/term/config config                                                                  1 ⚙
--- /home/user/Downloads/term/config    2023-09-15 22:53:54.000000000 +0530
+++ config      2023-09-16 01:19:09.171767167 +0530
@@ -13,7 +13,7 @@
       position = 26:23
       maximised = False
       fullscreen = False
-      size = 1848, 730
+      size = 1024, 800
       title = toma@Ub23-T1: ~
       last_active_term = 02a45cff-6a75-4939-9b76-5a09deb1c6be
       last_active_window = True
@@ -29,14 +29,16 @@
       order = 0
       profile = default
       uuid = 985c1f2b-bdca-465f-b761-830e4ee06c97
-      directory = ~/prog/CheckWeightApp/
+      directory = /var
+      command = top
     [[[terminal3]]]
       type = Terminal
       parent = child1
       order = 1
       profile = default
       uuid = 02a45cff-6a75-4939-9b76-5a09deb1c6be
-      directory = ~/prog/CheckWeightApp/CwCanOpenMaster/build/src
+      directory = /usr
+      command = who; read
   [[SaveLastSessionLayout]]
     [[[child0]]]
       type = Window

terminator-cwd-cmd-config

@tomatac
Copy link
Author

tomatac commented Sep 17, 2023

Thanks @vssdeo!
I did some more testing on a different computer and these are my findings:

  1. it does not like this folder: ~/repos
    but it likes this one: /home/username/repos
    these are the same folder (the first one is just relative to home: ~/)

  2. it does not like if the custom command gets finished like a simple: ls or cd /tmp
    it actually terminates that terminal if the command gets finished.
    It does that silently and typically you do not realize that that is the issue.
    if you run the top command it shows the output of the command but it would close the terminal window if you press CTRL/C
    on "Profiles" tabs there are some options for commands (exit, restart, hold) but none of them work as intended
    running a command that gets finished is very useful to setup a certain environment and continue with an interactive terminal session

  3. as you noted (and I think you fixed), as soon as you touch the save button it deletes all the settings (custom commands and working directories), but it works if you just press "Close"

quite misleading, but at least we are getting somewhere!

@vssdeo
Copy link
Contributor

vssdeo commented Sep 17, 2023

Bingo ! We have hit a jackpot my dear friend @tomatac !

So now we are sure that out of 3 issues. The number 3) is fixed in my pull request.

Now regarding 1) the expansion of home dir let me look into it.

for point 2 where the terminal tab/window gets killed after running the command I have notified @mattrose also since I had the same issue in my bookmark plugin https://github.com/vssdeo/terminator/tree/706-Favorites-Bookmarks-Plugin where the window would die after running a non loop command. I took a diff approach there and changed my bookmark plugin but now I see the same devil popping up. Actually in terminator the window gets killed after running command unlike terminal in osx where the window dies with a message and then user can close the window/tab. I personally prefer in plugin the window to be there after running command like in bookmarks plugin but in terminal I am not sure, so will check with others. Now we have all the issues known let me see if we can do this point 2 better.

vssdeo added a commit to vssdeo/terminator that referenced this issue Sep 17, 2023
- directory was not getting expanded for ~ to user dir while changing path
vssdeo added a commit to vssdeo/terminator that referenced this issue Sep 17, 2023
-added home dir ~ expansion to UI in prefs also
@vssdeo
Copy link
Contributor

vssdeo commented Sep 17, 2023

@tomatac have fixed the (1) dir issue and point (3) works as expected I guess. Let me check the window closing after command for non bookmark cases how the team suggests.

@tomatac
Copy link
Author

tomatac commented Sep 18, 2023

Thanks @vssdeo!
In my opinion on #2, the expected and default behavior for a terminal application is to continue to be a terminal after the command runs. We can use custom commands to setup a certain environment and then continue to work in a terminal.

@mattrose
Copy link
Member

The behaviour of number 2 can be specified in the Preferences window, under the custom command dialog. That way the user can specify the behaviour and we don't have to guess.

@vssdeo
Copy link
Contributor

vssdeo commented Sep 23, 2023

Have added the number 2 issue in detail Ref: #829 along with changes in my branch for now (not opening pull request)

Ref: https://github.com/vssdeo/terminator/tree/829-Handing-Behaviour-of-command-via-x-option-prefs-in-terminal-spawn_child-and-cross-check-shell-extraction-behaviour

@tomatac this you can check in behviour and whenever @mattrose has time he can look at #829

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants