mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-19 21:41:07 +01:00
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
This commit is contained in:
parent
f12cb5a697
commit
68425c266a
1 changed files with 1 additions and 3 deletions
|
@ -3,7 +3,6 @@ alias x=extract
|
||||||
extract() {
|
extract() {
|
||||||
local remove_archive
|
local remove_archive
|
||||||
local success
|
local success
|
||||||
local file_name
|
|
||||||
local extract_dir
|
local extract_dir
|
||||||
|
|
||||||
if (( $# == 0 )); then
|
if (( $# == 0 )); then
|
||||||
|
@ -29,8 +28,7 @@ extract() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
success=0
|
success=0
|
||||||
file_name="$( basename "$1" )"
|
extract_dir="${1:t:r}"
|
||||||
extract_dir="$( echo "$file_name" | sed "s/\.${1##*.}//g" )"
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
(*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$1" | tar xv } || tar zxvf "$1" ;;
|
(*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$1" | tar xv } || tar zxvf "$1" ;;
|
||||||
(*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;;
|
(*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;;
|
||||||
|
|
Loading…
Reference in a new issue