Skip to content

Commit

Permalink
Prefer VISUAL to EDITOR
Browse files Browse the repository at this point in the history
  • Loading branch information
taupiqueur committed Aug 9, 2023
1 parent 16e8251 commit 04df93d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
17 changes: 15 additions & 2 deletions docs/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ drop 'The Fool.png'
This shell script is opened in an editor for you to review.
After you close it, it will be executed.

### Editor configuration

By default, batch uses whatever you’ve set as your default text editor via one of the `VISUAL` or `EDITOR` environment variables, or else falls back to the vi editor to process items.

To change that default to something else, you can use the `--editor` option:

``` sh
batch -e vim
```

Now, no matter what is set as your default shell editor, batch will fire up Vim to process items.

### Advanced usage

batch lets you apply external filters—such as [tr], [sed] or [awk][gawk]—before invoking the editor:
Expand Down Expand Up @@ -141,7 +153,7 @@ Here is my personal configuration:
``` sh
# interactive map
imap() {
batch -e 'kak -n' -f 'iconv -f UTF-8 -t ASCII//TRANSLIT//IGNORE' -f 'tr [:upper:] [:lower:]' -f "tr -s \\'[:blank:] -" -f 'tr -d ?!,' "$@"
batch -e kak -f 'iconv -f UTF-8 -t ASCII//TRANSLIT//IGNORE' -f 'tr [:upper:] [:lower:]' -f "tr -s \\'[:blank:] -" -f 'tr -d ?!,' "$@"
}

# auto map
Expand Down Expand Up @@ -216,7 +228,7 @@ Specifies the shell script to run on deleted items.

Specifies the editor to use.

Default is fetch from the `EDITOR` environment variable.
Default is fetch from the `VISUAL` environment variable, then the `EDITOR` environment variable, and then the default chosen at compile time, which is usually `vi`.

###### `-f <command>`
###### `--filter=<command>`
Expand Down Expand Up @@ -258,6 +270,7 @@ Show version.

The following environment variables have an effect on `batch`.

###### VISUAL
###### EDITOR

Configures the default text editor.
1 change: 1 addition & 0 deletions src/env.cr
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ENV["EDITOR"] ||= "vi"
ENV["VISUAL"] ||= ENV["EDITOR"]
2 changes: 1 addition & 1 deletion src/main.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ VERSION = {{ `git describe --tags --always`.chomp.stringify }}
pick_command = Command.new("echo")
map_command = Command.new("echo")
drop_command = Command.new("echo")
editor_command = Command.parse(ENV["EDITOR"])
editor_command = Command.parse(ENV["VISUAL"])
filter_commands = Array(Command).new
edit = true
pick = true
Expand Down

0 comments on commit 04df93d

Please sign in to comment.