diff options
author | Tuowen Zhao <ztuowen@gmail.com> | 2018-06-09 13:05:26 -0400 |
---|---|---|
committer | Tuowen Zhao <ztuowen@gmail.com> | 2018-06-09 13:05:26 -0400 |
commit | 59e91cd97fcc3c406751f019215f957b36614022 (patch) | |
tree | 850cab9426806618e7e8a7a7b5c905a2be019e50 /plugins | |
parent | db38c7c3b2921783d955912262f87ee7dd8cd31b (diff) | |
parent | f461d21de1bd0c1394e57a2e3af69778692e4ba4 (diff) | |
download | zsh-59e91cd97fcc3c406751f019215f957b36614022.tar.gz zsh-59e91cd97fcc3c406751f019215f957b36614022.tar.bz2 zsh-59e91cd97fcc3c406751f019215f957b36614022.zip |
Merge branch 'master' of https://github.com/robbyrussell/oh-my-zsh
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/emacs/emacs.plugin.zsh | 2 | ||||
-rw-r--r-- | plugins/git/git.plugin.zsh | 2 | ||||
-rw-r--r-- | plugins/kubectl/kubectl.plugin.zsh | 14 | ||||
-rw-r--r-- | plugins/npm/README.md | 26 | ||||
-rw-r--r-- | plugins/npx/README.md | 18 | ||||
-rw-r--r-- | plugins/shrink-path/shrink-path.plugin.zsh | 16 | ||||
-rw-r--r-- | plugins/ssh-agent/README.md | 2 | ||||
-rw-r--r-- | plugins/transfer/README.md | 24 | ||||
-rw-r--r-- | plugins/transfer/transfer.plugin.zsh | 67 | ||||
-rw-r--r-- | plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh | 11 | ||||
-rw-r--r-- | plugins/vundle/vundle.plugin.zsh | 2 | ||||
-rw-r--r-- | plugins/xcode/README.md | 6 | ||||
-rw-r--r-- | plugins/xcode/xcode.plugin.zsh | 13 |
13 files changed, 180 insertions, 23 deletions
diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh index c102a5a1e..db0ab13af 100644 --- a/plugins/emacs/emacs.plugin.zsh +++ b/plugins/emacs/emacs.plugin.zsh @@ -10,7 +10,7 @@ # - Configuration changes made at runtime are applied to all frames. -if "$ZSH/tools/require_tool.sh" emacs 24 2>/dev/null ; then +if "$ZSH/tools/require_tool.sh" emacsclient 24 2>/dev/null ; then export EMACS_PLUGIN_LAUNCHER="$ZSH/plugins/emacs/emacsclient.sh" # set EDITOR if not already defined. diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index fd55be138..34598fb35 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -181,6 +181,8 @@ alias glgga='git log --graph --decorate --all' alias glgm='git log --graph --max-count=10' alias glo='git log --oneline --decorate' alias glol="git log --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'" +alias glod="git log --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'" +alias glods="git log --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short" alias glola="git log --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all" alias glog='git log --oneline --decorate --graph' alias gloga='git log --oneline --decorate --graph --all' diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh index ec1321d8b..c4e30dacd 100644 --- a/plugins/kubectl/kubectl.plugin.zsh +++ b/plugins/kubectl/kubectl.plugin.zsh @@ -1,9 +1,13 @@ -# Autocompletion for kubectl, the command line interface for Kubernetes -# -# Author: https://github.com/pstadler +if (( $+commands[kubectl] )); then + __KUBECTL_COMPLETION_FILE="${ZSH_CACHE_DIR}/kubectl_completion" -if [ $commands[kubectl] ]; then - source <(kubectl completion zsh) + if [[ ! -f $__KUBECTL_COMPLETION_FILE ]]; then + kubectl completion zsh >! $__KUBECTL_COMPLETION_FILE + fi + + [[ -f $__KUBECTL_COMPLETION_FILE ]] && source $__KUBECTL_COMPLETION_FILE + + unset __KUBECTL_COMPLETION_FILE fi # This command is used ALOT both below and in daily life diff --git a/plugins/npm/README.md b/plugins/npm/README.md new file mode 100644 index 000000000..202e2b0a4 --- /dev/null +++ b/plugins/npm/README.md @@ -0,0 +1,26 @@ +## npm plugin + +The npm plugin provides completion as well as adding many useful aliases. + +To use it, add npm to the plugins array of your zshrc file: +``` +plugins=(... npm) +``` + +## Aliases + +| Alias | Command | Descripton | +|:------ |:-----------------------------|:----------------------------------------------------------------| +| `npmg` | `npm i -g` | Install dependencies globally | +| `npmS` | `npm i -S` | Install and save to dependencies in your package.json | +| `npmD` | `npm i -D` | Install and save to dev-dependencies in your package.json | +| `npmE` | `PATH="$(npm bin)":"$PATH"` | Run command from node_modules folder based on current directory | +| `npmO` | `npm outdated` | Check which npm modules are outdated | +| `npmV` | `npm -v` | Check package versions | +| `npmL` | `npm list` | List installed packages | +| `npmL0` | `npm ls --depth=0` | List top-level installed packages | +| `npmst` | `npm start` | Run npm start | +| `npmt` | `npm test` | Run npm test | +| `npmR` | `npm run` | Run npm scripts | +| `npmP` | `npm publish` | Run npm publish | +| `npmI` | `npm init` | Run npm init | diff --git a/plugins/npx/README.md b/plugins/npx/README.md index 2c94e4515..1c052930b 100644 --- a/plugins/npx/README.md +++ b/plugins/npx/README.md @@ -11,7 +11,21 @@ This plugin automatically registers npx command-not-found handler if `npx` exist plugins=(.... npx) ``` -- Globally install npx binary (you need node.js installed too!) +- Globally install npx binary (npx will be auto installed with recent versions of Node.js) ```bash sudo npm install -g npx -```
\ No newline at end of file +``` + +## Note + +The shell auto-fallback doesn't auto-install plain packages. In order to get it to install something, you need to add `@`: + +``` +➜ jasmine@latest # or just `jasmine@` +npx: installed 13 in 1.896s +Randomized with seed 54385 +Started +``` + +It does it this way so folks using the fallback don't accidentally try to install regular typoes. + diff --git a/plugins/shrink-path/shrink-path.plugin.zsh b/plugins/shrink-path/shrink-path.plugin.zsh index 6dd6a930f..29e6f0deb 100644 --- a/plugins/shrink-path/shrink-path.plugin.zsh +++ b/plugins/shrink-path/shrink-path.plugin.zsh @@ -88,24 +88,18 @@ shrink_path () { if (( named )) { for part in ${(k)nameddirs}; { - [[ $dir == ${nameddirs[$part]}(/*|) ]] && dir=${dir/${nameddirs[$part]}/\~$part} + [[ $dir == ${nameddirs[$part]}(/*|) ]] && dir=${dir/#${nameddirs[$part]}/\~$part} } } - (( tilde )) && dir=${dir/$HOME/\~} + (( tilde )) && dir=${dir/#$HOME/\~} tree=(${(s:/:)dir}) ( - # unset chpwd_functions since we'll be calling `cd` and don't - # want any side-effects (eg., if the user was using auto-ls) - chpwd_functions=() - # unset chpwd since even if chpwd_functions is (), zsh will - # attempt to execute chpwd - unfunction chpwd 2> /dev/null if [[ $tree[1] == \~* ]] { - cd ${~tree[1]} + cd -q ${~tree[1]} result=$tree[1] shift tree } else { - cd / + cd -q / } for dir in $tree; { if (( lastfull && $#tree == 1 )) { @@ -122,7 +116,7 @@ shrink_path () { (( short )) && break done result+="/$part" - cd $dir + cd -q $dir shift tree } echo ${result:-/} diff --git a/plugins/ssh-agent/README.md b/plugins/ssh-agent/README.md index 00af42f01..85d8c8a85 100644 --- a/plugins/ssh-agent/README.md +++ b/plugins/ssh-agent/README.md @@ -11,6 +11,8 @@ plugins=(... ssh-agent) ## Instructions +**IMPORTANT: put these settings _before_ the line that sources oh-my-zsh** + To enable **agent forwarding support** add the following to your zshrc file: ```zsh diff --git a/plugins/transfer/README.md b/plugins/transfer/README.md new file mode 100644 index 000000000..5fa064445 --- /dev/null +++ b/plugins/transfer/README.md @@ -0,0 +1,24 @@ +# `transfer` plugin + +[`transfer.sh`](https://transfer.sh) is an easy to use file sharing service from the command line + +## Usage + +Add `transfer` to your plugins array in your zshrc file: +```zsh +plugins=(... transfer) +``` + +Then you can: + +- transfer a file: + +```zsh +transfer file.txt +``` + +- transfer a whole directory (it will be automatically compressed): + +```zsh +transfer directory/ +``` diff --git a/plugins/transfer/transfer.plugin.zsh b/plugins/transfer/transfer.plugin.zsh new file mode 100644 index 000000000..7a7cd85ec --- /dev/null +++ b/plugins/transfer/transfer.plugin.zsh @@ -0,0 +1,67 @@ +# transfer.sh Easy file sharing from the command line +# transfer Plugin +# Usage Example : +# > transfer file.txt +# > transfer directory/ + + + +# Author: +# Remco Verhoef <remco@dutchcoders.io> +# https://gist.github.com/nl5887/a511f172d3fb3cd0e42d +# Modified to use tar command instead of zip +# + +curl --version 2>&1 > /dev/null +if [ $? -ne 0 ]; then + echo "Could not find curl." + return 1 +fi + +transfer() { + # check arguments + if [ $# -eq 0 ]; + then + echo "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md" + return 1 + fi + + # get temporarily filename, output is written to this file show progress can be showed + tmpfile=$( mktemp -t transferXXX ) + + # upload stdin or file + file=$1 + + if tty -s; + then + basefile=$(basename "$file" | sed -e 's/[^a-zA-Z0-9._-]/-/g') + + if [ ! -e $file ]; + then + echo "File $file doesn't exists." + return 1 + fi + + if [ -d $file ]; + then + echo $file + # tar directory and transfer + tarfile=$( mktemp -t transferXXX.tar.gz ) + cd $(dirname $file) && tar -czf $tarfile $(basename $file) + curl --progress-bar --upload-file "$tarfile" "https://transfer.sh/$basefile.tar.gz" >> $tmpfile + rm -f $tarfile + else + # transfer file + curl --progress-bar --upload-file "$file" "https://transfer.sh/$basefile" >> $tmpfile + fi + else + # transfer pipe + curl --progress-bar --upload-file "-" "https://transfer.sh/$file" >> $tmpfile + fi + + # cat output link + cat $tmpfile + + # cleanup + rm -f $tmpfile +}
\ No newline at end of file diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh index 484f18c91..e27c6bb76 100644 --- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh +++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh @@ -1,6 +1,15 @@ virtualenvwrapper='virtualenvwrapper.sh' +virtualenvwrapper_lazy='virtualenvwrapper_lazy.sh' -if (( $+commands[$virtualenvwrapper] )); then +if (( $+commands[$virtualenvwrapper_lazy] )); then + function { + setopt local_options + unsetopt equals + virtualenvwrapper=${${virtualenvwrapper_lazy}:c} + source ${${virtualenvwrapper_lazy}:c} + [[ -z "$WORKON_HOME" ]] && WORKON_HOME="$HOME/.virtualenvs" + } +elif (( $+commands[$virtualenvwrapper] )); then function { setopt local_options unsetopt equals diff --git a/plugins/vundle/vundle.plugin.zsh b/plugins/vundle/vundle.plugin.zsh index 0f071597a..c84cacd0e 100644 --- a/plugins/vundle/vundle.plugin.zsh +++ b/plugins/vundle/vundle.plugin.zsh @@ -6,7 +6,7 @@ function vundle-init () { if [ ! -d ~/.vim/bundle/Vundle.vim/.git ] && [ ! -f ~/.vim/bundle/Vundle.vim/.git ] then - git clone git://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim + git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim echo "\n\tRead about vim configuration for vundle at https://github.com/VundleVim/Vundle.vim\n" fi } diff --git a/plugins/xcode/README.md b/plugins/xcode/README.md index c12ce047f..37f882638 100644 --- a/plugins/xcode/README.md +++ b/plugins/xcode/README.md @@ -19,7 +19,7 @@ plugins=(... xcode) | xcdd | Purge all temporary build information | rm -rf ~/Library/Developer/Xcode/DerivedData/* | | xcp | Show currently selected Xcode directory | xcode-select --print-path | | xcsel | Select different Xcode directory by path | sudo xcode-select --switch | - +| xx | Opens the files listed in Xcode | open -a "Xcode.app" | ## Functions @@ -29,6 +29,10 @@ plugins=(... xcode) Opens the current directory in Xcode as an Xcode project. This will open one of the `.xcworkspace` and `.xcodeproj` files that it can find in the current working directory. You can also specify a directory to look in for the Xcode files. Returns 1 if it didn't find any relevant files. +### `xx` + +Opens the files listed in Xcode, multiple files are opened in a multi-file browser. + ### `simulator` Opens the iOS Simulator from your command line, dependent on whichever is the active developer directory for Xcode. (That is, it respects the `xcsel` setting.) diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh index f711c39fb..b46e05f2f 100644 --- a/plugins/xcode/xcode.plugin.zsh +++ b/plugins/xcode/xcode.plugin.zsh @@ -27,6 +27,17 @@ function xc { fi } +# Opens a file or files in the Xcode IDE. Multiple files are opened in multi-file browser +# original author: @possen +function xx { + if [[ $# == 0 ]]; then + echo "Specify file(s) to open in xcode." + return 1 + fi + echo "${xcode_files}" + open -a "Xcode.app" "$@" +} + # "XCode-SELect by Version" - select Xcode by just version number # Uses naming convention: # - different versions of Xcode are named Xcode-<version>.app or stored @@ -70,7 +81,7 @@ function xcselv { function _omz_xcode_print_xcselv_usage { cat << EOF >&2 -Usage: +Usage: xcselv <version> xcselv [options] |