Skip to content

Commit

Permalink
Merge pull request #42 from acro5piano/master
Browse files Browse the repository at this point in the history
Add an environment variable ENHANCD_DOT_SHOW_FULLPATH
  • Loading branch information
b4b4r07 authored Sep 2, 2016
2 parents bf068c3 + 347efef commit 0c48c0d
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
**/*.swp
.bin/shpec
.env
.config
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,23 @@ Besides putting a setting such as this one in your `~/.bash_profile` or `.zshenv
ENHANCD_COMMAND=ecd; export ENHANCD_COMMAND
```

### `ENHANCD_DOT_SHOW_FULLPATH`

The ENHANCD_DOT_SHOW_FULLPATH environment variable is to set whether to show full path or not when executing Double-dot. It defaults to `0`.

```console
$ export ENHANCD_DOT_SHOW_FULLPATH=1
$ cd ..
/
/home
/home/lisa
/home/lisa/src
/home/lisa/src/github.com
> /home/lisa/src/github.com/b4b4r07
6/6
> _
```

### `ENHANCD_DISABLE_DOT`

If you don't want to use the interactive filter, when specifing a double dot (`..`), you should set not zero value to `$ENHANCD_DISABLE_DOT`. Dedaluts to 0.
Expand Down
1 change: 1 addition & 0 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export ENHANCD_DISABLE_DOT="${ENHANCD_DISABLE_DOT:-0}"
export ENHANCD_DISABLE_HYPHEN="${ENHANCD_DISABLE_HYPHEN:-0}"
export ENHANCD_DOT_ARG="${ENHANCD_DOT_ARG:-..}"
export ENHANCD_HYPHEN_ARG="${ENHANCD_HYPHEN_ARG:--}"
export ENHANCD_DOT_SHOW_FULLPATH="${ENHANCD_DOT_SHOW_FULLPATH:-0}"

export _ENHANCD_VERSION="2.2.0"

Expand Down
2 changes: 1 addition & 1 deletion src/enhancd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ __enhancd::split_path()
{
awk \
-f "$ENHANCD_ROOT/src/share/split_path.awk" \
-v arg="${1:-$PWD}"
-v arg="${1:-$PWD}" -v show_fullpath="$ENHANCD_DOT_SHOW_FULLPATH"
}

# __enhancd::get_dirstep returns a list of stepwise path
Expand Down
7 changes: 6 additions & 1 deletion src/share/split_path.awk
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ BEGIN {

# decompose the path by a slash
for (i = 1; i < num; i++) {
print arr[i]
if (show_fullpath == 1) {
split(s, dirname, arr[i])
print "/" dirname[1] arr[i]
} else {
print arr[i]
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions test/enhancd-enhancd_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ T_SUB "__enhancd::split_path()" ((
expect="/${LF}home${LF}lisa"
actual="$(__enhancd::split_path /home/lisa/work)"
t_is "$expect" "$actual"
T_SUB "With \$ENHANCD_DOT_SHOW_FULLPATH set" ((
ENHANCD_DOT_SHOW_FULLPATH=1
expect="/${LF}/home${LF}/home/lisa"
actual="$(__enhancd::split_path /home/lisa/work)"
t_is "$expect" "$actual"
))
))

T_SUB "__enhancd::get_dirstep()" ((
Expand Down

0 comments on commit 0c48c0d

Please sign in to comment.