Diff
1diff --git a/plugins/shrink-path/shrink-path.plugin.zsh b/plugins/shrink-path/shrink-path.plugin.zsh
2index 373fd5b054289c4fd3523afbc5188148a8ca1108..1739f9234e84fc14fa5f4c1e0206531d49f62e57 100644
3--- a/plugins/shrink-path/shrink-path.plugin.zsh
4+++ b/plugins/shrink-path/shrink-path.plugin.zsh
5@@ -56,7 +56,16 @@ shrink_path () {
6 tilde=1
7 named=1
8 fi
9- zstyle -t ':prompt:shrink_path' last && lastfull=1
10+
11+ local last
12+ zstyle -s ':prompt:shrink_path' last last
13+ case "$last" in
14+ (false|no|off|0) lastfull=0 ;;
15+ (true|yes|on|1) lastfull=1 ;;
16+ (""|*[^0-9]*) lastfull=0 ;;
17+ (*) lastfull=$last ;;
18+ esac
19+
20 zstyle -t ':prompt:shrink_path' short && short=1
21 zstyle -t ':prompt:shrink_path' tilde && tilde=1
22 zstyle -t ':prompt:shrink_path' glob && ellipsis='*'
23@@ -78,7 +87,7 @@ shrink_path () {
24 print 'Usage: shrink_path [-f -l -s -t] [directory]'
25 print ' -f, --fish fish-simulation, like -l -s -t'
26 print ' -g, --glob Add asterisk to allow globbing of shrunk path (equivalent to -e "*")'
27- print ' -l, --last Print the last directory''s full name'
28+ print ' -l, --last [#] Print the last n directory''s full name (default 1).'
29 print ' -s, --short Truncate directory names to the number of characters given by -#. Without'
30 print ' -s, names are truncated without making them ambiguous.'
31 print ' -t, --tilde Substitute ~ for the home directory'
32@@ -93,7 +102,13 @@ shrink_path () {
33 print ' zstyle :prompt:shrink_path fish yes'
34 return 0
35 ;;
36- -l|--last) lastfull=1 ;;
37+ -l|--last)
38+ lastfull=1
39+ if [[ -n "$2" && "$2" != *[^0-9]* ]]; then
40+ shift
41+ lastfull=$1
42+ fi
43+ ;;
44 -s|--short) short=1 ;;
45 -t|--tilde) tilde=1 ;;
46 -T|--nameddirs)
47@@ -148,8 +163,8 @@ shrink_path () {
48 cd -q /
49 }
50 for dir in $tree; {
51- if (( lastfull && $#tree == 1 )) {
52- result+="/$tree"
53+ if (( lastfull && $#tree <= lastfull )) {
54+ result+="/${(j:/:)tree[@]}"
55 break
56 }
57 expn=(a b)