Skip to content

Commit

Permalink
committed to using it2cmd as the default dir name. Added notes on set…
Browse files Browse the repository at this point in the history
…ting ITERM2_CMD_DIR for the exe
  • Loading branch information
oliverisaac committed Jan 19, 2022
1 parent 6dcc563 commit 1e82d4b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ This repo has a tool which does two things:
1. Handle clicks from iterm
2. Generate files which the iterm click-handler can understand

# Configuration

The only configuration option is `ITERM2_CMD_DIR` which sets where the files are created. This defaults to `${TMPDIR}/it2cmd` but can be set to any directory.

**I would suggest setting `ITERM2_CMD_DIR=/tmp/it2cmd`**

# Installation

### 1. Clone the Repo
Expand All @@ -26,7 +32,7 @@ go install .

1. Get the path to the `handle-click` script:
```bash
readlink "$GOPATH"/src/github.com/oliverisaac/iterm-cmd/handle-click
echo "$GOPATH"/src/github.com/oliverisaac/iterm-cmd/handle-click
```

2. In iTerm2, go to the application preferences (`cmd` + `comma`)
Expand All @@ -40,6 +46,11 @@ readlink "$GOPATH"/src/github.com/oliverisaac/iterm-cmd/handle-click
/Users/example/go/src/github.com/oliverisaac/iterm-cmd/handle-click '\1' '\2'
```

6. If you are using a custom `ITERM2_CMD_DIR` then you will want to prefix the command with that definition. You will end up with something like
```
ITERM2_CMD_DIR=/tmp/it2cmd $HOME/go/src/github.com/oliverisaac/iterm-cmd/handle-click '\1' '\2'
```

### 4. Use the script

You can now use `iterm-cmd` to generate a file which contains a command that iTerm2 can then execute. For example, run:
Expand Down
2 changes: 1 addition & 1 deletion handle-click
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -euo pipefail

EDITOR="${EDITOR:-vim}"
ITERM2_CMD_DIR="${ITERM2_CMD_DIR:-/tmp/it2cmd}"
ITERM2_CMD_DIR="${ITERM2_CMD_DIR:-${TMPDIR}/it2cmd}"

function handle_click(){
file="$1"
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

func main() {
workDir := path.Join(os.TempDir(), "iT2cmd")
workDir := path.Join(os.TempDir(), "it2cmd")

if dir, isSet := os.LookupEnv("ITERM2_CMD_DIR"); isSet {
workDir = dir
Expand Down

0 comments on commit 1e82d4b

Please sign in to comment.