From 65874f2b2201c2e55d410ab322dc20394a587b83 Mon Sep 17 00:00:00 2001 From: Leif Ringstad Date: Wed, 28 Sep 2016 14:47:00 +0200 Subject: Add more docker compose aliases (#5422) Adds the following aliases: ```zsh alias dco='docker-compose' alias dcr='docker-compose run' alias dce='docker-compose exec' ``` And sorts the aliases similar to `docker-compose help` order --- plugins/docker-compose/docker-compose.plugin.zsh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'plugins') diff --git a/plugins/docker-compose/docker-compose.plugin.zsh b/plugins/docker-compose/docker-compose.plugin.zsh index 351e77824..9f2457fc4 100644 --- a/plugins/docker-compose/docker-compose.plugin.zsh +++ b/plugins/docker-compose/docker-compose.plugin.zsh @@ -5,9 +5,16 @@ # Aliases ################################################################### -alias dcup='docker-compose up' +# Use dco as alias for docker-compose, since dc on *nix is 'dc - an arbitrary precision calculator' +# https://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html + +alias dco='docker-compose' + alias dcb='docker-compose build' -alias dcrm='docker-compose rm' +alias dce='docker-compose exec' alias dcps='docker-compose ps' -alias dcstop='docker-compose stop' alias dcrestart='docker-compose restart' +alias dcrm='docker-compose rm' +alias dcr='docker-compose run' +alias dcstop='docker-compose stop' +alias dcup='docker-compose up' -- cgit v1.2.3-70-g09d2 From ac8915d43f0e8de9294c8552dc338ecc9993acd2 Mon Sep 17 00:00:00 2001 From: Diego Said Anaya Mancilla Date: Wed, 28 Sep 2016 14:28:53 -0500 Subject: Update pip plugin to last stable release (#5472) Update pip plugin to last stable release --- plugins/pip/_pip | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'plugins') diff --git a/plugins/pip/_pip b/plugins/pip/_pip index cb155e5f4..732ffabea 100644 --- a/plugins/pip/_pip +++ b/plugins/pip/_pip @@ -1,7 +1,8 @@ #compdef pip pip2 pip-2.7 pip3 pip-3.2 pip-3.3 pip-3.4 #autoload -# pip zsh completion, based on homebrew completion +# pip zsh completion, based on last stable release (pip8) +# homebrew completion and backwards compatibility _pip_all() { # we cache the list of packages (originally from the macports plugin) @@ -17,30 +18,43 @@ _pip_installed() { local -a _1st_arguments _1st_arguments=( - 'bundle:create pybundles (archives containing multiple packages)' + 'install:install packages' + 'download:download packages' + 'uninstall:uninstall packages' 'freeze:output all currently installed packages (exact versions) to stdout' - 'help:show available commands' + 'list:list installed packages' 'show:show information about installed packages' - 'install:install packages' 'search:search PyPI' - 'uninstall:uninstall packages' - 'unzip:unzip individual packages' - 'zip:zip individual packages' + 'wheel:build individual wheel archives for your requirements and dependencies' + 'hash:compute a hash of a local package archive' + 'help:show available commands' + 'bundle:create pybundles (archives containing multiple packages)(deprecated)' + 'unzip:unzip individual packages(deprecated)' + 'zip:zip individual packages(deprecated)' ) local expl local -a all_pkgs installed_pkgs _arguments \ - '(--version)--version[show version number of program and exit]' \ '(-h --help)'{-h,--help}'[show help]' \ - '(-E --environment)'{-E,--environment}'[virtualenv environment to run pip in]' \ - '(-s --enable-site-packages)'{-s,--enable-site-packages}'[include site-packages in virtualenv]' \ + '(--isolated)--isolated[run pip in isolated mode, ignores environment variables and user configuration]' \ '(-v --verbose)'{-v,--verbose}'[give more output]' \ + '(-V --version)'{-V,--version}'[show version number of program and exit]' \ '(-q --quiet)'{-q,--quiet}'[give less output]' \ '(--log)--log[log file location]' \ '(--proxy)--proxy[proxy in form user:passwd@proxy.server:port]' \ + '(--retries)--retries[max number of retries per connection (default 5 times)]' \ '(--timeout)--timeout[socket timeout (default 15s)]' \ + '(--exists-action)--exists-action[default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup]' \ + '(--trusted-host)--trusted-host[mark this host as trusted]' \ + '(--cert)--cert[path to alternate CA bundle]' \ + '(--client-cert)--client-cert[path to SSL client certificate]' \ + '(--cache-dir)--cache-dir[store the cache data in specified directory]' \ + '(--no-cache-dir)--no-cache-dir[disable de cache]' \ + '(--disable-pip-version-check)--disable-pip-version-check[do not check periodically for new pip version downloads]' \ + '(-E --environment)'{-E,--environment}'[virtualenv environment to run pip in (deprecated)]' \ + '(-s --enable-site-packages)'{-s,--enable-site-packages}'[include site-packages in virtualenv (deprecated)]' \ '*:: :->subcmds' && return 0 if (( CURRENT == 1 )); then @@ -56,7 +70,7 @@ case "$words[1]" in _arguments \ '(-l --local)'{-l,--local}'[report only virtualenv packages]' ;; install) - _arguments \ + _arguments \ '(-U --upgrade)'{-U,--upgrade}'[upgrade all packages to the newest available version]' \ '(-f --find-links)'{-f,--find-links}'[URL for finding packages]' \ '(-r --requirement)'{-r,--requirement}'[Requirements file for packages to install]:File:_files' \ -- cgit v1.2.3-70-g09d2 From 10ffa4fe992e56a93396ed8914eba74821bb2cca Mon Sep 17 00:00:00 2001 From: Christian Ferbar Date: Tue, 27 Sep 2016 12:27:37 +0200 Subject: Add README to svn plugin --- plugins/svn/README.md | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 plugins/svn/README.md (limited to 'plugins') diff --git a/plugins/svn/README.md b/plugins/svn/README.md new file mode 100644 index 000000000..b8eff70f5 --- /dev/null +++ b/plugins/svn/README.md @@ -0,0 +1,64 @@ +# `svn` plugin + +This plugin adds some utility functions to display additional information regarding your current +svn repsitiory. See http://subversion.apache.org/ for the full svn documentation. + +## Functions + +| Command | Description | +|:-----------------------|:----------------------------------------| +|svn_prompt_info | prompt for some themes | +|in_svn | within svn directory | +|svn_get_repo_name | | +|svn_get_branch_name | branch name (see caveats) | +|svn_get_rev_nr | revision number | +|svn_dirty | changes in this subversion repo | + +## Caveats + +The plugin expects the first directory to be the current branch / tag / trunk. So, it returns +the first path element if you don't use branches. + +## Usage + +To use it, add `svn` to your plugins array: +```sh +plugins=(... svn) +``` + +### Agnoster theme git-like prompt + +Enable the svn plugin and add the followind lines to your ```~/.zshrc``` + +```shell +prompt_svn() { + local rev branch + if in_svn; then + rev=$(svn_get_rev_nr) + branch=$(svn_get_branch_name) + if [ `svn_dirty_choose_pwd 1 0` -eq 1 ]; then + prompt_segment yellow black + echo -n "$rev@$branch" + echo -n "±" + else + prompt_segment green black + echo -n "$rev@$branch" + fi + fi +} +``` + +override the agnoster build_prompt() function: + +```shell +build_prompt() { + RETVAL=$? + prompt_status + prompt_context + prompt_dir + prompt_git + prompt_svn + prompt_end +} +``` + -- cgit v1.2.3-70-g09d2 From 364019a3c9c4ef08d2d7f0752c0ac008293d62df Mon Sep 17 00:00:00 2001 From: Christian Ferbar Date: Tue, 27 Sep 2016 12:29:25 +0200 Subject: Add localization workaround to svn plugin --- plugins/svn/svn.plugin.zsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh index 816055afe..e95ee9d99 100644 --- a/plugins/svn/svn.plugin.zsh +++ b/plugins/svn/svn.plugin.zsh @@ -25,14 +25,14 @@ function in_svn() { function svn_get_repo_name() { if in_svn; then - svn info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT - svn info | sed -n "s/URL:\ .*$SVN_ROOT\///p" + LANG=C svn info | sed -n 's/^Repository\ Root:\ .*\///p' | read SVN_ROOT + LANG=C svn info | sed -n "s/^URL:\ .*$SVN_ROOT\///p" fi } function svn_get_branch_name() { local _DISPLAY=$( - svn info 2> /dev/null | \ + LANG=C svn info 2> /dev/null | \ awk -F/ \ '/^URL:/ { \ for (i=0; i<=NF; i++) { \ @@ -54,13 +54,13 @@ function svn_get_branch_name() { function svn_get_rev_nr() { if in_svn; then - svn info 2> /dev/null | sed -n 's/Revision:\ //p' + LANG=C svn info 2> /dev/null | sed -n 's/Revision:\ //p' fi } function svn_dirty_choose() { if in_svn; then - local root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'` + local root=`LANG=C svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'` if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then # Grep exits with 0 when "One or more lines were selected", return "dirty". echo $1 -- cgit v1.2.3-70-g09d2 From f573247a59773f47b1741967335ec6c495bcf4b4 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 29 Sep 2016 13:56:16 +0200 Subject: Clean up svn README --- plugins/svn/README.md | 93 ++++++++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 45 deletions(-) (limited to 'plugins') diff --git a/plugins/svn/README.md b/plugins/svn/README.md index b8eff70f5..1f7b70c86 100644 --- a/plugins/svn/README.md +++ b/plugins/svn/README.md @@ -1,64 +1,67 @@ # `svn` plugin This plugin adds some utility functions to display additional information regarding your current -svn repsitiory. See http://subversion.apache.org/ for the full svn documentation. +svn repository. See http://subversion.apache.org/ for the full svn documentation. + +To use it, add `svn` to your plugins array: + +```zsh +plugins=(... svn) +``` ## Functions -| Command | Description | -|:-----------------------|:----------------------------------------| -|svn_prompt_info | prompt for some themes | -|in_svn | within svn directory | -|svn_get_repo_name | | -|svn_get_branch_name | branch name (see caveats) | -|svn_get_rev_nr | revision number | -|svn_dirty | changes in this subversion repo | +| Command | Description | +|:----------------------|:--------------------------------------------| +| `svn_prompt_info` | Shows svn prompt in themes | +| `in_svn` | Checks if we're in an svn repository | +| `svn_get_repo_name` | Get repository name | +| `svn_get_branch_name` | Get branch name (see [caveats](#caveats)) | +| `svn_get_rev_nr` | Get revision number | +| `svn_dirty` | Checks if there are changes in the svn repo | ## Caveats -The plugin expects the first directory to be the current branch / tag / trunk. So, it returns +The plugin expects the first directory to be the current branch / tag / trunk. So it returns the first path element if you don't use branches. -## Usage +## Usage on themes -To use it, add `svn` to your plugins array: -```sh -plugins=(... svn) -``` +To use this in the `agnoster` theme follow these instructions: -### Agnoster theme git-like prompt +1. Enable the svn plugin -Enable the svn plugin and add the followind lines to your ```~/.zshrc``` +2. Add the following lines to your `zshrc` file: -```shell -prompt_svn() { - local rev branch - if in_svn; then - rev=$(svn_get_rev_nr) - branch=$(svn_get_branch_name) - if [ `svn_dirty_choose_pwd 1 0` -eq 1 ]; then - prompt_segment yellow black - echo -n "$rev@$branch" - echo -n "±" - else - prompt_segment green black - echo -n "$rev@$branch" + ```shell + prompt_svn() { + local rev branch + if in_svn; then + rev=$(svn_get_rev_nr) + branch=$(svn_get_branch_name) + if [[ $(svn_dirty_choose_pwd 1 0) -eq 1 ]]; then + prompt_segment yellow black + echo -n "$rev@$branch" + echo -n "±" + else + prompt_segment green black + echo -n "$rev@$branch" + fi fi - fi -} -``` + } + ``` -override the agnoster build_prompt() function: +3. Override the agnoster `build_prompt()` function: -```shell -build_prompt() { - RETVAL=$? - prompt_status - prompt_context - prompt_dir - prompt_git - prompt_svn - prompt_end -} -``` + ```zsh + build_prompt() { + RETVAL=$? + prompt_status + prompt_context + prompt_dir + prompt_git + prompt_svn + prompt_end + } + ``` -- cgit v1.2.3-70-g09d2 From e6df0e036e39bcc2c20d7feaef1749d3c4f2768f Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 29 Sep 2016 14:03:09 +0200 Subject: Clean up and refactor code in svn plugin --- plugins/svn/svn.plugin.zsh | 48 +++++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 28 deletions(-) (limited to 'plugins') diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh index e95ee9d99..fbc9ee538 100644 --- a/plugins/svn/svn.plugin.zsh +++ b/plugins/svn/svn.plugin.zsh @@ -1,9 +1,7 @@ -# vim:ft=zsh ts=2 sw=2 sts=2 -# -function svn_prompt_info() { +svn_prompt_info() { local _DISPLAY if in_svn; then - if [ "x$SVN_SHOW_BRANCH" = "xtrue" ]; then + if [[ "$SVN_SHOW_BRANCH" = true ]]; then unset SVN_SHOW_BRANCH _DISPLAY=$(svn_get_branch_name) else @@ -16,21 +14,18 @@ $ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_S } -function in_svn() { - if $(svn info >/dev/null 2>&1); then - return 0 - fi - return 1 +in_svn() { + svn info >/dev/null 2>&1 } -function svn_get_repo_name() { +svn_get_repo_name() { if in_svn; then LANG=C svn info | sed -n 's/^Repository\ Root:\ .*\///p' | read SVN_ROOT LANG=C svn info | sed -n "s/^URL:\ .*$SVN_ROOT\///p" fi } -function svn_get_branch_name() { +svn_get_branch_name() { local _DISPLAY=$( LANG=C svn info 2> /dev/null | \ awk -F/ \ @@ -44,24 +39,28 @@ function svn_get_branch_name() { } \ }' ) - - if [ "x$_DISPLAY" = "x" ]; then + + if [[ -z "$_DISPLAY" ]]; then svn_get_repo_name else echo $_DISPLAY fi } -function svn_get_rev_nr() { +svn_get_rev_nr() { if in_svn; then LANG=C svn info 2> /dev/null | sed -n 's/Revision:\ //p' fi } -function svn_dirty_choose() { +svn_dirty() { + svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN +} + +svn_dirty_choose() { if in_svn; then - local root=`LANG=C svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'` - if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then + local root=$(LANG=C svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p') + if svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'; then # Grep exits with 0 when "One or more lines were selected", return "dirty". echo $1 else @@ -71,14 +70,13 @@ function svn_dirty_choose() { fi } -function svn_dirty() { - svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN +svn_dirty_pwd () { + svn_dirty_choose_pwd $ZSH_THEME_SVN_PROMPT_DIRTY_PWD $ZSH_THEME_SVN_PROMPT_CLEAN_PWD } -function svn_dirty_choose_pwd () { +svn_dirty_choose_pwd () { if in_svn; then - local root=$PWD - if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then + if svn status "$PWD" 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'; then # Grep exits with 0 when "One or more lines were selected", return "dirty". echo $1 else @@ -87,9 +85,3 @@ function svn_dirty_choose_pwd () { fi fi } - -function svn_dirty_pwd () { - svn_dirty_choose_pwd $ZSH_THEME_SVN_PROMPT_DIRTY_PWD $ZSH_THEME_SVN_PROMPT_CLEAN_PWD -} - - -- cgit v1.2.3-70-g09d2 From 09d95251a7176e0c4b2a71837b7356980fe738e5 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 29 Sep 2016 13:19:47 +0200 Subject: extract: fix styling --- plugins/extract/_extract | 2 - plugins/extract/extract.plugin.zsh | 137 ++++++++++++++++++------------------- 2 files changed, 65 insertions(+), 74 deletions(-) (limited to 'plugins') diff --git a/plugins/extract/_extract b/plugins/extract/_extract index 387b344bc..a73c892d9 100644 --- a/plugins/extract/_extract +++ b/plugins/extract/_extract @@ -4,5 +4,3 @@ _arguments \ '(-r --remove)'{-r,--remove}'[Remove archive.]' \ "*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|ipsw|rar|7z|deb)(-.)'" && return 0 - - diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index 5d0809e9a..081d5168f 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -1,80 +1,73 @@ -# ------------------------------------------------------------------------------ -# FILE: extract.plugin.zsh -# DESCRIPTION: oh-my-zsh plugin file. -# AUTHOR: Sorin Ionescu (sorin.ionescu@gmail.com) -# VERSION: 1.0.1 -# ------------------------------------------------------------------------------ +alias x=extract +extract() { + local remove_archive + local success + local file_name + local extract_dir -function extract() { - local remove_archive - local success - local file_name - local extract_dir + if (( $# == 0 )); then + cat <<-'EOF' >&2 + Usage: extract [-option] [file ...] - if (( $# == 0 )); then - echo "Usage: extract [-option] [file ...]" - echo - echo Options: - echo " -r, --remove Remove archive." - echo - echo "Report bugs to ." - fi + Options: + -r, --remove Remove archive. + EOF + fi - remove_archive=1 - if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then - remove_archive=0 - shift - fi + remove_archive=1 + if [[ "$1" == "-r" ]] || [[ "$1" == "--remove" ]]; then + remove_archive=0 + shift + fi - while (( $# > 0 )); do - if [[ ! -f "$1" ]]; then - echo "extract: '$1' is not a valid file" 1>&2 - shift - continue - fi + while (( $# > 0 )); do + if [[ ! -f "$1" ]]; then + echo "extract: '$1' is not a valid file" >&2 + shift + continue + fi - success=0 - file_name="$( basename "$1" )" - extract_dir="$( echo "$file_name" | sed "s/\.${1##*.}//g" )" - case "$1" in - (*.tar.gz|*.tgz) [ -z $commands[pigz] ] && tar zxvf "$1" || pigz -dc "$1" | tar xv ;; - (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;; - (*.tar.xz|*.txz) tar --xz --help &> /dev/null \ - && tar --xz -xvf "$1" \ - || xzcat "$1" | tar xvf - ;; - (*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \ - && tar --lzma -xvf "$1" \ - || lzcat "$1" | tar xvf - ;; - (*.tar) tar xvf "$1" ;; - (*.gz) [ -z $commands[pigz] ] && gunzip "$1" || pigz -d "$1" ;; - (*.bz2) bunzip2 "$1" ;; - (*.xz) unxz "$1" ;; - (*.lzma) unlzma "$1" ;; - (*.Z) uncompress "$1" ;; - (*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk) unzip "$1" -d $extract_dir ;; - (*.rar) unrar x -ad "$1" ;; - (*.7z) 7za x "$1" ;; - (*.deb) - mkdir -p "$extract_dir/control" - mkdir -p "$extract_dir/data" - cd "$extract_dir"; ar vx "../${1}" > /dev/null - cd control; tar xzvf ../control.tar.gz - cd ../data; tar xzvf ../data.tar.gz - cd ..; rm *.tar.gz debian-binary - cd .. - ;; - (*) - echo "extract: '$1' cannot be extracted" 1>&2 - success=1 - ;; - esac + success=0 + file_name="$( basename "$1" )" + extract_dir="$( echo "$file_name" | sed "s/\.${1##*.}//g" )" + case "$1" in + (*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$1" | tar xv } || tar zxvf "$1" ;; + (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;; + (*.tar.xz|*.txz) + tar --xz --help &> /dev/null \ + && tar --xz -xvf "$1" \ + || xzcat "$1" | tar xvf - ;; + (*.tar.zma|*.tlz) + tar --lzma --help &> /dev/null \ + && tar --lzma -xvf "$1" \ + || lzcat "$1" | tar xvf - ;; + (*.tar) tar xvf "$1" ;; + (*.gz) (( $+commands[pigz] )) && pigz -d "$1" || gunzip "$1" ;; + (*.bz2) bunzip2 "$1" ;; + (*.xz) unxz "$1" ;; + (*.lzma) unlzma "$1" ;; + (*.Z) uncompress "$1" ;; + (*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk) unzip "$1" -d $extract_dir ;; + (*.rar) unrar x -ad "$1" ;; + (*.7z) 7za x "$1" ;; + (*.deb) + mkdir -p "$extract_dir/control" + mkdir -p "$extract_dir/data" + cd "$extract_dir"; ar vx "../${1}" > /dev/null + cd control; tar xzvf ../control.tar.gz + cd ../data; tar xzvf ../data.tar.gz + cd ..; rm *.tar.gz debian-binary + cd .. + ;; + (*) + echo "extract: '$1' cannot be extracted" >&2 + success=1 + ;; + esac - (( success = $success > 0 ? $success : $? )) - (( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1" - shift - done + (( success = $success > 0 ? $success : $? )) + (( $success == 0 )) && (( $remove_archive == 0 )) && rm "$1" + shift + done } - -alias x=extract - -- cgit v1.2.3-70-g09d2 From f12cb5a697ca45b3ef8acda24cef72fe041addb3 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 29 Sep 2016 13:20:26 +0200 Subject: extract: fix extraction of deb packages with data.tar.xz --- plugins/extract/extract.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index 081d5168f..24b16517b 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -56,8 +56,8 @@ extract() { mkdir -p "$extract_dir/data" cd "$extract_dir"; ar vx "../${1}" > /dev/null cd control; tar xzvf ../control.tar.gz - cd ../data; tar xzvf ../data.tar.gz - cd ..; rm *.tar.gz debian-binary + cd ../data; extract ../data.tar.* + cd ..; rm *.tar.* debian-binary cd .. ;; (*) -- cgit v1.2.3-70-g09d2 From 68425c266a5107e50a2897b7d7cfc0ccb9fb753c Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 29 Sep 2016 13:26:50 +0200 Subject: 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 --- plugins/extract/extract.plugin.zsh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'plugins') 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" ;; -- cgit v1.2.3-70-g09d2 From b5dc976d236e8f8d276aa0aeff49980bfccb0532 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 29 Sep 2016 13:38:01 +0200 Subject: extract: add file extensions to extract completion --- plugins/extract/_extract | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/extract/_extract b/plugins/extract/_extract index a73c892d9..172425d2c 100644 --- a/plugins/extract/_extract +++ b/plugins/extract/_extract @@ -3,4 +3,5 @@ _arguments \ '(-r --remove)'{-r,--remove}'[Remove archive.]' \ - "*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|ipsw|rar|7z|deb)(-.)'" && return 0 + "*::archive file:_files -g '(#i)*.(7z|Z|apk|bz2|deb|gz|ipsw|jar|lzma|rar|sublime-package|tar|tar.bz2|tar.gz|tar.xz|tar.zma|tbz|tbz2|tgz|tlz|txz|war|xpi|xz|zip)(-.)'" \ + && return 0 -- cgit v1.2.3-70-g09d2 From bac896fca7b1af1e4237e96c58a0c13b8ff2d0de Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Fri, 30 Sep 2016 00:37:14 +0200 Subject: extract: add README --- plugins/extract/README.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 plugins/extract/README.md (limited to 'plugins') diff --git a/plugins/extract/README.md b/plugins/extract/README.md new file mode 100644 index 000000000..c6bdd36dd --- /dev/null +++ b/plugins/extract/README.md @@ -0,0 +1,46 @@ +# extract plugin + +This plugin defines a function called `extract` that extracts the archive file +you pass it, and it supports a wide variety of archive filetypes. + +This way you don't have to know what specific command extracts a file, you just +do `extract ` and the function takes care of the rest. + +To use it, add `extract` to the plugins array in your zshrc file: + +```zsh +plugins=(... extract) +``` + +## Supported file extensions + +| Extension | Description | +|:------------------|:-------------------------------------| +| `7z` | 7zip file | +| `Z` | Z archive (LZW) | +| `apk` | Android app file | +| `bz2` | Bzip2 file | +| `deb` | Debian package | +| `gz` | Gzip file | +| `ipsw` | iOS firmware file | +| `jar` | Java Archive | +| `lzma` | LZMA archive | +| `rar` | WinRAR archive | +| `sublime-package` | Sublime Text package | +| `tar` | Tarball | +| `tar.bz2` | Tarball with bzip2 compression | +| `tar.gz` | Tarball with gzip compression | +| `tar.xz` | Tarball with lzma2 compression | +| `tar.zma` | Tarball with lzma compression | +| `tbz` | Tarball with bzip compression | +| `tbz2` | Tarball with bzip2 compression | +| `tgz` | Tarball with gzip compression | +| `tlz` | Tarball with lzma compression | +| `txz` | Tarball with lzma2 compression | +| `war` | Web Application archive (Java-based) | +| `xpi` | Mozilla XPI module file | +| `xz` | LZMA2 archive | +| `zip` | Zip archive | + +See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for +more information regarding archive formats. -- cgit v1.2.3-70-g09d2 From c713407f90e7024507c7fc621440cb171108e7f4 Mon Sep 17 00:00:00 2001 From: Allan Lewis Date: Fri, 30 Sep 2016 12:45:28 +0100 Subject: git.plugin.zsh: Don't run Git hooks when making a WIP commit (#4751) When making a WIP commit, we generally just want to save the state of the current branch temporarily, maybe because we want to push our work for backup purposes, or change branch to work on something else. Therefore, it's generally undesirable to run Git hooks, which might do things like run linters, because we probably don't care if our WIP has lint errors. --- plugins/git/git.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 25da03509..ea9ff8269 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -236,4 +236,4 @@ alias gupv='git pull --rebase -v' alias glum='git pull upstream master' alias gwch='git whatchanged -p --abbrev-commit --pretty=medium' -alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit -m "--wip--"' +alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify -m "--wip--"' -- cgit v1.2.3-70-g09d2 From 3de0235ad26d4584727f4cce17c09f1b4ae6cee5 Mon Sep 17 00:00:00 2001 From: Manuel Hutter Date: Fri, 30 Sep 2016 19:54:27 +0200 Subject: Add missing newline to end of `spotify status` output (#5480) --- plugins/osx/osx.plugin.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'plugins') diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index aa6a256c1..d7baa1191 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -314,7 +314,7 @@ function spotify() { position=$(osascript -e 'tell application "Spotify" to player position as string' | tr ',' '.'); position=$(echo "scale=2; $position / 60" | bc | awk '{printf "%0.2f", $0}'); - printf "$reset""Artist: %s\nAlbum: %s\nTrack: %s \nPosition: %s / %s" "$artist" "$album" "$track" "$position" "$duration"; + printf "$reset""Artist: %s\nAlbum: %s\nTrack: %s \nPosition: %s / %s\n" "$artist" "$album" "$track" "$position" "$duration"; fi } @@ -412,17 +412,17 @@ function spotify() { osascript -e 'tell application "Spotify" to playpause'; break ;; - "quit" ) + "quit" ) cecho "Quitting Spotify."; osascript -e 'tell application "Spotify" to quit'; exit 1 ;; - "next" ) + "next" ) cecho "Going to next track." ; osascript -e 'tell application "Spotify" to next track'; break ;; - "prev" ) + "prev" ) cecho "Going to previous track."; osascript -e 'tell application "Spotify" to previous track'; break ;; -- cgit v1.2.3-70-g09d2 From 8ea56633a40411d1b43127b9cd88e8851edaf922 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 28 Sep 2016 18:23:15 +0200 Subject: last-working-dir: clean up source --- .../last-working-dir/last-working-dir.plugin.zsh | 25 +++++++++------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'plugins') diff --git a/plugins/last-working-dir/last-working-dir.plugin.zsh b/plugins/last-working-dir/last-working-dir.plugin.zsh index c458464ce..c5278d640 100644 --- a/plugins/last-working-dir/last-working-dir.plugin.zsh +++ b/plugins/last-working-dir/last-working-dir.plugin.zsh @@ -1,26 +1,21 @@ -#!/usr/bin/env zsh -# Keeps track of the last used working directory and automatically jumps -# into it for new shells. - -# Flag indicating if we've previously jumped to last directory. +# Flag indicating if we've previously jumped to last directory typeset -g ZSH_LAST_WORKING_DIRECTORY -mkdir -p $ZSH_CACHE_DIR -cache_file="$ZSH_CACHE_DIR/last-working-dir" -# Updates the last directory once directory is changed. +# Updates the last directory once directory is changed chpwd_functions+=(chpwd_last_working_dir) -function chpwd_last_working_dir() { - # Use >| in case noclobber is set to avoid "file exists" error +chpwd_last_working_dir() { + local cache_file="$ZSH_CACHE_DIR/last-working-dir" pwd >| "$cache_file" } -# Changes directory to the last working directory. -function lwd() { - [[ ! -r "$cache_file" ]] || cd "`cat "$cache_file"`" +# Changes directory to the last working directory +lwd() { + local cache_file="$ZSH_CACHE_DIR/last-working-dir" + [[ -r "$cache_file" ]] && cd "$(cat "$cache_file")" } -# Automatically jump to last working directory unless this isn't the first time -# this plugin has been loaded. +# Automatically jump to last working directory unless this +# isn't the first time this plugin has been loaded. if [[ -z "$ZSH_LAST_WORKING_DIRECTORY" ]]; then lwd 2>/dev/null && ZSH_LAST_WORKING_DIRECTORY=1 || true fi -- cgit v1.2.3-70-g09d2 From fb6738a7e1d476ec9a74b0e8a04f5252f9de91fe Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 28 Sep 2016 18:30:46 +0200 Subject: last-working-dir: don't jump if not in $HOME --- plugins/last-working-dir/last-working-dir.plugin.zsh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/last-working-dir/last-working-dir.plugin.zsh b/plugins/last-working-dir/last-working-dir.plugin.zsh index c5278d640..e882b288f 100644 --- a/plugins/last-working-dir/last-working-dir.plugin.zsh +++ b/plugins/last-working-dir/last-working-dir.plugin.zsh @@ -14,8 +14,10 @@ lwd() { [[ -r "$cache_file" ]] && cd "$(cat "$cache_file")" } -# Automatically jump to last working directory unless this -# isn't the first time this plugin has been loaded. -if [[ -z "$ZSH_LAST_WORKING_DIRECTORY" ]]; then - lwd 2>/dev/null && ZSH_LAST_WORKING_DIRECTORY=1 || true -fi +# Jump to last directory automatically unless: +# - this isn't the first time the plugin is loaded +# - it's not in $HOME directory +[[ -n "$ZSH_LAST_WORKING_DIRECTORY" ]] && return +[[ "$PWD" != "$HOME" ]] && return + +lwd 2>/dev/null && ZSH_LAST_WORKING_DIRECTORY=1 || true -- cgit v1.2.3-70-g09d2 From c488ab15f3293c3870f66fe84fc7ee71a182f214 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 28 Sep 2016 18:23:28 +0200 Subject: last-working-dir: add README --- plugins/last-working-dir/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 plugins/last-working-dir/README.md (limited to 'plugins') diff --git a/plugins/last-working-dir/README.md b/plugins/last-working-dir/README.md new file mode 100644 index 000000000..4cc4acab6 --- /dev/null +++ b/plugins/last-working-dir/README.md @@ -0,0 +1,9 @@ +# last-working-dir plugin + +Keeps track of the last used working directory and automatically jumps into it +for new shells, unless: + +- The plugin is already loaded. +- The current `$PWD` is not `$HOME`. + +Adds `lwd` function to jump to the last working directory. -- cgit v1.2.3-70-g09d2 From 9263e9ca59a65cad53d1cf0581c2af344984c2af Mon Sep 17 00:00:00 2001 From: Adrian Petrescu Date: Fri, 30 Sep 2016 17:39:32 -0400 Subject: Add /usr/local/bin to autoenv search path (#5481) The current list of directories to search for autoenv on misses the default location on Ubuntu systems if you just do a normal `pip install autoenv` - [it will place](https://github.com/kennethreitz/autoenv/blob/master/setup.py#L16) `activate.sh` in `/usr/local/bin` unless you manually override the `--prefix` or something. The `/usr/local/opt/autoenv` is fine for macOS/homebrew installations but it would be nice not to have to manually patch on Linux :) --- plugins/autoenv/autoenv.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/autoenv/autoenv.plugin.zsh b/plugins/autoenv/autoenv.plugin.zsh index ea2e56dd6..af58ee77b 100644 --- a/plugins/autoenv/autoenv.plugin.zsh +++ b/plugins/autoenv/autoenv.plugin.zsh @@ -1,7 +1,7 @@ # Activates autoenv or reports its failure () { if ! type autoenv_init >/dev/null; then - for d (~/.autoenv /usr/local/opt/autoenv); do + for d (~/.autoenv /usr/local/opt/autoenv /usr/local/bin); do if [[ -e $d/activate.sh ]]; then autoenv_dir=$d break -- cgit v1.2.3-70-g09d2