Skip to content

Commit

Permalink
set the SD environment variable
Browse files Browse the repository at this point in the history
$SD is now a shorthand for $(dirname "$0")
  • Loading branch information
ianthehenry committed Feb 27, 2022
1 parent 90404cb commit f5b1ec2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ Will invoke:

$ ~/sd/foo/bar --help --really

# Context

When a script is invoked, `sd` will set the environment variable `SD` to the directory that the script was found in -- in other words, `$(dirname "$0")`.

This makes it slightly more convenient to refer to shared helper files or other scripts relative to the executing script.

# Options

`sd` respects some environment variables:
Expand Down Expand Up @@ -263,6 +269,7 @@ There are no *releases* of `sd`, per se, but I have occasionally made changes.

## 2021-02-26

- scripts now run with the `SD` environment variable set to the directory they were found in
- autocompletion now completes arguments to commands instead of just commands
- only completes positional file arguments and the built-in flags (like `--help`)
- `sd` now only forks a subshell when invoked as a function
Expand Down
2 changes: 1 addition & 1 deletion sd
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ __sd() {
exit 1
fi
elif [[ -x "$target" ]]; then
exec "$target" "$@"
SD="$(dirname "$target")" exec "$target" "$@"
else
__sd_cat "$@"
fi
Expand Down

0 comments on commit f5b1ec2

Please sign in to comment.