diff options
author | Marc Cornellà <marc.cornella@live.com> | 2016-09-29 13:26:50 +0200 |
---|---|---|
committer | Marc Cornellà <marc.cornella@live.com> | 2016-09-30 00:38:03 +0200 |
commit | 68425c266a5107e50a2897b7d7cfc0ccb9fb753c (patch) | |
tree | 1589502d7db5202ee4b821ffb4206d3a5bd98097 | |
parent | f12cb5a697ca45b3ef8acda24cef72fe041addb3 (diff) | |
download | zsh-68425c266a5107e50a2897b7d7cfc0ccb9fb753c.tar.gz zsh-68425c266a5107e50a2897b7d7cfc0ccb9fb753c.tar.bz2 zsh-68425c266a5107e50a2897b7d7cfc0ccb9fb753c.zip |
extract: replace basename&sed w/ zsh variable expansion syntax
`${var:t:h}` uses:
- `${var:t}` which acts as `basename`.
- `${var:r}` which removes the extension.
See http://zsh.sourceforge.net/Doc/Release/Expansion.html#Modifiers
-rw-r--r-- | plugins/extract/extract.plugin.zsh | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index 24b16517b..c524bf8f5 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -3,7 +3,6 @@ alias x=extract extract() { local remove_archive local success - local file_name local extract_dir if (( $# == 0 )); then @@ -29,8 +28,7 @@ extract() { fi success=0 - file_name="$( basename "$1" )" - extract_dir="$( echo "$file_name" | sed "s/\.${1##*.}//g" )" + extract_dir="${1:t:r}" case "$1" in (*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$1" | tar xv } || tar zxvf "$1" ;; (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;; |