summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTuowen Zhao <ztuowen@gmail.com>2021-06-06 14:40:38 -0600
committerTuowen Zhao <ztuowen@gmail.com>2021-06-06 14:40:38 -0600
commit0144641b7d8e4e6ff6ce153039b5a827f5347904 (patch)
tree88ffb476ef9c1eb84b22006afe8a729fb27dc3c4
parentffdc4bfe1204f911d71b136dbd95784176a44eb6 (diff)
parent706b2f3765d41bee2853b17724888d1a3f6f00d9 (diff)
downloadzsh-0144641b7d8e4e6ff6ce153039b5a827f5347904.tar.gz
zsh-0144641b7d8e4e6ff6ce153039b5a827f5347904.tar.bz2
zsh-0144641b7d8e4e6ff6ce153039b5a827f5347904.zip
Merge remote-tracking branch 'origin/master'
-rw-r--r--plugins/chucknorris/fortunes/chucknorris2
-rw-r--r--plugins/dirhistory/dirhistory.plugin.zsh23
-rw-r--r--plugins/extract/README.md1
-rw-r--r--plugins/extract/_extract2
-rw-r--r--plugins/extract/extract.plugin.zsh2
-rw-r--r--plugins/shrink-path/README.md87
-rw-r--r--plugins/shrink-path/shrink-path.plugin.zsh12
-rw-r--r--themes/gentoo.zsh-theme2
8 files changed, 95 insertions, 36 deletions
diff --git a/plugins/chucknorris/fortunes/chucknorris b/plugins/chucknorris/fortunes/chucknorris
index 0eb6e2e99..0ddb6c03b 100644
--- a/plugins/chucknorris/fortunes/chucknorris
+++ b/plugins/chucknorris/fortunes/chucknorris
@@ -312,7 +312,7 @@ Chuck Norris. Enough said.
%
Chuck Norris: even Naruto can't believe it.
%
-Chunk Norris can make sour milk turn fresh.
+Chuck Norris can make sour milk turn fresh.
%
Contrary to popular belief, Rome WAS built in a day, by Chuck Norris.
%
diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh
index ec1606940..cbac84600 100644
--- a/plugins/dirhistory/dirhistory.plugin.zsh
+++ b/plugins/dirhistory/dirhistory.plugin.zsh
@@ -2,7 +2,7 @@
# Navigate directory history using ALT-LEFT and ALT-RIGHT. ALT-LEFT moves back to directories
# that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT.
#
-# Navigate directory hierarchy using ALT-UP and ALT-DOWN. (mac keybindings not yet implemented)
+# Navigate directory hierarchy using ALT-UP and ALT-DOWN.
# ALT-UP moves to higher hierarchy (cd ..)
# ALT-DOWN moves into the first directory found in alphabetical order
#
@@ -124,10 +124,14 @@ zle -N dirhistory_zle_dirhistory_back
# xterm in normal mode
bindkey "\e[3D" dirhistory_zle_dirhistory_back
bindkey "\e[1;3D" dirhistory_zle_dirhistory_back
-# Mac teminal (alt+left/right)
+# Terminal.app
if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then
bindkey "^[b" dirhistory_zle_dirhistory_back
fi
+# iTerm2
+if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
+ bindkey "^[^[[D" dirhistory_zle_dirhistory_back
+fi
# Putty:
bindkey "\e\e[D" dirhistory_zle_dirhistory_back
# GNU screen:
@@ -136,9 +140,14 @@ bindkey "\eO3D" dirhistory_zle_dirhistory_back
zle -N dirhistory_zle_dirhistory_future
bindkey "\e[3C" dirhistory_zle_dirhistory_future
bindkey "\e[1;3C" dirhistory_zle_dirhistory_future
+# Terminal.app
if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then
bindkey "^[f" dirhistory_zle_dirhistory_future
fi
+# iTerm2
+if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
+ bindkey "^[^[[C" dirhistory_zle_dirhistory_future
+fi
bindkey "\e\e[C" dirhistory_zle_dirhistory_future
bindkey "\eO3C" dirhistory_zle_dirhistory_future
@@ -175,8 +184,9 @@ zle -N dirhistory_zle_dirhistory_up
# xterm in normal mode
bindkey "\e[3A" dirhistory_zle_dirhistory_up
bindkey "\e[1;3A" dirhistory_zle_dirhistory_up
-# Mac teminal (alt+up)
- #bindkey "^[?" dirhistory_zle_dirhistory_up #dont know it
+if [[ "$TERM_PROGRAM" == "Apple_Terminal" || "$TERM_PROGRAM" == "iTerm.app" ]]; then
+ bindkey "^[[A" dirhistory_zle_dirhistory_up
+fi
# Putty:
bindkey "\e\e[A" dirhistory_zle_dirhistory_up
# GNU screen:
@@ -185,7 +195,8 @@ bindkey "\eO3A" dirhistory_zle_dirhistory_up
zle -N dirhistory_zle_dirhistory_down
bindkey "\e[3B" dirhistory_zle_dirhistory_down
bindkey "\e[1;3B" dirhistory_zle_dirhistory_down
-# Mac teminal (alt+down)
- #bindkey "^[?" dirhistory_zle_dirhistory_down #dont know it
+if [[ "$TERM_PROGRAM" == "Apple_Terminal" || "$TERM_PROGRAM" == "iTerm.app" ]]; then
+ bindkey "^[[B" dirhistory_zle_dirhistory_down
+fi
bindkey "\e\e[B" dirhistory_zle_dirhistory_down
bindkey "\eO3B" dirhistory_zle_dirhistory_down
diff --git a/plugins/extract/README.md b/plugins/extract/README.md
index b2b731e39..f2e6ad1d1 100644
--- a/plugins/extract/README.md
+++ b/plugins/extract/README.md
@@ -22,6 +22,7 @@ plugins=(... extract)
| `aar` | Android library file |
| `bz2` | Bzip2 file |
| `deb` | Debian package |
+| `ear` | Enterprise Application aRchive |
| `gz` | Gzip file |
| `ipa` | iOS app package |
| `ipsw` | iOS firmware file |
diff --git a/plugins/extract/_extract b/plugins/extract/_extract
index f96f0d450..267c4d4e1 100644
--- a/plugins/extract/_extract
+++ b/plugins/extract/_extract
@@ -3,5 +3,5 @@
_arguments \
'(-r --remove)'{-r,--remove}'[Remove archive.]' \
- "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|deb|gz|ipa|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst)(-.)'" \
+ "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|deb|ear|gz|ipa|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst)(-.)'" \
&& return 0
diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh
index 46e69f08d..e390e2dcc 100644
--- a/plugins/extract/extract.plugin.zsh
+++ b/plugins/extract/extract.plugin.zsh
@@ -55,7 +55,7 @@ extract() {
(*.lz4) lz4 -d "$1" ;;
(*.lzma) unlzma "$1" ;;
(*.z) uncompress "$1" ;;
- (*.zip|*.war|*.jar|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d $extract_dir ;;
+ (*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d $extract_dir ;;
(*.rar) unrar x -ad "$1" ;;
(*.rpm) mkdir "$extract_dir" && cd "$extract_dir" && rpm2cpio "../$1" | cpio --quiet -id && cd .. ;;
(*.7z) 7za x "$1" ;;
diff --git a/plugins/shrink-path/README.md b/plugins/shrink-path/README.md
index 33dc3f8ae..71a242b2c 100644
--- a/plugins/shrink-path/README.md
+++ b/plugins/shrink-path/README.md
@@ -1,43 +1,50 @@
-# A plugin to shrink directory paths for brevity and pretty-printing
+# shrink-path
+A plugin to shrink directory paths for brevity and pretty-printing.
+
+To use it, add `shrink-path` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... shrink-path)
+```
## Examples
For this directory tree:
```
- /home/
- me/
- f o o/ # The prefix f is ambiguous between "f o o" and "f i g".
- bar/
- quux/
- biz/ # The prefix b is ambiguous between bar and biz.
- f i g/
- baz/
+/home/
+ me/
+ f o o/ # The prefix f is ambiguous between "f o o" and "f i g".
+ bar/
+ quux/
+ biz/ # The prefix b is ambiguous between bar and biz.
+ f i g/
+ baz/
```
here are the results of calling `shrink_path <option> /home/me/foo/bar/quux`:
```
- Option Result
- <none> /h/m/f o/ba/q
- -l|--last /h/m/f o/ba/q
- -s|--short /h/m/f/b/q
- -t|--tilde ~/f o/ba/q
- -f|--fish ~/f/b/quux
- -g|--glob /h*/m*/f o*/ba*/q*
- -3 /hom/me/f o/bar/quu
- -e '$' -3 /hom$/me/f o$/bar/quu$
- -q /h/m/f\ o/ba/q
- -g -q /h*/m*/f\ o*/ba*/q*
+Option Result
+<none> /h/m/f o/ba/q
+-l|--last /h/m/f o/ba/q
+-s|--short /h/m/f/b/q
+-t|--tilde ~/f o/ba/q
+-f|--fish ~/f/b/quux
+-g|--glob /h*/m*/f o*/ba*/q*
+-3 /hom/me/f o/bar/quu
+-e '$' -3 /hom$/me/f o$/bar/quu$
+-q /h/m/f\ o/ba/q
+-g -q /h*/m*/f\ o*/ba*/q*
+-x /home/me/foo/bar/quux
```
-
## Usage
For a fish-style working directory in your command prompt, add the following to
your theme or zshrc:
-```
- setopt prompt_subst
- PS1='%n@%m $(shrink_path -f)>'
+```zsh
+setopt prompt_subst
+PS1='%n@%m $(shrink_path -f)>'
```
The following options are available:
@@ -54,17 +61,45 @@ The following options are available:
ellipsis character(s) (defaulting to 1).
-e SYMBOL Postfix symbol(s) to indicate that a directory name had been truncated.
-q, --quote Quote special characters in the shrunk path
+ -x, --expand Print the full path. This takes precedence over the other options
```
The long options can also be set via zstyle, like
-```
- zstyle :prompt:shrink_path fish yes
+```zsh
+zstyle :prompt:shrink_path fish yes
```
Note: Directory names containing two or more consecutive spaces are not yet
supported.
+## Trick: toggle shrinking with a keyboard shortcut
+
+You can use the `expand` option to disable the path shrinking. You can combine that
+with a key binding widget to toggle path shrinking on and off.
+
+```zsh
+# Toggle off path shrinking
+zstyle ':prompt:shrink_path' expand true
+# Toggle on path shrinking
+zstyle -d ':prompt:shrink_path' expand
+```
+
+Combined with a widget:
+
+```zsh
+# Widget definition
+shrink-path-toggle() {
+ zstyle -t ':prompt:shrink_path' expand \
+ && zstyle -d ':prompt:shrink_path' expand \
+ || zstyle ':prompt:shrink_path' expand true
+ zle reset-prompt
+}
+zle -N shrink-path-toggle
+# Key binding to ALT+SHIFT+S
+bindkey "^[S" shrink-path-toggle
+```
+
## License
Copyright (C) 2008 by Daniel Friesel <derf@xxxxxxxxxxxxxxxxxx>
diff --git a/plugins/shrink-path/shrink-path.plugin.zsh b/plugins/shrink-path/shrink-path.plugin.zsh
index f0ed65138..373fd5b05 100644
--- a/plugins/shrink-path/shrink-path.plugin.zsh
+++ b/plugins/shrink-path/shrink-path.plugin.zsh
@@ -45,6 +45,7 @@ shrink_path () {
typeset -i length=1
typeset ellipsis=""
typeset -i quote=0
+ typeset -i expand=0
if zstyle -t ':prompt:shrink_path' fish; then
lastfull=1
@@ -60,6 +61,7 @@ shrink_path () {
zstyle -t ':prompt:shrink_path' tilde && tilde=1
zstyle -t ':prompt:shrink_path' glob && ellipsis='*'
zstyle -t ':prompt:shrink_path' quote && quote=1
+ zstyle -t ':prompt:shrink_path' expand && expand=1
while [[ $1 == -* ]]; do
case $1 in
@@ -85,6 +87,8 @@ shrink_path () {
print ' ellipsis character(s) (defaulting to 1).'
print ' -e SYMBOL Postfix symbol(s) to indicate that a directory name had been truncated.'
print ' -q, --quote Quote special characters in the shrunk path'
+ print ' -x, --expand Print the full path. This takes precedence over the other options'
+ print ''
print 'The long options can also be set via zstyle, like'
print ' zstyle :prompt:shrink_path fish yes'
return 0
@@ -109,6 +113,9 @@ shrink_path () {
-q|--quote)
quote=1
;;
+ -x|--expand)
+ expand=1
+ ;;
esac
shift
done
@@ -120,6 +127,11 @@ shrink_path () {
[[ -d $dir ]] || return 0
+ if (( expand )) {
+ echo "$dir"
+ return 0
+ }
+
if (( named )) {
for part in ${(k)nameddirs}; {
[[ $dir == ${nameddirs[$part]}(/*|) ]] && dir=${dir/#${nameddirs[$part]}/\~$part}
diff --git a/themes/gentoo.zsh-theme b/themes/gentoo.zsh-theme
index e18bce890..7ac461036 100644
--- a/themes/gentoo.zsh-theme
+++ b/themes/gentoo.zsh-theme
@@ -25,4 +25,4 @@ gentoo_precmd() {
autoload -U add-zsh-hook
add-zsh-hook precmd gentoo_precmd
-PROMPT='%(!.%B%F{red}.%B%F{green}%n@)%m %F{blue}%(!.%1~.%~) ${vcs_info_msg_0_}%(!.#.$)%k%b%f '
+PROMPT='%(!.%B%F{red}.%B%F{green}%n@)%m %F{blue}%(!.%1~.%~) ${vcs_info_msg_0_}%F{blue}%(!.#.$)%k%b%f '