iterm2-dwim is a click handler for iTerm2. The aim is that you command-click on any file path, relative or absolute, and it opens the file in your editor. If there was a line number, your editor goes to that line. So, compiler/linter output, tracebacks, etc.
Currently Emacs, PyCharm and Sublime are supported. To choose which editor to use, see settings.py.
The following path-like patterns are supported. For the ones with line numbers, the file will be opened at that line.
Pattern |
Type |
Status |
|---|---|---|
/absolute/path/to/file |
Absolute path |
✅ |
relative/path/to/file |
Relative path |
✅ |
relative/path/to/file:336:1: |
Compiler / Linter etc output |
❌ |
a/relative/path/to/file |
In git diff output |
✅ |
"/absolute/path/to/file.py", line 336, in some_function |
Python stack traces |
✅ |
> /path/to/file.py(336)some_function() |
Python ipdb output |
✅ |
Installation
Clone this repo and run python setup.py develop.
In settings.py, set the absolute path to the command-line utility that opens files in youe text editor / IDE. For PyCharm this is called charm, for Sublime this is called subl and for Emacs this is called emacsclient.
Find the absolute path to the iterm2-dwim executable, by running the command which iterm2-dwim. For example, on my system, this is /usr/local/bin/iterm2-dwim.
Open iTerm2 settings, click on “Profiles”, select your profile, click on the “Advanced” tab for that profile, and do two things (see screenshots below):
In the “Smart Selection” section, click “Edit”, select the “Paths” rule, click “Edit Actions”, click “+” to add an action, choose “Run Command” and enter /absolute/path/to/iterm2-dwim \0 as the “Parameter”.
In the “Semantic History” section, choose “Run command” and enter /absolute/path/to/iterm2-dwim \1 \4.
Make sure you didn’t literally enter /absolute/path/to/ – the path should be the path from step (5), given by which iterm2-dwim.
(Optional, but relative paths won’t be resolved without it): configure your shell prompt so that the current directory is written to a file named /tmp/cwd every time the prompt is displayed. For example, put this line in your ~/.bashrc:
export PROMPT_COMMAND='echo $PWD > /tmp/cwd'⌘-click on things!
Your iTerm2 settings should look something like this:
Optional configuration
To get error message alerts, run brew install terminal-notifier and check it’s working with terminal-notifier -message hello.
For Emacs users: 1. Make sure that you are starting the emacs server in your emacs config file: elisp (require 'server) (unless (server-running-p) (server-start))
Debugging
This is under development and you will encounter problems initially. Probably, you’ll command click on something and nothing will happen.
You can’t use ipdb to debug it: the python process is started by iTerm2 and is not attached to your terminal’s standard input/output. Similarly, note that the python process inherits its environment from the iTerm2 process and thus does not have access to environment modifications made in your shell config file.
It writes a log: run tail -f /tmp/iterm2-dwim.log.
If nothing happens and nothing is written to the log, another trick is just to run it from the command line and see the traceback:
$ iterm2-dwim /some/file.py 'any text can go here'
Metadata
Release files for iterm2-dwim 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| iterm2-dwim-0.0.3.tar.gz | 6.2 kB | Without provenance | Details for iterm2-dwim-0.0.3.tar.gz |
Release files / iterm2-dwim-0.0.3.tar.gz
| Download URL | iterm2-dwim-0.0.3.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a608c8e3e11c60e089b76aadda9db5354e19049fefc0aa7ab094c95736a62f36
|
|
BLAKE2b-256 checksum How to use checksums |
8029cdafd34d58e835cc9c8a606ce0840a5e59a4a4fb595baea8b58bfb13d5b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for iterm2-dwim 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.