Skip to content

Commit

Permalink
Also don't match the root directory (#216)
Browse files Browse the repository at this point in the history
besides the `$HOME` directory.

A `z /` call will cd to the root directory anyway, because of how the
code handles completion:

    # if we hit enter on a completion just go there
    case "$last" in
        # completions will always start with /
        /*) [ -z "$list" -a -d "$last" ] && builtin cd "$last" && return;;
    esac
  • Loading branch information
ericbn authored May 26, 2021
1 parent 61b5c5b commit 574f64b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions z.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ _z() {
if [ "$1" = "--add" ]; then
shift

# $HOME isn't worth matching
[ "$*" = "$HOME" ] && return
# $HOME and / aren't worth matching
[ "$*" = "$HOME" -o "$*" = '/' ] && return

# don't track excluded directory trees
local exclude
Expand Down

0 comments on commit 574f64b

Please sign in to comment.