2

I am working with a developer setup so that I run my code in a docker container and be able to edit it locally (via volume). Local path is e.g. /path/to/my/project while inside docker container it is /app/source. Say I have a file relative to the project called app/models/team.rb.

On an error in the container I see an output like this:

/app/source/app/models/team.rb:13:in my_method...

iTerm seemed to be smart about the open on -click such that it underlined only the app/models/team.rb:13 (incl. line number) when I hover over the a of app (unfortunately only on the first character), and opened the local file in my editor (VSCode). That was already great.

I now added an iTerm profile that identifies when a session is running inside docker (greedy: auto profile switching checking for "&docker") and sets the hostname and path via Triggers and regex (besides colors etc). This also works fine.

However now when I hover over the filename, the whole path is underlined and when I -click, iTerm tries to download via scp (which fails).

How can I avoid iTerm to try to scp the file and make it realize again how to load the local file?

I already tried not to set the hostname, but this results in iTerm not providing anything anymore for opening. When I don't set the path then it's working like before of course, but I'd like to have this information of the docker container in the status bar.

0

2 Answers 2

0

I know this is not a direct answer to your question, but here is how I have handled the situation in other cases. Instead of mounting your local volume at /app, mount it in the container at /path/to/my/project. That way the file has the same path name inside Docker as outside it and you can skip special processing of the path name in iTerm.

If you are running Docker Desktop for Mac, the default osxfs driver will handle for you the issues arising from the files having different owners and permissions inside the container than outside and you do not have to worry about it. (This is a unique benefit of running on the Mac, other platforms do not have this feature at this time.)

2
  • That's probably not going to work if you're working on a shared project. I can't just change the mount point inside the container to what fits best to me. :-)
    – Karsten S.
    Aug 3, 2020 at 8:03
  • @KarstenS. actually, that is one of the benefits of using a container: you can change the mount point inside the container when you run the container. Fundamentally, you have configured iTerm as if you are running the session on a remote computer and then asking how to get it to act like the session is on your host computer. Go back to your old settings and if you want some information about the Docker session in the title, add it using the standard escape sequences in a startup script, e.g. echo -ne "\033]0;Docker Proj\007"
    – Old Pro
    Aug 3, 2020 at 8:43
0

This is changed in Semantic History within the Profiles configuration of iTerm2. You can configure ⌘ Command Click to:

  • Open a URL
  • Open the file in an editor
  • Open file with the default app
  • Run a command
  • run a different process

Simply redefine this setting (or disable it) as to your preferences.

1
  • Thanks for your answer. Interesting fact about this is, that I do have this enabled to runa a local command (~/bin/iterm-open with params), but this simple script doesn't do anything with ssh/scp. It simply opens the file in an editor, but also tries to match line numbers. Somehow the default didn't work for me, not recognizing line numbers.
    – Karsten S.
    May 8 at 7:59

Not the answer you're looking for? Browse other questions tagged .