09d95251a7176e0c4b2a71837b7356980fe738e5

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

extract: fix styling

Diff

This diff is truncated to protect this page.

  1diff --git a/plugins/extract/_extract b/plugins/extract/_extract
  2index 387b344bc8e735c0966b4a02c2fee1caeb8b50d0..a73c892d9957bd19fbf4fce79d477a69bbf07037 100644
  3--- a/plugins/extract/_extract
  4+++ b/plugins/extract/_extract
  5@@ -4,5 +4,3 @@
  6 _arguments \
  7   '(-r --remove)'{-r,--remove}'[Remove archive.]' \
  8   "*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|ipsw|rar|7z|deb)(-.)'" && return 0
  9-
 10-
 11diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh
 12index 5d0809e9ad4c1c444b542460e5351f9416be9c72..081d5168fa4079f4e40a3ca3a237f0c12fc48548 100644
 13--- a/plugins/extract/extract.plugin.zsh
 14+++ b/plugins/extract/extract.plugin.zsh
 15@@ -1,80 +1,73 @@
 16-# ------------------------------------------------------------------------------
 17-#          FILE:  extract.plugin.zsh
 18-#   DESCRIPTION:  oh-my-zsh plugin file.
 19-#        AUTHOR:  Sorin Ionescu (sorin.ionescu@gmail.com)
 20-#       VERSION:  1.0.1
 21-# ------------------------------------------------------------------------------
 22+alias x=extract
 23 
 24+extract() {
 25+	local remove_archive
 26+	local success
 27+	local file_name
 28+	local extract_dir
 29 
 30-function extract() {
 31-  local remove_archive
 32-  local success
 33-  local file_name
 34-  local extract_dir
 35+	if (( $# == 0 )); then
 36+		cat <<-'EOF' >&2
 37+			Usage: extract [-option] [file ...]
 38 
 39-  if (( $# == 0 )); then
 40-    echo "Usage: extract [-option] [file ...]"
 41-    echo
 42-    echo Options:
 43-    echo "    -r, --remove    Remove archive."
 44-    echo
 45-    echo "Report bugs to <sorin.ionescu@gmail.com>."
 46-  fi
 47+			Options:
 48+			    -r, --remove    Remove archive.
 49+		EOF
 50+	fi
 51 
 52-  remove_archive=1
 53-  if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then
 54-    remove_archive=0
 55-    shift
 56-  fi
 57+	remove_archive=1
 58+	if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then
 59+		remove_archive=0
 60+		shift
 61+	fi
 62 
 63-  while (( $# > 0 )); do
 64-    if [[ ! -f "$1" ]]; then
 65-      echo "extract: '$1' is not a valid file" 1>&2
 66-      shift
 67-      continue
 68-    fi
 69+	while (( $# > 0 )); do
 70+		if [[ ! -f "$1" ]]; then
 71+			echo "extract: '$1' is not a valid file" >&2
 72+			shift
 73+			continue
 74+		fi
 75 
 76-    success=0
 77-    file_name="$( basename "$1" )"
 78-    extract_dir="$( echo "$file_name" | sed "s/\.${1##*.}//g" )"
 79-    case "$1" in
 80-      (*.tar.gz|*.tgz) [ -z $commands[pigz] ] && tar zxvf "$1" || pigz -dc "$1" | tar xv ;;
 81-      (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;;
 82-      (*.tar.xz|*.txz) tar --xz --help &> /dev/null \
 83-        && tar --xz -xvf "$1" \
 84-        || xzcat "$1" | tar xvf - ;;
 85-      (*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \
 86-        && tar --lzma -xvf "$1" \
 87-        || lzcat "$1" | tar xvf - ;;
 88-      (*.tar) tar xvf "$1" ;;
 89-      (*.gz) [ -z $commands[pigz] ] && gunzip "$1" || pigz -d "$1" ;;
 90-      (*.bz2) bunzip2 "$1" ;;
 91-      (*.xz) unxz "$1" ;;
 92-      (*.lzma) unlzma "$1" ;;
 93-      (*.Z) uncompress "$1" ;;
 94-      (*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk) unzip "$1" -d $extract_dir ;;
 95-      (*.rar) unrar x -ad "$1" ;;
 96-      (*.7z) 7za x "$1" ;;
 97-      (*.deb)
 98-        mkdir -p "$extract_dir/control"
 99-        mkdir -p "$extract_dir/data"
100-        cd "$extract_dir"; ar vx "../${1}" > /dev/null
101-        cd control; tar xzvf ../control.tar.gz
102-        cd ../data; tar xzvf ../data.tar.gz
103-        cd ..; rm *.tar.gz debian-binary
104-        cd ..
105-      ;;
106-      (*)
107-        echo "extract: '$1' cannot be extracted" 1>&2
108-        success=1
109-      ;;
110-    esac
111+		success=0
112+		file_name="$( basename "$1" )"
113+		extract_dir="$( echo "$file_name" | sed "s/\.${1##*.}//g" )"
114+		case "$1" in