diff options
Diffstat (limited to 'plugins')
58 files changed, 1250 insertions, 509 deletions
diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 0895cfb3a..231ac5ad2 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -1,27 +1,35 @@ -# AWS profile selection - -function agp { +function agp() { echo $AWS_PROFILE } -function asp { - export AWS_DEFAULT_PROFILE=$1 - export AWS_PROFILE=$1 - export AWS_EB_PROFILE=$1 - +# AWS profile selection +function asp() { if [[ -z "$1" ]]; then + unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE echo AWS profile cleared. + return + fi + + local available_profiles=($(aws_profiles)) + if [[ -z "${available_profiles[(r)$1]}" ]]; then + echo "${fg[red]}Profile '$1' not found in '${AWS_CONFIG_FILE:-$HOME/.aws/config}'" >&2 + echo "Available profiles: ${(j:, :)available_profiles:-no profiles found}${reset_color}" >&2 + return 1 fi + + export AWS_DEFAULT_PROFILE=$1 + export AWS_PROFILE=$1 + export AWS_EB_PROFILE=$1 } -function aws_change_access_key { - if [[ -z "$1" ]] then +function aws_change_access_key() { + if [[ -z "$1" ]]; then echo "usage: $0 <profile>" return 1 fi echo Insert the credentials when asked. - asp "$1" + asp "$1" || return 1 aws iam create-access-key aws configure --profile "$1" @@ -30,14 +38,17 @@ function aws_change_access_key { aws iam list-access-keys } -function aws_profiles { - reply=($(grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/')) +function aws_profiles() { + [[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1 + grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/' } -compctl -K aws_profiles asp aws_change_access_key +function _aws_profiles() { + reply=($(aws_profiles)) +} +compctl -K _aws_profiles asp aws_change_access_key # AWS prompt - function aws_prompt_info() { [[ -z $AWS_PROFILE ]] && return echo "${ZSH_THEME_AWS_PREFIX:=<aws:}${AWS_PROFILE}${ZSH_THEME_AWS_SUFFIX:=>}" @@ -50,7 +61,7 @@ fi # Load awscli completions -_awscli-homebrew-installed() { +function _awscli-homebrew-installed() { # check if Homebrew is installed (( $+commands[brew] )) || return 1 @@ -67,11 +78,18 @@ _awscli-homebrew-installed() { # get aws_zsh_completer.sh location from $PATH _aws_zsh_completer_path="$commands[aws_zsh_completer.sh]" -# otherwise check if installed via Homebrew -if [[ -z $_aws_zsh_completer_path ]] && _awscli-homebrew-installed; then - _aws_zsh_completer_path=$_brew_prefix/libexec/bin/aws_zsh_completer.sh -else - _aws_zsh_completer_path=/usr/share/zsh/site-functions/aws_zsh_completer.sh +# otherwise check common locations +if [[ -z $_aws_zsh_completer_path ]]; then + # Homebrew + if _awscli-homebrew-installed; then + _aws_zsh_completer_path=$_brew_prefix/libexec/bin/aws_zsh_completer.sh + # Ubuntu + elif [[ -e /usr/share/zsh/vendor-completions/_awscli ]]; then + _aws_zsh_completer_path=/usr/share/zsh/vendor-completions/_awscli + # RPM + else + _aws_zsh_completer_path=/usr/share/zsh/site-functions/aws_zsh_completer.sh + fi fi [[ -r $_aws_zsh_completer_path ]] && source $_aws_zsh_completer_path diff --git a/plugins/catimg/catimg.plugin.zsh b/plugins/catimg/catimg.plugin.zsh index 5f58ecde3..ca46444cc 100644 --- a/plugins/catimg/catimg.plugin.zsh +++ b/plugins/catimg/catimg.plugin.zsh @@ -4,7 +4,7 @@ # # # Ouput the content of an image to the stdout using the 256 colors of the # # terminal. # -# Github: https://github.com/posva/catimg # +# GitHub: https://github.com/posva/catimg # ################################################################################ diff --git a/plugins/catimg/catimg.sh b/plugins/catimg/catimg.sh index 83ccf6a95..713a03291 100644 --- a/plugins/catimg/catimg.sh +++ b/plugins/catimg/catimg.sh @@ -4,7 +4,7 @@ # # # Ouput the content of an image to the stdout using the 256 colors of the # # terminal. # -# Github: https://github.com/posva/catimg # +# GitHub: https://github.com/posva/catimg # ################################################################################ function help() { diff --git a/plugins/colorize/colorize.plugin.zsh b/plugins/colorize/colorize.plugin.zsh index 4e383867a..565ba5a36 100644 --- a/plugins/colorize/colorize.plugin.zsh +++ b/plugins/colorize/colorize.plugin.zsh @@ -47,7 +47,7 @@ colorize_via_pygmentize_less() ( trap 'cleanup' EXIT HUP TERM INT while (( $# != 0 )); do #TODO: filter out less opts - tmp_file="$(mktemp --tmpdir "tmp.colorize.XXXX.$(sed 's/\//./g' <<< "$1")")" + tmp_file="$(mktemp -t "tmp.colorize.XXXX.$(sed 's/\//./g' <<< "$1")")" tmp_files+=("$tmp_file") colorize_via_pygmentize "$1" > "$tmp_file" shift 1 diff --git a/plugins/debian/README.md b/plugins/debian/README.md index a676674dc..da5675c66 100644 --- a/plugins/debian/README.md +++ b/plugins/debian/README.md @@ -1,75 +1,85 @@ # debian -This plugin provides debian related zsh aliases. +This plugin provides Debian-related aliases and functions for zsh. + To use it add `debian` to the plugins array in your zshrc file. ```zsh plugins=(... debian) ``` +## Settings + +- `$apt_pref`: use apt or aptitude if installed, fallback is apt-get. +- `$apt_upgr`: use upgrade or safe-upgrade (for aptitude). + +Set `$apt_pref` and `$apt_upgr` to whatever command you want (before sourcing Oh My Zsh) to override this behavior. + ## Common Aliases -| Alias | Command | Description | -| -------- | ------------------------------------------------------------------------------|--------------------------------------------------------------------------- | -| `age` | apt-get | Command line tool for handling packages | -| `api` | aptitude | Same functionality as `apt-get`, provides extra options while installation | -| `acs` | apt-cache search | Command line tool for searching apt software package cache | -| `aps` | aptitude search | Searches installed packages using aptitude | -| `as` | aptitude -F \"* %p -> %d \n(%v/%V)\" \ -no-gui --disable-columns search | - | -| `afs` | apt-file search --regexp | Search file in packages | -| `asrc` | apt-get source | Fetch source packages through `apt-get` | -| `app` | apt-cache policy | Displays priority of package sources | +| Alias | Command | Description | +| ------ | ---------------------------------------------------------------------- | ---------------------------------------------------------- | +| `age` | `apt-get` | Command line tool for handling packages | +| `api` | `aptitude` | Same functionality as `apt-get`, provides extra options | +| `acs` | `apt-cache search` | Command line tool for searching apt software package cache | +| `aps` | `aptitude search` | Searches installed packages using aptitude | +| `as` | `aptitude -F '* %p -> %d \n(%v/%V)' --no-gui --disable-columns search` | Print searched packages using a custom format | +| `afs` | `apt-file search --regexp` | Search file in packages | +| `asrc` | `apt-get source` | Fetch source packages through `apt-get` | +| `app` | `apt-cache policy` | Displays priority of package sources | ## Superuser Operations Aliases -| Alias | Command | Description | -| -------- | -------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------- | -| `aac` | sudo $apt_pref autoclean | Clears out the local repository of retrieved package files | -| `abd` | sudo $apt_pref build-dep | Installs all dependencies for building packages | -| `ac` | sudo $apt_pref clean | Clears out the local repository of retrieved package files except lock files | -| `ad` | sudo $apt_pref update | Updates the package lists for upgrades for packages | -| `adg` | sudo $apt_pref update && sudo $apt_pref $apt_upgr | Update and upgrade packages | -| `adu` | sudo $apt_pref update && sudo $apt_pref dist-upgrade | Smart upgrade that handles dependencies | -| `afu` | sudo apt-file update | Update the files in packages | -| `au` | sudo $apt_pref $apt_upgr | - | -| `ai` | sudo $apt_pref install | Command-line tool to install package | -| `ail` | sed -e 's/ */ /g' -e 's/ *//' | cut -s -d ' ' -f 1 | "' xargs sudo $apt_pref install | Install all packages given on the command line while using only the first word of each line | -| `ap` | sudo $apt_pref purge | Removes packages along with configuration files | -| `ar` | sudo $apt_pref remove | Removes packages, keeps the configuration files | -| `ads` | sudo apt-get dselect-upgrade | Installs packages from list and removes all not in the list | -| `dia` | sudo dpkg -i ./*.deb | Install all .deb files in the current directory | -| `di` | sudo dpkg -i | Install all .deb files in the current directory | -| `kclean` | sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) ?not(~n`uname -r`)) | Remove ALL kernel images and headers EXCEPT the one in use | - -- `$apt_pref` - Use apt or aptitude if installed, fallback is apt-get. -- `$apt_upgr` - Use upgrade. +| Alias | Command | Description | +| -------- | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | +| `aac` | `sudo $apt_pref autoclean` | Clears out the local repository of retrieved package files | +| `abd` | `sudo $apt_pref build-dep` | Installs all dependencies for building packages | +| `ac` | `sudo $apt_pref clean` | Clears out the local repository of retrieved package files except lock files | +| `ad` | `sudo $apt_pref update` | Updates the package lists for upgrades for packages | +| `adg` | `sudo $apt_pref update && sudo $apt_pref $apt_upgr` | Update and upgrade packages | +| `adu` | `sudo $apt_pref update && sudo $apt_pref dist-upgrade` | Smart upgrade that handles dependencies | +| `afu` | `sudo apt-file update` | Update the files in packages | +| `au` | `sudo $apt_pref $apt_upgr` | Install package upgrades | +| `ai` | `sudo $apt_pref install` | Command-line tool to install package | +| `ail` | `sed -e 's/ */ /g' -e 's/ *//' \| cut -s -d ' ' -f 1 \| xargs sudo $apt_pref install` | Install all packages given on the command line while using only the first word of each line | +| `ap` | `sudo $apt_pref purge` | Removes packages along with configuration files | +| `ar` | `sudo $apt_pref remove` | Removes packages, keeps the configuration files | +| `ads` | `sudo apt-get dselect-upgrade` | Installs packages from list and removes all not in the list | +| `dia` | `sudo dpkg -i ./*.deb` | Install all .deb files in the current directory | +| `di` | `sudo dpkg -i` | Install all .deb files in the current directory | +| `kclean` | `sudo aptitude remove -P ?and(~i~nlinux-(ima\|hea) ?not(~n$(uname -r)))` | Remove ALL kernel images and headers EXCEPT the one in use | ## Aliases - Commands using `su` -| Alias | Command | -| -------- | ------------------------------------------------------------------------------| -| `aac` | su -ls \'$apt_pref autoclean\' root | -| `ac` | su -ls \'$apt_pref clean\' root | -| `ad` | su -lc \'$apt_pref update\' root | -| `adg` | su -lc \'$apt_pref update && aptitude $apt_upgr\' root | -| `adu` | su -lc \'$apt_pref update && aptitude dist-upgrade\' root | -| `afu` | su -lc "apt-file update | -| `ag` | su -lc \'$apt_pref $apt_upgr\' root | -| `dia` | su -lc "dpkg -i ./*.deb" root | +| Alias | Command | +| ----- | --------------------------------------------------------- | +| `aac` | `su -ls "$apt_pref autoclean" root` | +| `ac` | `su -ls "$apt_pref clean" root` | +| `ad` | `su -lc "$apt_pref update" root` | +| `adg` | `su -lc "$apt_pref update && aptitude $apt_upgr" root` | +| `adu` | `su -lc "$apt_pref update && aptitude dist-upgrade" root` | +| `afu` | `su -lc "apt-file update"` | +| `au` | `su -lc "$apt_pref $apt_upgr" root` | +| `dia` | `su -lc "dpkg -i ./*.deb" root` | ## Miscellaneous Aliases -| Alias | Command | Description | -| -------- | -------------------------------------------------|---------------------------------------- | -| `allpkgs`| aptitude search -F "%p" --disable-columns ~i | Display all installed packages | -| `mydeb` | time dpkg-buildpackage -rfakeroot -us -uc | Create a basic .deb package | +| Alias | Command | Description | +| --------- | ---------------------------------------------- | ------------------------------ | +| `allpkgs` | `aptitude search -F "%p" --disable-columns ~i` | Display all installed packages | +| `mydeb` | `time dpkg-buildpackage -rfakeroot -us -uc` | Create a basic .deb package | ## Functions -| Fucntion | Description | -|-----------------------|-------------------------------------------------------------------------------| -| `apt-copy` | Create a simple script that can be used to 'duplicate' a system | -| `apt-history` | Displays apt history for a command | -| `kerndeb` | Builds kernel packages | -| `apt-list-packages` | List packages by size | +| Function | Description | +| ------------------- | --------------------------------------------------------------- | +| `apt-copy` | Create a simple script that can be used to 'duplicate' a system | +| `apt-history` | Displays apt history for a command | +| `kerndeb` | Builds kernel packages | +| `apt-list-packages` | List packages by size | + +## Authors +- [@AlexBio](https://github.com/AlexBio) +- [@dbb](https://github.com/dbb) +- [@Mappleconfusers](https://github.com/Mappleconfusers) diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh index 654b692d2..be4062ebf 100644 --- a/plugins/debian/debian.plugin.zsh +++ b/plugins/debian/debian.plugin.zsh @@ -1,25 +1,21 @@ -# Authors: -# https://github.com/AlexBio -# https://github.com/dbb -# https://github.com/Mappleconfusers -# -# Debian-related zsh aliases and functions for zsh - # Use apt or aptitude if installed, fallback is apt-get # You can just set apt_pref='apt-get' to override it. -if [[ -e $( which -p apt 2>&1 ) ]]; then - apt_pref='apt' - apt_upgr='upgrade' -elif [[ -e $( which -p aptitude 2>&1 ) ]]; then - apt_pref='aptitude' - apt_upgr='safe-upgrade' -else - apt_pref='apt-get' - apt_upgr='upgrade' + +if [[ -z $apt_pref || -z $apt_upgr ]]; then + if [[ -e $commands[apt] ]]; then + apt_pref='apt' + apt_upgr='upgrade' + elif [[ -e $commands[aptitude] ]]; then + apt_pref='aptitude' + apt_upgr='safe-upgrade' + else + apt_pref='apt-get' + apt_upgr='upgrade' + fi fi # Use sudo by default if it's installed -if [[ -e $( which -p sudo 2>&1 ) ]]; then +if [[ -e $commands[sudo] ]]; then use_sudo=1 fi @@ -32,8 +28,7 @@ alias api='aptitude' # Some self-explanatory aliases alias acs="apt-cache search" alias aps='aptitude search' -alias as="aptitude -F \"* %p -> %d \n(%v/%V)\" \ - --no-gui --disable-columns search" # search package +alias as="aptitude -F '* %p -> %d \n(%v/%V)' --no-gui --disable-columns search" # apt-file alias afs='apt-file search --regexp' @@ -46,49 +41,48 @@ alias app='apt-cache policy' # superuser operations ###################################################### if [[ $use_sudo -eq 1 ]]; then # commands using sudo ####### - alias aac='sudo $apt_pref autoclean' - alias abd='sudo $apt_pref build-dep' - alias ac='sudo $apt_pref clean' - alias ad='sudo $apt_pref update' - alias adg='sudo $apt_pref update && sudo $apt_pref $apt_upgr' - alias adu='sudo $apt_pref update && sudo $apt_pref dist-upgrade' - alias afu='sudo apt-file update' - alias au='sudo $apt_pref $apt_upgr' - alias ai='sudo $apt_pref install' + alias aac="sudo $apt_pref autoclean" + alias abd="sudo $apt_pref build-dep" + alias ac="sudo $apt_pref clean" + alias ad="sudo $apt_pref update" + alias adg="sudo $apt_pref update && sudo $apt_pref $apt_upgr" + alias adu="sudo $apt_pref update && sudo $apt_pref dist-upgrade" + alias afu="sudo apt-file update" + alias au="sudo $apt_pref $apt_upgr" + alias ai="sudo $apt_pref install" # Install all packages given on the command line while using only the first word of each line: # acs ... | ail - alias ail="sed -e 's/ */ /g' -e 's/ *//' | cut -s -d ' ' -f 1 | "' xargs sudo $apt_pref install' - alias ap='sudo $apt_pref purge' - alias ar='sudo $apt_pref remove' + alias ail="sed -e 's/ */ /g' -e 's/ *//' | cut -s -d ' ' -f 1 | xargs sudo $apt_pref install" + alias ap="sudo $apt_pref purge" + alias ar="sudo $apt_pref remove" # apt-get only - alias ads='sudo apt-get dselect-upgrade' + alias ads="sudo apt-get dselect-upgrade" # Install all .deb files in the current directory. # Warning: you will need to put the glob in single quotes if you use: # glob_subst - alias dia='sudo dpkg -i ./*.deb' - alias di='sudo dpkg -i' + alias dia="sudo dpkg -i ./*.deb" + alias di="sudo dpkg -i" # Remove ALL kernel images and headers EXCEPT the one in use - alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) \ - ?not(~n`uname -r`))' + alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) ?not(~n$(uname -r)))' # commands using su ######### else - alias aac='su -ls \'$apt_pref autoclean\' root' + alias aac="su -ls '$apt_pref autoclean' root" abd() { cmd="su -lc '$apt_pref build-dep $@' root" print "$cmd" eval "$cmd" } - alias ac='su -ls \'$apt_pref clean\' root' - alias ad='su -lc \'$apt_pref update\' root' - alias adg='su -lc \'$apt_pref update && aptitude $apt_upgr\' root' - alias adu='su -lc \'$apt_pref update && aptitude dist-upgrade\' root' - alias afu='su -lc "apt-file update"' - alias ag='su -lc \'$apt_pref $apt_upgr\' root' + alias ac="su -ls '$apt_pref clean' root" + alias ad="su -lc '$apt_pref update' root" + alias adg="su -lc '$apt_pref update && aptitude $apt_upgr' root" + alias adu="su -lc '$apt_pref update && aptitude dist-upgrade' root" + alias afu="su -lc '$apt-file update'" + alias au="su -lc '$apt_pref $apt_upgr' root" ai() { cmd="su -lc 'aptitude -P install $@' root" print "$cmd" @@ -111,8 +105,7 @@ else alias di='su -lc "dpkg -i" root' # Remove ALL kernel images and headers EXCEPT the one in use - alias kclean='su -lc '\''aptitude remove -P ?and(~i~nlinux-(ima|hea) \ - ?not(~n`uname -r`))'\'' root' + alias kclean='su -lc "aptitude remove -P ?and(~i~nlinux-(ima|hea) ?not(~n$(uname -r)))" root' fi # Completion ################################################################ @@ -126,11 +119,11 @@ apt_pref_compdef() { f="_apt_pref_${2}" eval "function ${f}() { - shift words; - service=\"\$apt_pref\"; - words=(\"\$apt_pref\" '$2' \$words); - ((CURRENT++)) - test \"\${apt_pref}\" = 'aptitude' && _aptitude || _apt + shift words; + service=\"\$apt_pref\"; + words=(\"\$apt_pref\" '$2' \$words); + ((CURRENT++)) + test \"\${apt_pref}\" = 'aptitude' && _aptitude || _apt }" compdef "$f" "$1" @@ -141,7 +134,7 @@ apt_pref_compdef abd "build-dep" apt_pref_compdef ac "clean" apt_pref_compdef ad "update" apt_pref_compdef afu "update" -apt_pref_compdef ag "$apt_upgr" +apt_pref_compdef au "$apt_upgr" apt_pref_compdef ai "install" apt_pref_compdef ail "install" apt_pref_compdef ap "purge" @@ -213,7 +206,7 @@ kerndeb () { # temporarily unset MAKEFLAGS ( '-j3' will fail ) MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' ) print '$MAKEFLAGS set to '"'$MAKEFLAGS'" - appendage='-custom' # this shows up in $ (uname -r ) + appendage='-custom' # this shows up in $(uname -r ) revision=$(date +"%Y%m%d") # this shows up in the .deb file name make-kpkg clean diff --git a/plugins/django/django.plugin.zsh b/plugins/django/django.plugin.zsh index 29a51d29d..86558ff2e 100644 --- a/plugins/django/django.plugin.zsh +++ b/plugins/django/django.plugin.zsh @@ -154,7 +154,7 @@ _managepy-makemessages(){ "--no-default-ignore[Don't ignore the common glob-style patterns 'CVS', '.*', '*~' and '*.pyc'.]" \ "--no-wrap[Don't break long message lines into several lines.]" \ "--no-location[Don't write '#: filename:line' lines.]" \ - '--no-obsolete[emove obsolete message strings.]' \ + '--no-obsolete[Remove obsolete message strings.]' \ '--keep-pot[Keep .pot file after making messages.]' \ $nul_args && ret=0 } diff --git a/plugins/dnote/README.md b/plugins/dnote/README.md new file mode 100644 index 000000000..e1b9b7044 --- /dev/null +++ b/plugins/dnote/README.md @@ -0,0 +1,51 @@ +# Dnote Plugin + +This plugin adds auto-completion for [Dnote](https://dnote.io) project. + +To use it, add `dnote` to the plugins array in your zshrc file: + +```zsh +plugins=(dnote) +``` + +## Usage + +At the basic level, this plugin completes all Dnote commands. + +```zsh +$ dnote a(press <TAB> here) +``` + +would result in: + +```zsh +$ dnote add +``` + +For some commands, this plugin dynamically suggests matching book names. + +For instance, if you have three books that begin with 'j': 'javascript', 'job', 'js', + +```zsh +$ dnote view j(press <TAB> here) +``` + +would result in: + +```zsh +$ dnote v j +javascript job js +``` + +As another example, + +```zsh +$ dnote edit ja(press <TAB> here) +``` + +would result in: + + +```zsh +$ dnote v javascript +`````` diff --git a/plugins/dnote/_dnote b/plugins/dnote/_dnote new file mode 100644 index 000000000..c8b33486a --- /dev/null +++ b/plugins/dnote/_dnote @@ -0,0 +1,39 @@ +#compdef dnote + +local -a _1st_arguments + +_1st_arguments=( + 'add:add a new note' + 'view:list books, notes, or view a content' + 'edit:edit a note or a book' + 'remove:remove a note or a book' + 'find:find notes by keywords' + 'sync:sync data with the server' + 'login:login to the dnote server' + 'logout:logout from the dnote server' + 'version:print the current version' + 'help:get help about any command' +) + +get_booknames() { + local names=$(dnote view --name-only) + local -a ret + + while read -r line; do + ret+=("${line}") + done <<< "$names" + + echo "$ret" +} + +if (( CURRENT == 2 )); then + _describe -t commands "dnote subcommand" _1st_arguments + return +elif (( CURRENT == 3 )); then + case "$words[2]" in + v|view|a|add) + _alternative \ + "names:book names:($(get_booknames))" + esac +fi + diff --git a/plugins/dotenv/README.md b/plugins/dotenv/README.md index e880e9d69..cac552485 100644 --- a/plugins/dotenv/README.md +++ b/plugins/dotenv/README.md @@ -32,6 +32,17 @@ PORT=3001 ``` You can even mix both formats, although it's probably a bad idea. +### ZSH_DOTENV_FILE + +You can also modify the name of the file to be loaded with the variable `ZSH_DOTENV_FILE`. +If the variable isn't set, the plugin will default to use `.env`. +For example, this will make the plugin look for files named `.dotenv` and load them: + +``` +# in ~/.zshrc, before Oh My Zsh is sourced: +ZSH_DOTENV_FILE=.dotenv +``` + ## Version Control **It's strongly recommended to add `.env` file to `.gitignore`**, because usually it contains sensitive information such as your credentials, secret keys, passwords etc. You don't want to commit this file, it's supposed to be local only. diff --git a/plugins/dotenv/dotenv.plugin.zsh b/plugins/dotenv/dotenv.plugin.zsh index b701b5596..89763d0ee 100644 --- a/plugins/dotenv/dotenv.plugin.zsh +++ b/plugins/dotenv/dotenv.plugin.zsh @@ -1,13 +1,13 @@ source_env() { - if [[ -f .env ]]; then + if [[ -f $ZSH_DOTENV_FILE ]]; then # test .env syntax - zsh -fn .env || echo 'dotenv: error when sourcing `.env` file' >&2 + zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2 if [[ -o a ]]; then - source .env + source $ZSH_DOTENV_FILE else set -a - source .env + source $ZSH_DOTENV_FILE set +a fi fi @@ -16,4 +16,8 @@ source_env() { autoload -U add-zsh-hook add-zsh-hook chpwd source_env +if [[ -z $ZSH_DOTENV_FILE ]]; then + ZSH_DOTENV_FILE=.env +fi + source_env diff --git a/plugins/emotty/emotty.plugin.zsh b/plugins/emotty/emotty.plugin.zsh index b0d24c322..e288b5cfb 100644 --- a/plugins/emotty/emotty.plugin.zsh +++ b/plugins/emotty/emotty.plugin.zsh @@ -25,8 +25,14 @@ emotty_default_set=emoji function emotty() { # Use emotty set defined by user, fallback to default local emotty=${_emotty_sets[${emotty_set:-$emotty_default_set}]} - # Parse $TTY number, normalizing it to an emotty set index - (( tty = (${TTY##/dev/tty} % ${#${=emotty}}) + 1 )) + + # Parse tty number via prompt expansion. %l equals: + # - N if tty = /dev/ttyN + # - pts/N if tty = /dev/pts/N + local tty = ${${(%):-%l}##pts/} + # Normalize it to an emotty set index + (( tty = (tty % ${#${=emotty}}) + 1 )) + local character_name=${${=emotty}[tty]} echo "${emoji[${character_name}]}${emoji2[emoji_style]}" } diff --git a/plugins/fasd/fasd.plugin.zsh b/plugins/fasd/fasd.plugin.zsh index 36a0428a7..ec2e5183a 100644 --- a/plugins/fasd/fasd.plugin.zsh +++ b/plugins/fasd/fasd.plugin.zsh @@ -6,7 +6,7 @@ if [ $commands[fasd] ]; then # check if fasd is installed source "$fasd_cache" unset fasd_cache - alias v="f -e \"$EDITOR\"" + alias v='f -e "$EDITOR"' alias o='a -e xdg-open' alias j='zz' fi diff --git a/plugins/frontend-search/README.md b/plugins/frontend-search/README.md index f06e79102..bf76902fd 100644 --- a/plugins/frontend-search/README.md +++ b/plugins/frontend-search/README.md @@ -1,9 +1,8 @@ -## Introduction ## +## Introduction > Searches for your frontend web development made easier - -## Installation ## +## Installation Open your `~/.zshrc` file and enable the `frontend-search` plugin: @@ -13,53 +12,59 @@ plugins=( ... frontend-search) ``` - -## Usage ## +## Usage You can use the frontend-search plugin in these two forms: -* `frontend <context> <term> [more terms if you want]` -* `<context> <term> [more terms if you want]` +- `frontend <context> <term> [more terms if you want]` +- `<context> <term> [more terms if you want]` For example, these two are equivalent: ```zsh -$ frontend angularjs dependency injection -$ angularjs dependency injection +$ angular dependency injection +# Will turn into ... +$ frontend angular dependency injection ``` Available search contexts are: -| context | URL | -|---------------|--------------------------------------------------------------------------| -| angularjs | `https://google.com/search?as_sitesearch=angularjs.org&as_q=` | -| aurajs | `http://aurajs.com/api/#stq=` | -| bem | `https://google.com/search?as_sitesearch=bem.info&as_q=` | -| bootsnipp | `https://bootsnipp.com/search?q=` | -| caniuse | `https://caniuse.com/#search=` | -| codepen | `https://codepen.io/search?q=` | -| compassdoc | `http://compass-style.org/search?q=` | -| cssflow | `http://www.cssflow.com/search?q=` | -| dartlang | `https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:` | -| emberjs | `https://emberjs.com/api/#stp=1&stq=` | -| fontello | `http://fontello.com/#search=` | -| html5please | `http://html5please.com/#` | -| jquery | `https://api.jquery.com/?s=` | -| lodash | `https://devdocs.io/lodash/index#` | -| mdn | `https://developer.mozilla.org/search?q=` | -| npmjs | `https://www.npmjs.com/search?q=` | -| qunit | `https://api.qunitjs.com/?s=` | -| reactjs | `https://google.com/search?as_sitesearch=facebook.github.io/react&as_q=` | -| smacss | `https://google.com/search?as_sitesearch=smacss.com&as_q=` | -| stackoverflow | `https://stackoverflow.com/search?q=` | -| unheap | `http://www.unheap.com/?s=` | +| context | URL | +| ------------- | --------------------------------------------------------------------------- | +| angular | `https://angular.io/?search=` | +| angularjs | `https://google.com/search?as_sitesearch=angularjs.org&as_q=` | +| bem | `https://google.com/search?as_sitesearch=bem.info&as_q=` | +| bootsnipp | `https://bootsnipp.com/search?q=` | +| bundlephobia | `https://bundlephobia.com/result?p=` | +| caniuse | `https://caniuse.com/#search=` | +| codepen | `https://codepen.io/search?q=` | +| compassdoc | `http://compass-style.org/search?q=` | +| cssflow | `http://www.cssflow.com/search?q=` | +| dartlang | `https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:` | +| emberjs | `https://www.google.com/search?as_sitesearch=emberjs.com/&as_q=` | +| flowtype | `https://google.com/search?as_sitesearch=flow.org/en/docs/&as_q=` | +| fontello | `http://fontello.com/#search=` | +| github | `https://github.com/search?q=` | +| html5please | `https://html5please.com/#` | +| jestjs | `https://www.google.com/search?as_sitesearch=jestjs.io&as_q=` | +| jquery | `https://api.jquery.com/?s=` | +| lodash | `https://devdocs.io/lodash/index#` | +| mdn | `https://developer.mozilla.org/search?q=` | +| nodejs | `https://www.google.com/search?as_sitesearch=nodejs.org/en/docs/&as_q=` | +| npmjs | `https://www.npmjs.com/search?q=` | +| qunit | `https://api.qunitjs.com/?s=` | +| reactjs | `https://google.com/search?as_sitesearch=facebook.github.io/react&as_q=` | +| smacss | `https://google.com/search?as_sitesearch=smacss.com&as_q=` | +| stackoverflow | `https://stackoverflow.com/search?q=` | +| typescript | `https://google.com/search?as_sitesearch=www.typescriptlang.org/docs&as_q=` | +| unheap | `http://www.unheap.com/?s=` | +| vuejs | `https://www.google.com/search?as_sitesearch=vuejs.org&as_q=` | If you want to have another context, open an Issue and tell us! - ## Author **Wilson Mendes (willmendesneto)** -+ <https://plus.google.com/+WilsonMendes> -+ <https://twitter.com/willmendesneto> -+ <https://github.com/willmendesneto> + +- <https://twitter.com/willmendesneto> +- <https://github.com/willmendesneto> diff --git a/plugins/frontend-search/_frontend-search.sh b/plugins/frontend-search/_frontend-search.sh index 9aad76f76..c59640e74 100644 --- a/plugins/frontend-search/_frontend-search.sh +++ b/plugins/frontend-search/_frontend-search.sh @@ -17,27 +17,34 @@ function _frontend() { frontend_points=( "${(f)mapfile[$CONFIG]//$HOME/~}" ) commands=( - 'jquery: Search in jQuery website' - 'mdn: Search in MDN website' - 'compassdoc: Search in COMPASS website' - 'html5please: Search in HTML5 Please website' + 'angular: Search in Angular.io website' + 'angularjs: Search in docs.angularjs.org website' + 'bem: Search in BEM website' + 'bootsnipp: Search in bootsnipp website' + 'bundlephobia: Search in Bundlephobia website' 'caniuse: Search in Can I Use website' - 'aurajs: Search in AuraJs website' + 'codepen: Search in codepen website' + 'compassdoc: Search in COMPASS website' + 'cssflow: Search in cssflow website' 'dartlang: Search in Dart website' + 'emberjs: Search in Ember website' + 'flowtype: Search in Flowtype website' + 'fontello: Search in fontello website' + 'github: Search in GitHub website' + 'html5please: Search in HTML5 Please website' + 'jestjs: Search in Jest website' + 'jquery: Search in jQuery website' 'lodash: Search in Lo-Dash website' + 'mdn: Search in MDN website' + 'nodejs: Search in NodeJS website' + 'npmjs: Search in NPMJS website' 'qunit: Search in Qunit website' - 'fontello: Search in fontello website' - 'bootsnipp: Search in bootsnipp website' - 'cssflow: Search in cssflow website' - 'codepen: Search in codepen website' - 'unheap: Search in unheap website' - 'bem: Search in BEM website' - 'smacss: Search in SMACSS website' - 'angularjs: Search in Angular website' 'reactjs: Search in React website' - 'emberjs: Search in Ember website' + 'smacss: Search in SMACSS website' 'stackoverflow: Search in StackOverflow website' - 'npmjs: Search in NPMJS website' + 'typescript: Search in TypeScript website' + 'unheap: Search in unheap website' + 'vuejs: Search in VueJS website' ) _arguments -C \ @@ -66,9 +73,6 @@ function _frontend() { caniuse) _describe -t points "Warp points" frontend_points && ret=0 ;; - aurajs) - _describe -t points "Warp points" frontend_points && ret=0 - ;; dartlang) _describe -t points "Warp points" frontend_points && ret=0 ;; @@ -81,6 +85,9 @@ function _frontend() { fontello) _describe -t points "Warp points" frontend_points && ret=0 ;; + github) + _describe -t points "Warp points" frontend_points && ret=0 + ;; bootsnipp) _describe -t points "Warp points" frontend_points && ret=0 ;; @@ -114,6 +121,24 @@ function _frontend() { npmjs) _describe -t points "Warp points" frontend_points && ret=0 ;; + bundlephobia) + _describe -t points "Warp points" frontend_points && ret=0 + ;; + flowtype) + _describe -t points "Warp points" frontend_points && ret=0 + ;; + typescript) + _describe -t points "Warp points" frontend_points && ret=0 + ;; + vuejs) + _describe -t points "Warp points" frontend_points && ret=0 + ;; + nodejs) + _describe -t points "Warp points" frontend_points && ret=0 + ;; + jestjs) + _describe -t points "Warp points" frontend_points && ret=0 + ;; esac ;; esac diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh index 14877fb0d..87243be13 100644 --- a/plugins/frontend-search/frontend-search.plugin.zsh +++ b/plugins/frontend-search/frontend-search.plugin.zsh @@ -1,24 +1,31 @@ +alias angular='frontend angular' alias angularjs='frontend angularjs' -alias aurajs='frontend aurajs' alias bem='frontend bem' alias bootsnipp='frontend bootsnipp' +alias bundlephobia='frontend bundlephobia' alias caniuse='frontend caniuse' alias codepen='frontend codepen' alias compassdoc='frontend compassdoc' alias cssflow='frontend cssflow' alias dartlang='frontend dartlang' alias emberjs='frontend emberjs' +alias flowtype='frontend flowtype' alias fontello='frontend fontello' +alias github='frontend github' alias html5please='frontend html5please' +alias jestjs='frontend jestjs' alias jquery='frontend jquery' alias lodash='frontend lodash' alias mdn='frontend mdn' +alias nodejs='frontend nodejs' alias npmjs='frontend npmjs' alias qunit='frontend qunit' alias reactjs='frontend reactjs' alias smacss='frontend smacss' alias stackoverflow='frontend stackoverflow' +alias typescript='frontend typescript' alias unheap='frontend unheap' +alias vuejs='frontend vuejs' function frontend() { emulate -L zsh @@ -26,27 +33,34 @@ function frontend() { # define search context URLS typeset -A urls urls=( + angular 'https://angular.io/?search=' angularjs 'https://google.com/search?as_sitesearch=angularjs.org&as_q=' - aurajs 'http://aurajs.com/api/#stq=' bem 'https://google.com/search?as_sitesearch=bem.info&as_q=' bootsnipp 'https://bootsnipp.com/search?q=' + bundlephobia 'https://bundlephobia.com/result?p=' caniuse 'https://caniuse.com/#search=' codepen 'https://codepen.io/search?q=' compassdoc 'http://compass-style.org/search?q=' cssflow 'http://www.cssflow.com/search?q=' dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:' - emberjs 'https://emberjs.com/api/#stp=1&stq=' + emberjs 'https://www.google.com/search?as_sitesearch=emberjs.com/&as_q=' + flowtype 'https://google.com/search?as_sitesearch=flow.org/en/docs/&as_q=' fontello 'http://fontello.com/#search=' - html5please 'http://html5please.com/#' + github 'https://github.com/search?q=' + html5please 'https://html5please.com/#' + jestjs 'https://www.google.com/search?as_sitesearch=jestjs.io&as_q=' jquery 'https://api.jquery.com/?s=' lodash 'https://devdocs.io/lodash/index#' mdn 'https://developer.mozilla.org/search?q=' + nodejs 'https://www.google.com/search?as_sitesearch=nodejs.org/en/docs/&as_q=' npmjs 'https://www.npmjs.com/search?q=' qunit 'https://api.qunitjs.com/?s=' reactjs 'https://google.com/search?as_sitesearch=facebook.github.io/react&as_q=' smacss 'https://google.com/search?as_sitesearch=smacss.com&as_q=' stackoverflow 'https://stackoverflow.com/search?q=' + typescript 'https://google.com/search?as_sitesearch=www.typescriptlang.org/docs&as_q=' unheap 'http://www.unheap.com/?s=' + vuejs 'https://www.google.com/search?as_sitesearch=vuejs.org&as_q=' ) # show help for command list @@ -57,9 +71,9 @@ function frontend() { print -P "%Uterm%u and what follows is what will be searched for in the %Ucontext%u website," print -P "and %Ucontext%u is one of the following:" print -P "" - print -P " angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow," - print -P " dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs," - print -P " qunit, reactjs, smacss, stackoverflow, unheap" + print -P " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow," + print -P " dartlang, emberjs, fontello, flowtype, github, html5please, jestjs, jquery, lodash," + print -P " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia" print -P "" print -P "For example: frontend npmjs mocha (or just: npmjs mocha)." print -P "" @@ -73,17 +87,17 @@ function frontend() { echo "" echo "Valid contexts are:" echo "" - echo " angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, " - echo " dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs, " - echo " qunit, reactjs, smacss, stackoverflow, unheap" + echo " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow," + echo " dartlang, emberjs, fontello, github, html5please, jest, jquery, lodash," + echo " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia" echo "" return 1 fi # build search url: - # join arguments passed with '+', then append to search context URL + # join arguments passed with '%20', then append to search context URL # TODO substitute for proper urlencode method - url="${urls[$1]}${(j:+:)@[2,-1]}" + url="${urls[$1]}${(j:%20:)@[2,-1]}" echo "Opening $url ..." diff --git a/plugins/gatsby/README.md b/plugins/gatsby/README.md new file mode 100644 index 000000000..36846a228 --- /dev/null +++ b/plugins/gatsby/README.md @@ -0,0 +1,7 @@ +# gatsby autocomplete plugin + +* Adds autocomplete options for all gatsby commands. + +## Requirements + +In order to make this work, you will need to have gatsby set up in your path. diff --git a/plugins/gatsby/_gatsby b/plugins/gatsby/_gatsby new file mode 100644 index 000000000..66eb02f00 --- /dev/null +++ b/plugins/gatsby/_gatsby @@ -0,0 +1,24 @@ +#compdef gatsby +#autoload + +# in order to make this work, you will need to have gatsby +# https://www.gatsbyjs.org/ + +local -a _1st_arguments +_1st_arguments=( +'develop:Start development server. Watches files, rebuilds, and hot reloads if something changes' +'build:Build a Gatsby project.' +'serve:Serve previously built Gatsby site.' +'info:Get environment information for debugging and issue reporting' +'clean:Wipe the local gatsby environment including built assets and cache' +'repl:Get a node repl with context of Gatsby environment, see (add docs link here)' +'new: [rootPath] [starter] Create new Gatsby project.' +'telemetry:Enable or disable Gatsby anonymous analytics collection.' +) + +_arguments -C '*:: :->subcmds' && return 0 + +if (( CURRENT == 1 )); then + _describe -t commands "gatsby subcommand" _1st_arguments + return +fi diff --git a/plugins/git-extras/git-extras.plugin.zsh b/plugins/git-extras/git-extras.plugin.zsh index ef6c35988..b86d7c5b6 100644 --- a/plugins/git-extras/git-extras.plugin.zsh +++ b/plugins/git-extras/git-extras.plugin.zsh @@ -454,9 +454,9 @@ zstyle ':completion:*:*:git:*' user-commands $existing_user_commands \ extras:'awesome git utilities' \ feature:'create/merge feature branch' \ force-clone:'overwrite local repositories with clone' \ - fork:'fork a repo on github' \ + fork:'fork a repo on GitHub' \ fresh-branch:'create fresh branches' \ - gh-pages:'create the github pages branch' \ + gh-pages:'create the GitHub pages branch' \ graft:'merge and destroy a given branch' \ guilt:'calculate change between two revisions' \ ignore-io:'get sample gitignore file' \ diff --git a/plugins/git-hubflow/git-hubflow.plugin.zsh b/plugins/git-hubflow/git-hubflow.plugin.zsh index 05479f7e6..50d7b23ce 100644 --- a/plugins/git-hubflow/git-hubflow.plugin.zsh +++ b/plugins/git-hubflow/git-hubflow.plugin.zsh @@ -75,8 +75,8 @@ __git-hf-release () 'finish:Finish a release branch.' 'list:List all your release branches. (Alias to `git hf release`)' 'cancel:Cancel release' - 'push:Push release to github' - 'pull:Pull release from github' + 'push:Push release to GitHub' + 'pull:Pull release from GitHub' 'track:Track release' ) _describe -t commands 'git hf release' subcommands @@ -133,8 +133,8 @@ __git-hf-hotfix () 'list:List all your hotfix branches. (Alias to `git hf hotfix`)' 'publish:Publish the hotfix branch.' 'track:Track the hotfix branch.' - 'pull:Pull the hotfix from github.' - 'push:Push the hotfix to github.' + 'pull:Pull the hotfix from GitHub.' + 'push:Push the hotfix to GitHub.' 'cancel:Cancel the hotfix.' ) _describe -t commands 'git hf hotfix' subcommands @@ -195,8 +195,8 @@ __git-hf-feature () 'diff:Diff' 'rebase:Rebase feature branch against develop' 'checkout:Checkout feature' - 'pull:Pull feature branch from github' - 'push:Push feature branch to github' + 'pull:Pull feature branch from GitHub' + 'push:Push feature branch to GitHub' 'cancel:Cancel feature' ) _describe -t commands 'git hf feature' subcommands diff --git a/plugins/git/README.md b/plugins/git/README.md index 76da2a8ae..d66ad234d 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -1,10 +1,211 @@ -## git +# git plugin -**Maintainer:** [@ncanceill](https://github.com/ncanceill) +The git plugin provides many [aliases](#aliases) and a few useful [functions](#functions). -This plugin adds many useful aliases and functions. +To use it, add `git` to the plugins array in your zshrc file: -### Usage +```zsh +plugins=(... git) +``` -See the [wiki](https://github.com/robbyrussell/oh-my-zsh/wiki/Plugin:git) for a list of aliases and functions provided by the plugin. +## Aliases +| Alias | Command | +|:---------------------|:------------------------------------------------------------------------------------------------------------------------------| +| g | git | +| ga | git add | +| gaa | git add --all | +| gapa | git add --patch | +| gau | git add --update | +| gav | git add --verbose | +| gap | git apply | +| gb | git branch | +| gba | git branch -a | +| gbd | git branch -d | +| gbda | git branch --no-color --merged \| command grep -vE "^(\*\|\s*(master\|develop\|dev)\s*$)" \| command xargs -n 1 git branch -d | +| gbD | git branch -D | +| gbl | git blame -b -w | +| gbnm | git branch --no-merged | +| gbr | git branch --remote | +| gbs | git bisect | +| gbsb | git bisect bad | +| gbsg | git bisect good | +| gbsr | git bisect reset | +| gbss | git bisect start | +| gc | git commit -v | +| gc! | git commit -v --amend | +| gcn! | git commit -v --no-edit --amend | +| gca | git commit -v -a | +| gca! | git commit -v -a --amend | +| gcan! | git commit -v -a --no-edit --amend | +| gcans! | git commit -v -a -s --no-edit --amend | +| gcam | git commit -a -m | +| gcsm | git commit -s -m | +| gcb | git checkout -b | +| gcf | git config --list | +| gcl | git clone --recurse-submodules | +| gclean | git clean -id | +| gpristine | git reset --hard && git clean -dfx | +| gcm | git checkout master | +| gcd | git checkout develop | +| gcmsg | git commit -m | +| gco | git checkout | +| gcount | git shortlog -sn | +| gcp | git cherry-pick | +| gcpa | git cherry-pick --abort | +| gcpc | git cherry-pick --continue | +| gcs | git commit -S | +| gd | git diff | +| gdca | git diff --cached | +| gdcw | git diff --cached --word-diff | +| gdct | git describe --tags $(git rev-list --tags --max-count=1) | +| gds | git diff --staged | +| gdt | git diff-tree --no-commit-id --name-only -r | +| gdv | git diff -w $@ \| view - | +| gdw | git diff --word-diff | +| gf | git fetch | +| gfa | git fetch --all --prune | +| gfg | git ls-files \| grep | +| gfo | git fetch origin | +| gg | git gui citool | +| gga | git gui citool --amend | +| ggf | git push --force origin $(current_branch) | +| ggfl | git push --force-with-lease origin $(current_branch) | +| ggl | git pull origin $(current_branch) | +| ggp | git push origin $(current_branch) | +| ggpnp | ggl && ggp | +| ggpull | git pull origin "$(git_current_branch)" | +| ggpur | ggu | +| ggpush | git push origin "$(git_current_branch)" | +| ggsup | git branch --set-upstream-to=origin/$(git_current_branch) | +| ggu | git pull --rebase origin $(current_branch) | +| gpsup | git push --set-upstream origin $(git_current_branch) | +| ghh | git help | +| gignore | git update-index --assume-unchanged | +| gignored | git ls-files -v \| grep "^[[:lower:]]" | +| git-svn-dcommit-push | git svn dcommit && git push github master:svntrunk | +| gk | gitk --all --branches | +| gke | gitk --all $(git log -g --pretty=%h) | +| gl | git pull | +| glg | git log --stat | +| glgp | git log --stat -p | +| glgg | git log --graph | +| glgga | git log --graph --decorate --all | +| glgm | git log --graph --max-count=10 | +| glo | git log --oneline --decorate | +| glol | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' | +| glols | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --stat | +| glod | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' | +| glods | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short | +| glola | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all | +| glog | git log --oneline --decorate --graph | +| gloga | git log --oneline --decorate --graph --all | +| glp | `_git_log_prettily` | +| gm | git merge | +| gmom | git merge origin/master | +| gmt | git mergetool --no-prompt | +| gmtvim | git mergetool --no-prompt --tool=vimdiff | +| gmum | git merge upstream/master | +| gma | git merge --abort | +| gp | git push | +| gpd | git push --dry-run | +| gpf | git push --force-with-lease | +| gpf! | git push --force | +| gpoat | git push origin --all && git push origin --tags | +| gpu | git push upstream | +| gpv | git push -v | +| gr | git remote | +| gra | git remote add | +| grb | git rebase | +| grba | git rebase --abort | +| grbc | git rebase --continue | +| grbd | git rebase develop | +| grbi | git rebase -i | +| grbm | git rebase master | +| grbs | git rebase --skip | +| grh | git reset | +| grhh | git reset --hard | +| groh | git reset origin/$(git_current_branch) --hard | +| grm | git rm | +| grmc | git rm --cached | +| grmv | git remote rename | +| grrm | git remote remove | +| grset | git remote set-url | +| grt | cd "$(git rev-parse --show-toplevel \|\| echo .)" | +| gru | git reset -- | +| grup | git remote update | +| grv | git remote -v | +| gsb | git status -sb | +| gsd | git svn dcommit | +| gsh | git show | +| gsi | git submodule init | +| gsps | git show --pretty=short --show-signature | +| gsr | git svn rebase | +| gss | git status -s | +| gst | git status | +| gsta | git stash push | +| gsta | git stash save | +| gstaa | git stash apply | +| gstc | git stash clear | +| gstd | git stash drop | +| gstl | git stash list | +| gstp | git stash pop | +| gsts | git stash show --text | +| gstall | git stash --all | +| gsu | git submodule update | +| gts | git tag -s | +| gtv | git tag \| sort -V | +| gtl | gtl(){ git tag --sort=-v:refname -n -l ${1}* }; noglob gtl | +| gunignore | git update-index --no-assume-unchanged | +| gunwip | git log -n 1 \| grep -q -c "\-\-wip\-\-" && git reset HEAD~1 | +| gup | git pull --rebase | +| gupv | git pull --rebase -v | +| gupa | git pull --rebase --autostash | +| gupav | git pull --rebase --autostash -v | +| glum | git pull upstream master | +| gwch | git whatchanged -p --abbrev-commit --pretty=medium | +| gwip | git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]" | + +### Deprecated + +These are aliases that have been removed, renamed, or otherwise modified in a way that may, or may not, receive further support. + +| Alias | Command | Modification | +| :----- | :----------------------------------------------------------------------------------| --------------------------------------------------------------------------------------------------- | +| gap | git add --patch | new alias `gapa` | +| gcl | git config --list | new alias `gcf` | +| gdc | git diff --cached | new alias `gdca` | +| gdt | git difftool | no replacement | +| ggpull | git pull origin $(current_branch) | new alias `ggl` (`ggpull` still exists for now though) | +| ggpur | git pull --rebase origin $(current_branch) | new alias `ggu` (`ggpur` still exists for now though) | +| ggpush | git push origin $(current_branch) | new alias `ggp` (`ggpush` still exists for now though) | +| gk | gitk --all --branches | now aliased to `gitk --all --branches` | +| glg | git log --stat --max-count = 10 | now aliased to `git log --stat --color` | +| glgg | git log --graph --max-count = 10 | now aliased to `git log --graph --color` | +| gwc | git whatchanged -p --abbrev-commit --pretty = medium | new alias `gwch` | + +## Functions + +### Current + +| Command | Description | +|:-----------------------|:----------------------------------------| +| current_branch | Return the name of the current branch | +| git_current_user_name | Returns the `user.name` config value | +| git_current_user_email | Returns the `user.email` config value | + +### Work in Progress (WIP) + +These features allow to pause a branch development and switch to another one (_"Work in Progress"_, or wip). When you want to go back to work, just unwip it. + +| Command | Description | +|:-----------------|:------------------------------------------------| +| work_in_progress | Echoes a warning if the current branch is a wip | +| gwip | Commit wip branch | +| gunwip | Uncommit wip branch | + +### Deprecated + +| Command | Description | Reason | +|:-----------------------|:----------------------------------------|:----------------------------------------------------------------| +| current_repository | Return the names of the current remotes | Didn't work properly. Use `git remote -v` instead (`grv` alias) | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index b82d49b5e..e0ce27fd4 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -1,7 +1,3 @@ -# Query/use custom command for `git`. -zstyle -s ":vcs_info:git:*:-all-" "command" _omz_git_git_cmd -: ${_omz_git_git_cmd:=git} - # # Functions # @@ -13,19 +9,15 @@ zstyle -s ":vcs_info:git:*:-all-" "command" _omz_git_git_cmd function current_branch() { git_current_branch } -# The list of remotes -function current_repository() { - if ! $_omz_git_git_cmd rev-parse --is-inside-work-tree &> /dev/null; then - return - fi - echo $($_omz_git_git_cmd remote -v | cut -d':' -f 2) -} + # Pretty log messages function _git_log_prettily(){ if ! [ -z $1 ]; then git log --pretty=$1 fi } +compdef _git _git_log_prettily=git-log + # Warn if the current branch is a WIP function work_in_progress() { if $(git log -n 1 2>/dev/null | grep -q -c "\-\-wip\-\-"); then @@ -80,7 +72,6 @@ alias gcd='git checkout develop' alias gcmsg='git commit -m' alias gco='git checkout' alias gcount='git shortlog -sn' -compdef _git gcount alias gcp='git cherry-pick' alias gcpa='git cherry-pick --abort' alias gcpc='git cherry-pick --continue' @@ -89,35 +80,35 @@ alias gcs='git commit -S' alias gd='git diff' alias gdca='git diff --cached' alias gdcw='git diff --cached --word-diff' -alias gdct='git describe --tags `git rev-list --tags --max-count=1`' +alias gdct='git describe --tags $(git rev-list --tags --max-count=1)' alias gds='git diff --staged' alias gdt='git diff-tree --no-commit-id --name-only -r' alias gdw='git diff --word-diff' -gdv() { git diff -w "$@" | view - } +function gdv() { git diff -w "$@" | view - } compdef _git gdv=git-diff alias gf='git fetch' alias gfa='git fetch --all --prune' alias gfo='git fetch origin' -function gfg() { git ls-files | grep $@ } -compdef _grep gfg +alias gfg='git ls-files | grep' alias gg='git gui citool' alias gga='git gui citool --amend' -ggf() { +function ggf() { [[ "$#" != 1 ]] && local b="$(git_current_branch)" git push --force origin "${b:=$1}" } -ggfl() { +compdef _git ggf=git-checkout +function ggfl() { [[ "$#" != 1 ]] && local b="$(git_current_branch)" git push --force-with-lease origin "${b:=$1}" } -compdef _git ggf=git-checkout +compdef _git ggfl=git-checkout -ggl() { +function ggl() { if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then git pull origin "${*}" else @@ -127,7 +118,7 @@ ggl() { } compdef _git ggl=git-checkout -ggp() { +function ggp() { if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then git push origin "${*}" else @@ -137,7 +128,7 @@ ggp() { } compdef _git ggp=git-checkout -ggpnp() { +function ggpnp() { if [[ "$#" == 0 ]]; then ggl && ggp else @@ -146,20 +137,15 @@ ggpnp() { } compdef _git ggpnp=git-checkout -ggu() { +function ggu() { [[ "$#" != 1 ]] && local b="$(git_current_branch)" git pull --rebase origin "${b:=$1}" } compdef _git ggu=git-checkout alias ggpur='ggu' -compdef _git ggpur=git-checkout - alias ggpull='git pull origin "$(git_current_branch)"' -compdef _git ggpull=git-checkout - alias ggpush='git push origin "$(git_current_branch)"' -compdef _git ggpush=git-checkout alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)' alias gpsup='git push --set-upstream origin $(git_current_branch)' @@ -169,12 +155,9 @@ alias ghh='git help' alias gignore='git update-index --assume-unchanged' alias gignored='git ls-files -v | grep "^[[:lower:]]"' alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk' -compdef _git git-svn-dcommit-push=git alias gk='\gitk --all --branches' -compdef _git gk='gitk' alias gke='\gitk --all $(git log -g --pretty=%h)' -compdef _git gke='gitk' alias gl='git pull' alias glg='git log --stat' @@ -191,7 +174,6 @@ alias glola="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgr alias glog='git log --oneline --decorate --graph' alias gloga='git log --oneline --decorate --graph --all' alias glp="_git_log_prettily" -compdef _git glp=git-log alias gm='git merge' alias gmom='git merge origin/master' @@ -205,7 +187,6 @@ alias gpd='git push --dry-run' alias gpf='git push --force-with-lease' alias gpf!='git push --force' alias gpoat='git push origin --all && git push origin --tags' -compdef _git gpoat=git-push alias gpu='git push upstream' alias gpv='git push -v' @@ -218,6 +199,7 @@ alias grbd='git rebase develop' alias grbi='git rebase -i' alias grbm='git rebase master' alias grbs='git rebase --skip' +alias grev='git revert' alias grh='git reset' alias grhh='git reset --hard' alias groh='git reset origin/$(git_current_branch) --hard' diff --git a/plugins/gitfast/git-completion.bash b/plugins/gitfast/git-completion.bash index d93441747..b6ff5dc08 100644 --- a/plugins/gitfast/git-completion.bash +++ b/plugins/gitfast/git-completion.bash @@ -111,8 +111,7 @@ __git () # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# along with this program; if not, see <http://www.gnu.org/licenses/>. # # The latest version of this software can be obtained here: # @@ -1205,7 +1204,7 @@ _git_branch () --color --no-color --verbose --abbrev= --no-abbrev --track --no-track --contains --no-contains --merged --no-merged --set-upstream-to= --edit-description --list - --unset-upstream --delete --move --remotes + --unset-upstream --delete --move --copy --remotes --column --no-column --sort= --points-at " ;; @@ -1250,7 +1249,8 @@ _git_checkout () --*) __gitcomp " --quiet --ours --theirs --track --no-track --merge - --conflict= --orphan --patch + --conflict= --orphan --patch --detach --ignore-skip-worktree-bits + --recurse-submodules --no-recurse-submodules " ;; *) @@ -1385,7 +1385,7 @@ _git_describe () __gitcomp " --all --tags --contains --abbrev= --candidates= --exact-match --debug --long --match --always --first-parent - --exclude + --exclude --dirty --broken " return esac @@ -1400,7 +1400,7 @@ __git_diff_common_options="--stat --numstat --shortstat --summary --patch-with-stat --name-only --name-status --color --no-color --color-words --no-renames --check --full-index --binary --abbrev --diff-filter= - --find-copies-harder + --find-copies-harder --ignore-cr-at-eol --text --ignore-space-at-eol --ignore-space-change --ignore-all-space --ignore-blank-lines --exit-code --quiet --ext-diff --no-ext-diff @@ -1922,6 +1922,7 @@ _git_pull () --*) __gitcomp " --rebase --no-rebase + --autostash --no-autostash $__git_merge_options $__git_fetch_options " @@ -2350,6 +2351,7 @@ _git_config () advice.rmHints advice.statusHints advice.statusUoption + advice.ignoredHook alias. am.keepcr am.threeWay @@ -2640,6 +2642,7 @@ _git_config () sendemail.suppressfrom sendemail.thread sendemail.to + sendemail.tocmd sendemail.validate sendemail.smtpbatchsize sendemail.smtprelogindelay @@ -3312,6 +3315,6 @@ __git_complete gitk __gitk_main # when the user has tab-completed the executable name and consequently # included the '.exe' suffix. # -if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then +if [[ "$OSTYPE" = cygwin* ]]; then __git_complete git.exe __git_main fi diff --git a/plugins/gitfast/git-prompt.sh b/plugins/gitfast/git-prompt.sh index cd905759e..fd2b049db 100644 --- a/plugins/gitfast/git-prompt.sh +++ b/plugins/gitfast/git-prompt.sh @@ -278,11 +278,12 @@ __git_ps1_colorize_gitstring () r="$c_clear$r" } +# Helper function to read the first line of a file into a variable. +# __git_eread requires 2 arguments, the file path and the name of the +# variable, in that order. __git_eread () { - local f="$1" - shift - test -r "$f" && read "$@" <"$f" + test -r "$1" && IFS=$'\r\n' read "$2" <"$1" } # __git_ps1 accepts 0 or 1 arguments (i.e., format string) diff --git a/plugins/gitfast/gitfast.plugin.zsh b/plugins/gitfast/gitfast.plugin.zsh index 8c2aea497..7b6b67e92 100644 --- a/plugins/gitfast/gitfast.plugin.zsh +++ b/plugins/gitfast/gitfast.plugin.zsh @@ -1,9 +1,6 @@ -dir="${0:A:h}" -source "$dir/git-prompt.sh" +source "${0:A:h}/git-prompt.sh" function git_prompt_info() { dirty="$(parse_git_dirty)" __git_ps1 "${ZSH_THEME_GIT_PROMPT_PREFIX//\%/%%}%s${dirty//\%/%%}${ZSH_THEME_GIT_PROMPT_SUFFIX//\%/%%}" } - -unset dir diff --git a/plugins/gitfast/update b/plugins/gitfast/update new file mode 100755 index 000000000..05054245f --- /dev/null +++ b/plugins/gitfast/update @@ -0,0 +1,9 @@ +#!/bin/sh + +url="https://git.kernel.org/pub/scm/git/git.git/plain/contrib/completion" +version="2.16.0" + +curl -s -o _git "${url}/git-completion.zsh?h=v${version}" && +curl -s -o git-completion.bash "${url}/git-completion.bash?h=v${version}" && +curl -s -o git-prompt.sh "${url}/git-prompt.sh?h=v${version}" && +git apply updates.patch diff --git a/plugins/gitfast/updates.patch b/plugins/gitfast/updates.patch new file mode 100644 index 000000000..28a31f859 --- /dev/null +++ b/plugins/gitfast/updates.patch @@ -0,0 +1,56 @@ +diff --git b/plugins/gitfast/_git a/plugins/gitfast/_git +index e2554130..a2e3bef5 100644 +--- b/plugins/gitfast/_git ++++ a/plugins/gitfast/_git +@@ -30,7 +30,7 @@ if [ -z "$script" ]; then + local -a locations + local e + locations=( +- $(dirname ${funcsourcetrace[1]%:*})/git-completion.bash ++ "$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash" + '/etc/bash_completion.d/git' # fedora, old debian + '/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian + '/usr/share/bash-completion/git' # gentoo +@@ -214,8 +214,10 @@ _git () + + if (( $+functions[__${service}_zsh_main] )); then + __${service}_zsh_main +- else ++ elif (( $+functions[__${service}_main] )); then + emulate ksh -c __${service}_main ++ elif (( $+functions[_${service}] )); then ++ emulate ksh -c _${service} + fi + + let _ret && _default && _ret=0 +diff --git b/plugins/gitfast/git-completion.bash a/plugins/gitfast/git-completion.bash +index 9c8f7380..14012cab 100644 +--- b/plugins/gitfast/git-completion.bash ++++ a/plugins/gitfast/git-completion.bash +@@ -2915,6 +2915,6 @@ __git_complete gitk __gitk_main + # when the user has tab-completed the executable name and consequently + # included the '.exe' suffix. + # +-if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then ++if [[ "$OSTYPE" = cygwin* ]]; then + __git_complete git.exe __git_main + fi +diff --git b/plugins/gitfast/git-prompt.sh a/plugins/gitfast/git-prompt.sh +index 97eacd78..c1de34eb 100644 +--- b/plugins/gitfast/git-prompt.sh ++++ a/plugins/gitfast/git-prompt.sh +@@ -502,9 +502,11 @@ __git_ps1 () + + local z="${GIT_PS1_STATESEPARATOR-" "}" + +- # NO color option unless in PROMPT_COMMAND mode +- if [ $pcmode = yes ] && [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then +- __git_ps1_colorize_gitstring ++ # NO color option unless in PROMPT_COMMAND mode or it's Zsh ++ if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then ++ if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then ++ __git_ps1_colorize_gitstring ++ fi + fi + + b=${b##refs/heads/} diff --git a/plugins/github/_hub b/plugins/github/_hub index 1833a9c09..209a3df9e 100644 --- a/plugins/github/_hub +++ b/plugins/github/_hub @@ -58,6 +58,7 @@ __hub_setup_zsh_fns () { - set1 \ '-m[message]' \ '-F[file]' \ + '--no-edit[use first commit message for pull request title/description]' \ '-a[user]' \ '-M[milestone]' \ '-l[labels]' \ @@ -84,11 +85,15 @@ __hub_setup_zsh_fns () { hub_commands=( alias:'show shell instructions for wrapping git' pull-request:'open a pull request on GitHub' + pr:'list or checkout a GitHub pull request' + issue:'list or create a GitHub issue' + release:'list or create a GitHub release' fork:'fork origin repo on GitHub' create:'create new repo on GitHub for the current project' + delete:'delete a GitHub repo' browse:'browse the project on GitHub' compare:'open GitHub compare view' - ci-status:'lookup commit in GitHub Status API' + ci-status:'show status of GitHub checks for a commit' sync:'update local branches from upstream' ) _describe -t hub-commands 'hub command' hub_commands && ret=0 @@ -111,8 +116,12 @@ __hub_setup_bash_fns () { cat <<-EOF alias pull-request +pr +issue +release fork create +delete browse compare ci-status diff --git a/plugins/gulp/gulp.plugin.zsh b/plugins/gulp/gulp.plugin.zsh index ec597421d..6234302c5 100644 --- a/plugins/gulp/gulp.plugin.zsh +++ b/plugins/gulp/gulp.plugin.zsh @@ -11,7 +11,7 @@ # # André König -# Github: https://github.com/akoenig +# GitHub: https://github.com/akoenig # Twitter: https://twitter.com/caiifr # diff --git a/plugins/jira/README.md b/plugins/jira/README.md index a934ae68c..091dccb97 100644 --- a/plugins/jira/README.md +++ b/plugins/jira/README.md @@ -21,6 +21,7 @@ jira new # opens a new issue jira dashboard # opens your JIRA dashboard jira reported [username] # queries for issues reported by a user jira assigned [username] # queries for issues assigned to a user +jira myissues # queries for you own issues jira branch # opens an existing issue matching the current branch name jira ABC-123 # opens an existing issue jira ABC-123 m # opens an existing issue for adding a comment diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh index 052481a60..e706948e9 100644 --- a/plugins/jira/jira.plugin.zsh +++ b/plugins/jira/jira.plugin.zsh @@ -43,7 +43,10 @@ function jira() { echo "Opening new issue" open_command "${jira_url}/secure/CreateIssue!default.jspa" elif [[ "$action" == "assigned" || "$action" == "reported" ]]; then - _jira_query $@ + _jira_query ${@:-$action} + elif [[ "$action" == "myissues" ]]; then + echo "Opening my issues" + open_command "${jira_url}/issues/?filter=-1" elif [[ "$action" == "dashboard" ]]; then echo "Opening dashboard" if [[ "$JIRA_RAPID_BOARD" == "true" ]]; then diff --git a/plugins/kube-ps1/kube-ps1.plugin.zsh b/plugins/kube-ps1/kube-ps1.plugin.zsh index 8a751bda8..3cb21284a 100644 --- a/plugins/kube-ps1/kube-ps1.plugin.zsh +++ b/plugins/kube-ps1/kube-ps1.plugin.zsh @@ -41,9 +41,9 @@ KUBE_PS1_SUFFIX="${KUBE_PS1_SUFFIX-)}" KUBE_PS1_LAST_TIME=0 KUBE_PS1_ENABLED=true -KUBE_PS1_COLOR_SYMBOL="%F{blue}" -KUBE_PS1_COLOR_CONTEXT="%F{red}" -KUBE_PS1_COLOR_NS="%F{cyan}" +KUBE_PS1_COLOR_SYMBOL="%{$fg[blue]%}" +KUBE_PS1_COLOR_CONTEXT="%{$fg[red]%}" +KUBE_PS1_COLOR_NS="%{$fg[cyan]%}" _kube_ps1_binary_check() { command -v "$1" >/dev/null diff --git a/plugins/kubectl/README.md b/plugins/kubectl/README.md index 9cd4a369e..4541c7e92 100644 --- a/plugins/kubectl/README.md +++ b/plugins/kubectl/README.md @@ -13,7 +13,7 @@ plugins=(... kubectl) | Alias | Command | Description | |:--------|:------------------------------------|:-------------------------------------------------------------------------------------------------| -| ku | `kubectl` | The kubectl command | +| k | `kubectl` | The kubectl command | | kca | `kubectl --all-namespaces` | The kubectl command targeting all namespaces | | kaf | `kubectl apply -f` | Apply a YML file | | keti | `kubectl exec -ti` | Drop into an interactive terminal on a container | @@ -22,6 +22,7 @@ plugins=(... kubectl) | kcsc | `kubectl config set-context` | Set a context entry in kubeconfig | | kcdc | `kubectl config delete-context` | Delete the specified context from the kubeconfig | | kccc | `kubectl config current-context` | Display the current-context | +| kcgc | `kubectl config get-contexts` | List of contexts available | | | **General aliases** | | kdel | `kubectl delete` | Delete resources by filenames, stdin, resources and names, or by resources and label selector | | kdelf | `kubectl delete -f` | Delete a pod using the type and name specified in -f argument | @@ -89,3 +90,9 @@ plugins=(... kubectl) | keno | `kubectl edit node` | Edit nodes resource from the default editor | | kdno | `kubectl describe node` | Describe node resource in detail | | kdelno | `kubectl delete node` | Delete the node | +| | | **Persistent Volume Claim management** | +| kgpvc | `kubectl get pvc` | List all PVCs | +| kgpvcw | `kgpvc --watch` | After listing/getting the requested object, watch for changes | +| kepvc | `kubectl edit pvc` | Edit pvcs from the default editor | +| kdpvc | `kubectl describe pvc` | Descirbe all pvcs | +| kdelpvc | `kubectl delete pvc` | Delete all pvcs matching passed arguments | diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh index 9a4489fb6..5097732db 100644 --- a/plugins/kubectl/kubectl.plugin.zsh +++ b/plugins/kubectl/kubectl.plugin.zsh @@ -10,7 +10,8 @@ if (( $+commands[kubectl] )); then unset __KUBECTL_COMPLETION_FILE fi -alias ku=kubectl +# This command is used a LOT both below and in daily life +alias k=kubectl # Execute a kubectl command against all namespaces alias kca='f(){ kubectl "$@" --all-namespaces; unset -f f; }; f' @@ -27,6 +28,9 @@ alias kcsc='kubectl config set-context' alias kcdc='kubectl config delete-context' alias kccc='kubectl config current-context' +# List all contexts +alias kcgc='kubectl config get-contexts' + # General aliases alias kdel='kubectl delete' alias kdelf='kubectl delete -f' @@ -111,3 +115,11 @@ alias kgno='kubectl get nodes' alias keno='kubectl edit node' alias kdno='kubectl describe node' alias kdelno='kubectl delete node' + +# PVC management. +alias kgpvc='kubectl get pvc' +alias kgpvcw='kgpvc --watch' +alias kepvc='kubectl edit pvc' +alias kdpvc='kubectl describe pvc' +alias kdelpvc='kubectl delete pvc' + diff --git a/plugins/ng/ng.plugin.zsh b/plugins/ng/ng.plugin.zsh index b802bf617..44102e2a6 100644 --- a/plugins/ng/ng.plugin.zsh +++ b/plugins/ng/ng.plugin.zsh @@ -1,4 +1,3 @@ - ng_opts='addon asset-sizes b build completion d destroy doc e2e g generate get github-pages:deploy gh-pages:deploy h help i init install lint make-this-awesome new s serve server set t test update v version -h --help' _ng_completion () { @@ -73,9 +72,7 @@ _ng_completion () { ;; esac - setopt shwordsplit - reply=($opts) - unset shwordsplit + reply=(${=opts}) } compctl -K _ng_completion ng diff --git a/plugins/osx/README.md b/plugins/osx/README.md index 3559dee02..4595ee319 100644 --- a/plugins/osx/README.md +++ b/plugins/osx/README.md @@ -18,7 +18,7 @@ This application makes use of the following third party scripts: [shpotify](https://github.com/hnarayanan/shpotify) -Copyright (c) 2012–2017 [Harish Narayanan](https://harishnarayanan.org/). +Copyright (c) 2012–2019 [Harish Narayanan](https://harishnarayanan.org/). Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh index 7deed0ba6..eb3c4fb7a 100644 --- a/plugins/osx/osx.plugin.zsh +++ b/plugins/osx/osx.plugin.zsh @@ -236,7 +236,19 @@ function itunes() { opt="$opt track" ;; vol) - opt="set sound volume to $1" #$1 Due to the shift + local new_volume volume=$(osascript -e 'tell application "iTunes" to get sound volume') + if [[ $# -eq 0 ]]; then + echo "Current volume is ${volume}." + return 0 + fi + case $1 in + up) new_volume=$((volume + 10 < 100 ? volume + 10 : 100)) ;; + down) new_volume=$((volume - 10 > 0 ? volume - 10 : 0)) ;; + <0-100>) new_volume=$1 ;; + *) echo "'$1' is not valid. Expected <0-100>, up or down." + return 1 ;; + esac + opt="set sound volume to ${new_volume}" ;; playlist) # Inspired by: https://gist.github.com/nakajijapan/ac8b45371064ae98ea7f @@ -299,7 +311,7 @@ EOF echo "\tmute|unmute\tcontrol volume set" echo "\tnext|previous\tplay next or previous track" echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer." - echo "\tvol\tSet the volume, takes an argument from 0 to 100" + echo "\tvol [0-100|up|down]\tGet or set the volume. 0 to 100 sets the volume. 'up' / 'down' increases / decreases by 10 points. No argument displays current volume." echo "\tplaying|status\tShow what song is currently playing in iTunes." echo "\tplaylist [playlist name]\t Play specific playlist" echo "\thelp\tshow this message and exit" diff --git a/plugins/osx/spotify b/plugins/osx/spotify index b4215dbe7..39f8e0437 100644 --- a/plugins/osx/spotify +++ b/plugins/osx/spotify @@ -1,7 +1,7 @@ #!/usr/bin/env bash function spotify() { -# Copyright (c) 2012--2018 Harish Narayanan <mail@harishnarayanan.org> +# Copyright (c) 2012--2019 Harish Narayanan <mail@harishnarayanan.org> # # Contains numerous helpful contributions from Jorge Colindres, Thomas # Pritchard, iLan Epstein, Gabriele Bonetti, Sean Heller, Eric Martin @@ -70,7 +70,7 @@ showHelp () { echo; echo " next # Skips to the next song in a playlist."; echo " prev # Returns to the previous song in a playlist."; - echo " replay # Replays the current track from the begining."; + echo " replay # Replays the current track from the beginning."; echo " pos <time> # Jumps to a time (in secs) in the current song."; echo " pause # Pauses (or resumes) Spotify playback."; echo " stop # Stops playback."; @@ -82,6 +82,9 @@ showHelp () { echo " vol [show] # Shows the current Spotify volume."; echo; echo " status # Shows the current player status."; + echo " status artist # Shows the currently playing artist."; + echo " status album # Shows the currently playing album."; + echo " status track # Shows the currently playing track."; echo; echo " share # Displays the current song's Spotify URL and URI." echo " share url # Displays the current song's Spotify URL and copies it to the clipboard." @@ -99,12 +102,21 @@ cecho(){ echo $bold$green"$1"$reset; } +showArtist() { + echo `osascript -e 'tell application "Spotify" to artist of current track as string'`; +} + +showAlbum() { + echo `osascript -e 'tell application "Spotify" to album of current track as string'`; +} + +showTrack() { + echo `osascript -e 'tell application "Spotify" to name of current track as string'`; +} + showStatus () { state=`osascript -e 'tell application "Spotify" to player state as string'`; cecho "Spotify is currently $state."; - artist=`osascript -e 'tell application "Spotify" to artist of current track as string'`; - album=`osascript -e 'tell application "Spotify" to album of current track as string'`; - track=`osascript -e 'tell application "Spotify" to name of current track as string'`; duration=`osascript -e 'tell application "Spotify" set durSec to (duration of current track / 1000) as text set tM to (round (durSec / 60) rounding down) as text @@ -128,7 +140,7 @@ showStatus () { end tell return nowAt'`; - echo -e $reset"Artist: $artist\nAlbum: $album\nTrack: $track \nPosition: $position / $duration"; + echo -e $reset"Artist: $(showArtist)\nAlbum: $(showAlbum)\nTrack: $(showTrack) \nPosition: $position / $duration"; } if [ $# = 0 ]; then @@ -223,18 +235,18 @@ while [ $# -gt 0 ]; do results=$( \ curl -s -G $SPOTIFY_SEARCH_API --data-urlencode "q=$Q" -d "type=playlist&limit=10&offset=0" -H "Accept: application/json" -H "Authorization: Bearer ${SPOTIFY_ACCESS_TOKEN}" \ - | grep -E -o "spotify:user:[a-zA-Z0-9_]+:playlist:[a-zA-Z0-9]+" -m 10 \ + | grep -E -o "spotify:playlist:[a-zA-Z0-9]+" -m 10 \ ) count=$( \ - echo "$results" | grep -c "spotify:user" \ + echo "$results" | grep -c "spotify:playlist" \ ) if [ "$count" -gt 0 ]; then random=$(( $RANDOM % $count)); SPOTIFY_PLAY_URI=$( \ - echo "$results" | awk -v random="$random" '/spotify:user:[a-zA-Z0-9]+:playlist:[a-zA-Z0-9]+/{i++}i==random{print; exit}' \ + echo "$results" | awk -v random="$random" '/spotify:playlist:[a-zA-Z0-9]+/{i++}i==random{print; exit}' \ ) fi;; @@ -295,7 +307,7 @@ while [ $# -gt 0 ]; do "quit" ) cecho "Quitting Spotify."; osascript -e 'tell application "Spotify" to quit'; - exit 1 ;; + exit 0 ;; "next" ) cecho "Going to next track." ; osascript -e 'tell application "Spotify" to next track'; @@ -346,7 +358,7 @@ while [ $# -gt 0 ]; do echo " vol down # Decreases the volume by 10%."; echo " vol [amount] # Sets the volume to an amount between 0 and 100."; echo " vol # Shows the current Spotify volume."; - break + exit 1; fi osascript -e "tell application \"Spotify\" to set sound volume to $newvol"; @@ -365,7 +377,25 @@ while [ $# -gt 0 ]; do break ;; "status" ) - showStatus; + if [ $# != 1 ]; then + # There are additional arguments, a status subcommand + case $2 in + "artist" ) + showArtist; + break ;; + + "album" ) + showAlbum; + break ;; + + "track" ) + showTrack; + break ;; + esac + else + # status is the only param + showStatus; + fi break ;; "info" ) @@ -428,16 +458,20 @@ while [ $# -gt 0 ]; do cecho "Spotify URI: $uri"; echo -n $uri | pbcopy fi - break;; + break ;; "pos" ) cecho "Adjusting Spotify play position." osascript -e "tell application \"Spotify\" to set player position to $2"; - break;; + break ;; - "help" | * ) + "help" ) showHelp; break ;; + * ) + showHelp; + exit 1; + esac done } diff --git a/plugins/per-directory-history/README.md b/plugins/per-directory-history/README.md index ea445d329..69854aa38 100644 --- a/plugins/per-directory-history/README.md +++ b/plugins/per-directory-history/README.md @@ -1,55 +1,48 @@ -[Per-Directory-History][6] -========================= +per-directory-history plugin +---------------------------- -Per directory history for zsh, as well as global history, and the -ability to toggle between them with ^G. +This plugin adds per-directory history for zsh, as well as a global history, +and the ability to toggle between them with a keyboard shortcut. This is a +bundle of the [official plugin by @jimhester][5]. -This is a implementation of per directory history for zsh, some -implementations of which exist in bash[1][],[2][]. It also implements -a per-directory-history-toggle-history function to change from using the -directory history to using the global history. In both cases the history is -always saved to both the global history and the directory history, so the -toggle state will not effect the saved histories. Being able to switch -between global and directory histories on the fly is a novel feature as far -as I am aware. +To use it, add `per-directory-history` to the plugins array in your zshrc file: -This is a standalone repository for the script, however it is also included in -[oh-my-zsh][4] as a plugin. +```zsh +plugins=(... per-directory-history) +``` ----------------------------------------------------------------------------- -Usage ----------------------------------------------------------------------------- +This is an implementation of per-directory history for zsh, some implementations +of which exist in bash[1][],[2][]. It also implements a toggle-history function +to change from using the directory history to using the global history. In both +cases the history is always saved to both the global history and the directory +history, so the toggle state will not effect the saved histories. Being able to +switch between global and directory histories on the fly is a novel feature. -1. Load this script into your interactive ZSH session: +## Usage - % source zsh-per-directory-history.zsh +The default mode is per directory history, interact with your history as normal. -2. The default mode if per directory history, interact with your history as normal. +Press ^G (the <kbd>Control</kbd> and <kbd>G</kbd> keys simultaneously) to toggle +between local and global histories. If you would prefer a different shortcut to +toggle set the `PER_DIRECTORY_HISTORY_TOGGLE` environment variable. -3. Press ^G (the Control and G keys simultaneously) to toggle between local - and global histories. If you would prefer a different shortcut to toggle - set the PER_DIRECTORY_HISTORY_TOGGLE environment variable. +## Configuration -------------------------------------------------------------------------------- -Configuration -------------------------------------------------------------------------------- +* `HISTORY_BASE` is a global variable that defines the base directory in which the + directory histories are stored (default `$HOME/.directory_history`). +* `per-directory-history-toggle-history` is the function to toggle between local + and global histories. +* `PER_DIRECTORY_HISTORY_TOGGLE` is the key binding used to run the toggle-history + function above (default `^G`) -* HISTORY_BASE a global variable that defines the base directory in which the - directory histories are stored -* per-directory-history-toggle-history is the function to toggle the history - -------------------------------------------------------------------------------- -History -------------------------------------------------------------------------------- +## History The idea/inspiration for a per directory history is from [Stewart MacArthur][1] -and [Dieter][2], the implementation idea is from [Bart Schaefer][3]. The -implementation is by [Jim Hester][5] in September 2012. +and [Dieter][2], the implementation idea is from [Bart Schaefer][3]. The +implementation is by [Jim Hester][4] in September 2012. [1]: http://www.compbiome.com/2010/07/bash-per-directory-bash-history.html [2]: http://dieter.plaetinck.be/per_directory_bash [3]: https://www.zsh.org/mla/users/1997/msg00226.html -[4]: https://github.com/robbyrussell/oh-my-zsh -[5]: http://jimhester.com -[6]: https://github.com/jimhester/per-directory-history - +[4]: https://jimhester.com +[5]: https://github.com/jimhester/per-directory-history diff --git a/plugins/pip/pip.plugin.zsh b/plugins/pip/pip.plugin.zsh index 5539187e1..aaae90185 100644 --- a/plugins/pip/pip.plugin.zsh +++ b/plugins/pip/pip.plugin.zsh @@ -29,6 +29,7 @@ zsh-pip-cache-packages() { if [[ ! -f $ZSH_PIP_CACHE_FILE ]]; then echo -n "(...caching package index...)" tmp_cache=/tmp/zsh_tmp_cache + touch $tmp_cache for index in $ZSH_PIP_INDEXES ; do # well... I've already got two problems curl -L $index 2>/dev/null | \ diff --git a/plugins/pipenv/README.md b/plugins/pipenv/README.md new file mode 100644 index 000000000..ab1c1e442 --- /dev/null +++ b/plugins/pipenv/README.md @@ -0,0 +1,28 @@ +# Pipenv + +## Installation +In your `.zshrc` file, add `pipenv` to the plugins section + +``` +plugins=(... pipenv ...) +``` + +## Features +This plugin provides some features to simplify the use of Pipenv while working on ZSH. +- Adds completion for pipenv +- Auto activates and deactivates pipenv shell +- Adds short aliases for common pipenv commands + - `pch` is aliased to `pipenv check` + - `pcl` is aliased to `pipenv clean` + - `pgr` is aliased to `pipenv graph` + - `pi` is aliased to `pipenv install` + - `pidev` is aliased to `pipenv install --dev` + - `pl` is aliased to `pipenv lock` + - `po` is aliased to `pipenv open` + - `prun` is aliased to `pipenv run` + - `psh` is aliased to `pipenv shell` + - `psy` is aliased to `pipenv sync` + - `pu` is aliased to `pipenv uninstall` + - `pwh` is aliased to `pipenv --where` + - `pvenv` is aliased to `pipenv --venv` + - `ppy` is aliased to `pipenv --py` diff --git a/plugins/pipenv/pipenv.plugin.zsh b/plugins/pipenv/pipenv.plugin.zsh new file mode 100644 index 000000000..0a5dc56a4 --- /dev/null +++ b/plugins/pipenv/pipenv.plugin.zsh @@ -0,0 +1,42 @@ +# Pipenv completion +_pipenv() { + eval $(env COMMANDLINE="${words[1,$CURRENT]}" _PIPENV_COMPLETE=complete-zsh pipenv) +} +compdef _pipenv pipenv + +# Automatic pipenv shell activation/deactivation +_togglePipenvShell() { + # deactivate shell if Pipfile doesn't exist and not in a subdir + if [[ ! -a "$PWD/Pipfile" ]]; then + if [[ "$PIPENV_ACTIVE" == 1 ]]; then + if [[ "$PWD" != "$pipfile_dir"* ]]; then + exit + fi + fi + fi + + # activate the shell if Pipfile exists + if [[ "$PIPENV_ACTIVE" != 1 ]]; then + if [[ -a "$PWD/Pipfile" ]]; then + export pipfile_dir="$PWD" + pipenv shell + fi + fi +} +chpwd_functions+=(_togglePipenvShell) + +# Aliases +alias pch="pipenv check" +alias pcl="pipenv clean" +alias pgr="pipenv graph" +alias pi="pipenv install" +alias pidev="pipenv install --dev" +alias pl="pipenv lock" +alias po="pipenv open" +alias prun="pipenv run" +alias psh="pipenv shell" +alias psy="pipenv sync" +alias pu="pipenv uninstall" +alias pwh="pipenv --where" +alias pvenv="pipenv --venv" +alias ppy="pipenv --py" diff --git a/plugins/please/README.md b/plugins/please/README.md new file mode 100644 index 000000000..89bfbf105 --- /dev/null +++ b/plugins/please/README.md @@ -0,0 +1,26 @@ +# please plugin + +[Please](https://please.build) is a cross-language build system with an emphasis on +high performance, extensibility and reproduceability. It supports a number of popular +languages and can automate nearly any aspect of your build process. + +This plugin adds autocomplete and major aliases for `plz`, the command line tool for +Please. + +To use it, add `please` to the plugins array in your zshrc file: + +```zsh +plugins=(... please) +``` + +## Aliases + +| Alias | Command | +|-------|-------------| +| `pb` | `plz build` | +| `pt` | `plz test` | +| `pw` | `plz watch` | + +## Maintainer + +[@thought-machine](https://github.com/thought-machine) diff --git a/plugins/please/please.plugin.zsh b/plugins/please/please.plugin.zsh new file mode 100644 index 000000000..0f58307ab --- /dev/null +++ b/plugins/please/please.plugin.zsh @@ -0,0 +1,7 @@ +if (( $+commands[plz] )); then + source <(plz --completion_script) +fi + +alias pb='plz build' +alias pt='plz test' +alias pw='plz watch' diff --git a/plugins/pyenv/pyenv.plugin.zsh b/plugins/pyenv/pyenv.plugin.zsh index 4e92b8017..40e58b5c2 100644 --- a/plugins/pyenv/pyenv.plugin.zsh +++ b/plugins/pyenv/pyenv.plugin.zsh @@ -38,4 +38,4 @@ else } fi -unset FOUND_PYENV dir +unset FOUND_PYENV pyenvdirs dir diff --git a/plugins/rails/README.md b/plugins/rails/README.md index 7a3db3d64..5549ba18b 100644 --- a/plugins/rails/README.md +++ b/plugins/rails/README.md @@ -18,7 +18,7 @@ plugins=(... rails) | `rcs` | `rails console --sandbox` | Test code in a sandbox, without changing any data | | `rd` | `rails destroy` | Undo a generate operation | | `rdb` | `rails dbconsole` | Interact with your db from the console | -| `rg` | `rails generate` | Generate boilerplate code | +| `rgen` | `rails generate` | Generate boilerplate code | | `rgm` | `rails generate migration` | Generate a db migration | | `rp` | `rails plugin` | Run a Rails plugin command | | `ru` | `rails runner` | Run Ruby code in the context of Rails | @@ -66,7 +66,7 @@ plugins=(... rails) | `RET` | `RAILS_ENV=test` | Sets `RAILS_ENV` to test | These are global aliases. Use in combination with a command or just run them -separately. For example: `RED rake db:migrate` will migrate the production db. +separately. For example: `REP rake db:migrate` will migrate the production db. ### Legacy stuff diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh index eb3f30360..a8ec79db2 100644 --- a/plugins/rails/rails.plugin.zsh +++ b/plugins/rails/rails.plugin.zsh @@ -43,7 +43,7 @@ alias rc='rails console' alias rcs='rails console --sandbox' alias rd='rails destroy' alias rdb='rails dbconsole' -alias rg='rails generate' +alias rgen='rails generate' alias rgm='rails generate migration' alias rp='rails plugin' alias ru='rails runner' diff --git a/plugins/rbenv/rbenv.plugin.zsh b/plugins/rbenv/rbenv.plugin.zsh index 7430e9625..ed46d355b 100644 --- a/plugins/rbenv/rbenv.plugin.zsh +++ b/plugins/rbenv/rbenv.plugin.zsh @@ -1,60 +1,65 @@ -_homebrew-installed() { - type brew &> /dev/null -} - -FOUND_RBENV=0 -rbenvdirs=("$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv" "/usr/local/opt/rbenv") -if _homebrew-installed && rbenv_homebrew_path=$(brew --prefix rbenv 2>/dev/null); then - rbenvdirs=($rbenv_homebrew_path "${rbenvdirs[@]}") - unset rbenv_homebrew_path - if [[ $RBENV_ROOT = '' ]]; then - RBENV_ROOT="$HOME/.rbenv" - fi +# This plugin loads rbenv into the current shell and provides prompt info via +# the 'rbenv_prompt_info' function. + +FOUND_RBENV=$+commands[rbenv] + +if [[ $FOUND_RBENV -ne 1 ]]; then + rbenvdirs=("$HOME/.rbenv" "/usr/local/rbenv" "/opt/rbenv" "/usr/local/opt/rbenv") + for dir in $rbenvdirs; do + if [[ -d $dir/bin ]]; then + export PATH="$dir/bin:$PATH" + FOUND_RBENV=1 + break + fi + done fi -for rbenvdir in "${rbenvdirs[@]}" ; do - if [ -d $rbenvdir/bin -a $FOUND_RBENV -eq 0 ] ; then - FOUND_RBENV=1 - if [[ $RBENV_ROOT = '' ]]; then - RBENV_ROOT=$rbenvdir +if [[ $FOUND_RBENV -ne 1 ]]; then + if (( $+commands[brew] )) && dir=$(brew --prefix rbenv 2>/dev/null); then + if [[ -d $dir/bin ]]; then + export PATH="$dir/bin:$PATH" + FOUND_RBENV=1 + fi fi - export RBENV_ROOT - export PATH=${rbenvdir}/bin:$PATH +fi + +if [[ $FOUND_RBENV -eq 1 ]]; then eval "$(rbenv init --no-rehash - zsh)" alias rubies="rbenv versions" alias gemsets="rbenv gemset list" function current_ruby() { - echo "$(rbenv version-name)" + echo "$(rbenv version-name)" } function current_gemset() { - echo "$(rbenv gemset active 2&>/dev/null | sed -e ":a" -e '$ s/\n/+/gp;N;b a' | head -n1)" + echo "$(rbenv gemset active 2&>/dev/null | sed -e ":a" -e '$ s/\n/+/gp;N;b a' | head -n1)" } - function gems { - local rbenv_path=$(rbenv prefix) - gem list $@ | sed -E \ - -e "s/\([0-9a-z, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \ - -e "s|$(echo $rbenv_path)|$fg[magenta]\$rbenv_path$reset_color|g" \ - -e "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \ - -e "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g" + function gems() { + local rbenv_path=$(rbenv prefix) + gem list $@ | sed -E \ + -e "s/\([0-9a-z, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \ + -e "s|$(echo $rbenv_path)|$fg[magenta]\$rbenv_path$reset_color|g" \ + -e "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \ + -e "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g" } function rbenv_prompt_info() { - if [[ -n $(current_gemset) ]] ; then - echo "$(current_ruby)@$(current_gemset)" - else - echo "$(current_ruby)" - fi + if [[ -n $(current_gemset) ]] ; then + echo "$(current_ruby)@$(current_gemset)" + else + echo "$(current_ruby)" + fi } - fi -done -unset rbenvdir - -if [ $FOUND_RBENV -eq 0 ] ; then - alias rubies='ruby -v' - function gemsets() { echo 'not supported' } - function rbenv_prompt_info() { echo "system: $(ruby -v | cut -f-2 -d ' ')" } +else + alias rubies="ruby -v" + function gemsets() { echo "not supported" } + function current_ruby() { echo "not supported" } + function current_gemset() { echo "not supported" } + function gems() { echo "not supported" } + function rbenv_prompt_info() { echo "system: $(ruby -v | cut -f-2 -d ' ')" } fi + +unset FOUND_RBENV rbenvdirs dir diff --git a/plugins/sdk/README.md b/plugins/sdk/README.md new file mode 100644 index 000000000..b237f3b4c --- /dev/null +++ b/plugins/sdk/README.md @@ -0,0 +1,8 @@ +# sdk + +Plugin for SDKMAN, a tool for managing parallel versions of multiple Software Development Kits on most Unix based systems. +Provides autocompletion for all known commands. + +## Requirements + + * [SDKMAN](http://sdkman.io/) diff --git a/plugins/sdk/sdk.plugin.zsh b/plugins/sdk/sdk.plugin.zsh new file mode 100644 index 000000000..d00459b16 --- /dev/null +++ b/plugins/sdk/sdk.plugin.zsh @@ -0,0 +1,82 @@ +### SDKMAN Autocomplete for Oh My Zsh + +# This is the output from sdkman. All the these options are supported at the +# moment. + +# Usage: sdk <command> [candidate] [version] +# sdk offline <enable|disable> +# +# commands: +# install or i <candidate> [version] +# uninstall or rm <candidate> <version> +# list or ls [candidate] +# use or u <candidate> [version] +# default or d <candidate> [version] +# current or c [candidate] +# upgrade or ug [candidate] +# version or v +# broadcast or b +# help or h +# offline [enable|disable] +# selfupdate [force] +# update +# flush <candidates|broadcast|archives|temp> +# +# candidate : the SDK to install: groovy, scala, grails, gradle, kotlin, etc. +# use list command for comprehensive list of candidates +# eg: $ sdk list +# +# version : where optional, defaults to latest stable if not provided +# eg: $ sdk install groovy + +local _sdk_commands=( + install i + uninstall rm + list ls + use u + default d + current c + upgrade ug + version v + broadcast b + help h + offline + selfupdate + update + flush +) + +_listInstalledVersions() { + __sdkman_build_version_csv $1 | sed -e "s/,/ /g" +} + +_listInstallableVersions() { + __sdkman_list_versions $1 | grep "^ " | sed -e "s/\* /*/g" | \ + sed -e "s/>//g" | xargs -n 1 echo | grep -v "^*" +} + +_listAllVersion() { + __sdkman_list_versions $1 | grep "^ " | sed -e "s/\*/ /g" | sed -e "s/>//g" +} + +_sdk () { + case $CURRENT in + 2) compadd -- $_sdk_commands ;; + 3) case "$words[2]" in + i|install|rm|uninstall|ls|list|u|use|d|default|c|current|ug|upgrade) + compadd -- $SDKMAN_CANDIDATES ;; + offline) compadd -- enable disable ;; + selfupdate) compadd -- force ;; + flush) compadd -- candidates broadcast archives temp ;; + esac + ;; + 4) case "$words[2]" in + rm|uninstall|d|default) compadd -- $(_listInstalledVersions $words[3]) ;; + i|install) compadd -- $(_listInstallableVersions $words[3]) ;; + u|use) compadd -- $(_listAllVersion $words[3]) ;; + esac + ;; + esac +} + +compdef _sdk sdk diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index a7a4ee33a..9471ff49c 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -5,7 +5,7 @@ function _start_agent() { zstyle -s :omz:plugins:ssh-agent lifetime lifetime # start ssh-agent and setup environment - echo starting ssh-agent... + echo Starting ssh-agent... ssh-agent -s ${lifetime:+-t} ${lifetime} | sed 's/^echo/#echo/' >! $_ssh_env_cache chmod 600 $_ssh_env_cache . $_ssh_env_cache > /dev/null diff --git a/plugins/svn-fast-info/svn-fast-info.plugin.zsh b/plugins/svn-fast-info/svn-fast-info.plugin.zsh index 9ea7f641d..fe5265315 100644 --- a/plugins/svn-fast-info/svn-fast-info.plugin.zsh +++ b/plugins/svn-fast-info/svn-fast-info.plugin.zsh @@ -16,30 +16,30 @@ function svn_prompt_info() { if [[ -n $repo_need_upgrade ]]; then printf '%s%s%s%s%s%s%s\n' \ - $ZSH_PROMPT_BASE_COLOR \ - $ZSH_THEME_SVN_PROMPT_PREFIX \ - $ZSH_PROMPT_BASE_COLOR \ - $repo_need_upgrade \ - $ZSH_PROMPT_BASE_COLOR \ - $ZSH_THEME_SVN_PROMPT_SUFFIX \ - $ZSH_PROMPT_BASE_COLOR + "$ZSH_PROMPT_BASE_COLOR" \ + "$ZSH_THEME_SVN_PROMPT_PREFIX" \ + "$ZSH_PROMPT_BASE_COLOR" \ + "$repo_need_upgrade" \ + "$ZSH_PROMPT_BASE_COLOR" \ + "$ZSH_THEME_SVN_PROMPT_SUFFIX" \ + "$ZSH_PROMPT_BASE_COLOR" else - printf '%s%s%s %s%s:%s%s%s%s%s' \ - $ZSH_PROMPT_BASE_COLOR \ - $ZSH_THEME_SVN_PROMPT_PREFIX \ + printf '%s%s%s%s %s%s%s:%s%s%s%s' \ + "$ZSH_PROMPT_BASE_COLOR" \ + "$ZSH_THEME_SVN_PROMPT_PREFIX" \ \ "$(svn_status_info $info)" \ - $ZSH_PROMPT_BASE_COLOR \ + "$ZSH_PROMPT_BASE_COLOR" \ \ - $ZSH_THEME_BRANCH_NAME_COLOR \ - $(svn_current_branch_name $info) \ - $ZSH_PROMPT_BASE_COLOR \ + "$ZSH_THEME_BRANCH_NAME_COLOR" \ + "$(svn_current_branch_name $info)" \ + "$ZSH_PROMPT_BASE_COLOR" \ \ - $(svn_current_revision $info) \ - $ZSH_PROMPT_BASE_COLOR \ + "$(svn_current_revision $info)" \ + "$ZSH_PROMPT_BASE_COLOR" \ \ - $ZSH_THEME_SVN_PROMPT_SUFFIX \ - $ZSH_PROMPT_BASE_COLOR + "$ZSH_THEME_SVN_PROMPT_SUFFIX" \ + "$ZSH_PROMPT_BASE_COLOR" fi } @@ -63,11 +63,12 @@ function svn_current_revision() { function svn_status_info() { local svn_status_string="$ZSH_THEME_SVN_PROMPT_CLEAN" local svn_status="$(svn status 2> /dev/null)"; - if command grep -E '^\s*A' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_ADDITIONS:-+}"; fi - if command grep -E '^\s*D' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DELETIONS:-✖}"; fi - if command grep -E '^\s*M' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_MODIFICATIONS:-✎}"; fi - if command grep -E '^\s*[R~]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_REPLACEMENTS:-∿}"; fi - if command grep -E '^\s*\?' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_UNTRACKED:-?}"; fi - if command grep -E '^\s*[CI!L]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DIRTY:-'!'}"; fi + if command grep -E '^\s*A' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_ADDITIONS:-+}"; fi + if command grep -E '^\s*D' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_DELETIONS:-✖}"; fi + if command grep -E '^\s*M' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_MODIFICATIONS:-✎}"; fi + if command grep -E '^\s*[R~]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_REPLACEMENTS:-∿}"; fi + if command grep -E '^\s*\?' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_UNTRACKED:-?}"; fi + if command grep -E '^\s*[CI!L]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_DIRTY:-!}"; fi echo $svn_status_string } + diff --git a/plugins/torrent/README.md b/plugins/torrent/README.md new file mode 100644 index 000000000..079aafcb0 --- /dev/null +++ b/plugins/torrent/README.md @@ -0,0 +1,13 @@ +# torrent + +This plugin creates a Torrent file based on a [MagnetURI](https://en.wikipedia.org/wiki/Magnet_URI_scheme). + +To use it, add `torrent` to the plugins array in your zshrc file. + +```zsh +plugins=(... torrent) +``` + +## Plugin commands + +* `magnet_to_torrent <MagnetURI>`: creates Torrent file. diff --git a/plugins/ubuntu/README.md b/plugins/ubuntu/README.md index caa6a90b4..f72182f5c 100644 --- a/plugins/ubuntu/README.md +++ b/plugins/ubuntu/README.md @@ -2,7 +2,7 @@ This plugin adds completions and aliases for [Ubuntu](https://www.ubuntu.com/). -To use it, add `ubuntu` to the plugins array in your zshrc file: +To use it, add `ubuntu` to the plugins array in your zshrc file: ```zsh plugins=(... ubuntu) @@ -10,34 +10,34 @@ plugins=(... ubuntu) ## Aliases -Commands that use `$APT` will use apt if installed or defer to apt-get otherwise. - -| Alias | Command | Description | -|---------|------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------| -| acs | `apt-cache search` | Search the apt-cache with the specified criteria | -| acp | `apt-cache policy` | Display the package source priorities | -| afs | `apt-file search --regexp` | Perform a regular expression apt-file search | -| afu | `sudo apt-file update` | Generates or updates the apt-file package database | -| ag | `sudo $APT` | Run apt-get with sudo | -| aga | `sudo $APT autoclean` | Clears out the local reposityory of retrieved package files that can no longer be downloaded | -| agb | `sudo $APT build-dep <source_pkg>` | Installs/Removes packages to satisfy the dependencies of a specified build pkg | -| agc | `sudo $APT clean` | Clears out the local repository of retrieved package files leaving everything from the lock files | -| agd | `sudo $APT dselect-upgrade` | Follows dselect choices for package installation | -| agi | `sudo $APT install <pkg>` | Install the specified package | -| agli | `apt list --installed` | List the installed packages | -| aglu | `sudo apt-get -u upgrade --assume-no` | Run an apt-get upgrade assuming no to all prompts | -| agp | `sudo $APT purge <pkg>` | Remove a package including any configuration files | -| agr | `sudo $APT remove <pkg>` | Remove a package | -| ags | `$APT source <pkg>` | Fetch the source for the specified package | -| agu | `sudo $APT update` | Update package list | -| agud | `sudo $APT update && sudo $APT dist-upgrade` | Update packages list and perform a distribution upgrade | -| agug | `sudo $APT upgrade` | Upgrade available packages | -| agar | `sudo $APT autoremove` | Remove automatically installed packages no longer needed | -| aguu | `sudo $APT update && sudo $APT upgrade` | Update packages list and upgrade available packages | -| allpkgs | `dpkg --get-selections \| grep -v deinstall` | Print all installed packages | -| kclean | `sudo aptitude remove -P ?and(~i~nlinux-(ima\|hea) ?not(~n$(uname -r)))` |Remove ALL kernel images and headers EXCEPT the one in use | -| mydeb | `time dpkg-buildpackage -rfakeroot -us -uc` | Create a basic .deb package | -| ppap | `sudo ppa-purge <ppa>` | Remove the specified PPA | +Commands that use `$APT` will use `apt` if installed or defer to `apt-get` otherwise. + +| Alias | Command | Description | +|---------|--------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------| +| age | `sudo $APT` | Run apt-get with sudo | +| acs | `apt-cache search` | Search the apt-cache with the specified criteria | +| acp | `apt-cache policy` | Display the package source priorities | +| afs | `apt-file search --regexp` | Perform a regular expression apt-file search | +| afu | `sudo apt-file update` | Generates or updates the apt-file package database | +| aga | `sudo $APT autoclean` | Clears out the local reposityory of retrieved package files that can no longer be downloaded | +| agb | `sudo $APT build-dep <source_pkg>` | Installs/Removes packages to satisfy the dependencies of a specified build pkg | +| agc | `sudo $APT clean` | Clears out the local repository of retrieved package files leaving everything from the lock files | +| agd | `sudo $APT dselect-upgrade` | Follows dselect choices for package installation | +| agi | `sudo $APT install <pkg>` | Install the specified package | +| agli | `apt list --installed` | List the installed packages | +| aglu | `sudo apt-get -u upgrade --assume-no` | Run an apt-get upgrade assuming no to all prompts | +| agp | `sudo $APT purge <pkg>` | Remove a package including any configuration files | +| agr | `sudo $APT remove <pkg>` | Remove a package | +| ags | `$APT source <pkg>` | Fetch the source for the specified package | +| agu | `sudo $APT update` | Update package list | +| agud | `sudo $APT update && sudo $APT dist-upgrade` | Update packages list and perform a distribution upgrade | +| agug | `sudo $APT upgrade` | Upgrade available packages | +| agar | `sudo $APT autoremove` | Remove automatically installed packages no longer needed | +| aguu | `sudo $APT update && sudo $APT upgrade` | Update packages list and upgrade available packages | +| allpkgs | `dpkg --get-selections \| grep -v deinstall` | Print all installed packages | +| kclean | `sudo aptitude remove -P ?and(~i~nlinux-(ima\|hea) ?not(~n$(uname -r)))` |Remove ALL kernel images and headers EXCEPT the one in use | +| mydeb | `time dpkg-buildpackage -rfakeroot -us -uc` | Create a basic .deb package | +| ppap | `sudo ppa-purge <ppa>` | Remove the specified PPA | ## Functions @@ -47,6 +47,14 @@ Commands that use `$APT` will use apt if installed or defer to apt-get otherwise | aar | `aar ppa:xxxxxx/xxxxxx [packagename]` | apt-add-repository with automatic install/upgrade of the desired package | | apt-history | `apt-history <action>` | Prints the Apt history of the specified action | | apt-list-packages | `apt-list-packages` | List packages by size | -| kerndeb | `kerndeb` | Kernel-package building shortcut | +| kerndeb | `kerndeb` | Kernel-package building shortcut | +## Authors: +- [@AlexBio](https://github.com/AlexBio) +- [@dbb](https://github.com/dbb) +- [@Mappleconfusers](https://github.com/Mappleconfusers) +- [@trinaldi](https://github.com/trinaldi) +- [Nicolas Jonas](https://nextgenthemes.com) +- [@loctauxphilippe](https://github.com/loctauxphilippe) +- [@HaraldNordgren](https://github.com/HaraldNordgren) diff --git a/plugins/ubuntu/ubuntu.plugin.zsh b/plugins/ubuntu/ubuntu.plugin.zsh index 198f06743..d589096c3 100644 --- a/plugins/ubuntu/ubuntu.plugin.zsh +++ b/plugins/ubuntu/ubuntu.plugin.zsh @@ -1,76 +1,43 @@ -# Authors: -# https://github.com/AlexBio -# https://github.com/dbb -# https://github.com/Mappleconfusers -# https://github.com/trinaldi -# Nicolas Jonas nextgenthemes.com -# https://github.com/loctauxphilippe -# https://github.com/HaraldNordgren -# -# Debian, Ubuntu and friends related zsh aliases and functions for zsh - (( $+commands[apt] )) && APT=apt || APT=apt-get alias acs='apt-cache search' -compdef _acs acs='apt-cache search' alias afs='apt-file search --regexp' -compdef _afs afs='apt-file search --regexp' # These are apt/apt-get only -alias ags="$APT source" # asrc -compdef _ags ags="$APT source" +alias ags="$APT source" -alias acp='apt-cache policy' # app -compdef _acp acp='apt-cache policy' +alias acp='apt-cache policy' #List all installed packages alias agli='apt list --installed' -compdef _agli agli='apt list --installed' # superuser operations ###################################################### # List available updates only alias aglu='sudo apt-get -u upgrade --assume-no' -compdef _aglu aglu='sudo apt-get -u upgrade --assume-no' alias afu='sudo apt-file update' -compdef _afu afu='sudo apt-file update' alias ppap='sudo ppa-purge' -compdef _ppap ppap='sudo ppa-purge' - -alias ag="sudo $APT" # age - but without sudo -alias aga="sudo $APT autoclean" # aac -alias agb="sudo $APT build-dep" # abd -alias agc="sudo $APT clean" # adc -alias agd="sudo $APT dselect-upgrade" # ads -alias agi="sudo $APT install" # ai -alias agp="sudo $APT purge" # ap -alias agr="sudo $APT remove" # ar -alias agu="sudo $APT update" # ad -alias agud="sudo $APT update && sudo $APT dist-upgrade" #adu -alias agug="sudo $APT upgrade" # ag -alias aguu="sudo $APT update && sudo $APT upgrade" #adg + +alias age="sudo $APT" +alias aga="sudo $APT autoclean" +alias agb="sudo $APT build-dep" +alias agc="sudo $APT clean" +alias agd="sudo $APT dselect-upgrade" +alias agi="sudo $APT install" +alias agp="sudo $APT purge" +alias agr="sudo $APT remove" +alias agu="sudo $APT update" +alias agud="sudo $APT update && sudo $APT dist-upgrade" +alias agug="sudo $APT upgrade" +alias aguu="sudo $APT update && sudo $APT upgrade" alias agar="sudo $APT autoremove" -compdef _ag ag="sudo $APT" -compdef _aga aga="sudo $APT autoclean" -compdef _agb agb="sudo $APT build-dep" -compdef _agc agc="sudo $APT clean" -compdef _agd agd="sudo $APT dselect-upgrade" -compdef _agi agi="sudo $APT install" -compdef _agp agp="sudo $APT purge" -compdef _agr agr="sudo $APT remove" -compdef _agu agu="sudo $APT update" -compdef _agud agud="sudo $APT update && sudo $APT dist-upgrade" -compdef _agug agug="sudo $APT upgrade" -compdef _aguu aguu="sudo $APT update && sudo $APT upgrade" -compdef _agar agar="sudo $APT autoremove" # Remove ALL kernel images and headers EXCEPT the one in use -alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) \ - ?not(~n`uname -r`))' +alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) ?not(~n`uname -r`))' # Misc. ##################################################################### # print all installed packages @@ -89,11 +56,11 @@ aar() { else read "PACKAGE?Type in the package name to install/upgrade with this ppa [${1##*/}]: " fi - + if [ -z "$PACKAGE" ]; then PACKAGE=${1##*/} fi - + sudo apt-add-repository $1 && sudo $APT update sudo $APT install $PACKAGE } @@ -136,22 +103,22 @@ apt-history () { # Kernel-package building shortcut kerndeb () { - # temporarily unset MAKEFLAGS ( '-j3' will fail ) - MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' ) - print '$MAKEFLAGS set to '"'$MAKEFLAGS'" - appendage='-custom' # this shows up in $ (uname -r ) - revision=$(date +"%Y%m%d") # this shows up in the .deb file name + # temporarily unset MAKEFLAGS ( '-j3' will fail ) + MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' ) + print '$MAKEFLAGS set to '"'$MAKEFLAGS'" + appendage='-custom' # this shows up in $(uname -r) + revision=$(date +"%Y%m%d") # this shows up in the .deb file name - make-kpkg clean + make-kpkg clean - time fakeroot make-kpkg --append-to-version "$appendage" --revision \ - "$revision" kernel_image kernel_headers + time fakeroot make-kpkg --append-to-version "$appendage" --revision \ + "$revision" kernel_image kernel_headers } # List packages by size function apt-list-packages { - dpkg-query -W --showformat='${Installed-Size} ${Package} ${Status}\n' | \ - grep -v deinstall | \ - sort -n | \ - awk '{print $1" "$2}' + dpkg-query -W --showformat='${Installed-Size} ${Package} ${Status}\n' | \ + grep -v deinstall | \ + sort -n | \ + awk '{print $1" "$2}' } diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh index a82e41439..c91ba05ba 100644 --- a/plugins/vi-mode/vi-mode.plugin.zsh +++ b/plugins/vi-mode/vi-mode.plugin.zsh @@ -8,13 +8,24 @@ function zle-keymap-select() { } zle -N zle-keymap-select -zle -N edit-command-line + +function vi-accept-line() { + VI_KEYMAP=main + zle accept-line +} + +zle -N vi-accept-line bindkey -v +# use custom accept-line widget to update $VI_KEYMAP +bindkey -M vicmd '^J' vi-accept-line +bindkey -M vicmd '^M' vi-accept-line + # allow v to edit the command line (standard behaviour) autoload -Uz edit-command-line +zle -N edit-command-line bindkey -M vicmd 'v' edit-command-line # allow ctrl-p, ctrl-n for navigate history (standard behaviour) diff --git a/plugins/vscode/README.md b/plugins/vscode/README.md index 8ee45525a..74b5a45aa 100644 --- a/plugins/vscode/README.md +++ b/plugins/vscode/README.md @@ -8,6 +8,21 @@ To start using it, add the `vscode` plugin to your `plugins` array in `~/.zshrc` plugins=(... vscode) ``` +If you are using [Visual Studio Code Insiders](https://code.visualstudio.com/insiders/), +add the following line in the oh-my-zsh settings section (between the `ZSH_THEME` and +the `plugins=()` line). This will make the plugin use the Insiders version instead. + +```zsh +ZSH_THEME=... + +# Add this line to use code-insiders instead of code +VSCODE=code-insiders + +plugins=(... vscode) + +source $ZSH/oh-my-zsh.sh +``` + ## Common aliases | Alias | Command | Description | diff --git a/plugins/vscode/vscode.plugin.zsh b/plugins/vscode/vscode.plugin.zsh index 902c23ecf..4c15df2b0 100644 --- a/plugins/vscode/vscode.plugin.zsh +++ b/plugins/vscode/vscode.plugin.zsh @@ -1,19 +1,22 @@ # VScode zsh plugin # author: https://github.com/MarsiBarsi -alias vsc='code .' -alias vsca='code --add' -alias vscd='code --diff' -alias vscg='code --goto' -alias vscn='code --new-window' -alias vscr='code --reuse-window' -alias vscw='code --wait' -alias vscu='code --user-data-dir' +# Use main Visual Studio Code version by default +: ${VSCODE:=code} -alias vsced='code --extensions-dir' -alias vscie='code --install-extension' -alias vscue='code --uninstall-extension' +alias vsc="$VSCODE ." +alias vsca="$VSCODE --add" +alias vscd="$VSCODE --diff" +alias vscg="$VSCODE --goto" +alias vscn="$VSCODE --new-window" +alias vscr="$VSCODE --reuse-window" +alias vscw="$VSCODE --wait" +alias vscu="$VSCODE --user-data-dir" -alias vscv='code --verbose' -alias vscl='code --log' -alias vscde='code --disable-extensions' +alias vsced="$VSCODE --extensions-dir" +alias vscie="$VSCODE --install-extension" +alias vscue="$VSCODE --uninstall-extension" + +alias vscv="$VSCODE --verbose" +alias vscl="$VSCODE --log" +alias vscde="$VSCODE --disable-extensions" |