Skip to content

Commit

Permalink
Merge branch 'master' into production
Browse files Browse the repository at this point in the history
* master: (46 commits)
  Allow ssh module to run on OSX
  Change the zstyle config name for sorin-ionescu#607
  Add the ability to specify tmux session name
  Cache the completion for a quicker startup
  broken $path and $PATH  if nodenv exists (sorin-ionescu#1315)
  Use the lazy-loaded version of virtualenvwrapper if available
  Add gbr and gbR aliases to module readme
  Add some new git aliases, modify a few more. (sorin-ionescu#1301)
  Add better support for pyenv virtualenvs
  Convert long-pwd to pwd-length
  Add zstyle option to show pwd in long format
  rsync: Update reference to Bombich's rsync page
  Add support for 'pip', 'pip2', 'pip3' completion
  Update ssh module for multi session hosts
  New `alias gfa=git fetch --all` for git module
  Add utility alias for pydf
  Add perl-info function & plenv subcommand aliases (sorin-ionescu#1303)
  archive: add archive function
  archive: add support for *.jar files (sorin-ionescu#1302)
  Move python-info call in paradox from preexec to precmd
  ...
  • Loading branch information
rosenstrauch committed May 21, 2017
2 parents 02bef68 + 658fffb commit f9ae591
Show file tree
Hide file tree
Showing 43 changed files with 1,015 additions and 104 deletions.
25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE.md
@@ -0,0 +1,25 @@
Please check if a similar issue already exists or has been closed before before opening your issue.

### Description

[Description of the bug or feature]

### Expected behavior

[What you expected to happen]

### Actual behavior

[What actually happened]

### Steps to Reproduce

1. [First Step]
2. [Second Step]
3. [and so on...]

### Versions

- Prezto commit:
- ZSH version:
- OS information:
9 changes: 9 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,9 @@
Please be sure to check out our [contributing guidelines](https://github.com/sorin-ionescu/prezto/blob/master/CONTRIBUTING.md) before submitting your pull request.

Fixes #

## Proposed Changes

-
-
-
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Expand Up @@ -23,6 +23,18 @@ improve its performance, do not hesitate to fork and send pull requests.
- Open a [pull request][4] that relates to but one subject with a clear
title and description in grammatically correct, complete sentences.

#### Code Style

- Indent using 2 spaces. No tabs.
- Put `; do` and `; then` on the same line as the `while`, `for` or `if`.
- Local variables should be used whenever possible.
- Use `snake_case` for variable and function naming.
- Local variables should be lower cased.
- Global variables should be upper cased.
- Use `$(command)` instead of backticks.
- Avoid `eval` if possible.
- Prefer `zstyle` over environment variables for configuration.

#### Modules

- A *README.md* must be present.
Expand Down
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -29,6 +29,12 @@ version is 4.3.17.
done
```

Note: If you already have any of the given config files, ln will error. In
simple cases you can add `source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"` to
the bottom of your `.zshrc` to load prezto but keep your config intact. For
more complicated setups, it is recommended that you back up your original
configs and replace them with the provided prezto runcoms.

4. Set Zsh as your default shell:

`chsh -s /bin/zsh`
Expand Down
14 changes: 10 additions & 4 deletions modules/archive/README.md
@@ -1,11 +1,12 @@
Archive
=======

Provides functions to list and extract archives.
Provides functions to create, list, and extract archives.

Functions
---------

- `archive` creates an archive based on the provided archive name.
- `lsarchive` lists the contents of one or more archives.
- `unarchive` extracts the contents of one or more archives.

Expand All @@ -15,8 +16,8 @@ Supported Formats
The following archive formats are supported when the required utilities are
installed:

- *.tar.gz*, *.tgz* require `tar`.
- *.tar.bz2*, *.tbz* require `tar`.
- *.tar.gz*, *.tgz* require `tar` (optionally `pigz`).
- *.tar.bz2*, *.tbz* require `tar` (optionally `pbzip2`).
- *.tar.xz*, *.txz* require `tar` with *xz* support.
- *.tar.zma*, *.tlz* require `tar` with *lzma* support.
- *.tar* requires `tar`.
Expand All @@ -25,16 +26,21 @@ installed:
- *.xz* requires `unxz`.
- *.lzma* requires `unlzma`.
- *.Z* requires `uncompress`.
- *.zip* requires `unzip`.
- *.zip*, *.jar* requires `unzip`.
- *.rar* requires `unrar` or `rar`.
- *.7z* requires `7za`.
- *.deb* requires `ar`, `tar`.

Additionally, if `pigz' and/or `pbzip2` are installed, `archive` will use them over
their traditional counterparts, `gzip` and `bzip2` respectively, to take full advantage
of all available CPU cores for compression.

Authors
-------

*The authors of this module should be contacted via the [issue tracker][1].*

- [Sorin Ionescu](https://github.com/sorin-ionescu)
- [Matt Hamilton](https://github.com/Eriner)

[1]: https://github.com/sorin-ionescu/prezto/issues
2 changes: 1 addition & 1 deletion modules/archive/functions/_lsarchive
Expand Up @@ -10,4 +10,4 @@

_arguments \
'(-v --verbose)'{-v,--remove}'[verbose archive listing]' \
"*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|rar|7z)(-.)'" && return 0
"*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|jar|rar|7z)(-.)'" && return 0
2 changes: 1 addition & 1 deletion modules/archive/functions/_unarchive
Expand Up @@ -10,4 +10,4 @@

_arguments \
'(-r --remove)'{-r,--remove}'[remove archive]' \
"*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|rar|7z|deb)(-.)'" && return 0
"*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|jar|rar|7z|deb)(-.)'" && return 0
67 changes: 67 additions & 0 deletions modules/archive/functions/archive
@@ -0,0 +1,67 @@
#!/usr/bin/env zsh
#
# Creates archive file
#
# Authors:
# Matt Hamilton <m@tthamilton.com>
#

local archive_name dir_to_archive _gzip_bin _bzip2_bin

if (( $# != 2 )); then
cat >&2 <<EOF
usage: $0 [archive_name.zip] [/path/to/include/into/archive]
Where 'archive.zip' uses any of the following extensions:
.tar.gz, .tar.bz2, .tar.xz, .tar.lzma, .tar, .zip, .rar, .7z
There is no '-v' switch; all operations are verbose.
EOF
return 1
fi

# we are quitting (above) if there are not exactly 2 vars,
# so we don't need any argc check here.

# strip the path, just in case one is provided for some reason
archive_name="${1:t}"
# use absolute paths, and follow symlinks
dir_to_archive="${2}"

# if the directory doesn't exist, quit. Nothing to archive
if [[ ! -e "${dir_to_archive}" ]]; then
print "$0: file or directory not valid: ${dir_to_archive}" >&2
return 1
fi

# here, we check for dropin/multi-threaded replacements
# this should eventually be moved to modules/archive/init.zsh
# as a global alias
if (( $+commands[pigz] )); then
_gzip_bin='pigz'
else
_gzip_bin='gzip'
fi

if (( $+commands[pbzip2] )); then
_bzip2_bin='pbzip2'
else
_bzip2_bin='bzip2'
fi

case "${archive_name}" in
(*.tar.gz|*.tgz) tar -cvf "${archive_name}" --use-compress-program="${_gzip_bin}" "${dir_to_archive}" ;;
(*.tar.bz2|*.tbz|*.tbz2) tar -cvf "${archive_name}" --use-compress-program="${_bzip2_bin}" "${dir_to_archive}" ;;
(*.tar.xz|*.txz) tar -cvJf "${archive_name}" "${dir_to_archive}" ;;
(*.tar.lzma|*.tlz) tar -cvf "${archive_name}" --lzma "${dir_to_archive}" ;;
(*.tar) tar -cvf "${archive_name}" "${dir_to_archive}" ;;
(*.zip|*.jar) zip -r "${archive_name}" "${dir_to_archive}" ;;
(*.rar) rar a "${archive_name}" "${dir_to_archive}" ;;
(*.7z) 7za a "${archive_name}" "${dir_to_archive}" ;;
(*.gz) print "\n.gz is only useful for single files, and does not capture permissions. Use .tar.gz" ;;
(*.bz2) print "\n.bzip2 is only useful for single files, and does not capture permissions. Use .tar.bz2" ;;
(*.xz) print "\n.xz is only useful for single files, and does not capture permissions. Use .tar.xz" ;;
(*.lzma) print "\n.lzma is only useful for single files, and does not capture permissions. Use .tar.lzma" ;;
(*) print "\nunknown archive type for archive: ${archive_name}" ;;
esac
2 changes: 1 addition & 1 deletion modules/archive/functions/lsarchive
Expand Up @@ -40,7 +40,7 @@ while (( $# > 0 )); do
&& tar --lzma -t${verbose:+v}f "$1" \
|| lzcat "$1" | tar x${verbose:+v}f - ;;
(*.tar) tar t${verbose:+v}f "$1" ;;
(*.zip) unzip -l${verbose:+v} "$1" ;;
(*.zip|*.jar) unzip -l${verbose:+v} "$1" ;;
(*.rar) unrar &> /dev/null \
&& unrar ${${verbose:+v}:-l} "$1" \
|| rar ${${verbose:+v}:-l} "$1" ;;
Expand Down
2 changes: 1 addition & 1 deletion modules/archive/functions/unarchive
Expand Up @@ -54,7 +54,7 @@ while (( $# > 0 )); do
(*.xz) unxz "$1" ;;
(*.lzma) unlzma "$1" ;;
(*.Z) uncompress "$1" ;;
(*.zip) unzip "$1" -d $extract_dir ;;
(*.zip|*.jar) unzip "$1" -d $extract_dir ;;
(*.rar) unrar &> /dev/null \
&& unrar x -ad "$1" \
|| rar x -ad "$1" ;;
Expand Down
20 changes: 15 additions & 5 deletions modules/completion/init.zsh
Expand Up @@ -14,9 +14,6 @@ fi
# Add zsh-completions to $fpath.
fpath=("${0:h}/external/src" $fpath)

# Load and initialize the completion system ignoring insecure directories.
autoload -Uz compinit && compinit -i

#
# Options
#
Expand All @@ -27,9 +24,21 @@ setopt PATH_DIRS # Perform path search even on command names with slas
setopt AUTO_MENU # Show completion menu on a successive tab press.
setopt AUTO_LIST # Automatically list choices on ambiguous completion.
setopt AUTO_PARAM_SLASH # If completed parameter is a directory, add a trailing slash.
setopt EXTENDED_GLOB # Needed for file modification glob modifiers with compinit
unsetopt MENU_COMPLETE # Do not autoselect the first completion entry.
unsetopt FLOW_CONTROL # Disable start/stop characters in shell editor.

# Load and initialize the completion system ignoring insecure directories with a
# cache time of 20 hours, so it should almost always regenerate the first time a
# shell is opened each day.
autoload -Uz compinit
compfiles=(${ZDOTDIR:-$HOME}/.zcompdump(Nm-20))
if [[ $#compfiles > 0 ]]; then
compinit -i -C
else
compinit -i
fi

#
# Styles
#
Expand Down Expand Up @@ -66,8 +75,9 @@ zstyle ':completion:*' completer _complete _match _approximate
zstyle ':completion:*:match:*' original only
zstyle ':completion:*:approximate:*' max-errors 1 numeric

# Increase the number of errors based on the length of the typed word.
zstyle -e ':completion:*:approximate:*' max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3))numeric)'
# Increase the number of errors based on the length of the typed word. But make
# sure to cap (at 7) the max-errors to avoid hanging.
zstyle -e ':completion:*:approximate:*' max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3>7?7:($#PREFIX+$#SUFFIX)/3))numeric)'

# Don't complete unavailable commands.
zstyle ':completion:*:functions' ignored-patterns '(_*|pre(cmd|exec))'
Expand Down

0 comments on commit f9ae591

Please sign in to comment.