Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,14 @@ Run `exed -h` to see all available options.

## Environment Variables
If no editor is passed with `-e`, `exed` will check your environment for
`$FCEDIT`, `$VISUAL`, and `$EDITOR`, in that order. If none are set, it will
fall back to `vim`.
`$VISUAL`, and `$EDITOR`, in that order. It is recommended to use these
variables, as it's the *nix standard. If, for some reason, you want to specify a
certain editor specifically for exed, you can set `editor=EDITOR` in the
[configuration file](#configuration-file).

If you want to set a default editor, add something like this to your shell
configuration.
If none of the above are set, `exed` falls back to `vi`.

```sh
export VISUAL=code # Make VSCode your default graphical editor.
```

## Configuration Files
## Configuration File
`exed` accepts a configuration file where you can set default variables. Create
a file in your home directory called `.exedrc`. Available variables:

Expand All @@ -68,7 +65,7 @@ a file in your home directory called `.exedrc`. Available variables:
- `clobber=true` (same as passing `-C`)
- `clobber_mode=clobber`, `clobber_mode=noclobber`, or
`clobber_mode=interactive`
- `setifs=true` (same as passing `-I`)
- `set_ifs=true` (same as passing `-I`)

All boolean values are `false` by default. Any variables set in the
configuration file can be overwritten by flags when initiating the program. For
Expand All @@ -82,5 +79,16 @@ Run the test suite with:
bats test
```

## Reporting Bugs
To report bugs, please create an issue in the repository.
## Reporting Bugs and Requesting Features
If you have an idea or find a bug, please [create an
issue](https://github.com/evanthegrayt/exed/issues/new). Just make sure
the topic doesn't already exist. Better yet, you can always submit a Pull
Request.

## Support this project
I love knowing when people find my work useful. Any kind of support is very much
appreciated!

- ⭐️ Like the project? Star [the repository](https://github.com/evanthegrayt/exed)!
- ❤️ Love the project? Follow me [on GitHub](https://github.com/evanthegrayt)!
- 💸 *Really* love it? Consider [buying me a tea](https://paypal.me/evanrgray)!
15 changes: 3 additions & 12 deletions bin/exed
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ print_help() {
-O | prompt before overwriting in create mode (default)

--- GENERAL ---
-e EDITOR | choose editor; defaults to \$FCEDIT, \$VISUAL,
+ \$EDITOR, then vim
-e EDITOR | choose editor; defaults to \$VISUAL, \$EDITOR, then vi
-V | print version and exit
-u | print usage
-h | print this help and exit
Expand Down Expand Up @@ -92,15 +91,7 @@ resolve_command() {
}

set_editor() {
if [[ -n ${FCEDIT:-} ]]; then
printf '%s\n' "$FCEDIT"
elif [[ -n ${VISUAL:-} ]]; then
printf '%s\n' "$VISUAL"
elif [[ -n ${EDITOR:-} ]]; then
printf '%s\n' "$EDITOR"
else
printf '%s\n' "vim"
fi
printf '%s\n' ${VISUAL:-${EDITOR:-vi}}
}

editor_available() {
Expand Down Expand Up @@ -315,7 +306,7 @@ load_config() {
CLOBBER_MODE=clobber
fi

if is_true "${setifs:-false}"; then
if is_true "${set_ifs:-false}"; then
IFS_SETTING=$IFS_LINE
fi
}
Expand Down
8 changes: 3 additions & 5 deletions man/man1/exed.1
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ This option cannot be used with \fB-c\fR.
Create \fIEXECUTABLE_NAME\fR instead of finding it in \fBPATH\fR.
.IP "\fB-e \fIEDITOR\fR"
Choose the editor to open the file in.
If this option is not used, \fBexed\fR checks \fB$FCEDIT\fR,
\fB$VISUAL\fR, and \fB$EDITOR\fR, in that order.
If this option is not used, \fBexed\fR checks \fB$VISUAL\fR, and \fB$EDITOR\fR,
in that order.
If none are set, it defaults to \fBvim\fR.
.IP "\fB-v\fR"
Print the selected editor and file location before opening.
Expand Down Expand Up @@ -68,8 +68,6 @@ Prompt before overwriting an existing file.
This is the default and is useful for overriding \fBclobber=true\fR in
\fB~/.exedrc\fR.
.SH ENVIRONMENT
.IP "\fBFCEDIT\fR"
First editor fallback checked when \fB-e\fR is not passed.
.IP "\fBVISUAL\fR"
Second editor fallback checked when \fB-e\fR is not passed.
.IP "\fBEDITOR\fR"
Expand All @@ -89,7 +87,7 @@ clobber=true
clobber_mode=clobber
clobber_mode=noclobber
clobber_mode=interactive
setifs=true
set_ifs=true
.fi
.PP
Boolean values are false by default.
Expand Down
10 changes: 5 additions & 5 deletions test/exed.bats
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ setup() {
}

exed() {
HOME="$TEST_HOME" FCEDIT= VISUAL= EDITOR= "$EXED" "$@" 2>&1
HOME="$TEST_HOME" VISUAL= EDITOR= "$EXED" "$@" 2>&1
}

file_mode() {
Expand Down Expand Up @@ -64,7 +64,7 @@ make_recording_editor() {

make_executable "$target"

run env PATH="$PATH_FIXTURES:$PATH" HOME="$TEST_HOME" FCEDIT= VISUAL= EDITOR= \
run env PATH="$PATH_FIXTURES:$PATH" HOME="$TEST_HOME" VISUAL= EDITOR= \
"$EXED" -e "touch $opened" existing

[ "$status" -eq 0 ]
Expand All @@ -84,15 +84,15 @@ make_recording_editor() {
make_executable "$second_target"
make_recording_editor "$editor" "$opened"

run bash -c 'printf "2\n" | PATH="$1:$2:$PATH" HOME="$3" FCEDIT= VISUAL= EDITOR= "$4" -e "$5" -a dupe' \
run bash -c 'printf "2\n" | PATH="$1:$2:$PATH" HOME="$3" VISUAL= EDITOR= "$4" -e "$5" -a dupe' \
_ "$first_dir" "$second_dir" "$TEST_HOME" "$EXED" "$editor"

[ "$status" -eq 0 ]
[ "$(line_at 1 "$opened")" = "$second_target" ]
}

@test "default mode refuses missing executables" {
run env PATH="$PATH_FIXTURES:$PATH" HOME="$TEST_HOME" FCEDIT= VISUAL= EDITOR= \
run env PATH="$PATH_FIXTURES:$PATH" HOME="$TEST_HOME" VISUAL= EDITOR= \
"$EXED" -e true definitely-not-an-exed-test-executable

[ "$status" -eq 1 ]
Expand Down Expand Up @@ -189,7 +189,7 @@ make_recording_editor() {
printf '%s\n' "editor=true"
printf '%s\n' "perms=700"
printf '%s\n' "env=true"
printf '%s\n' "setifs=true"
printf '%s\n' "set_ifs=true"
printf '%s\n' "clobber_mode=clobber"
} > "$TEST_HOME/.exedrc"

Expand Down
Loading