1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-11-28 00:30:07 +00:00

Merge branch 'master' into clipboard

This commit is contained in:
Marc Cornellà 2020-02-27 22:55:30 +01:00 committed by GitHub
commit 18ee5dffdc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
261 changed files with 5590 additions and 2782 deletions

View file

@ -1,7 +1,7 @@
--- ---
name: Bug report name: Bug report
about: Create a report to help us improve about: Create a report to help us improve Oh My Zsh
labels: 'Type: bug' labels: 'Type: support'
--- ---
@ -11,29 +11,26 @@ an issue where no sections have been filled will be deleted without comment.
--> -->
**Describe the bug** **Describe the bug**
<!-- A clear and concise description of what the bug is. --> A clear description of what the bug is.
**To Reproduce** **To Reproduce**
<!-- Steps to reproduce the behavior, for example:
Steps to reproduce the behavior: 1. Enable this plugin '...'
1. Enable plugin '...' 2. Run command '...' or try the autocomplete command '...'
2. Run command '...', _or_ try to complete command '...', _etc._
3. See error 3. See error
-->
**Expected behavior** **Expected behavior**
<!-- A clear and concise description of what you expected to happen. --> A brief description of what should happen.
**Screenshots or recordings** **Screenshots and/or Recordings**
<!-- If applicable, add screenshots to help explain your problem.
If applicable, add screenshots or record an asciinema session (https://asciinema.org/) You can also record an asciinema session: https://asciinema.org/
to help explain your problem.
-->
**System:** **Desktop (please complete the following information):**
- OS: [e.g. macOS] - OS / Distro: [e.g. Arch Linux, macOS]
- Zsh version [e.g. 5.6] - Latest ohmyzsh Update?: [e.g. Yes/No]
- ZSH Version: [e.g. 5.6]
- Terminal emulator [e.g. iTerm2] - Terminal emulator [e.g. iTerm2]
**Additional context** **Additional context**
<!-- Add any other context about the problem here. --> Add any other context about the problem here. This can be themes, plugins, custom configs.

View file

@ -11,16 +11,16 @@ an issue where no sections have been filled will be deleted without comment.
--> -->
**Is your feature request related to a particular plugin or theme? If so, specify it.** **Is your feature request related to a particular plugin or theme? If so, specify it.**
<!-- The name of the plugin or theme you'd like us to improve. --> The name of the plugin or theme that you would like us to improve. [...]
**Is your feature request related to a problem? Please describe.** **Is your feature request related to a problem? Please describe.**
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] --> A description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like** **Describe the solution you'd like**
<!-- A clear and concise description of what you want to happen. --> A description of what you want to happen.
**Describe alternatives you've considered** **Describe alternatives you've considered**
<!-- A clear and concise description of any alternative solutions or features you've considered. --> A description of any alternative solutions or features you've considered. This can also include other plugins or aliases.
**Additional context** **Additional context**
<!-- Add any other context or screenshots about the feature request here. --> Add any other context or screenshots about the feature request here. Also if you have any PRs related to this issue that are already open that you would like us to look at.

View file

@ -5,8 +5,6 @@ labels: 'Type: support'
--- ---
<!--
1. Look for similar issues already posted (including closed ones) 1. Look for similar issues already posted (including closed ones)
2. Include as much relevant information as possible 2. Include as much relevant information as possible
3. Try to make sure the issue is due to Oh My Zsh 3. Try to make sure the issue is due to Oh My Zsh
-->

17
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,17 @@
## Standards checklist:
- [ ] The PR title is descriptive.
- [ ] The PR doesn't replicate another PR which is already open.
- [ ] I have read the contribution guide and followed all the instructions.
- [ ] The code follows the code style guide detailed in the wiki.
- [ ] The code is mine or it's from somewhere with an MIT-compatible license.
- [ ] The code is efficient, to the best of my ability, and does not waste computer resources.
- [ ] The code is stable and I have tested it myself, to the best of my abilities.
## Changes:
- [...]
## Other comments:
...

17
.github/main.workflow vendored
View file

@ -1,17 +0,0 @@
workflow "Triage Pull Request" {
on = "pull_request"
resolves = ["Triage"]
}
# Only act if there are code changes: if the pull_request
# event's action is either 'opened' (new PR) or 'synchronize' (new commits)
action "Filter actions" {
uses = "actions/bin/filter@0ac6d44"
args = "action 'opened|synchronize'"
}
action "Triage" {
needs = ["Filter actions"]
uses = "ohmyzsh/github-actions/pull-request-triage@master"
secrets = ["GITHUB_TOKEN"]
}

36
.github/workflows/main.yml vendored Normal file
View file

@ -0,0 +1,36 @@
name: CI
on:
pull_request:
types:
- opened
- synchronize
branches:
- master
push:
branches:
- master
jobs:
tests:
name: Run tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- name: Set up git repository
uses: actions/checkout@v2
- name: Install zsh
if: runner.os == 'Linux'
run: sudo apt-get update; sudo apt-get install zsh
- name: Test installer
run: sh ./tools/install.sh
- name: Check syntax
run: |
for file in ./oh-my-zsh.sh \
./lib/*.zsh \
./plugins/*/*.plugin.zsh \
./plugins/*/_* \
./themes/*.zsh-theme; do
zsh -n "$file" || return 1
done

2
.gitignore vendored
View file

@ -4,3 +4,5 @@ custom/
# temp files directories # temp files directories
cache/ cache/
log/ log/
*.swp
.DS_Store

View file

@ -31,7 +31,7 @@ your problem.
If you find one, comment on it so we can know there are more people experiencing it. If you find one, comment on it so we can know there are more people experiencing it.
If not, look at the [Troubleshooting](https://github.com/robbyrussell/oh-my-zsh/wiki/Troubleshooting) If not, look at the [Troubleshooting](https://github.com/ohmyzsh/ohmyzsh/wiki/Troubleshooting)
page for instructions on how to gather data to better debug your problem. page for instructions on how to gather data to better debug your problem.
Then, you can go ahead and create an issue with as much detail as you can provide. Then, you can go ahead and create an issue with as much detail as you can provide.
@ -62,7 +62,7 @@ maintainers) by mentioning their GitHub handle (starting with `@`) in your messa
You should be familiar with the basics of You should be familiar with the basics of
[contributing on GitHub](https://help.github.com/articles/using-pull-requests) and have a fork [contributing on GitHub](https://help.github.com/articles/using-pull-requests) and have a fork
[properly set up](https://github.com/robbyrussell/oh-my-zsh/wiki/Contribution-Technical-Practices). [properly set up](https://github.com/ohmyzsh/ohmyzsh/wiki/Contribution-Technical-Practices).
You MUST always create PRs with _a dedicated branch_ based on the latest upstream tree. You MUST always create PRs with _a dedicated branch_ based on the latest upstream tree.
@ -85,7 +85,7 @@ maintainers) by mentioning their GitHub handle (starting with `@`) in your messa
### You have an addition ### You have an addition
Please [do not](https://github.com/robbyrussell/oh-my-zsh/wiki/Themes#dont-send-us-your-theme-for-now) Please [do not](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#dont-send-us-your-theme-for-now)
send themes for now. send themes for now.
Please be so kind as to [search](#use-the-search-luke) for any pending, merged or rejected Pull Requests Please be so kind as to [search](#use-the-search-luke) for any pending, merged or rejected Pull Requests
@ -109,7 +109,7 @@ to help you check whether a similar contribution to yours already exists. Please
before making any contribution, it avoids duplicates and eases maintenance. Trust me, before making any contribution, it avoids duplicates and eases maintenance. Trust me,
that works 90% of the time. that works 90% of the time.
You can also take a look at the [FAQ](https://github.com/robbyrussell/oh-my-zsh/wiki/FAQ) You can also take a look at the [FAQ](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ)
to be sure your contribution has not already come up. to be sure your contribution has not already come up.
If all fails, your thing has probably not been reported yet, so you can go ahead If all fails, your thing has probably not been reported yet, so you can go ahead
@ -121,5 +121,5 @@ and [create an issue](#reporting-issues) or [submit a PR](#submitting-pull-reque
Very nice!! :) Very nice!! :)
Please have a look at the [Volunteer](https://github.com/robbyrussell/oh-my-zsh/wiki/Volunteers) Please have a look at the [Volunteer](https://github.com/ohmyzsh/ohmyzsh/wiki/Volunteers)
page for instructions on where to start and more. page for instructions on where to start and more.

View file

@ -1,7 +1,6 @@
The MIT License (MIT) MIT License
Copyright (c) 2009-2019 Robby Russell and contributors Copyright (c) 2009-2020 Robby Russell and contributors (https://github.com/ohmyzsh/ohmyzsh/contributors)
See the full list at https://github.com/robbyrussell/oh-my-zsh/contributors
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View file

@ -12,16 +12,18 @@ Once installed, your terminal shell will become the talk of the town _or your mo
Finally, you'll begin to get the sort of attention that you have always felt you deserved. ...or maybe you'll use the time that you're saving to start flossing more often. 😬 Finally, you'll begin to get the sort of attention that you have always felt you deserved. ...or maybe you'll use the time that you're saving to start flossing more often. 😬
To learn more, visit [ohmyz.sh](https://ohmyz.sh) and follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter, and/or join us on Discord.
[![CI](https://github.com/ohmyzsh/ohmyzsh/workflows/CI/badge.svg)](https://github.com/ohmyzsh/ohmyzsh/actions?query=workflow%3ACI)
[![Follow @ohmyzsh](https://img.shields.io/twitter/follow/ohmyzsh?label=Follow+@ohmyzsh&style=flat)](https://twitter.com/intent/follow?screen_name=ohmyzsh)
[![Discord server](https://img.shields.io/discord/642496866407284746)](https://discord.gg/bpXWhnN)
## Getting Started ## Getting Started
### Prerequisites ### Prerequisites
__Disclaimer:__ _Oh My Zsh works best on macOS and Linux._ * A Unix-like operating system: macOS, Linux, BSD. On Windows: WSL is preferred, but cygwin or msys also mostly work.
* [Zsh](https://www.zsh.org) should be installed (v4.3.9 or more recent). If not pre-installed (run `zsh --version` to confirm), check the following instructions here: [Installing ZSH](https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH)
* Unix-like operating system (macOS or Linux)
* [Zsh](https://www.zsh.org) should be installed (v4.3.9 or more recent). If not pre-installed (`zsh --version` to confirm), check the following instruction here: [Installing ZSH](https://github.com/robbyrussell/oh-my-zsh/wiki/Installing-ZSH)
* `curl` or `wget` should be installed * `curl` or `wget` should be installed
* `git` should be installed * `git` should be installed
@ -32,13 +34,13 @@ Oh My Zsh is installed by running one of the following commands in your terminal
#### via curl #### via curl
```shell ```shell
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
``` ```
#### via wget #### via wget
```shell ```shell
sh -c "$(wget -O- https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
``` ```
#### Manual inspection #### Manual inspection
@ -48,7 +50,7 @@ that by downloading the install script first, looking through it so everything l
then running it: then running it:
```shell ```shell
curl -Lo install.sh https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh curl -Lo install.sh https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
sh install.sh sh install.sh
``` ```
@ -56,7 +58,7 @@ sh install.sh
### Plugins ### Plugins
Oh My Zsh comes with a shitload of plugins to take advantage of. You can take a look in the [plugins](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins) directory and/or the [wiki](https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins) to see what's currently available. Oh My Zsh comes with a shitload of plugins to take advantage of. You can take a look in the [plugins](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins) directory and/or the [wiki](https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins) to see what's currently available.
#### Enabling Plugins #### Enabling Plugins
@ -88,7 +90,7 @@ Most plugins (should! we're working on this) include a __README__, which documen
### Themes ### Themes
We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme happy. We have over one hundred themes now bundled. Most of them have [screenshots](https://github.com/robbyrussell/oh-my-zsh/wiki/Themes) on the wiki. Check them out! We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme happy. We have over one hundred themes now bundled. Most of them have [screenshots](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes) on the wiki. Check them out!
#### Selecting a Theme #### Selecting a Theme
@ -104,7 +106,7 @@ To use a different theme, simply change the value to match the name of your desi
```shell ```shell
ZSH_THEME="agnoster" # (this is one of the fancy ones) ZSH_THEME="agnoster" # (this is one of the fancy ones)
# see https://github.com/robbyrussell/oh-my-zsh/wiki/Themes#agnoster # see https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#agnoster
``` ```
_Note: many themes require installing the [Powerline Fonts](https://github.com/powerline/fonts) in order to render properly._ _Note: many themes require installing the [Powerline Fonts](https://github.com/powerline/fonts) in order to render properly._
@ -113,7 +115,7 @@ Open up a new terminal window and your prompt should look something like this:
![Agnoster theme](https://cloud.githubusercontent.com/assets/2618447/6316862/70f58fb6-ba03-11e4-82c9-c083bf9a6574.png) ![Agnoster theme](https://cloud.githubusercontent.com/assets/2618447/6316862/70f58fb6-ba03-11e4-82c9-c083bf9a6574.png)
In case you did not find a suitable theme for your needs, please have a look at the wiki for [more of them](https://github.com/robbyrussell/oh-my-zsh/wiki/External-themes). In case you did not find a suitable theme for your needs, please have a look at the wiki for [more of them](https://github.com/ohmyzsh/ohmyzsh/wiki/External-themes).
If you're feeling feisty, you can let the computer select one randomly for you each time you open a new terminal window. If you're feeling feisty, you can let the computer select one randomly for you each time you open a new terminal window.
@ -131,6 +133,10 @@ ZSH_THEME_RANDOM_CANDIDATES=(
) )
``` ```
### FAQ
If you have some more questions or issues, you might find a solution in our [FAQ](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ).
## Advanced Topics ## Advanced Topics
If you're the type that likes to get their hands dirty, these sections might resonate. If you're the type that likes to get their hands dirty, these sections might resonate.
@ -159,14 +165,14 @@ flag `--unattended` to the `install.sh` script. This will have the effect of not
the default shell, and also won't run `zsh` when the installation has finished. the default shell, and also won't run `zsh` when the installation has finished.
```shell ```shell
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" "" --unattended sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
``` ```
#### Installing from a forked repository #### Installing from a forked repository
The install script also accepts these variables to allow installation of a different repository: The install script also accepts these variables to allow installation of a different repository:
- `REPO` (default: `robbyrussell/oh-my-zsh`): this takes the form of `owner/repository`. If you set - `REPO` (default: `ohmyzsh/ohmyzsh`): this takes the form of `owner/repository`. If you set
this variable, the installer will look for a repository at `https://github.com/{owner}/{repository}`. this variable, the installer will look for a repository at `https://github.com/{owner}/{repository}`.
- `REMOTE` (default: `https://github.com/${REPO}.git`): this is the full URL of the git repository - `REMOTE` (default: `https://github.com/${REPO}.git`): this is the full URL of the git repository
@ -190,7 +196,7 @@ REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh
##### 1. Clone the repository: ##### 1. Clone the repository:
```shell ```shell
git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
``` ```
##### 2. *Optionally*, backup your existing `~/.zshrc` file: ##### 2. *Optionally*, backup your existing `~/.zshrc` file:
@ -272,13 +278,13 @@ Before you participate in our delightful community, please read the [code of con
I'm far from being a [Zsh](https://www.zsh.org/) expert and suspect there are many ways to improve if you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests! I'm far from being a [Zsh](https://www.zsh.org/) expert and suspect there are many ways to improve if you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests!
We also need people to test out pull-requests. So take a look through [the open issues](https://github.com/robbyrussell/oh-my-zsh/issues) and help where you can. We also need people to test out pull-requests. So take a look through [the open issues](https://github.com/ohmyzsh/ohmyzsh/issues) and help where you can.
See [Contributing](CONTRIBUTING.md) for more details. See [Contributing](CONTRIBUTING.md) for more details.
### Do NOT send us themes ### Do NOT send us themes
We have (more than) enough themes for the time being. Please add your theme to the [external themes](https://github.com/robbyrussell/oh-my-zsh/wiki/External-themes) wiki page. We have (more than) enough themes for the time being. Please add your theme to the [external themes](https://github.com/ohmyzsh/ohmyzsh/wiki/External-themes) wiki page.
## Contributors ## Contributors

View file

@ -54,7 +54,7 @@ function detect-clipboard() {
if [[ "${OSTYPE}" == darwin* ]] && (( ${+commands[pbcopy]} )) && (( ${+commands[pbpaste]} )); then if [[ "${OSTYPE}" == darwin* ]] && (( ${+commands[pbcopy]} )) && (( ${+commands[pbpaste]} )); then
function clipcopy() { pbcopy < "${1:-/dev/stdin}"; } function clipcopy() { pbcopy < "${1:-/dev/stdin}"; }
function clippaste() { pbpaste; } function clippaste() { pbpaste; }
elif [[ "${OSTYPE}" == cygwin* ]]; then elif [[ "${OSTYPE}" == (cygwin|msys)* ]]; then
function clipcopy() { cat "${1:-/dev/stdin}" > /dev/clipboard; } function clipcopy() { cat "${1:-/dev/stdin}" > /dev/clipboard; }
function clippaste() { cat /dev/clipboard; } function clippaste() { cat /dev/clipboard; }
elif [ -n "${WAYLAND_DISPLAY:-}" ] && (( ${+commands[wl-copy]} )) && (( ${+commands[wl-paste]} )); then elif [ -n "${WAYLAND_DISPLAY:-}" ] && (( ${+commands[wl-copy]} )) && (( ${+commands[wl-paste]} )); then

View file

@ -71,3 +71,6 @@ if [[ $COMPLETION_WAITING_DOTS = true ]]; then
zle -N expand-or-complete-with-dots zle -N expand-or-complete-with-dots
bindkey "^I" expand-or-complete-with-dots bindkey "^I" expand-or-complete-with-dots
fi fi
# automatically load bash completion functions
autoload -Uz bashcompinit && bashcompinit

View file

@ -3,11 +3,12 @@ function zsh_stats() {
} }
function uninstall_oh_my_zsh() { function uninstall_oh_my_zsh() {
env ZSH=$ZSH sh $ZSH/tools/uninstall.sh env ZSH="$ZSH" sh "$ZSH/tools/uninstall.sh"
} }
function upgrade_oh_my_zsh() { function upgrade_oh_my_zsh() {
env ZSH=$ZSH sh $ZSH/tools/upgrade.sh env ZSH="$ZSH" sh "$ZSH/tools/upgrade.sh"
rm -rf "$ZSH/log/update.lock"
} }
function take() { function take() {
@ -21,7 +22,7 @@ function open_command() {
case "$OSTYPE" in case "$OSTYPE" in
darwin*) open_cmd='open' ;; darwin*) open_cmd='open' ;;
cygwin*) open_cmd='cygstart' ;; cygwin*) open_cmd='cygstart' ;;
linux*) ! [[ $(uname -a) =~ "Microsoft" ]] && open_cmd='xdg-open' || { linux*) [[ "$(uname -r)" != *icrosoft* ]] && open_cmd='nohup xdg-open' || {
open_cmd='cmd.exe /c start ""' open_cmd='cmd.exe /c start ""'
[[ -e "$1" ]] && { 1="$(wslpath -w "${1:a}")" || return 1 } [[ -e "$1" ]] && { 1="$(wslpath -w "${1:a}")" || return 1 }
} ;; } ;;
@ -31,12 +32,7 @@ function open_command() {
;; ;;
esac esac
# don't use nohup on OSX
if [[ "$OSTYPE" == darwin* ]]; then
${=open_cmd} "$@" &>/dev/null ${=open_cmd} "$@" &>/dev/null
else
nohup ${=open_cmd} "$@" &>/dev/null
fi
} }
# #

View file

@ -12,11 +12,21 @@ function git_prompt_info() {
function parse_git_dirty() { function parse_git_dirty() {
local STATUS local STATUS
local -a FLAGS local -a FLAGS
FLAGS=('--porcelain' '--ignore-submodules=dirty') FLAGS=('--porcelain')
if [[ "$(command git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then if [[ "$(command git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then
if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then
FLAGS+='--untracked-files=no' FLAGS+='--untracked-files=no'
fi fi
case "$GIT_STATUS_IGNORE_SUBMODULES" in
git)
# let git decide (this respects per-repo config in .gitmodules)
;;
*)
# if unset: ignore dirty submodules
# other values are passed to --ignore-submodules
FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}"
;;
esac
STATUS=$(command git status ${FLAGS} 2> /dev/null | tail -n1) STATUS=$(command git status ${FLAGS} 2> /dev/null | tail -n1)
fi fi
if [[ -n $STATUS ]]; then if [[ -n $STATUS ]]; then
@ -189,3 +199,12 @@ function git_current_user_name() {
function git_current_user_email() { function git_current_user_email() {
command git config user.email 2>/dev/null command git config user.email 2>/dev/null
} }
# Output the name of the root directory of the git repository
# Usage example: $(git_repo_name)
function git_repo_name() {
local repo_path
if repo_path="$(git rev-parse --show-toplevel 2>/dev/null)" && [[ -n "$repo_path" ]]; then
echo ${repo_path:t}
fi
}

View file

@ -31,10 +31,5 @@ else
alias afind='ack -il' alias afind='ack -il'
fi fi
# only define LC_CTYPE if undefined
if [[ -z "$LC_CTYPE" && -z "$LC_ALL" ]]; then
export LC_CTYPE=${LANG%%:*} # pick the first entry from LANG
fi
# recognize comments # recognize comments
setopt interactivecomments setopt interactivecomments

View file

@ -75,8 +75,9 @@ function omz_termsupport_preexec {
title '$CMD' '%100>...>$LINE%<<' title '$CMD' '%100>...>$LINE%<<'
} }
precmd_functions+=(omz_termsupport_precmd) autoload -U add-zsh-hook
preexec_functions+=(omz_termsupport_preexec) add-zsh-hook precmd omz_termsupport_precmd
add-zsh-hook preexec omz_termsupport_preexec
# Keep Apple Terminal.app's current working directory updated # Keep Apple Terminal.app's current working directory updated
@ -99,7 +100,7 @@ if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
} }
# Use a precmd hook instead of a chpwd hook to avoid contaminating output # Use a precmd hook instead of a chpwd hook to avoid contaminating output
precmd_functions+=(update_terminalapp_cwd) add-zsh-hook precmd update_terminalapp_cwd
# Run once to get initial cwd set # Run once to get initial cwd set
update_terminalapp_cwd update_terminalapp_cwd
fi fi

View file

@ -32,8 +32,8 @@ fi
is_plugin() { is_plugin() {
local base_dir=$1 local base_dir=$1
local name=$2 local name=$2
test -f $base_dir/plugins/$name/$name.plugin.zsh \ builtin test -f $base_dir/plugins/$name/$name.plugin.zsh \
|| test -f $base_dir/plugins/$name/_$name || builtin test -f $base_dir/plugins/$name/_$name
} }
# Add all defined plugins to fpath. This must be done # Add all defined plugins to fpath. This must be done
@ -97,18 +97,6 @@ done
unset config_file unset config_file
# Load the theme # Load the theme
if [[ "$ZSH_THEME" == "random" ]]; then
if [[ "${(t)ZSH_THEME_RANDOM_CANDIDATES}" = "array" ]] && [[ "${#ZSH_THEME_RANDOM_CANDIDATES[@]}" -gt 0 ]]; then
themes=($ZSH/themes/${^ZSH_THEME_RANDOM_CANDIDATES}.zsh-theme)
else
themes=($ZSH/themes/*zsh-theme)
fi
N=${#themes[@]}
((N=(RANDOM%N)+1))
RANDOM_THEME=${themes[$N]}
source "$RANDOM_THEME"
echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
else
if [ ! "$ZSH_THEME" = "" ]; then if [ ! "$ZSH_THEME" = "" ]; then
if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then
source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
@ -118,4 +106,3 @@ else
source "$ZSH/themes/$ZSH_THEME.zsh-theme" source "$ZSH/themes/$ZSH_THEME.zsh-theme"
fi fi
fi fi
fi

View file

@ -0,0 +1,46 @@
# alias-finder plugin
This plugin searches the defined aliases and outputs any that match the command inputted. This makes learning new aliases easier.
To use it, add `alias-finder` to the `plugins` array of your zshrc file:
```
plugins=(... alias-finder)
```
## Usage
To see if there is an alias defined for the command, pass it as an argument to `alias-finder`. This can also run automatically before each command you input - add `ZSH_ALIAS_FINDER_AUTOMATIC=true` to your zshrc if you want this.
## Options
- Use `--longer` or `-l` to allow the aliases to be longer than the input (match aliases if they contain the input).
- Use `--exact` or `-e` to avoid matching aliases that are shorter than the input.
## Examples
```
$ alias-finder "git pull"
gl='git pull'
g=git
```
```
$ alias-finder "web_search google oh my zsh"
google='web_search google'
```
```
$ alias-finder "git commit -v"
gc="git commit -v"
g=git
```
```
$ alias-finder -e "git commit -v"
gc='git commit -v'
```
```
$ alias-finder -l "git commit -v"
gc='git commit -v'
'gc!'='git commit -v --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'
'gcn!'='git commit -v --no-edit --amend'
```

View file

@ -0,0 +1,47 @@
alias-finder() {
local cmd="" exact="" longer="" wordStart="" wordEnd="" multiWordEnd=""
for i in $@; do
case $i in
-e|--exact) exact=true;;
-l|--longer) longer=true;;
*)
if [[ -z $cmd ]]; then
cmd=$i
else
cmd="$cmd $i"
fi
;;
esac
done
cmd=$(sed 's/[].\|$(){}?+*^[]/\\&/g' <<< $cmd) # adds escaping for grep
if (( $(wc -l <<< $cmd) == 1 )); then
while [[ $cmd != "" ]]; do
if [[ $longer = true ]]; then
wordStart="'{0,1}"
else
wordEnd="$"
multiWordEnd="'$"
fi
if [[ $cmd == *" "* ]]; then
local finder="'$cmd$multiWordEnd"
else
local finder=$wordStart$cmd$wordEnd
fi
alias | grep -E "=$finder"
if [[ $exact = true || $longer = true ]]; then
break
else
cmd=$(sed -E 's/ {0,1}[^ ]*$//' <<< $cmd) # removes last word
fi
done
fi
}
preexec_alias-finder() {
if [[ $ZSH_ALIAS_FINDER_AUTOMATIC = true ]]; then
alias-finder $1
fi
}
autoload -U add-zsh-hook
add-zsh-hook preexec preexec_alias-finder

View file

@ -1,5 +1,29 @@
## arcanist ## arcanist
**Maintainer:** [@emzar](https://github.com/emzar) This plugin adds many useful aliases for [arcanist](https://github.com/phacility/arcanist).
This plugin adds many useful aliases. To use it, add `arcanist` to the plugins array of your zshrc file:
```zsh
plugins=(... arcanist)
```
## Aliases
| Alias | Command |
|---------|------------------------------------|
| ara | `arc amend` |
| arb | `arc branch` |
| arco | `arc cover` |
| arci | `arc commit` |
| ard | `arc diff` |
| ardc | `arc diff --create` |
| ardnu | `arc diff --nounit` |
| ardnupc | `arc diff --nounit --plan-changes` |
| ardpc | `arc diff --plan-changes` |
| are | `arc export` |
| arh | `arc help` |
| arl | `arc land` |
| arli | `arc lint` |
| arls | `arc list` |
| arpa | `arc patch` |

View file

@ -9,6 +9,7 @@ alias arco='arc cover'
alias arci='arc commit' alias arci='arc commit'
alias ard='arc diff' alias ard='arc diff'
alias ardc='arc diff --create'
alias ardnu='arc diff --nounit' alias ardnu='arc diff --nounit'
alias ardnupc='arc diff --nounit --plan-changes' alias ardnupc='arc diff --nounit --plan-changes'
alias ardpc='arc diff --plan-changes' alias ardpc='arc diff --plan-changes'

14
plugins/autoenv/README.md Normal file
View file

@ -0,0 +1,14 @@
# Autoenv plugin
This plugin loads the [Autoenv](https://github.com/inishchith/autoenv).
To use it, add `autoenv` to the plugins array in your zshrc file:
```zsh
plugins=(... autoenv)
```
## Requirements
In order to make this work, you will need to have the autoenv installed.
More info on the usage and install: https://github.com/inishchith/autoenv

View file

@ -1,8 +1,3 @@
(( $+commands[autojump] )) || {
echo '[oh-my-zsh] Please install autojump first (https://github.com/wting/autojump)'
return
}
declare -a autojump_paths declare -a autojump_paths
autojump_paths=( autojump_paths=(
$HOME/.autojump/etc/profile.d/autojump.zsh # manual installation $HOME/.autojump/etc/profile.d/autojump.zsh # manual installation

View file

@ -10,7 +10,8 @@ function asp() {
return return
fi fi
local available_profiles=($(aws_profiles)) local -a available_profiles
available_profiles=($(aws_profiles))
if [[ -z "${available_profiles[(r)$1]}" ]]; then if [[ -z "${available_profiles[(r)$1]}" ]]; then
echo "${fg[red]}Profile '$1' not found in '${AWS_CONFIG_FILE:-$HOME/.aws/config}'" >&2 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 echo "Available profiles: ${(j:, :)available_profiles:-no profiles found}${reset_color}" >&2

View file

@ -7,23 +7,25 @@
# Email: neuralsandwich@gmail.com # # Email: neuralsandwich@gmail.com #
# Modified to add support for Apple Mac # # Modified to add support for Apple Mac #
########################################### ###########################################
# Author: J (927589452) #
# Modified to add support for FreeBSD #
###########################################
if [[ "$OSTYPE" = darwin* ]]; then if [[ "$OSTYPE" = darwin* ]]; then
function battery_pct() { function battery_is_charging() {
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")" ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ Yes'
typeset -F maxcapacity=$(echo $smart_battery_status | grep '^.*"MaxCapacity"\ =\ ' | sed -e 's/^.*"MaxCapacity"\ =\ //')
typeset -F currentcapacity=$(echo $smart_battery_status | grep '^.*"CurrentCapacity"\ =\ ' | sed -e 's/^.*CurrentCapacity"\ =\ //')
integer i=$(((currentcapacity/maxcapacity) * 100))
echo $i
} }
function plugged_in() { function battery_pct() {
[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ Yes') -eq 1 ] local battery_status="$(ioreg -rc AppleSmartBattery)"
local -i capacity=$(sed -n -e '/MaxCapacity/s/^.*"MaxCapacity"\ =\ //p' <<< $battery_status)
local -i current=$(sed -n -e '/CurrentCapacity/s/^.*"CurrentCapacity"\ =\ //p' <<< $battery_status)
echo $(( current * 100 / capacity ))
} }
function battery_pct_remaining() { function battery_pct_remaining() {
if plugged_in ; then if battery_is_charging; then
echo "External Power" echo "External Power"
else else
battery_pct battery_pct
@ -32,8 +34,8 @@ if [[ "$OSTYPE" = darwin* ]] ; then
function battery_time_remaining() { function battery_time_remaining() {
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")" local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
if [[ $(echo $smart_battery_status | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then if [[ $(echo $smart_battery_status | command grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]]; then
timeremaining=$(echo $smart_battery_status | grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //') timeremaining=$(echo $smart_battery_status | command grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //')
if [ $timeremaining -gt 720 ]; then if [ $timeremaining -gt 720 ]; then
echo "::" echo "::"
else else
@ -45,39 +47,36 @@ if [[ "$OSTYPE" = darwin* ]] ; then
} }
function battery_pct_prompt () { function battery_pct_prompt () {
if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then local battery_pct color
b=$(battery_pct_remaining) if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then
if [ $b -gt 50 ] ; then battery_pct=$(battery_pct_remaining)
if [[ $battery_pct -gt 50 ]]; then
color='green' color='green'
elif [ $b -gt 20 ] ; then elif [[ $battery_pct -gt 20 ]]; then
color='yellow' color='yellow'
else else
color='red' color='red'
fi fi
echo "%{$fg[$color]%}[$(battery_pct_remaining)%%]%{$reset_color%}" echo "%{$fg[$color]%}[${battery_pct}%%]%{$reset_color%}"
else else
echo "∞" echo "∞"
fi fi
} }
function battery_is_charging() { elif [[ "$OSTYPE" = freebsd* ]]; then
[[ $(ioreg -rc "AppleSmartBattery"| grep '^.*"IsCharging"\ =\ ' | sed -e 's/^.*"IsCharging"\ =\ //') == "Yes" ]]
}
elif [[ "$OSTYPE" = linux* ]] ; then
function battery_is_charging() { function battery_is_charging() {
! [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] [[ $(sysctl -n hw.acpi.battery.state) -eq 2 ]]
} }
function battery_pct() { function battery_pct() {
if (( $+commands[acpi] )) ; then if (( $+commands[sysctl] )); then
echo "$(acpi 2>/dev/null | cut -f2 -d ',' | tr -cd '[:digit:]')" sysctl -n hw.acpi.battery.life
fi fi
} }
function battery_pct_remaining() { function battery_pct_remaining() {
if [ ! $(battery_is_charging) ] ; then if ! battery_is_charging; then
battery_pct battery_pct
else else
echo "External Power" echo "External Power"
@ -85,76 +84,128 @@ elif [[ "$OSTYPE" = linux* ]] ; then
} }
function battery_time_remaining() { function battery_time_remaining() {
if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then local remaining_time
echo $(acpi 2>/dev/null | cut -f3 -d ',') remaining_time=$(sysctl -n hw.acpi.battery.time)
if [[ $remaining_time -ge 0 ]]; then
((hour = $remaining_time / 60 ))
((minute = $remaining_time % 60 ))
printf %02d:%02d $hour $minute
fi fi
} }
function battery_pct_prompt() { function battery_pct_prompt() {
b=$(battery_pct_remaining) local battery_pct color
if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then battery_pct=$(battery_pct_remaining)
if [ $b -gt 50 ] ; then if battery_is_charging; then
echo "∞"
else
if [[ $battery_pct -gt 50 ]]; then
color='green' color='green'
elif [ $b -gt 20 ] ; then elif [[ $battery_pct -gt 20 ]]; then
color='yellow' color='yellow'
else else
color='red' color='red'
fi fi
echo "%{$fg[$color]%}$(battery_pct_remaining)%%%{$reset_color%}" echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi
}
elif [[ "$OSTYPE" = linux* ]]; then
function battery_is_charging() {
! acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -q '^Battery.*Discharging'
}
function battery_pct() {
if (( $+commands[acpi] )); then
acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -E '^Battery.*(Disc|C)harging' | cut -f2 -d ',' | tr -cd '[:digit:]'
fi
}
function battery_pct_remaining() {
if ! battery_is_charging; then
battery_pct
else else
echo "External Power"
fi
}
function battery_time_remaining() {
if ! battery_is_charging; then
acpi 2>/dev/null | command grep -v "rate information unavailable" | cut -f3 -d ','
fi
}
function battery_pct_prompt() {
local battery_pct color
battery_pct=$(battery_pct_remaining)
if battery_is_charging; then
echo "∞" echo "∞"
else
if [[ $battery_pct -gt 50 ]]; then
color='green'
elif [[ $battery_pct -gt 20 ]]; then
color='yellow'
else
color='red'
fi
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi fi
} }
else else
# Empty functions so we don't cause errors in prompts # Empty functions so we don't cause errors in prompts
function battery_pct_remaining() { function battery_is_charging { false }
} function battery_pct \
battery_pct_remaining \
function battery_time_remaining() { battery_time_remaining \
} battery_pct_prompt { }
function battery_pct_prompt() {
}
fi fi
function battery_level_gauge() { function battery_level_gauge() {
local gauge_slots=${BATTERY_GAUGE_SLOTS:-10}; local gauge_slots=${BATTERY_GAUGE_SLOTS:-10}
local green_threshold=${BATTERY_GREEN_THRESHOLD:-6}; local green_threshold=${BATTERY_GREEN_THRESHOLD:-$(( gauge_slots * 0.6 ))}
local yellow_threshold=${BATTERY_YELLOW_THRESHOLD:-4}; local yellow_threshold=${BATTERY_YELLOW_THRESHOLD:-$(( gauge_slots * 0.4 ))}
local color_green=${BATTERY_COLOR_GREEN:-%F{green}}; local color_green=${BATTERY_COLOR_GREEN:-%F{green}}
local color_yellow=${BATTERY_COLOR_YELLOW:-%F{yellow}}; local color_yellow=${BATTERY_COLOR_YELLOW:-%F{yellow}}
local color_red=${BATTERY_COLOR_RED:-%F{red}}; local color_red=${BATTERY_COLOR_RED:-%F{red}}
local color_reset=${BATTERY_COLOR_RESET:-%{%f%k%b%}}; local color_reset=${BATTERY_COLOR_RESET:-%{%f%k%b%}}
local battery_prefix=${BATTERY_GAUGE_PREFIX:-'['}; local battery_prefix=${BATTERY_GAUGE_PREFIX:-'['}
local battery_suffix=${BATTERY_GAUGE_SUFFIX:-']'}; local battery_suffix=${BATTERY_GAUGE_SUFFIX:-']'}
local filled_symbol=${BATTERY_GAUGE_FILLED_SYMBOL:-'▶'}; local filled_symbol=${BATTERY_GAUGE_FILLED_SYMBOL:-'▶'}
local empty_symbol=${BATTERY_GAUGE_EMPTY_SYMBOL:-'▷'}; local empty_symbol=${BATTERY_GAUGE_EMPTY_SYMBOL:-'▷'}
local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow}; local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow}
local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'}; local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'}
local battery_remaining_percentage=$(battery_pct); local battery_remaining_percentage=$(battery_pct)
local filled empty gauge_color
if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then
local filled=$(((( $battery_remaining_percentage + $gauge_slots - 1) / $gauge_slots))); filled=$(( ($battery_remaining_percentage * $gauge_slots) / 100 ))
local empty=$(($gauge_slots - $filled)); empty=$(( $gauge_slots - $filled ))
if [[ $filled -gt $green_threshold ]]; then local gauge_color=$color_green; if [[ $filled -gt $green_threshold ]]; then
elif [[ $filled -gt $yellow_threshold ]]; then local gauge_color=$color_yellow; gauge_color=$color_green
else local gauge_color=$color_red; elif [[ $filled -gt $yellow_threshold ]]; then
gauge_color=$color_yellow
else
gauge_color=$color_red
fi fi
else else
local filled=$gauge_slots; filled=$gauge_slots
local empty=0; empty=0
filled_symbol=${BATTERY_UNKNOWN_SYMBOL:-'.'}; filled_symbol=${BATTERY_UNKNOWN_SYMBOL:-'.'}
fi fi
local charging=' ' && battery_is_charging && charging=$charging_symbol; local charging=' '
battery_is_charging && charging=$charging_symbol
# Charging status and prefix
printf ${charging_color//\%/\%\%}$charging${color_reset//\%/\%\%}${battery_prefix//\%/\%\%}${gauge_color//\%/\%\%} printf ${charging_color//\%/\%\%}$charging${color_reset//\%/\%\%}${battery_prefix//\%/\%\%}${gauge_color//\%/\%\%}
printf ${filled_symbol//\%/\%\%}'%.0s' {1..$filled} # Filled slots
[[ $filled -gt 0 ]] && printf ${filled_symbol//\%/\%\%}'%.0s' {1..$filled}
# Empty slots
[[ $filled -lt $gauge_slots ]] && printf ${empty_symbol//\%/\%\%}'%.0s' {1..$empty} [[ $filled -lt $gauge_slots ]] && printf ${empty_symbol//\%/\%\%}'%.0s' {1..$empty}
# Suffix
printf ${color_reset//\%/\%\%}${battery_suffix//\%/\%\%}${color_reset//\%/\%\%} printf ${color_reset//\%/\%\%}${battery_suffix//\%/\%\%}${color_reset//\%/\%\%}
} }

View file

@ -15,7 +15,7 @@
- calls `bundle exec <gem executable>` otherwise - calls `bundle exec <gem executable>` otherwise
Common gems wrapped by default (by name of the executable): Common gems wrapped by default (by name of the executable):
`annotate`, `cap`, `capify`, `cucumber`, `foodcritic`, `guard`, `hanami`, `irb`, `jekyll`, `kitchen`, `knife`, `middleman`, `nanoc`, `pry`, `puma`, `rackup`, `rainbows`, `rake`, `rspec`, `shotgun`, `sidekiq`, `spec`, `spork`, `spring`, `strainer`, `tailor`, `taps`, `thin`, `thor`, `unicorn` and `unicorn_rails`. `annotate`, `cap`, `capify`, `cucumber`, `foodcritic`, `guard`, `hanami`, `irb`, `jekyll`, `kitchen`, `knife`, `middleman`, `nanoc`, `pry`, `puma`, `rackup`, `rainbows`, `rake`, `rspec`, `rubocop`, `shotgun`, `sidekiq`, `spec`, `spork`, `spring`, `strainer`, `tailor`, `taps`, `thin`, `thor`, `unicorn` and `unicorn_rails`.
## Configuration ## Configuration
@ -42,7 +42,7 @@ This will exclude the `foreman` and `spin` gems (i.e. their executable) from bei
## Excluded gems ## Excluded gems
These gems should not be called with `bundle exec`. Please see [issue #2923](https://github.com/robbyrussell/oh-my-zsh/pull/2923) on GitHub for clarification. These gems should not be called with `bundle exec`. Please see [issue #2923](https://github.com/ohmyzsh/ohmyzsh/pull/2923) on GitHub for clarification.
`berks` `berks`
`foreman` `foreman`

View file

@ -27,6 +27,7 @@ bundled_commands=(
rainbows rainbows
rake rake
rspec rspec
rubocop
shotgun shotgun
sidekiq sidekiq
spec spec
@ -81,7 +82,7 @@ _bundler-installed() {
_within-bundled-project() { _within-bundled-project() {
local check_dir="$PWD" local check_dir="$PWD"
while [ "$check_dir" != "/" ]; do while [ "$check_dir" != "/" ]; do
[ -f "$check_dir/Gemfile" ] && return [ -f "$check_dir/Gemfile" -o -f "$check_dir/gems.rb" ] && return
check_dir="$(dirname $check_dir)" check_dir="$(dirname $check_dir)"
done done
false false
@ -94,7 +95,7 @@ _binstubbed() {
_run-with-bundler() { _run-with-bundler() {
if _bundler-installed && _within-bundled-project; then if _bundler-installed && _within-bundled-project; then
if _binstubbed $1; then if _binstubbed $1; then
./bin/$@ ./bin/${^^@}
else else
bundle exec $@ bundle exec $@
fi fi

View file

@ -1,12 +0,0 @@
# Bwana
This plugin provides a function to open `man` pages directly with [Bwana](https://www.bruji.com/bwana/).
To use it add bwana to the plugins array in your zshrc file.
```bash
plugins=(... bwana)
```
The `bwana` function opens the man page of the passed argument in the Bwana app.
For example: `bwana ln` opens the man page for `ln` in Bwana.

View file

@ -1,13 +0,0 @@
#
# Requires https://www.bruji.com/bwana/
#
if [[ -e /Applications/Bwana.app ]] ||
( system_profiler -detailLevel mini SPApplicationsDataType | grep -q Bwana )
then
function bwana() {
open "man:$1"
}
else
echo "Bwana lets you read man files in Safari through a man: URI scheme"
echo "To use it within Zsh, install it from https://www.bruji.com/bwana/"
fi

View file

@ -0,0 +1,16 @@
# cakephp3 plugin
The plugin adds aliases and autocompletion for [cakephp3](https://book.cakephp.org/3.0/en/index.html).
To use it, add `cakephp3` to the plugins array of your zshrc file:
```
plugins=(... cakephp3)
```
## Aliases
| Alias | Command |
|-----------|-------------------------------|
| c3 | `bin/cake` |
| c3cache | `bin/cake orm_cache clear` |
| c3migrate | `bin/cake migrations migrate` |

View file

@ -2,489 +2,367 @@
autoload -U regexp-replace autoload -U regexp-replace
zstyle -T ':completion:*:*:cargo:*' tag-order && \
zstyle ':completion:*:*:cargo:*' tag-order 'common-commands'
_cargo() { _cargo() {
local context state state_descr line local curcontext="$curcontext" ret=1
local -a command_scope_spec common parallel features msgfmt triple target registry
local -a state line state_descr # These are set by _arguments
typeset -A opt_args typeset -A opt_args
common=(
'(-q --quiet)*'{-v,--verbose}'[use verbose output]'
'(-q --quiet -v --verbose)'{-q,--quiet}'[no output printed to stdout]'
'-Z+[pass unstable (nightly-only) flags to cargo]: :_cargo_unstable_flags'
'--frozen[require that Cargo.lock and cache are up-to-date]'
'--locked[require that Cargo.lock is up-to-date]'
'--color=[specify colorization option]:coloring:(auto always never)'
'(- 1 *)'{-h,--help}'[show help message]'
)
# leading items in parentheses are an exclusion list for the arguments following that arg # leading items in parentheses are an exclusion list for the arguments following that arg
# See: http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-Functions # See: http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-Functions
# - => exclude all other options # - => exclude all other options
# 1 => exclude positional arg 1 # 1 => exclude positional arg 1
# * => exclude all other args # * => exclude all other args
# +blah => exclude +blah # +blah => exclude +blah
_arguments \ _arguments -s -S -C $common \
'(- 1 *)'{-h,--help}'[show help message]' \
'(- 1 *)--list[list installed commands]' \ '(- 1 *)--list[list installed commands]' \
'(- 1 *)--explain=[provide a detailed explanation of an error message]:error code' \
'(- 1 *)'{-V,--version}'[show version information]' \ '(- 1 *)'{-V,--version}'[show version information]' \
{-v,--verbose}'[use verbose output]' \
--color'[colorization option]' \
'(+beta +nightly)+stable[use the stable toolchain]' \ '(+beta +nightly)+stable[use the stable toolchain]' \
'(+stable +nightly)+beta[use the beta toolchain]' \ '(+stable +nightly)+beta[use the beta toolchain]' \
'(+stable +beta)+nightly[use the nightly toolchain]' \ '(+stable +beta)+nightly[use the nightly toolchain]' \
'1: :->command' \ '1: :_cargo_cmds' \
'*:: :->args' '*:: :->args'
case $state in # These flags are mutually exclusive specifiers for the scope of a command; as
command) # they are used in multiple places without change, they are expanded into the
_alternative 'common-commands:common:_cargo_cmds' 'all-commands:all:_cargo_all_cmds' # appropriate command's `_arguments` where appropriate.
;; command_scope_spec=(
'(--bin --example --test --lib)--bench=[specify benchmark name]: :_cargo_benchmark_names'
'(--bench --bin --test --lib)--example=[specify example name]:example name'
'(--bench --example --test --lib)--bin=[specify binary name]:binary name'
'(--bench --bin --example --test)--lib=[specify library name]:library name'
'(--bench --bin --example --lib)--test=[specify test name]:test name'
)
parallel=(
'(-j --jobs)'{-j+,--jobs=}'[specify number of parallel jobs]:jobs [# of CPUs]'
)
features=(
'(--all-features)--features=[specify features to activate]:feature'
'(--features)--all-features[activate all available features]'
"--no-default-features[don't build the default features]"
)
msgfmt='--message-format=[specify error format]:error format [human]:(human json short)'
triple='--target=[specify target triple]:target triple'
target='--target-dir=[specify directory for all generated artifacts]:directory:_directories'
manifest='--manifest-path=[specify path to manifest]:path:_directories'
registry='--registry=[specify registry to use]:registry'
case $state in
args) args)
case $words[1] in curcontext="${curcontext%:*}-${words[1]}:"
case ${words[1]} in
bench) bench)
_arguments \ _arguments -s -A "^--" $common $parallel $features $msgfmt $triple $target $manifest \
'--features=[space separated feature list]' \
'--all-features[enable all available features]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
"${command_scope_spec[@]}" \ "${command_scope_spec[@]}" \
'--manifest-path=[path to manifest]: :_files -/' \ '--all-targets[benchmark all targets]' \
'--no-default-features[do not build the default features]' \ "--no-run[compile but don't run]" \
'--no-run[compile but do not run]' \ '(-p --package)'{-p+,--package=}'[specify package to run benchmarks for]:package:_cargo_package_names' \
'(-p,--package)'{-p=,--package=}'[package to run benchmarks for]:packages:_get_package_names' \ '--exclude=[exclude packages from the benchmark]:spec' \
'--target=[target triple]' \ '--no-fail-fast[run all benchmarks regardless of failure]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ '1: :_guard "^-*" "bench name"' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ '*:args:_default'
'--color=:colorization option:(auto always never)' \
;; ;;
build) build)
_arguments \ _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
'--features=[space separated feature list]' \ '--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \
'--all-features[enable all available features]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
"${command_scope_spec[@]}" \ "${command_scope_spec[@]}" \
'--manifest-path=[path to manifest]: :_files -/' \ '(-p --package)'{-p+,--package=}'[specify package to build]:package:_cargo_package_names' \
'--no-default-features[do not build the default features]' \ '--release[build in release mode]' \
'(-p,--package)'{-p=,--package=}'[package to build]:packages:_get_package_names' \ '--build-plan[output the build plan in JSON]' \
'--release=[build in release mode]' \
'--target=[target triple]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--color=:colorization option:(auto always never)' \
;; ;;
check) check)
_arguments \ _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
'--features=[space separated feature list]' \ '--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \
'--all-features[enable all available features]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
"${command_scope_spec[@]}" \ "${command_scope_spec[@]}" \
'--manifest-path=[path to manifest]: :_files -/' \ '(-p --package)'{-p+,--package=}'[specify package to check]:package:_cargo_package_names' \
'--no-default-features[do not check the default features]' \ '--release[check in release mode]' \
'(-p,--package)'{-p=,--package=}'[package to check]:packages:_get_package_names' \
'--release=[check in release mode]' \
'--target=[target triple]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--color=:colorization option:(auto always never)' \
;; ;;
clean) clean)
_arguments \ _arguments -s -S $common $triple $target $manifest \
'(-h, --help)'{-h,--help}'[show help message]' \ '(-p --package)'{-p+,--package=}'[specify package to clean]:package:_cargo_package_names' \
'--manifest-path=[path to manifest]: :_files -/' \ '--release[clean release artifacts]' \
'(-p,--package)'{-p=,--package=}'[package to clean]:packages:_get_package_names' \ '--doc[clean just the documentation directory]'
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--release[whether or not to clean release artifacts]' \
'--target=[target triple(default:all)]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;; ;;
doc) doc)
_arguments \ _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
'--features=[space separated feature list]' \
'--all-features[enable all available features]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
'--manifest-path=[path to manifest]: :_files -/' \
'--no-deps[do not build docs for dependencies]' \ '--no-deps[do not build docs for dependencies]' \
'--no-default-features[do not build the default features]' \ '--document-private-items[include non-public items in the documentation]' \
'--open[open docs in browser after the build]' \ '--open[open docs in browser after the build]' \
'(-p, --package)'{-p,--package}'=[package to document]' \ '(-p --package)'{-p+,--package=}'[specify package to document]:package:_cargo_package_names' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--release[build artifacts in release mode, with optimizations]' \ '--release[build artifacts in release mode, with optimizations]' \
'--target=[build for the target triple]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;; ;;
fetch) fetch)
_arguments \ _arguments -s -S $common $triple $manifest
'(-h, --help)'{-h,--help}'[show help message]' \ ;;
'--manifest-path=[path to manifest]: :_files -/' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ fix)
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
'--color=:colorization option:(auto always never)' \ "${command_scope_spec[@]}" \
'--broken-code[fix code even if it already has compiler errors]' \
'--edition[fix in preparation for the next edition]' \
'--edition-idioms[fix warnings to migrate to the idioms of an edition]' \
'--allow-no-vcs[fix code even if a VCS was not detected]' \
'--allow-dirty[fix code even if the working directory is dirty]' \
'--allow-staged[fix code even if the working directory has staged changes]'
;; ;;
generate-lockfile) generate-lockfile)
_arguments \ _arguments -s -S $common $manifest
'(-h, --help)'{-h,--help}'[show help message]' \
'--manifest-path=[path to manifest]: :_files -/' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;; ;;
git-checkout) git-checkout)
_arguments \ _arguments -s -S $common \
'(-h, --help)'{-h,--help}'[show help message]' \ '--reference=:reference' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ '--url=:url:_urls'
'--reference=[REF]' \
'--url=[URL]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;; ;;
help) help)
_arguments \ _cargo_cmds
'(-h, --help)'{-h,--help}'[show help message]' \
'*: :_cargo_cmds' \
;; ;;
init) init)
_arguments \ _arguments -s -S $common $registry \
'--bin[use binary template]' \ '--lib[use library template]' \
'--vcs:initialize a new repo with a given VCS:(git hg none)' \ '--edition=[specify edition to set for the crate generated]:edition:(2015 2018)' \
'(-h, --help)'{-h,--help}'[show help message]' \ '--vcs=[initialize a new repo with a given VCS]:vcs:(git hg pijul fossil none)' \
'--name=[set the resulting package name]' \ '--name=[set the resulting package name]:name' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ '1:path:_directories'
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;; ;;
install) install)
_arguments \ _arguments -s -S $common $parallel $features $triple $registry \
'--bin=[only install the specified binary]' \ '(-f --force)'{-f,--force}'[force overwriting of existing crates or binaries]' \
'--branch=[branch to use when installing from git]' \ '--bin=[only install the specified binary]:binary' \
'--color=:colorization option:(auto always never)' \ '--branch=[branch to use when installing from git]:branch' \
'--debug[build in debug mode instead of release mode]' \ '--debug[build in debug mode instead of release mode]' \
'--example[install the specified example instead of binaries]' \ '--example=[install the specified example instead of binaries]:example' \
'--features=[space separated feature list]' \ '--git=[specify URL from which to install the crate]:url:_urls' \
'--all-features[enable all available features]' \ '--path=[local filesystem path to crate to install]: :_directories' \
'--git=[URL from which to install the crate]' \ '--rev=[specific commit to use when installing from git]:commit' \
'(-h, --help)'{-h,--help}'[show help message]' \ '--root=[directory to install packages into]: :_directories' \
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ '--tag=[tag to use when installing from git]:tag' \
'--no-default-features[do not build the default features]' \ '--vers=[version to install from crates.io]:version' \
'--path=[local filesystem path to crate to install]: :_files -/' \ '--list[list all installed packages and their versions]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ '*: :_guard "^-*" "crate"'
'--rev=[specific commit to use when installing from git]' \
'--root=[directory to install packages into]: :_files -/' \
'--tag=[tag to use when installing from git]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--vers=[version to install from crates.io]' \
;; ;;
locate-project) locate-project)
_arguments \ _arguments -s -S $common $manifest
'(-h, --help)'{-h,--help}'[show help message]' \
'--manifest-path=[path to manifest]: :_files -/' \
;; ;;
login) login)
_arguments \ _arguments -s -S $common $registry \
'(-h, --help)'{-h,--help}'[show help message]' \ '*: :_guard "^-*" "token"'
'--host=[Host to set the token for]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;; ;;
metadata) metadata)
_arguments \ _arguments -s -S $common $features $manifest \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
"--no-deps[output information only about the root package and don't fetch dependencies]" \ "--no-deps[output information only about the root package and don't fetch dependencies]" \
'--no-default-features[do not include the default feature]' \ '--format-version=[specify format version]:version [1]:(1)'
'--manifest-path=[path to manifest]: :_files -/' \
'--features=[space separated feature list]' \
'--all-features[enable all available features]' \
'--format-version=[format version(default: 1)]' \
'--color=:colorization option:(auto always never)' \
;; ;;
new) new)
_arguments \ _arguments -s -S $common $registry \
'--bin[use binary template]' \ '--lib[use library template]' \
'--vcs:initialize a new repo with a given VCS:(git hg none)' \ '--vcs:initialize a new repo with a given VCS:(git hg none)' \
'(-h, --help)'{-h,--help}'[show help message]' \ '--name=[set the resulting package name]'
'--name=[set the resulting package name]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;; ;;
owner) owner)
_arguments \ _arguments -s -S $common $registry \
'(-a, --add)'{-a,--add}'[add owner LOGIN]' \ '(-a --add)'{-a,--add}'[specify name of a user or team to invite as an owner]:name' \
'(-h, --help)'{-h,--help}'[show help message]' \ '--index=[specify registry index]:index' \
'--index[registry index]' \ '(-l --list)'{-l,--list}'[list owners of a crate]' \
'(-l, --list)'{-l,--list}'[list owners of a crate]' \ '(-r --remove)'{-r,--remove}'[specify name of a user or team to remove as an owner]:name' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ '--token=[specify API token to use when authenticating]:token' \
'(-r, --remove)'{-r,--remove}'[remove owner LOGIN]' \ '*: :_guard "^-*" "crate"'
'--token[API token to use when authenticating]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;; ;;
package) package)
_arguments \ _arguments -s -S $common $parallel $features $triple $target $manifest \
'(-h, --help)'{-h,--help}'[show help message]' \ '(-l --list)'{-l,--list}'[print files included in a package without making one]' \
'(-l, --list)'{-l,--list}'[print files included in a package without making one]' \
'--manifest-path=[path to manifest]: :_files -/' \
'--no-metadata[ignore warnings about a lack of human-usable metadata]' \ '--no-metadata[ignore warnings about a lack of human-usable metadata]' \
'--no-verify[do not build to verify contents]' \ '--allow-dirty[allow dirty working directories to be packaged]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ "--no-verify[don't build to verify contents]"
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;; ;;
pkgid) pkgid)
_arguments \ _arguments -s -S $common $manifest \
'(-h, --help)'{-h,--help}'[show help message]' \ '(-p --package)'{-p+,--package=}'[specify package to get ID specifier for]:package:_cargo_package_names' \
'--manifest-path=[path to manifest]: :_files -/' \ '*: :_guard "^-*" "spec"'
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;; ;;
publish) publish)
_arguments \ _arguments -s -S $common $parallel $features $triple $target $manifest $registry \
'(-h, --help)'{-h,--help}'[show help message]' \ '--index=[specify registry index]:index' \
'--host=[Host to set the token for]' \ '--allow-dirty[allow dirty working directories to be packaged]' \
'--manifest-path=[path to manifest]: :_files -/' \ "--no-verify[don't verify the contents by building them]" \
'--no-verify[Do not verify tarball until before publish]' \ '--token=[specify token to use when uploading]:token' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ '--dry-run[perform all checks without uploading]'
'--token[token to use when uploading]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;; ;;
read-manifest) read-manifest)
_arguments \ _arguments -s -S $common $manifest
'(-h, --help)'{-h,--help}'[show help message]' \
'--manifest-path=[path to manifest]: :_files -/' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;; ;;
run) run)
_arguments \ _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
'--example=[name of the bin target]' \ '--example=[name of the bin target]:name' \
'--features=[space separated feature list]' \ '--bin=[name of the bin target]:name' \
'--all-features[enable all available features]' \ '(-p --package)'{-p+,--package=}'[specify package with the target to run]:package:_cargo_package_names' \
'(-h, --help)'{-h,--help}'[show help message]' \ '--release[build in release mode]' \
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \ '*: :_default'
'--manifest-path=[path to manifest]: :_files -/' \
'--bin=[name of the bin target]' \
'--no-default-features[do not build the default features]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--release=[build in release mode]' \
'--target=[target triple]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
'*: :_normal' \
;; ;;
rustc) rustc)
_arguments \ _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
'--color=:colorization option:(auto always never)' \ '(-p --package)'{-p+,--package=}'[specify package to build]:package:_cargo_package_names' \
'--features=[features to compile for the package]' \ '--profile=[specify profile to build the selected target for]:profile' \
'--all-features[enable all available features]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \
'--manifest-path=[path to the manifest to fetch dependencies for]: :_files -/' \
'--no-default-features[do not compile default features for the package]' \
'(-p, --package)'{-p,--package}'=[profile to compile for]' \
'--profile=[profile to build the selected target for]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--release[build artifacts in release mode, with optimizations]' \ '--release[build artifacts in release mode, with optimizations]' \
'--target=[target triple which compiles will be for]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
"${command_scope_spec[@]}" \ "${command_scope_spec[@]}" \
'*: : _dispatch rustc rustc -default-'
;; ;;
rustdoc) rustdoc)
_arguments \ _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
'--color=:colorization option:(auto always never)' \ '--document-private-items[include non-public items in the documentation]' \
'--features=[space-separated list of features to also build]' \
'--all-features[enable all available features]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \
'--manifest-path=[path to the manifest to document]: :_files -/' \
'--no-default-features[do not build the `default` feature]' \
'--open[open the docs in a browser after the operation]' \ '--open[open the docs in a browser after the operation]' \
'(-p, --package)'{-p,--package}'=[package to document]' \ '(-p --package)'{-p+,--package=}'[specify package to document]:package:_cargo_package_names' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--release[build artifacts in release mode, with optimizations]' \ '--release[build artifacts in release mode, with optimizations]' \
'--target=[build for the target triple]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
"${command_scope_spec[@]}" \ "${command_scope_spec[@]}" \
'*: : _dispatch rustdoc rustdoc -default-'
;; ;;
search) search)
_arguments \ _arguments -s -S $common $registry \
'--color=:colorization option:(auto always never)' \ '--index=[specify registry index]:index' \
'(-h, --help)'{-h,--help}'[show help message]' \ '--limit=[limit the number of results]:results [10]' \
'--host=[host of a registry to search in]' \ '*: :_guard "^-*" "query"'
'--limit=[limit the number of results]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
;; ;;
test) test)
_arguments \ _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
'--features=[space separated feature list]' \ '--test=[test name]: :_cargo_test_names' \
'--all-features[enable all available features]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
'--manifest-path=[path to manifest]: :_files -/' \
'--test=[test name]: :_test_names' \
'--no-default-features[do not build the default features]' \
'--no-fail-fast[run all tests regardless of failure]' \ '--no-fail-fast[run all tests regardless of failure]' \
'--no-run[compile but do not run]' \ '--no-run[compile but do not run]' \
'(-p,--package)'{-p=,--package=}'[package to run tests for]:packages:_get_package_names' \ '(-p --package)'{-p+,--package=}'[package to run tests for]:package:_cargo_package_names' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \ '--all[test all packages in the workspace]' \
'--release[build artifacts in release mode, with optimizations]' \ '--release[build artifacts in release mode, with optimizations]' \
'--target=[target triple]' \ '1: :_cargo_test_names' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
'1: :_test_names' \
'(--doc --bin --example --test --bench)--lib[only test library]' \ '(--doc --bin --example --test --bench)--lib[only test library]' \
'(--lib --bin --example --test --bench)--doc[only test documentation]' \ '(--lib --bin --example --test --bench)--doc[only test documentation]' \
'(--lib --doc --example --test --bench)--bin=[binary name]' \ '(--lib --doc --example --test --bench)--bin=[binary name]' \
'(--lib --doc --bin --test --bench)--example=[example name]' \ '(--lib --doc --bin --test --bench)--example=[example name]' \
'(--lib --doc --bin --example --bench)--test=[test name]' \ '(--lib --doc --bin --example --bench)--test=[test name]' \
'(--lib --doc --bin --example --test)--bench=[benchmark name]' \ '(--lib --doc --bin --example --test)--bench=[benchmark name]' \
'--message-format:error format:(human json short)' \ '*: :_default'
'--frozen[require lock and cache up to date]' \
'--locked[require lock up to date]'
;; ;;
uninstall) uninstall)
_arguments \ _arguments -s -S $common \
'--bin=[only uninstall the binary NAME]' \ '(-p --package)'{-p+,--package=}'[specify package to uninstall]:package:_cargo_package_names' \
'--color=:colorization option:(auto always never)' \ '--bin=[only uninstall the specified binary]:name' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-q, --quiet)'{-q,--quiet}'[less output printed to stdout]' \
'--root=[directory to uninstall packages from]: :_files -/' \ '--root=[directory to uninstall packages from]: :_files -/' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ '*:crate:_cargo_installed_crates -F line'
;; ;;
update) update)
_arguments \ _arguments -s -S $common $manifest \
'--aggressive=[force dependency update]' \ '--aggressive=[force dependency update]' \
'(-h, --help)'{-h,--help}'[show help message]' \ "--dry-run[don't actually write the lockfile]" \
'--manifest-path=[path to manifest]: :_files -/' \ '(-p --package)'{-p+,--package=}'[specify package to update]:package:_cargo_package_names' \
'(-p,--package)'{-p=,--package=}'[package to update]:packages:__get_package_names' \ '--precise=[update single dependency to precise release]:release'
'--precise=[update single dependency to PRECISE]: :' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;; ;;
verify-project) verify-project)
_arguments \ _arguments -s -S $common $manifest
'(-h, --help)'{-h,--help}'[show help message]' \
'--manifest-path=[path to manifest]: :_files -/' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;; ;;
version) version)
_arguments \ _arguments -s -S $common
'(-h, --help)'{-h,--help}'[show help message]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
;; ;;
yank) yank)
_arguments \ _arguments -s -S $common $registry \
'(-h, --help)'{-h,--help}'[show help message]' \ '--vers=[specify yank version]:version' \
'--index[registry index]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--token[API token to use when authenticating]' \
'--undo[undo a yank, putting a version back into the index]' \ '--undo[undo a yank, putting a version back into the index]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \ '--index=[specify registry index to yank from]:registry index' \
'--color=:colorization option:(auto always never)' \ '--token=[specify API token to use when authenticating]:token' \
'--vers[yank version]' \ '*: :_guard "^-*" "crate"'
;;
*)
# allow plugins to define their own functions
if ! _call_function ret _cargo-${words[1]}; then
# fallback on default completion for unknown commands
_default && ret=0
fi
(( ! ret ))
;; ;;
esac esac
;; ;;
esac esac
} }
_cargo_unstable_flags() {
local flags
flags=( help ${${${(M)${(f)"$(_call_program flags cargo -Z help)"}:#*--*}/ #-- #/:}##*-Z } )
_describe -t flags 'unstable flag' flags
}
_cargo_installed_crates() {
local expl
_description crates expl 'crate'
compadd "$@" "$expl[@]" - ${${${(f)"$(cargo install --list)"}:# *}%% *}
}
_cargo_cmds() { _cargo_cmds() {
local -a commands;commands=( local -a commands
'bench:execute all benchmarks of a local package' # This uses Parameter Expansion Flags, which are a built-in Zsh feature.
'build:compile the current package' # See more: http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags
'check:check the current package without compiling' # and http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion
'clean:remove generated artifacts' #
'doc:build package documentation' # # How this work?
'fetch:fetch package dependencies' #
'generate-lockfile:create lockfile' # First it splits the result of `cargo --list` at newline, then it removes the first line.
'git-checkout:git checkout' # Then it removes indentation (4 whitespaces) before each items. (Note the x## pattern [1]).
'help:get help for commands' # Then it replaces those spaces between item and description with a `:`
'init:create new package in current directory' #
'install:install a Rust binary' # [1]: https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org#patterns
'locate-project:print "Cargo.toml" location' commands=( ${${${(M)"${(f)$(_call_program commands cargo --list)}":# *}/ ##/}/ ##/:} )
'login:login to remote server' _describe -t commands 'command' commands
'metadata:the metadata for a package in json'
'new:create a new package'
'owner:manage the owners of a crate on the registry'
'package:assemble local package into a distributable tarball'
'pkgid:print a fully qualified package specification'
'publish:upload package to the registry'
'read-manifest:print manifest in JSON format'
'run:run the main binary of the local package'
'rustc:compile a package and all of its dependencies'
'rustdoc:build documentation for a package'
'search:search packages on crates.io'
'test:execute all unit and tests of a local package'
'uninstall:remove a Rust binary'
'update:update dependencies'
'verify-project:check Cargo.toml'
'version:show version information'
'yank:remove pushed file from index'
)
_describe -t common-commands 'common commands' commands
}
_cargo_all_cmds(){
local -a commands;commands=($(cargo --list))
_describe -t all-commands 'all commands' commands
} }
#FIXME: Disabled until fixed #FIXME: Disabled until fixed
#gets package names from the manifest file #gets package names from the manifest file
_get_package_names() _cargo_package_names() {
{ _message -e packages package
}
#TODO:see if it makes sense to have 'locate-project' to have non-json output.
#strips package name from json stuff
_locate_manifest(){
local manifest=`cargo locate-project 2>/dev/null`
regexp-replace manifest '\{"root":"|"\}' ''
echo $manifest
} }
# Extracts the values of "name" from the array given in $1 and shows them as # Extracts the values of "name" from the array given in $1 and shows them as
# command line options for completion # command line options for completion
_get_names_from_array() _cargo_names_from_array() {
{ # strip json from the path
local -a filelist; local manifest=${${${"$(cargo locate-project)"}%\"\}}##*\"}
local manifest=$(_locate_manifest)
if [[ -z $manifest ]]; then if [[ -z $manifest ]]; then
return 0 return 0
fi fi
@ -494,51 +372,36 @@ _get_names_from_array()
local in_block=false local in_block=false
local block_name=$1 local block_name=$1
names=() names=()
while read line while read -r line; do
do
if [[ $last_line == "[[$block_name]]" ]]; then if [[ $last_line == "[[$block_name]]" ]]; then
in_block=true in_block=true
else else
if [[ $last_line =~ '.*\[\[.*' ]]; then if [[ $last_line =~ '\s*\[\[.*' ]]; then
in_block=false in_block=false
fi fi
fi fi
if [[ $in_block == true ]]; then if [[ $in_block == true ]]; then
if [[ $line =~ '.*name.*=' ]]; then if [[ $line =~ '\s*name\s*=' ]]; then
regexp-replace line '^.*name *= *|"' "" regexp-replace line '^\s*name\s*=\s*|"' ''
names+=$line names+=( "$line" )
fi fi
fi fi
last_line=$line last_line=$line
done < $manifest done < "$manifest"
_describe $block_name names _describe "$block_name" names
} }
#Gets the test names from the manifest file #Gets the test names from the manifest file
_test_names() _cargo_test_names() {
{ _cargo_names_from_array "test"
_get_names_from_array "test"
} }
#Gets the bench names from the manifest file #Gets the bench names from the manifest file
_benchmark_names() _cargo_benchmark_names() {
{ _cargo_names_from_array "bench"
_get_names_from_array "bench"
} }
# These flags are mutually exclusive specifiers for the scope of a command; as
# they are used in multiple places without change, they are expanded into the
# appropriate command's `_arguments` where appropriate.
set command_scope_spec
command_scope_spec=(
'(--bin --example --test --lib)--bench=[benchmark name]: :_benchmark_names'
'(--bench --bin --test --lib)--example=[example name]'
'(--bench --example --test --lib)--bin=[binary name]'
'(--bench --bin --example --test)--lib=[library name]'
'(--bench --bin --example --lib)--test=[test name]'
)
_cargo _cargo

View file

@ -17,10 +17,10 @@ Plugin for displaying images on the terminal using the the `catimg.sh` script pr
) )
``` ```
2. Reload the source file or restart your Terminal session: 2. Restart the shell or restart your Terminal session:
```console ```console
$ source ~/.zshrc $ exec zsh
$ $
``` ```

20
plugins/chruby/README.md Normal file
View file

@ -0,0 +1,20 @@
# chruby plugin
This plugin loads [chruby](https://github.com/postmodern/chruby), a tool that changes the
current Ruby version, and completion and a prompt function to display the Ruby version.
Supports brew and manual installation of chruby.
To use it, add `chruby` to the plugins array in your zshrc file:
```zsh
plugins=(... chruby)
```
## Usage
If you'd prefer to specify an explicit path to load chruby from
you can set variables like so:
```
zstyle :omz:plugins:chruby path /local/path/to/chruby.sh
zstyle :omz:plugins:chruby auto /local/path/to/auto.sh
```

View file

@ -0,0 +1,24 @@
# CloudApp plugin
[CloudApp](https://www.getcloudapp.com) brings screen recording, screenshots, and GIF creation to the cloud, in an easy-to-use enterprise-level app. The CloudApp plugin allows you to upload a file to your CloadApp account from the command line.
To use it, add `cloudapp` to the plugins array of your `~/.zshrc` file:
```
plugins=(... cloudapp)
```
## Requirements
1. [Aaron Russell's `cloudapp_api` gem](https://github.com/aaronrussell/cloudapp_api#installation)
2. That you set your CloudApp credentials in `~/.cloudapp` as a simple text file like below:
```
email
password
```
## Usage
- `cloudapp <filename>`: uploads `<filename>` to your CloudApp account, and if you're using
macOS, copies the URL to your clipboard.

View file

@ -0,0 +1,8 @@
# codeclimate plugin
This plugin adds autocompletion for the [`codeclimate` CLI](https://github.com/codeclimate/codeclimate).
To use it, add `codeclimate` to the plugins array in your zshrc file:
```zsh
plugins=(... codeclimate)
```

48
plugins/colemak/README.md Normal file
View file

@ -0,0 +1,48 @@
# Colemak plugin
This plugin remaps keys in `zsh`'s [`vi`-style navigation mode](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Keymaps)
for a [Colemak](https://colemak.com/) keyboard layout, to match the QWERTY position:
![Colemak layout on a US keyboard](https://colemak.com/wiki/images/6/6c/Colemak2.png)
To use it, add it to the plugins array in your `~/.zshrc` file:
```
plugins=(... colemak)
```
You will also need to enable `vi` mode, so add another line to `~/.zshrc`:
```
bindkey -v
```
Restart your shell and hit the `<ESC>` key to activate `vicmd` (navigation) mode,
and start navigating `zsh` with your new keybindings!
## Key bindings for vicmd
| Old | New | Binding | Description |
|------------|------------|---------------------------|----------------------------------------------------|
| `CTRL`+`j` | `CTRL`+`n` | accept-line | Insert new line |
| `j` | `n` | down-line-or-history | Move one line down or command history forwards |
| `k` | `e` | up-line-or-history | Move one line up or command history backwards |
| `l` | `i` | vi-forward-char | Move one character to the right |
| `n` | `k` | vi-repeat-search | Repeat command search forwards |
| `N` | `K` | vi-rev-repeat-search | Repeat command search backwards |
| `i` | `u` | vi-insert | Enter insert mode |
| `I` | `U` | vi-insert-bol | Move to first non-blank char and enter insert mode |
| `<none>` | `l` | vi-undo-change | Undo change |
| `J` | `N` | vi-join | Join the current line with the next one |
| `e` | `j` | vi-forward-word-end | Move to the end of the next word |
| `E` | `J` | vi-forward-blank-word-end | Move to end of the current or next word |
## Key bindings for less
| Keyboard shortcut | `less` key binding |
|-------------------|--------------------|
| `n` | forw-line |
| `e` | back-line |
| `k` | repeat-search |
| `ESC`+`k` | repeat-search-all |
| `K` | reverse-search |
| `ESC`+`K` | reverse-search-all |

View file

@ -0,0 +1,15 @@
# Colored man pages plugin
This plugin adds colors to man pages.
To use it, add `colored-man-pages` to the plugins array in your zshrc file:
```zsh
plugins=(... colored-man-pages)
```
You can also try to color other pages by prefixing the respective command with `colored`:
```zsh
colored git help clone
```

View file

@ -16,8 +16,8 @@ EOF
fi fi
fi fi
function man() { function colored() {
env \ command env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \ LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \ LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \ LESS_TERMCAP_me=$(printf "\e[0m") \
@ -28,5 +28,9 @@ function man() {
PAGER="${commands[less]:-$PAGER}" \ PAGER="${commands[less]:-$PAGER}" \
_NROFF_U=1 \ _NROFF_U=1 \
PATH="$HOME/bin:$PATH" \ PATH="$HOME/bin:$PATH" \
man "$@" "$@"
}
function man() {
colored man "$@"
} }

View file

@ -6,30 +6,43 @@ Colorize will highlight the content based on the filename extension. If it can't
method for a given extension, it will try to find one by looking at the file contents. If no highlight method method for a given extension, it will try to find one by looking at the file contents. If no highlight method
is found it will just cat the file normally, without syntax highlighting. is found it will just cat the file normally, without syntax highlighting.
To use it, add colorize to the plugins array of your zshrc file: ## Setup
To use it, add colorize to the plugins array of your `~/.zshrc` file:
``` ```
plugins=(... colorize) plugins=(... colorize)
``` ```
## Styles ## Configuration
### Requirements
This plugin requires that at least one of the following tools is installed:
* [Chroma](https://github.com/alecthomas/chroma)
* [Pygments](https://pygments.org/download/)
### Colorize tool
Colorize supports `pygmentize` and `chroma` as syntax highlighter. By default colorize uses `pygmentize` unless it's not installed and `chroma` is. This can be overridden by the `ZSH_COLORIZE_TOOL` environment variable:
```
ZSH_COLORIZE_TOOL=chroma
```
### Styles
Pygments offers multiple styles. By default, the `default` style is used, but you can choose another theme by setting the `ZSH_COLORIZE_STYLE` environment variable: Pygments offers multiple styles. By default, the `default` style is used, but you can choose another theme by setting the `ZSH_COLORIZE_STYLE` environment variable:
`ZSH_COLORIZE_STYLE="colorful"` ```
ZSH_COLORIZE_STYLE="colorful"
```
## Usage ## Usage
* `ccat <file> [files]`: colorize the contents of the file (or files, if more than one are provided). * `ccat <file> [files]`: colorize the contents of the file (or files, if more than one are provided).
If no arguments are passed it will colorize the standard input or stdin. If no files are passed it will colorize the standard input.
* `cless <file> [files]`: colorize the contents of the file (or files, if more than one are provided) and * `cless [less-options] <file> [files]`: colorize the contents of the file (or files, if more than one are provided) and open less.
open less. If no arguments are passed it will colorize the standard input or stdin. If no files are passed it will colorize the standard input.
The LESSOPEN and LESSCLOSE will be overwritten for this to work, but only in a local scope.
Note that `cless` will behave as less when provided more than one file: you have to navigate files with
the commands `:n` for next and `:p` for previous. The downside is that less options are not supported.
But you can circumvent this by either using the LESS environment variable, or by running `ccat file1 file2|less --opts`.
In the latter form, the file contents will be concatenated and presented by less as a single file.
## Requirements
You have to install Pygments first: [pygments.org](http://pygments.org/download/)

View file

@ -1,57 +1,113 @@
# easier alias to use the plugin # Easier alias to use the plugin
alias ccat='colorize_via_pygmentize' alias ccat="colorize_cat"
alias cless='colorize_via_pygmentize_less' alias cless="colorize_less"
colorize_via_pygmentize() { # '$0:A' gets the absolute path of this file
if ! (( $+commands[pygmentize] )); then ZSH_COLORIZE_PLUGIN_PATH=$0:A
echo "package 'Pygments' is not installed!"
colorize_check_requirements() {
local available_tools=("chroma" "pygmentize")
if [ -z "$ZSH_COLORIZE_TOOL" ]; then
if (( $+commands[pygmentize] )); then
ZSH_COLORIZE_TOOL="pygmentize"
elif (( $+commands[chroma] )); then
ZSH_COLORIZE_TOOL="chroma"
else
echo "Neither 'pygments' nor 'chroma' is installed!" >&2
return 1
fi
fi
if [[ ${available_tools[(Ie)$ZSH_COLORIZE_TOOL]} -eq 0 ]]; then
echo "ZSH_COLORIZE_TOOL '$ZSH_COLORIZE_TOOL' not recognized. Available options are 'pygmentize' and 'chroma'." >&2
return 1
elif (( $+commands["$ZSH_COLORIZE_TOOL"] )); then
echo "Package '$ZSH_COLORIZE_TOOL' is not installed!" >&2
return 1
fi
}
colorize_cat() {
if ! colorize_check_requirements; then
return 1 return 1
fi fi
# If the environment varianle ZSH_COLORIZE_STYLE # If the environment variable ZSH_COLORIZE_STYLE
# is set, use that theme instead. Otherwise, # is set, use that theme instead. Otherwise,
# use the default. # use the default.
if [ -z $ZSH_COLORIZE_STYLE ]; then if [ -z "$ZSH_COLORIZE_STYLE" ]; then
ZSH_COLORIZE_STYLE="default" # Both pygmentize & chroma support 'emacs'
ZSH_COLORIZE_STYLE="emacs"
fi fi
# pygmentize stdin if no arguments passed # Use stdin if no arguments have been passed.
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g pygmentize -O style="$ZSH_COLORIZE_STYLE" -g
else
chroma --style="$ZSH_COLORIZE_STYLE"
fi
return $? return $?
fi fi
# guess lexer from file extension, or # Guess lexer from file extension, or guess it from file contents if unsuccessful.
# guess it from file contents if unsuccessful
local FNAME lexer local FNAME lexer
for FNAME in "$@" for FNAME in "$@"; do
do if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then
lexer=$(pygmentize -N "$FNAME") lexer=$(pygmentize -N "$FNAME")
if [[ $lexer != text ]]; then if [[ $lexer != text ]]; then
pygmentize -O style="$ZSH_COLORIZE_STYLE" -l "$lexer" "$FNAME" pygmentize -O style="$ZSH_COLORIZE_STYLE" -l "$lexer" "$FNAME"
else else
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g "$FNAME" pygmentize -O style="$ZSH_COLORIZE_STYLE" -g "$FNAME"
fi fi
else
chroma --style="$ZSH_COLORIZE_STYLE" "$FNAME"
fi
done done
} }
colorize_via_pygmentize_less() ( # The less option 'F - Forward forever; like "tail -f".' will not work in this implementation
# this function is a subshell so tmp_files can be shared to cleanup function # caused by the lack of the ability to follow the file within pygmentize.
declare -a tmp_files colorize_less() {
if ! colorize_check_requirements; then
return 1
fi
cleanup () { _cless() {
[[ ${#tmp_files} -gt 0 ]] && rm -f "${tmp_files[@]}" # LESS="-R $LESS" enables raw ANSI colors, while maintain already set options.
exit local LESS="-R $LESS"
# This variable tells less to pipe every file through the specified command
# (see the man page of less INPUT PREPROCESSOR).
# 'zsh -ic "colorize_cat %s 2> /dev/null"' would not work for huge files like
# the ~/.zsh_history. For such files the tty of the preprocessor will be supended.
# Therefore we must source this file to make colorize_cat available in the
# preprocessor without the interactive mode.
# `2>/dev/null` will suppress the error for large files 'broken pipe' of the python
# script pygmentize, which will show up if less has not fully "loaded the file"
# (e.g. when not scrolled to the bottom) while already the next file will be displayed.
local LESSOPEN="| zsh -c 'source \"$ZSH_COLORIZE_PLUGIN_PATH\"; \
ZSH_COLORIZE_TOOL=$ZSH_COLORIZE_TOOL ZSH_COLORIZE_STYLE=$ZSH_COLORIZE_STYLE \
colorize_cat %s 2> /dev/null'"
# LESSCLOSE will be set to prevent any errors by executing a user script
# which assumes that his LESSOPEN has been executed.
local LESSCLOSE=""
LESS="$LESS" LESSOPEN="$LESSOPEN" LESSCLOSE="$LESSCLOSE" less "$@"
} }
trap 'cleanup' EXIT HUP TERM INT
while (( $# != 0 )); do #TODO: filter out less opts if [ -t 0 ]; then
tmp_file="$(mktemp -t "tmp.colorize.XXXX.$(sed 's/\//./g' <<< "$1")")" _cless "$@"
tmp_files+=("$tmp_file") else
colorize_via_pygmentize "$1" > "$tmp_file" # The input is not associated with a terminal, therefore colorize_cat will
shift 1 # colorize this input and pass it to less.
done # Less has now to decide what to use. If any files have been provided, less
# will ignore the input by default, otherwise the colorized input will be used.
less -f "${tmp_files[@]}" # If files have been supplied and the input has been redirected, this will
) # lead to unnecessary overhead, but retains the ability to use the less options
# without checking for them inside this script.
colorize_cat | _cless "$@"
fi
}

View file

@ -0,0 +1,121 @@
# Common Aliases Plugin
This plugin creates helpful shortcut aliases for many commonly used commands.
To use it add `common-aliases` to the plugins array in your zshrc file:
```zsh
plugins=(... common-aliases)
```
## Aliases
### ls command
| Alias | Command | Description |
|-------|---------------|--------------------------------------------------------------------------------|
| l | `ls -lFh` | List files as a long list, show size, type, human-readable |
| la | `ls -lAFh` | List almost all files as a long list show size, type, human-readable |
| lr | `ls -tRFh` | List files recursively sorted by date, show type, human-readable |
| lt | `ls -ltFh` | List files as a long list sorted by date, show type, human-readable |
| ll | `ls -l` | List files as a long list |
| ldot | `ls -ld .*` | List dot files as a long list |
| lS | `ls -1FSsh` | List files showing only size and name sorted by size |
| lart | `ls -1Fcart` | List all files sorted in reverse of create/modification time (oldest first) |
| lrt | `ls -1Fcrt` | List files sorted in reverse of create/modification time(oldest first) |
### File handling
| Alias | Command | Description |
|-------|-----------------------|------------------------------------------------------------------------------------|
| rm | `rm -i` | Remove a file |
| cp | `cp -i` | Copy a file |
| mv | `mv -i` | Move a file |
| zshrc | `${=EDITOR} ~/.zshrc` | Quickly access the ~/.zshrc file |
| dud | `du -d 1 -h` | Display the size of files at depth 1 in current location in human-readable form |
| duf | `du -sh` | Display the size of files in current location in human-readable form |
| t | `tail -f` | Shorthand for tail which outputs the last part of a file |
### find and grep
| Alias | Command | Description |
|-------|-----------------------------------------------------|-----------------------------------------|
| fd | `find . -type d -name` | Find a directory with the given name |
| ff | `find . -type f -name` | Find a file with the given name |
| grep | `grep --color` | Searches for a query string |
| sgrep | `grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS}` | Useful for searching within files |
### Other Aliases
| Alias | Command | Description |
|-----------|---------------------|-------------------------------------------------------------|
| h | `history` | Lists all recently used commands |
| hgrep | `fc -El 0 \| grep` | Searches for a word in the list of previously used commands |
| help | `man` | Opens up the man page for a command |
| p | `ps -f` | Displays currently executing processes |
| sortnr | `sort -n -r` | Used to sort the lines of a text file |
| unexport | `unset` | Used to unset an environment variable |
## Global aliases
These aliases are expanded in any position in the command line, meaning you can use them even at the
end of the command you've typed. Examples:
Quickly pipe to less:
```zsh
$ ls -l /var/log L
# will run
$ ls -l /var/log | less
```
Silences stderr output:
```zsh
$ find . -type f NE
# will run
$ find . -type f 2>/dev/null
```
| Alias | Command | Description |
|-------|-----------------------------|-------------------------------------------------------------|
| H | `\| head` | Pipes output to head which outputs the first part of a file |
| T | `\| tail` | Pipes output to tail which outputs the last part of a file |
| G | `\| grep` | Pipes output to grep to search for some word |
| L | `\| less` | Pipes output to less, useful for paging |
| M | `\| most` | Pipes output to more, useful for paging |
| LL | `2>&1 \| less` | Writes stderr to stdout and passes it to less |
| CA | `2>&1 \| cat -A` | Writes stderr to stdout and passes it to cat |
| NE | `2 > /dev/null` | Silences stderr |
| NUL | `> /dev/null 2>&1` | Silences both stdout and stderr |
| P | `2>&1\| pygmentize -l pytb` | Writes stderr to stdout and passes it to pygmentize |
## File extension aliases
These are special aliases that are triggered when a file name is passed as the command. For example,
if the pdf file extension is aliased to `acroread` (a popular Linux pdf reader), when running `file.pdf`
that file will be open with `acroread`.
### Reading Docs
| Alias | Command | Description |
|-------|-------------|-------------------------------------|
| pdf | `acroread` | Opens up a document using acroread |
| ps | `gv` | Opens up a .ps file using gv |
| dvi | `xdvi` | Opens up a .dvi file using xdvi |
| chm | `xchm` | Opens up a .chm file using xchm |
| djvu | `djview` | Opens up a .djvu file using djview |
### Listing files inside a packed file
| Alias | Command | Description |
|---------|-------------|-------------------------------------|
| zip | `unzip -l` | Lists files inside a .zip file |
| rar | `unrar l` | Lists files inside a .rar file |
| tar | `tar tf` | Lists files inside a .tar file |
| tar.gz | `echo` | Lists files inside a .tar.gz file |
| ace | `unace l` | Lists files inside a .ace file |
### Some other features
- Opens urls in terminal using browser specified by the variable `$BROWSER`
- Opens C, C++, Tex and text files using editor specified by the variable `$EDITOR`
- Opens images using image viewer specified by the variable `$XIVIEWER`
- Opens videos and other media using mplayer

View file

@ -50,6 +50,7 @@ alias mv='mv -i'
# zsh is able to auto-do some kungfoo # zsh is able to auto-do some kungfoo
# depends on the SUFFIX :) # depends on the SUFFIX :)
autoload -Uz is-at-least
if is-at-least 4.2.0; then if is-at-least 4.2.0; then
# open browser on urls # open browser on urls
if [[ -n "$BROWSER" ]]; then if [[ -n "$BROWSER" ]]; then

View file

@ -0,0 +1,8 @@
# compleat plugin
This plugin looks for [compleat](https://github.com/mbrubeck/compleat) and loads its completion.
To use it, add compleat to the plugins array in your zshrc file:
```
plugins=(... compleat)
```

View file

@ -1,9 +1,9 @@
# copy the active line from the command line buffer # copy the active line from the command line buffer
# onto the system clipboard (requires clipcopy plugin) # onto the system clipboard
copybuffer () { copybuffer () {
if which clipcopy &>/dev/null; then if which clipcopy &>/dev/null; then
echo $BUFFER | clipcopy printf "%s" "$BUFFER" | clipcopy
else else
echo "clipcopy function not found. Please make sure you have Oh My Zsh installed correctly." echo "clipcopy function not found. Please make sure you have Oh My Zsh installed correctly."
fi fi

28
plugins/dash/README.md Normal file
View file

@ -0,0 +1,28 @@
# Dash plugin
This plugin adds command line functionality for [Dash](https://kapeli.com/dash),
an API Documentation Browser for macOS. This plugin requires Dash to be installed
to work.
To use it, add `dash` to the plugins array in your zshrc file:
```zsh
plugins=(... dash)
```
## Usage
- Open and switch to the dash application.
```
dash
```
- Query for something in dash app: `dash query`
```
dash golang
```
- You can optionally provide a keyword: `dash [keyword:]query`
```
dash python:tuple
```

View file

@ -35,36 +35,30 @@ _dash() {
if [[ "$locator" == "platform" ]]; then if [[ "$locator" == "platform" ]]; then
# Since these are the only special cases right now, let's not do the # Since these are the only special cases right now, let's not do the
# expensive processing unless we have to # expensive processing unless we have to
if [[ "$keyword" == "python" || "$keyword" == "java" || \ if [[ "$keyword" = (python|java|qt|cocos2d) ]]; then
"$keyword" == "qt" || "$keyword" == "cocs2d" ]]; then
docsetName=`echo $doc | grep -Eo "docsetName = .*?;" | sed -e "s/docsetName = \(.*\);/\1/" -e "s/[\":]//g"` docsetName=`echo $doc | grep -Eo "docsetName = .*?;" | sed -e "s/docsetName = \(.*\);/\1/" -e "s/[\":]//g"`
if [[ "$keyword" == "python" ]]; then case "$keyword" in
if [[ "$docsetName" == "Python 2" ]]; then python)
keyword="python2" case "$docsetName" in
elif [[ "$docsetName" == "Python 3" ]]; then "Python 2") keyword="python2" ;;
keyword="python3" "Python 3") keyword="python3" ;;
fi esac ;;
elif [[ "$keyword" == "java" ]]; then java)
if [[ "$docsetName" == "Java SE7" ]]; then case "$docsetName" in
keyword="java7" "Java SE7") keyword="java7" ;;
elif [[ "$docsetName" == "Java SE6" ]]; then "Java SE6") keyword="java6" ;;
keyword="java6" "Java SE8") keyword="java8" ;;
elif [[ "$docsetName" == "Java SE8" ]]; then esac ;;
keyword="java8" qt)
fi case "$docsetName" in
elif [[ "$keyword" == "qt" ]]; then "Qt 5") keyword="qt5" ;;
if [[ "$docsetName" == "Qt 5" ]]; then "Qt 4"|Qt) keyword="qt4" ;;
keyword="qt5" esac ;;
elif [[ "$docsetName" == "Qt 4" ]]; then cocos2d)
keyword="qt4" case "$docsetName" in
elif [[ "$docsetName" == "Qt" ]]; then Cocos3D) keyword="cocos3d" ;;
keyword="qt4" esac ;;
fi esac
elif [[ "$keyword" == "cocos2d" ]]; then
if [[ "$docsetName" == "Cocos3D" ]]; then
keyword="cocos3d"
fi
fi
fi fi
fi fi

View file

@ -72,7 +72,7 @@ if [[ $use_sudo -eq 1 ]]; then
# commands using su ######### # commands using su #########
else else
alias aac="su -ls '$apt_pref autoclean' root" alias aac="su -ls '$apt_pref autoclean' root"
abd() { function abd() {
cmd="su -lc '$apt_pref build-dep $@' root" cmd="su -lc '$apt_pref build-dep $@' root"
print "$cmd" print "$cmd"
eval "$cmd" eval "$cmd"
@ -83,17 +83,17 @@ else
alias adu="su -lc '$apt_pref update && aptitude dist-upgrade' root" alias adu="su -lc '$apt_pref update && aptitude dist-upgrade' root"
alias afu="su -lc '$apt-file update'" alias afu="su -lc '$apt-file update'"
alias au="su -lc '$apt_pref $apt_upgr' root" alias au="su -lc '$apt_pref $apt_upgr' root"
ai() { function ai() {
cmd="su -lc 'aptitude -P install $@' root" cmd="su -lc 'aptitude -P install $@' root"
print "$cmd" print "$cmd"
eval "$cmd" eval "$cmd"
} }
ap() { function ap() {
cmd="su -lc '$apt_pref -P purge $@' root" cmd="su -lc '$apt_pref -P purge $@' root"
print "$cmd" print "$cmd"
eval "$cmd" eval "$cmd"
} }
ar() { function ar() {
cmd="su -lc '$apt_pref -P remove $@' root" cmd="su -lc '$apt_pref -P remove $@' root"
print "$cmd" print "$cmd"
eval "$cmd" eval "$cmd"
@ -114,7 +114,7 @@ fi
# Registers a compdef for $1 that calls $apt_pref with the commands $2 # Registers a compdef for $1 that calls $apt_pref with the commands $2
# To do that it creates a new completion function called _apt_pref_$2 # To do that it creates a new completion function called _apt_pref_$2
# #
apt_pref_compdef() { function apt_pref_compdef() {
local f fb local f fb
f="_apt_pref_${2}" f="_apt_pref_${2}"
@ -151,7 +151,7 @@ alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc'
# Functions ################################################################# # Functions #################################################################
# create a simple script that can be used to 'duplicate' a system # create a simple script that can be used to 'duplicate' a system
apt-copy() { function apt-copy() {
print '#!/bin/sh'"\n" > apt-copy.sh print '#!/bin/sh'"\n" > apt-copy.sh
cmd='$apt_pref install' cmd='$apt_pref install'
@ -173,7 +173,7 @@ apt-copy() {
# apt-history rollback # apt-history rollback
# apt-history list # apt-history list
# Based On: https://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html # Based On: https://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html
apt-history () { function apt-history() {
case "$1" in case "$1" in
install) install)
zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*) zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*)
@ -202,7 +202,7 @@ apt-history () {
} }
# Kernel-package building shortcut # Kernel-package building shortcut
kerndeb () { function kerndeb() {
# temporarily unset MAKEFLAGS ( '-j3' will fail ) # temporarily unset MAKEFLAGS ( '-j3' will fail )
MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' ) MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' )
print '$MAKEFLAGS set to '"'$MAKEFLAGS'" print '$MAKEFLAGS set to '"'$MAKEFLAGS'"
@ -216,10 +216,9 @@ kerndeb () {
} }
# List packages by size # List packages by size
function apt-list-packages { function apt-list-packages() {
dpkg-query -W --showformat='${Installed-Size} ${Package} ${Status}\n' | \ dpkg-query -W --showformat='${Installed-Size} ${Package} ${Status}\n' | \
grep -v deinstall | \ grep -v deinstall | \
sort -n | \ sort -n | \
awk '{print $1" "$2}' awk '{print $1" "$2}'
} }

View file

@ -15,10 +15,10 @@ This plugin enables directory navigation similar to using back and forward on br
) )
``` ```
2. Reload the source file or restart your Terminal session: 2. Restart the shell or restart your Terminal session:
```console ```console
$ source ~/.zshrc $ exec zsh
$ $
``` ```

View file

@ -53,7 +53,8 @@ function push_future() {
} }
# Called by zsh when directory changes # Called by zsh when directory changes
chpwd_functions+=(chpwd_dirhistory) autoload -U add-zsh-hook
add-zsh-hook chpwd chpwd_dirhistory
function chpwd_dirhistory() { function chpwd_dirhistory() {
push_past $PWD push_past $PWD
# If DIRHISTORY_CD is not set... # If DIRHISTORY_CD is not set...

View file

@ -11,7 +11,8 @@ if [[ -f ${dirstack_file} ]] && [[ ${#dirstack[*]} -eq 0 ]] ; then
[[ -d $dirstack[1] ]] && cd $dirstack[1] && cd $OLDPWD [[ -d $dirstack[1] ]] && cd $dirstack[1] && cd $OLDPWD
fi fi
chpwd_functions+=(chpwd_dirpersist) autoload -U add-zsh-hook
add-zsh-hook chpwd chpwd_dirpersist
chpwd_dirpersist() { chpwd_dirpersist() {
if (( $DIRSTACKSIZE <= 0 )) || [[ -z $dirstack_file ]]; then return; fi if (( $DIRSTACKSIZE <= 0 )) || [[ -z $dirstack_file ]]; then return; fi
local -ax my_stack local -ax my_stack

View file

@ -374,7 +374,8 @@ _managepy-commands() {
_applist() { _applist() {
local line local line
local -a apps local -a apps
_call_program help-command "python -c \"import os.path as op, re, django.conf, sys;\\ _call_program help-command "python -c \"import sys; del sys.path[0];\\
import os.path as op, re, django.conf;\\
bn=op.basename(op.abspath(op.curdir));[sys\\ bn=op.basename(op.abspath(op.curdir));[sys\\
.stdout.write(str(re.sub(r'^%s\.(.*?)$' % .stdout.write(str(re.sub(r'^%s\.(.*?)$' %
bn, r'\1', i)) + '\n') for i in django.conf.settings.\\ bn, r'\1', i)) + '\n') for i in django.conf.settings.\\

View file

@ -1,5 +1,11 @@
## Docker autocomplete plugin # Docker plugin
A copy of the completion script from the This plugin adds auto-completion for [docker](https://www.docker.com/).
[docker/cli](https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker)
git repo. To use it add `docker` to the plugins array in your zshrc file.
```zsh
plugins=(... docker)
```
A copy of the completion script from the docker/cli git repo:
https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker

View file

@ -32,6 +32,8 @@ PORT=3001
``` ```
You can even mix both formats, although it's probably a bad idea. You can even mix both formats, although it's probably a bad idea.
## Plugin options
### ZSH_DOTENV_FILE ### ZSH_DOTENV_FILE
You can also modify the name of the file to be loaded with the variable `ZSH_DOTENV_FILE`. You can also modify the name of the file to be loaded with the variable `ZSH_DOTENV_FILE`.
@ -43,6 +45,10 @@ For example, this will make the plugin look for files named `.dotenv` and load t
ZSH_DOTENV_FILE=.dotenv ZSH_DOTENV_FILE=.dotenv
``` ```
### ZSH_DOTENV_PROMPT
Set `ZSH_DOTENV_PROMPT=false` in your zshrc file if you don't want the confirmation message.
## Version Control ## 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. **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.

View file

@ -1,5 +1,17 @@
source_env() { source_env() {
if [[ -f $ZSH_DOTENV_FILE ]]; then if [[ -f $ZSH_DOTENV_FILE ]]; then
if [ "$ZSH_DOTENV_PROMPT" != "false" ]; then
# confirm before sourcing file
local confirmation
# print same-line prompt and output newline character if necessary
echo -n "dotenv: source '$ZSH_DOTENV_FILE' file in the directory? (Y/n) "
read -k 1 confirmation; [[ "$confirmation" != $'\n' ]] && echo
# only bail out if confirmation character is n
if [[ "$confirmation" = [nN] ]]; then
return
fi
fi
# test .env syntax # test .env syntax
zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2 zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2

23
plugins/dotnet/README.md Normal file
View file

@ -0,0 +1,23 @@
# .NET Core CLI plugin
This plugin provides completion and useful aliases for [.NET Core CLI](https://dotnet.microsoft.com/).
To use it, add `dotnet` to the plugins array in your zshrc file.
```
plugins=(... dotnet)
```
## Aliases
| Alias | Command | Description |
|-------|------------------|-------------------------------------------------------------------|
| dn | dotnet new | Create a new .NET project or file. |
| dr | dotnet run | Build and run a .NET project output. |
| dt | dotnet test | Run unit tests using the test runner specified in a .NET project. |
| dw | dotnet watch | Watch for source file changes and restart the dotnet command. |
| dwr | dotnet watch run | Watch for source file changes and restart the `run` command. |
| ds | dotnet sln | Modify Visual Studio solution files. |
| da | dotnet add | Add a package or reference to a .NET project. |
| dp | dotnet pack | Create a NuGet package. |
| dng | dotnet nuget | Provides additional NuGet commands. |

View file

@ -0,0 +1,32 @@
# This scripts is copied from (MIT License):
# https://github.com/dotnet/toolset/blob/master/scripts/register-completions.zsh
_dotnet_zsh_complete()
{
local completions=("$(dotnet complete "$words")")
# If the completion list is empty, just continue with filename selection
if [ -z "$completions" ]
then
_arguments '*::arguments: _normal'
return
fi
# This is not a variable assigment, don't remove spaces!
_values = "${(ps:\n:)completions}"
}
compdef _dotnet_zsh_complete dotnet
# Aliases bellow are here for backwards compatibility
# added by Shaun Tabone (https://github.com/xontab)
alias dn='dotnet new'
alias dr='dotnet run'
alias dt='dotnet test'
alias dw='dotnet watch'
alias dwr='dotnet watch run'
alias ds='dotnet sln'
alias da='dotnet add'
alias dp='dotnet pack'
alias dng='dotnet nuget'

11
plugins/eecms/README.md Normal file
View file

@ -0,0 +1,11 @@
# eecms plugin
This plugin adds auto-completion of console commands for [`eecms`](https://github.com/ExpressionEngine/ExpressionEngine).
To use it, add `eecms` to the plugins array of your `.zshrc` file:
```
plugins=(... eecms)
```
It also adds the alias `eecms` which finds the eecms file in the current project
and runs it with php.

View file

@ -20,7 +20,8 @@ _emacsfun()
# tempfile. (first argument will be `--no-wait` passed in by the plugin.zsh) # tempfile. (first argument will be `--no-wait` passed in by the plugin.zsh)
if [ "$#" -ge "2" -a "$2" = "-" ] if [ "$#" -ge "2" -a "$2" = "-" ]
then then
tempfile="$(mktemp emacs-stdin-$USER.XXXXXXX --tmpdir)" tempfile="$(mktemp --tmpdir emacs-stdin-$USER.XXXXXXX 2>/dev/null \
|| mktemp -t emacs-stdin-$USER)" # support BSD mktemp
cat - > "$tempfile" cat - > "$tempfile"
_emacsfun --no-wait $tempfile _emacsfun --no-wait $tempfile
else else

View file

@ -2,7 +2,7 @@
# FILE: emoji-clock.plugin.zsh # FILE: emoji-clock.plugin.zsh
# DESCRIPTION: The current time with half hour accuracy as an emoji symbol. # DESCRIPTION: The current time with half hour accuracy as an emoji symbol.
# Inspired by Andre Torrez' "Put A Burger In Your Shell" # Inspired by Andre Torrez' "Put A Burger In Your Shell"
# http://notes.torrez.org/2013/04/put-a-burger-in-your-shell.html # https://notes.torrez.org/2013/04/put-a-burger-in-your-shell.html
# AUTHOR: Alexis Hildebrandt (afh[at]surryhill.net) # AUTHOR: Alexis Hildebrandt (afh[at]surryhill.net)
# VERSION: 1.0.0 # VERSION: 1.0.0
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------

39
plugins/emotty/README.md Normal file
View file

@ -0,0 +1,39 @@
# emotty plugin
This plugin returns an emoji for the current $TTY number so it can be used
in a prompt.
To use it, add emotty to the plugins array in your zshrc file:
```
plugins=(... emotty)
```
**NOTE:** it requires the [emoji plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/emoji).
## Usage
The function `emotty` displays an emoji from the current character set (default: `emoji`), based
on the number associated to the `$TTY`.
There are different sets of emoji characters available, to choose a different
set, set `$emotty_set` to the name of the set you would like to use, e.g.:
```
emotty_set=nature
```
### Character Sets
- emoji
- loral
- love
- nature
- stellar
- zodiac
Use the `display_emotty` function to list the emojis in the current character set, or
the character set passed as the first argument. For example:
```
$ display_emotty zodiac
<list of all the emojis in the zodiac character set>
```

View file

@ -20,10 +20,10 @@ Alias plugin for encoding or decoding using `base64` command
) )
``` ```
2. Restart your terminal session or reload configuration by running: 2. Restart your terminal session or restart the shell:
```sh ```sh
source ~/.zshrc exec zsh
``` ```
## Usage and examples ## Usage and examples

View file

@ -25,23 +25,32 @@ plugins=(... extract)
| `gz` | Gzip file | | `gz` | Gzip file |
| `ipsw` | iOS firmware file | | `ipsw` | iOS firmware file |
| `jar` | Java Archive | | `jar` | Java Archive |
| `lrz` | LRZ archive |
| `lz4` | LZ4 archive |
| `lzma` | LZMA archive | | `lzma` | LZMA archive |
| `rar` | WinRAR archive | | `rar` | WinRAR archive |
| `rpm` | RPM package |
| `sublime-package` | Sublime Text package | | `sublime-package` | Sublime Text package |
| `tar` | Tarball | | `tar` | Tarball |
| `tar.bz2` | Tarball with bzip2 compression | | `tar.bz2` | Tarball with bzip2 compression |
| `tar.gz` | Tarball with gzip compression | | `tar.gz` | Tarball with gzip compression |
| `tar.lrz` | Tarball with lrzip compression |
| `tar.lz` | Tarball with lzip compression |
| `tar.lz4` | Tarball with lz4 compression |
| `tar.xz` | Tarball with lzma2 compression | | `tar.xz` | Tarball with lzma2 compression |
| `tar.zma` | Tarball with lzma compression | | `tar.zma` | Tarball with lzma compression |
| `tar.zst` | Tarball with zstd compression |
| `tbz` | Tarball with bzip compression | | `tbz` | Tarball with bzip compression |
| `tbz2` | Tarball with bzip2 compression | | `tbz2` | Tarball with bzip2 compression |
| `tgz` | Tarball with gzip compression | | `tgz` | Tarball with gzip compression |
| `tlz` | Tarball with lzma compression | | `tlz` | Tarball with lzma compression |
| `txz` | Tarball with lzma2 compression | | `txz` | Tarball with lzma2 compression |
| `tzst` | Tarball with zstd compression |
| `war` | Web Application archive (Java-based) | | `war` | Web Application archive (Java-based) |
| `xpi` | Mozilla XPI module file | | `xpi` | Mozilla XPI module file |
| `xz` | LZMA2 archive | | `xz` | LZMA2 archive |
| `zip` | Zip archive | | `zip` | Zip archive |
| `zst` | Zstandard file (zstd) |
See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for
more information regarding archive formats. more information regarding archive formats.

View file

@ -3,5 +3,5 @@
_arguments \ _arguments \
'(-r --remove)'{-r,--remove}'[Remove archive.]' \ '(-r --remove)'{-r,--remove}'[Remove archive.]' \
"*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|deb|gz|ipsw|jar|lzma|rar|sublime-package|tar|tar.bz2|tar.gz|tar.xz|tar.zma|tbz|tbz2|tgz|tlz|txz|war|whl|xpi|xz|zip)(-.)'" \ "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|deb|gz|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst)(-.)'" \
&& return 0 && return 0

View file

@ -40,14 +40,24 @@ extract() {
tar --lzma --help &> /dev/null \ tar --lzma --help &> /dev/null \
&& tar --lzma -xvf "$1" \ && tar --lzma -xvf "$1" \
|| lzcat "$1" | tar xvf - ;; || lzcat "$1" | tar xvf - ;;
(*.tar.zst|*.tzst)
tar --zstd --help &> /dev/null \
&& tar --zstd -xvf "$1" \
|| zstdcat "$1" | tar xvf - ;;
(*.tar) tar xvf "$1" ;; (*.tar) tar xvf "$1" ;;
(*.gz) (( $+commands[pigz] )) && pigz -d "$1" || gunzip "$1" ;; (*.tar.lz) (( $+commands[lzip] )) && tar xvf "$1" ;;
(*.tar.lz4) lz4 -c -d "$1" | tar xvf - ;;
(*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$1" ;;
(*.gz) (( $+commands[pigz] )) && pigz -dk "$1" || gunzip -k "$1" ;;
(*.bz2) bunzip2 "$1" ;; (*.bz2) bunzip2 "$1" ;;
(*.xz) unxz "$1" ;; (*.xz) unxz "$1" ;;
(*.lrz) (( $+commands[lrunzip] )) && lrunzip "$1" ;;
(*.lz4) lz4 -d "$1" ;;
(*.lzma) unlzma "$1" ;; (*.lzma) unlzma "$1" ;;
(*.z) uncompress "$1" ;; (*.z) uncompress "$1" ;;
(*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d $extract_dir ;; (*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d $extract_dir ;;
(*.rar) unrar x -ad "$1" ;; (*.rar) unrar x -ad "$1" ;;
(*.rpm) mkdir "$extract_dir" && cd "$extract_dir" && rpm2cpio "../$1" | cpio --quiet -id && cd .. ;;
(*.7z) 7za x "$1" ;; (*.7z) 7za x "$1" ;;
(*.deb) (*.deb)
mkdir -p "$extract_dir/control" mkdir -p "$extract_dir/control"
@ -58,6 +68,7 @@ extract() {
cd ..; rm *.tar.* debian-binary cd ..; rm *.tar.* debian-binary
cd .. cd ..
;; ;;
(*.zst) unzstd "$1" ;;
(*) (*)
echo "extract: '$1' cannot be extracted" >&2 echo "extract: '$1' cannot be extracted" >&2
success=1 success=1

View file

@ -4,10 +4,19 @@
local curcontext=$curcontext state line local curcontext=$curcontext state line
declare -A opt_args declare -A opt_args
declare target_list declare -a target_list
target_list=(`fab --shortlist 2>/dev/null`) target_list=("${(@f)$(fab -l 2>/dev/null | awk '{
if (NF == 0 || NR == 1) next
if (NF < 2) print $1
else {
docstring=substr($0, index($0,$2))
gsub(":", "\\:", docstring)
print $1":"docstring
}
}')}")
_targets() { _fab_targets() {
[[ -n "$target_list" ]] || return
_describe -t commands "fabric targets" target_list _describe -t commands "fabric targets" target_list
} }
@ -28,7 +37,7 @@ _arguments -w -S -C \
'(-)--shortlist[print non-verbose list of possible commands and exit]: :->noargs' \ '(-)--shortlist[print non-verbose list of possible commands and exit]: :->noargs' \
'(--reject-unknown-hosts)--reject-unknown-hosts[reject unknown hosts]' \ '(--reject-unknown-hosts)--reject-unknown-hosts[reject unknown hosts]' \
'(--no-pty)--no-pty[do not use pseudo-terminal in run/sudo]' \ '(--no-pty)--no-pty[do not use pseudo-terminal in run/sudo]' \
"(-d+ --display=-)"{-d+,--display=-}"[print detailed info about a given command]: :_targets" \ "(-d+ --display=-)"{-d+,--display=-}"[print detailed info about a given command]: :_fab_targets" \
'(-D --disable-known-hosts)'{-D,--disable-known-hosts}'[do not load user known_hosts file]' \ '(-D --disable-known-hosts)'{-D,--disable-known-hosts}'[do not load user known_hosts file]' \
'(-r --reject-unknown-hosts)'{-r,--reject-unknown-hosts}'[reject unknown hosts]' \ '(-r --reject-unknown-hosts)'{-r,--reject-unknown-hosts}'[reject unknown hosts]' \
'(-u+ --user=-)'{-u+,--user=-}'[username to use when connecting to remote hosts]: :' \ '(-u+ --user=-)'{-u+,--user=-}'[username to use when connecting to remote hosts]: :' \
@ -53,7 +62,7 @@ if [[ CURRENT -ge 1 ]]; then
levels) levels)
_describe -t commands "output levels" output_levels;; _describe -t commands "output levels" output_levels;;
*) *)
_targets;; _fab_targets;;
esac esac
return return

21
plugins/fasd/README.md Normal file
View file

@ -0,0 +1,21 @@
# fasd
[`Fasd`](https://github.com/clvv/fasd) (pronounced similar to "fast") is a command-line productivity booster. Fasd offers quick access to files and directories for POSIX shells.
To use it, add `fasd` to the plugins array in your zshrc file:
```zsh
plugins=(... fasd)
```
## Installation
Please find detailed installation guide [`here`](https://github.com/clvv/fasd#install)
## Aliases
| Alias | Command | Description |
|-------|-------------------------------------------|-------------------------------------------------------------|
| v | `fasd -f -e "$EDITOR"` | List frequent/recent files matching the given filename. |
| o | `fasd -a -e xdg-open` | List frequent/recent files and directories matching. |
| j | `fasd_cd -d -i` | cd with interactive selection |

View file

@ -0,0 +1,84 @@
# Fastfile plugin
This plugin adds a way to reference certain files or folders used frequently using
a global alias or shortcut.
To use it, add `fastfile` to the plugins array in your zshrc file:
```zsh
plugins=(... fastfile)
```
## Usage
Example: you access folder `/code/project/backend/database` very frequently.
First, generate a shortcut with the name `pjdb`:
```zsh
$ fastfile pjdb /code/project/backend/database
```
Next time you want to access it, use `§pjdb`. For example:
```zsh
$ cd §pjdb
$ subl §pjdb
```
where § is the fastfile prefix (see [below](#options) for how to change).
**Note:** shortcuts with spaces in the name are assigned a global alias
where the spaces have been substituted with underscores (`_`). For example:
a shortcut named `"hello world"` corresponds with `§hello_world`.
## Functions
- `fastfile <shortcut_name> <path/to/file/or/folder>`: generate a shortcut.
- `fastfile_print <shortcut_name>`: prints a shortcut, with the format
`<prefix><shortcut_name> -> <shortcut_path>`.
- `fastfile_ls`: lists all shortcuts.
- `fastfile_rm <shortcut_name> `: remove a shortcut.
- `fastfile_sync`: generates the global aliases for the shortcuts.
### Internal functions
- `fastfile_resolv <shortcut_name>`: resolves the location of the shortcut
file, i.e., the file in the fastfile directory where the shortcut path
is stored.
- `fastfile_get <shortcut_name>`: get the real path of the shortcut.
## Aliases
| Alias | Function |
|--------|------------------|
| ff | `fastfile` |
| ffp | `fastfile_print` |
| ffrm | `fastfile_rm` |
| ffls | `fastfile_ls` |
| ffsync | `fastfile_sync` |
## Options
These are options you can set to change certain parts of the plugin. To change
them, add `<variable>=<value>` to your zshrc file, before Oh My Zsh is sourced.
For example: `fastfile_var_prefix='@'`.
- `fastfile_var_prefix`: prefix for the global aliases created. Controls the prefix of the
created global aliases.
**Default:** `§` (section sign), easy to type in a german keyboard via the combination
[`⇧ Shift`+`3`](https://en.wikipedia.org/wiki/German_keyboard_layout#/media/File:KB_Germany.svg),
or using `⌥ Option`+`6` in macOS.
- `fastfile_dir`: directory where the fastfile shortcuts are stored. Needs to end
with a trailing slash.
**Default:** `$HOME/.fastfile/`.
## Author
- [Karolin Varner](https://github.com/koraa)

View file

@ -1,13 +1,3 @@
################################################################################
# FILE: fastfile.plugin.zsh
# DESCRIPTION: oh-my-zsh plugin file.
# AUTHOR: Michael Varner (musikmichael@web.de)
# VERSION: 1.0.0
#
# This plugin adds the ability to on the fly generate and access file shortcuts.
#
################################################################################
########################### ###########################
# Settings # Settings
@ -51,7 +41,7 @@ function fastfile() {
# Arguments: # Arguments:
# 1. name - The name of the shortcut # 1. name - The name of the shortcut
# STDOUT: # STDOUT:
# The path # The path to the shortcut file
# #
function fastfile_resolv() { function fastfile_resolv() {
echo "${fastfile_dir}${1}" echo "${fastfile_dir}${1}"
@ -102,7 +92,6 @@ function fastfile_ls() {
# #
# Arguments: # Arguments:
# 1. name - The name of the shortcut (default: name of the file) # 1. name - The name of the shortcut (default: name of the file)
# 2. file - The file or directory to make the shortcut for
# STDOUT: # STDOUT:
# => fastfle_print # => fastfle_print
# #

9
plugins/fbterm/README.md Normal file
View file

@ -0,0 +1,9 @@
# fbterm
This plugin automatically starts [fbterm](https://github.com/zhangyuanwei/fbterm)
if on a real TTY (`/dev/tty*`).
To use it, add fbterm to the plugins array of your zshrc file:
```
plugins=(... fbterm)
```

View file

@ -1 +1 @@
The fedora plugin is deprecated. Use the [dnf plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/dnf) instead. The fedora plugin is deprecated. Use the [dnf plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/dnf) instead.

21
plugins/flutter/README.md Normal file
View file

@ -0,0 +1,21 @@
## Flutter plugin
The Flutter plugin provides completion and useful aliases
To use it, add flutter to the plugins array of your zshrc file:
```
plugins=(... flutter)
```
## Aliases
| Alias | Command | Description |
| :--------- | :--------------------- | :------------------------------------------------------------------------- |
| `fl` | `flutter` | Shorthand for flutter command |
| `flr` | `flutter run` | Runs flutter app |
| `fldoc` | `flutter doctor` | Runs flutter doctor |
| `flb` | `flutter build` | Build flutter application |
| `flattach` | `flutter attach` | Attaches flutter to a running flutter application with enabled observatory |
| `flget` | `flutter packages get` | Installs dependencies |
| `flc` | `flutter clean` | Cleans flutter porject |

37
plugins/flutter/_flutter Normal file
View file

@ -0,0 +1,37 @@
#compdef flutter
#autoload
local -a _1st_arguments
_1st_arguments=(
"analyze":"Analyze the project's Dart code."
"assemble":"Assemble and build flutter resources."
"attach":"Attach to a running application."
"build":"Flutter build commands."
"channel":"List or switch flutter channels."
"clean":"Delete the build/ and .dart_tool/ directories."
"config":"Configure Flutter settings."
"create":"Create a new Flutter project."
"devices":"List all connected devices."
"doctor":"Show information about the installed tooling."
"drive":"Runs Flutter Driver tests for the current project."
"emulators":"List, launch and create emulators."
"format":" Format one or more dart files."
"help":"Display help information for flutter."
"install":"Install a Flutter app on an attached device."
"logs":"Show log output for running Flutter apps."
"make-host-app-editable":"Moves host apps from generated directories to non-generated directories so that they can be edited by developers."
"precache":"Populates the Flutter tool's cache of binary artifacts."
"pub":"Commands for managing Flutter packages."
"run":"Run your Flutter app on an attached device."
"screenshot":"Take a screenshot from a connected device."
"test":"Run Flutter unit tests for the current project."
"upgrade":"Upgrade your copy of Flutter."
"version":"List or switch flutter versions."
)
_arguments -C '*:: :->subcmds'
if (( CURRENT == 1 )); then
_describe -t commands "flutter command" _1st_arguments
return
fi

View file

@ -0,0 +1,7 @@
alias fl="flutter"
alias flr="flutter run"
alias fldoc="flutter doctor"
alias flb="flutter build"
alias flattach="flutter attach"
alias flget="flutter packages get"
alias flc="flutter clean"

View file

@ -62,6 +62,10 @@ Available search contexts are:
If you want to have another context, open an Issue and tell us! If you want to have another context, open an Issue and tell us!
## Fallback search behaviour
The plugin will use Google as a fallback if the docs site for a search context does not have a search function. You can set the fallback search engine to DuckDuckGo by setting `FRONTEND_SEARCH_FALLBACK='duckduckgo'` in your `~/.zshrc` file before Oh My Zsh is sourced.
## Author ## Author
**Wilson Mendes (willmendesneto)** **Wilson Mendes (willmendesneto)**

View file

@ -27,6 +27,17 @@ alias typescript='frontend typescript'
alias unheap='frontend unheap' alias unheap='frontend unheap'
alias vuejs='frontend vuejs' alias vuejs='frontend vuejs'
function _frontend_fallback() {
local url
if [[ "$FRONTEND_SEARCH_FALLBACK" == duckduckgo ]]; then
url="https://duckduckgo.com/?sites=$1&q="
else
url="https://google.com/search?as_sitesearch=$1&as_q="
fi
echo "$url"
}
function frontend() { function frontend() {
emulate -L zsh emulate -L zsh
@ -34,8 +45,8 @@ function frontend() {
typeset -A urls typeset -A urls
urls=( urls=(
angular 'https://angular.io/?search=' angular 'https://angular.io/?search='
angularjs 'https://google.com/search?as_sitesearch=angularjs.org&as_q=' angularjs $(_frontend_fallback 'angularjs.org')
bem 'https://google.com/search?as_sitesearch=bem.info&as_q=' bem $(_frontend_fallback 'bem.info')
bootsnipp 'https://bootsnipp.com/search?q=' bootsnipp 'https://bootsnipp.com/search?q='
bundlephobia 'https://bundlephobia.com/result?p=' bundlephobia 'https://bundlephobia.com/result?p='
caniuse 'https://caniuse.com/#search=' caniuse 'https://caniuse.com/#search='
@ -43,24 +54,24 @@ function frontend() {
compassdoc 'http://compass-style.org/search?q=' compassdoc 'http://compass-style.org/search?q='
cssflow 'http://www.cssflow.com/search?q=' cssflow 'http://www.cssflow.com/search?q='
dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:' dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:'
emberjs 'https://www.google.com/search?as_sitesearch=emberjs.com/&as_q=' emberjs $(_frontend_fallback 'emberjs.com/')
flowtype 'https://google.com/search?as_sitesearch=flow.org/en/docs/&as_q=' flowtype $(_frontend_fallback 'flow.org/en/docs/')
fontello 'http://fontello.com/#search=' fontello 'http://fontello.com/#search='
github 'https://github.com/search?q=' github 'https://github.com/search?q='
html5please 'https://html5please.com/#' html5please 'https://html5please.com/#'
jestjs 'https://www.google.com/search?as_sitesearch=jestjs.io&as_q=' jestjs $(_frontend_fallback 'jestjs.io')
jquery 'https://api.jquery.com/?s=' jquery 'https://api.jquery.com/?s='
lodash 'https://devdocs.io/lodash/index#' lodash 'https://devdocs.io/lodash/index#'
mdn 'https://developer.mozilla.org/search?q=' mdn 'https://developer.mozilla.org/search?q='
nodejs 'https://www.google.com/search?as_sitesearch=nodejs.org/en/docs/&as_q=' nodejs $(_frontend_fallback 'nodejs.org/en/docs/')
npmjs 'https://www.npmjs.com/search?q=' npmjs 'https://www.npmjs.com/search?q='
qunit 'https://api.qunitjs.com/?s=' qunit 'https://api.qunitjs.com/?s='
reactjs 'https://google.com/search?as_sitesearch=facebook.github.io/react&as_q=' reactjs $(_frontend_fallback 'reactjs.org/')
smacss 'https://google.com/search?as_sitesearch=smacss.com&as_q=' smacss $(_frontend_fallback 'smacss.com')
stackoverflow 'https://stackoverflow.com/search?q=' stackoverflow 'https://stackoverflow.com/search?q='
typescript 'https://google.com/search?as_sitesearch=www.typescriptlang.org/docs&as_q=' typescript $(_frontend_fallback 'www.typescriptlang.org/docs')
unheap 'http://www.unheap.com/?s=' unheap 'http://www.unheap.com/?s='
vuejs 'https://www.google.com/search?as_sitesearch=vuejs.org&as_q=' vuejs $(_frontend_fallback 'vuejs.org')
) )
# show help for command list # show help for command list

View file

@ -1,10 +1,19 @@
function setup_using_base_dir() {
# Declare all variables local not no mess with outside env in any way
local fzf_base
local fzf_shell
local fzfdirs
local dir
test -d "${FZF_BASE}" && fzf_base="${FZF_BASE}" test -d "${FZF_BASE}" && fzf_base="${FZF_BASE}"
if [[ -z "${fzf_base}" ]]; then if [[ -z "${fzf_base}" ]]; then
fzfdirs=( fzfdirs=(
"${HOME}/.fzf" "${HOME}/.fzf"
"${HOME}/.nix-profile/share/fzf"
"/usr/local/opt/fzf" "/usr/local/opt/fzf"
"/usr/share/fzf" "/usr/share/fzf"
"/usr/local/share/examples/fzf"
) )
for dir in ${fzfdirs}; do for dir in ${fzfdirs}; do
if [[ -d "${dir}" ]]; then if [[ -d "${dir}" ]]; then
@ -22,36 +31,70 @@ if [[ -z "${fzf_base}" ]]; then
fi fi
fi fi
if [[ -n "${fzf_base}" ]]; then if [[ -d "${fzf_base}" ]]; then
# Fix fzf shell directory for Arch Linux, NixOS or Void Linux packages
# Fix fzf shell directory for Archlinux package if [[ ! -d "${fzf_base}/shell" ]]; then
if [[ ! -d "${fzf_base}/shell" ]] && [[ -f /etc/arch-release ]]; then
fzf_shell="${fzf_base}" fzf_shell="${fzf_base}"
else else
fzf_shell="${fzf_base}/shell" fzf_shell="${fzf_base}/shell"
fi fi
# Setup fzf # Setup fzf binary path
# ---------
if ! (( ${+commands[fzf]} )) && [[ ! "$PATH" == *$fzf_base/bin* ]]; then if ! (( ${+commands[fzf]} )) && [[ ! "$PATH" == *$fzf_base/bin* ]]; then
export PATH="$PATH:$fzf_base/bin" export PATH="$PATH:$fzf_base/bin"
fi fi
# Auto-completion # Auto-completion
# ---------------
if [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then if [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then
[[ $- == *i* ]] && source "${fzf_shell}/completion.zsh" 2> /dev/null [[ $- == *i* ]] && source "${fzf_shell}/completion.zsh" 2> /dev/null
fi fi
# Key bindings # Key bindings
# ------------
if [[ ! "$DISABLE_FZF_KEY_BINDINGS" == "true" ]]; then if [[ ! "$DISABLE_FZF_KEY_BINDINGS" == "true" ]]; then
source "${fzf_shell}/key-bindings.zsh" source "${fzf_shell}/key-bindings.zsh"
fi fi
else else
print "[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.\n"\ return 1
"Please add \`export FZF_BASE=/path/to/fzf/install/dir\` to your .zshrc" >&2 fi
}
function setup_using_debian_package() {
(( $+commands[dpkg] )) && dpkg -s fzf &> /dev/null
if (( $? )); then
# Either not a debian based distro, or no fzf installed. In any case skip ahead
return 1
fi fi
unset fzf_base fzf_shell dir fzfdirs # NOTE: There is no need to configure PATH for debian package, all binaries
# are installed to /usr/bin by default
# Determine completion file path: first bullseye/sid, then buster/stretch
local completions="/usr/share/doc/fzf/examples/completion.zsh"
[[ -f "$completions" ]] || completions="/usr/share/zsh/vendor-completions/_fzf"
local key_bindings="/usr/share/doc/fzf/examples/key-bindings.zsh"
# Auto-completion
if [[ $- == *i* ]] && [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then
source $completions 2> /dev/null
fi
# Key bindings
if [[ ! "$DISABLE_FZF_KEY_BINDINGS" == "true" ]]; then
source $key_bindings
fi
return 0
}
function indicate_error() {
print "[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.\n"\
"Please add \`export FZF_BASE=/path/to/fzf/install/dir\` to your .zshrc" >&2
}
# Check for debian package first, because it easy to short cut
# Indicate to user that fzf installation not found if nothing worked
setup_using_debian_package || setup_using_base_dir || indicate_error
unset -f setup_using_debian_package setup_using_base_dir indicate_error

9
plugins/gas/README.md Normal file
View file

@ -0,0 +1,9 @@
# Gas plugin
This plugin adds autocompletion for the [gas](http://walle.github.com/gas) command,
a utility to manage Git authors.
To use it, add `gas` to the plugins array of your zshrc file:
```zsh
plugins=(... gas)
```

24
plugins/gcloud/README.md Normal file
View file

@ -0,0 +1,24 @@
# gcloud
This plugin provides completion support for the
[Google Cloud SDK CLI](https://cloud.google.com/sdk/gcloud/).
To use it, add `gcloud` to the plugins array in your zshrc file.
```zsh
plugins=(... gcloud)
```
It relies on you having installed the SDK using one of the supported options
listed [here](https://cloud.google.com/sdk/install).
## Plugin Options
* Set `CLOUDSDK_HOME` in your `zshrc` file before you load oh-my-zsh if you have
your GCloud SDK installed in a non-standard location. The plugin will use this
as the base for your SDK if it finds it set already.
* If you do not have a `python2` in your `PATH` you'll also need to set the
`CLOUDSDK_PYTHON` environment variable at the end of your `.zshrc`. This is
used by the SDK to call a compatible interpreter when you run one of the
SDK commands.

View file

@ -0,0 +1,33 @@
#####################################################
# gcloud plugin for oh-my-zsh #
# Author: Ian Chesal (github.com/ianchesal) #
#####################################################
if [[ -z "${CLOUDSDK_HOME}" ]]; then
search_locations=(
"$HOME/google-cloud-sdk"
"/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
"/usr/share/google-cloud-sdk"
"/snap/google-cloud-sdk/current"
"/usr/lib64/google-cloud-sdk/"
"/opt/google-cloud-sdk"
)
for gcloud_sdk_location in $search_locations; do
if [[ -d "${gcloud_sdk_location}" ]]; then
CLOUDSDK_HOME="${gcloud_sdk_location}"
break
fi
done
fi
if (( ${+CLOUDSDK_HOME} )); then
if (( ! $+commands[gcloud] )); then
# Only source this if GCloud isn't already on the path
if [[ -f "${CLOUDSDK_HOME}/path.zsh.inc" ]]; then
source "${CLOUDSDK_HOME}/path.zsh.inc"
fi
fi
source "${CLOUDSDK_HOME}/completion.zsh.inc"
export CLOUDSDK_HOME
fi

View file

@ -1,16 +1,17 @@
GIT_AUTO_FETCH_INTERVAL=${GIT_AUTO_FETCH_INTERVAL:=60} GIT_AUTO_FETCH_INTERVAL=${GIT_AUTO_FETCH_INTERVAL:=60}
function git-fetch-all { function git-fetch-all {
(`git rev-parse --is-inside-work-tree 2>/dev/null` && (`command git rev-parse --is-inside-work-tree 2>/dev/null` &&
dir=`git rev-parse --git-dir` && dir=`command git rev-parse --git-dir` &&
[[ ! -f $dir/NO_AUTO_FETCH ]] && [[ ! -f $dir/NO_AUTO_FETCH ]] &&
(( `date +%s` - `date -r $dir/FETCH_LOG +%s 2>/dev/null || echo 0` > $GIT_AUTO_FETCH_INTERVAL )) && (( `date +%s` - `date -r $dir/FETCH_LOG +%s 2>/dev/null || echo 0` > $GIT_AUTO_FETCH_INTERVAL )) &&
git fetch --all 2>/dev/null &>! $dir/FETCH_LOG &) GIT_SSH_COMMAND="command ssh -o BatchMode=yes" \
command git fetch --all 2>/dev/null &>! $dir/FETCH_LOG &)
} }
function git-auto-fetch { function git-auto-fetch {
`git rev-parse --is-inside-work-tree 2>/dev/null` || return `command git rev-parse --is-inside-work-tree 2>/dev/null` || return
guard="`git rev-parse --git-dir`/NO_AUTO_FETCH" guard="`command git rev-parse --git-dir`/NO_AUTO_FETCH"
(rm $guard 2>/dev/null && (rm $guard 2>/dev/null &&
echo "${fg_bold[green]}enabled${reset_color}") || echo "${fg_bold[green]}enabled${reset_color}") ||
@ -18,10 +19,18 @@ function git-auto-fetch {
echo "${fg_bold[red]}disabled${reset_color}") echo "${fg_bold[red]}disabled${reset_color}")
} }
# Override zle-line-init if it exists
if (( $+functions[zle-line-init] )); then
eval "override-git-auto-fetch-$(declare -f zle-line-init)" eval "override-git-auto-fetch-$(declare -f zle-line-init)"
function zle-line-init () { function zle-line-init () {
git-fetch-all git-fetch-all
override-git-auto-fetch-zle-line-init override-git-auto-fetch-zle-line-init
} }
else
function zle-line-init () {
git-fetch-all
}
fi
zle -N zle-line-init zle -N zle-line-init

View file

@ -0,0 +1,16 @@
# Git Escape Magic
This plugin is copied from the original at
https://github.com/knu/zsh-git-escape-magic. All credit for the
functionality enabled by this plugin should go to @knu.
An excerpt from that project's readme explains its purpose.
> It eliminates the need for manually escaping those meta-characters. The zle function it provides is context aware and recognizes the characteristics of each subcommand of git. Every time you type one of these meta-characters on a git command line, it automatically escapes the meta-character with a backslash as necessary and as appropriate.
## Usage
To use this plugin, add it to your list of plugins in your `.zshrc` file.
**NOTE**: If you use url-quote-magic, it must be included before this
plugin runs to prevent any conflicts.

View file

@ -0,0 +1,135 @@
# -*- mode: sh -*-
#
# git-escape-magic - zle tweak for git command line arguments
#
# Copyright (c) 2011, 2012, 2014 Akinori MUSHA
# Licensed under the 2-clause BSD license.
#
# This tweak eliminates the need for manually escaping shell
# meta-characters such as [~^{}] that are used for specifying a git
# object (commit or tree). Every time you type one of these
# characters on a git command line, it is automatically escaped with a
# backslash as necessary and as appropriate.
#
# If you want to use this with url-quote-magic, make sure to enable it
# first.
#
# Usage:
# autoload -Uz git-escape-magic
# git-escape-magic
#
git-escape-magic.self-insert() {
emulate -L zsh
setopt extendedglob
local self_insert_function
zstyle -s ':git-escape-magic' self-insert-function self_insert_function
if [[ "$KEYS" == [{}~^]* ]] && {
local qkey="${(q)KEYS}"
[[ "$KEYS" != "$qkey" ]]
} && {
local lbuf="$LBUFFER$qkey"
[[ "${(Q)LBUFFER}$KEYS" == "${(Q)lbuf}" ]]
} && {
local -a words
words=("${(@Q)${(z)lbuf}}")
[[ "$words[(i)(*/|)git(|-[^/]##)]" -le $#words ]]
}
then
local i
i="$words[(I)([;(){\&]|\&[\&\!]|\|\||[=<>]\(*)]"
if [[ $i -gt 0 ]]; then
shift $((i-1)) words
if [[ "$words[1]" == [\=\<\>]\(* ]]; then
words[1]="${words[1]#[=<>]\(}"
else
[[ "$words[1]" == \; && $words[2] == (then|else|elif|do) ]] && shift words
shift words
fi
fi
while [[ "$words[1]" == (if|while|until|\!) ]]; do
shift words
done
while [[ "$words[1]" == [A-Za-z_][A-Za-z0-9_]#=* ]]; do
shift words
done
[[ "$words[1]" == (*/|)git(|-[^/]##) ]] && {
local subcommand
subcommand="${words[1]##*/git-}"
if [[ -z "$subcommand" ]]; then
shift words
subcommand="$words[1]"
fi
[[ $#words -ge 2 ]]
} &&
case "$subcommand" in
# commands that may take pathspec but never take refspec with [{}~^]
(add|rm|am|apply|check-attr|checkout-index|clean|clone|config|diff-files|hash-object|help|index-pack|mailinfo|mailsplit|merge-file|merge-index|mergetool|mktag|mv|pack-objects|pack-redundant|relink|send-email|show-index|show-ref|stage|status|verify-pack)
false ;;
# commands that may take pathspec but rarely take refspec with [{}~^]
(for-each-ref|grep|ls-files|update-index)
false ;;
(archive|ls-tree)
! [[ $#words -ge 3 &&
"$words[-2]" == [^-]* ]] ;;
(diff-tree)
! [[ $#words -ge 4 &&
"$words[-2]" == [^-]* &&
"$words[-3]" == [^-]* ]] ;;
(*)
[[ $words[(i)--] -gt $#words ]] ;;
esac &&
case "${words[-1]%%"$KEYS"}" in
(*[@^])
[[ "$KEYS" == [{~^]* ]] ;;
(*[@^]\{[^}]##)
[[ "$KEYS" == \}* ]] ;;
(?*)
[[ "$KEYS" == [~^]* ]] ;;
(*)
false ;;
esac &&
LBUFFER="$LBUFFER\\"
fi
zle "$self_insert_function"
}
git-escape-magic.on() {
emulate -L zsh
local self_insert_function="${$(zle -lL | awk \
'$1=="zle"&&$2=="-N"&&$3=="self-insert"{print $4;exit}'):-.self-insert}"
[[ "$self_insert_function" == git-escape-magic.self-insert ]] &&
return 0
# For url-quote-magic which does not zle -N itself
zle -la "$self_insert_function" || zle -N "$self_insert_function"
zstyle ':git-escape-magic' self-insert-function "$self_insert_function"
zle -A git-escape-magic.self-insert self-insert
return 0
}
git-escape-magic.off() {
emulate -L zsh
local self_insert_function
zstyle -s ':git-escape-magic' self-insert-function self_insert_function
[[ -n "$self_insert_function" ]] &&
zle -A "$self_insert_function" self-insert
return 0
}
zle -N git-escape-magic.self-insert
zle -N git-escape-magic.on
zle -N git-escape-magic.off
git-escape-magic() {
git-escape-magic.on
}
[[ -o kshautoload ]] || git-escape-magic "$@"

View file

@ -0,0 +1,9 @@
# Automatically detect and escape zsh globbing meta-characters when used with
# git refspec characters like `[^~{}]`. NOTE: This must be loaded _after_
# url-quote-magic.
#
# This trick is detailed at https://github.com/knu/zsh-git-escape-magic and is
# what allowed this plugin to exist.
autoload -Uz git-escape-magic
git-escape-magic

View file

@ -20,9 +20,10 @@ function precmd_update_git_vars() {
fi fi
} }
chpwd_functions+=(chpwd_update_git_vars) autoload -U add-zsh-hook
precmd_functions+=(precmd_update_git_vars) add-zsh-hook chpwd chpwd_update_git_vars
preexec_functions+=(preexec_update_git_vars) add-zsh-hook precmd precmd_update_git_vars
add-zsh-hook preexec preexec_update_git_vars
## Function definitions ## Function definitions

View file

@ -4,26 +4,21 @@ from __future__ import print_function
import os import os
import sys import sys
import re import re
import shlex
from subprocess import Popen, PIPE, check_output from subprocess import Popen, PIPE, check_output
def get_tagname_or_hash(): def get_tagname_or_hash():
"""return tagname if exists else hash""" """return tagname if exists else hash"""
cmd = 'git log -1 --format="%h%d"'
output = check_output(shlex.split(cmd)).decode('utf-8').strip()
hash_, tagname = None, None
# get hash # get hash
m = re.search('\(.*\)$', output) hash_cmd = ['git', 'rev-parse', '--short', 'HEAD']
if m: hash_ = check_output(hash_cmd).strip()
hash_ = output[:m.start()-1]
# get tagname
m = re.search('tag: .*[,\)]', output)
if m:
tagname = 'tags/' + output[m.start()+len('tag: '): m.end()-1]
if tagname: # get tagname
return tagname.replace(' ', '') tags_cmd = ['git', 'for-each-ref', '--points-at=HEAD', '--count=2', '--sort=-version:refname', '--format=%(refname:short)', 'refs/tags']
tags = check_output(tags_cmd).split()
if tags:
return tags[0] + ('+' if len(tags) > 1 else '')
elif hash_: elif hash_:
return hash_ return hash_
return None return None

View file

@ -0,0 +1,14 @@
# git-remote-branch plugin
This plugin adds completion for [`grb`](https://github.com/webmat/git_remote_branch),
or `git_remote_branch`.
To use it, add `git-remote-branch` to the plugins array of your `.zshrc` file:
```
plugins=(... git-remote-branch)
```
## Deprecation
[git_remote_branch was archived in 2018](https://github.com/webmat/git_remote_branch#archived),
meaning it's not actively maintained anymore. Use at your own risk.

View file

@ -11,7 +11,7 @@ plugins=(... git)
## Aliases ## Aliases
| Alias | Command | | Alias | Command |
|:---------------------|:------------------------------------------------------------------------------------------------------------------------------| |:---------------------|:---------------------------------------------------------------------------------------------------------------------------------|
| g | git | | g | git |
| ga | git add | | ga | git add |
| gaa | git add --all | | gaa | git add --all |
@ -22,7 +22,7 @@ plugins=(... git)
| gb | git branch | | gb | git branch |
| gba | git branch -a | | gba | git branch -a |
| gbd | git branch -d | | 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 | | 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 | | gbD | git branch -D |
| gbl | git blame -b -w | | gbl | git blame -b -w |
| gbnm | git branch --no-merged | | gbnm | git branch --no-merged |
@ -131,7 +131,9 @@ plugins=(... git)
| grmc | git rm --cached | | grmc | git rm --cached |
| grmv | git remote rename | | grmv | git remote rename |
| grrm | git remote remove | | grrm | git remote remove |
| grs | git restore |
| grset | git remote set-url | | grset | git remote set-url |
| grss | git restore --source |
| grt | cd "$(git rev-parse --show-toplevel \|\| echo .)" | | grt | cd "$(git rev-parse --show-toplevel \|\| echo .)" |
| gru | git reset -- | | gru | git reset -- |
| grup | git remote update | | grup | git remote update |
@ -152,8 +154,11 @@ plugins=(... git)
| gstl | git stash list | | gstl | git stash list |
| gstp | git stash pop | | gstp | git stash pop |
| gsts | git stash show --text | | gsts | git stash show --text |
| gstu | git stash --include-untracked |
| gstall | git stash --all | | gstall | git stash --all |
| gsu | git submodule update | | gsu | git submodule update |
| gsw | git switch |
| gswc | git switch -c |
| gts | git tag -s | | gts | git tag -s |
| gtv | git tag \| sort -V | | gtv | git tag \| sort -V |
| gtl | gtl(){ git tag --sort=-v:refname -n -l ${1}* }; noglob gtl | | gtl | gtl(){ git tag --sort=-v:refname -n -l ${1}* }; noglob gtl |
@ -172,25 +177,26 @@ plugins=(... git)
These are aliases that have been removed, renamed, or otherwise modified in a way that may, or may not, receive further support. 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 | | Alias | Command | Modification |
| :----- | :----------------------------------------------------------------------------------| --------------------------------------------------------------------------------------------------- | | :----- | :----------------------------------------------------- | :----------------------------------------------------- |
| gap | git add --patch | new alias `gapa` | | gap | `git add --patch` | new alias `gapa` |
| gcl | git config --list | new alias `gcf` | | gcl | `git config --list` | new alias `gcf` |
| gdc | git diff --cached | new alias `gdca` | | gdc | `git diff --cached` | new alias `gdca` |
| gdt | git difftool | no replacement | | gdt | `git difftool` | no replacement |
| ggpull | git pull origin $(current_branch) | new alias `ggl` (`ggpull` still exists for now though) | | 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) | | 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) | | 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` | | gk | `gitk --all --branches` | now aliased to `gitk --all --branches` |
| glg | git log --stat --max-count = 10 | now aliased to `git log --stat --color` | | 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` | | 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` | | gwc | `git whatchanged -p --abbrev-commit --pretty = medium` | new alias `gwch` |
## Functions ## Functions
### Current ### Current
| Command | Description | | Command | Description |
|:-----------------------|:----------------------------------------| |:-----------------------|:---------------------------------------------------------|
| `grename <old> <new>` | Rename `old` branch to `new`, including in origin remote |
| current_branch | Return the name of the current branch | | current_branch | Return the name of the current branch |
| git_current_user_name | Returns the `user.name` config value | | git_current_user_name | Returns the `user.name` config value |
| git_current_user_email | Returns the `user.email` config value | | git_current_user_email | Returns the `user.email` config value |

View file

@ -42,7 +42,7 @@ alias gap='git apply'
alias gb='git branch' alias gb='git branch'
alias gba='git branch -a' alias gba='git branch -a'
alias gbd='git branch -d' alias gbd='git branch -d'
alias gbda='git branch --no-color --merged | command grep -vE "^(\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d' alias gbda='git branch --no-color --merged | command grep -vE "^(\+|\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d'
alias gbD='git branch -D' alias gbD='git branch -D'
alias gbl='git blame -b -w' alias gbl='git blame -b -w'
alias gbnm='git branch --no-merged' alias gbnm='git branch --no-merged'
@ -207,7 +207,9 @@ alias grm='git rm'
alias grmc='git rm --cached' alias grmc='git rm --cached'
alias grmv='git remote rename' alias grmv='git remote rename'
alias grrm='git remote remove' alias grrm='git remote remove'
alias grs='git restore'
alias grset='git remote set-url' alias grset='git remote set-url'
alias grss='git restore --source'
alias grt='cd "$(git rev-parse --show-toplevel || echo .)"' alias grt='cd "$(git rev-parse --show-toplevel || echo .)"'
alias gru='git reset --' alias gru='git reset --'
alias grup='git remote update' alias grup='git remote update'
@ -234,12 +236,15 @@ alias gstd='git stash drop'
alias gstl='git stash list' alias gstl='git stash list'
alias gstp='git stash pop' alias gstp='git stash pop'
alias gsts='git stash show --text' alias gsts='git stash show --text'
alias gstu='git stash --include-untracked'
alias gstall='git stash --all' alias gstall='git stash --all'
alias gsu='git submodule update' alias gsu='git submodule update'
alias gsw='git switch'
alias gswc='git switch -c'
alias gts='git tag -s' alias gts='git tag -s'
alias gtv='git tag | sort -V' alias gtv='git tag | sort -V'
alias gtl='gtl(){ git tag --sort=-v:refname -n -l ${1}* }; noglob gtl' alias gtl='gtl(){ git tag --sort=-v:refname -n -l "${1}*" }; noglob gtl'
alias gunignore='git update-index --no-assume-unchanged' alias gunignore='git update-index --no-assume-unchanged'
alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1' alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1'
@ -251,3 +256,17 @@ alias glum='git pull upstream master'
alias gwch='git whatchanged -p --abbrev-commit --pretty=medium' alias gwch='git whatchanged -p --abbrev-commit --pretty=medium'
alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]"' alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]"'
function grename() {
if [[ -z "$1" || -z "$2" ]]; then
echo "Usage: $0 old_branch new_branch"
return 1
fi
# Rename branch locally
git branch -m "$1" "$2"
# Rename branch in origin remote
if git push origin :"$1"; then
git push --set-upstream origin "$2"
fi
}

View file

@ -11,5 +11,5 @@ plugins=(... gitfast)
## Aliases ## Aliases
An earlier version of the plugin also loaded the git plugin. If you want to keep those An earlier version of the plugin also loaded the git plugin. If you want to keep those
aliases enable the [git plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/git) aliases enable the [git plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git)
as well. as well.

View file

@ -30,7 +30,7 @@ if [ -z "$script" ]; then
local -a locations local -a locations
local e local e
locations=( locations=(
"$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash" $(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
'/etc/bash_completion.d/git' # fedora, old debian '/etc/bash_completion.d/git' # fedora, old debian
'/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian '/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian
'/usr/share/bash-completion/git' # gentoo '/usr/share/bash-completion/git' # gentoo
@ -39,7 +39,7 @@ if [ -z "$script" ]; then
test -f $e && script="$e" && break test -f $e && script="$e" && break
done done
fi fi
ZSH_VERSION='' . "$script" GIT_SOURCING_ZSH_COMPLETION=y . "$script"
__gitcomp () __gitcomp ()
{ {
@ -93,13 +93,22 @@ __gitcomp_nl_append ()
compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
} }
__gitcomp_file_direct ()
{
emulate -L zsh
local IFS=$'\n'
compset -P '*[=:]'
compadd -f -- ${=1} && _ret=0
}
__gitcomp_file () __gitcomp_file ()
{ {
emulate -L zsh emulate -L zsh
local IFS=$'\n' local IFS=$'\n'
compset -P '*[=:]' compset -P '*[=:]'
compadd -Q -p "${2-}" -f -- ${=1} && _ret=0 compadd -p "${2-}" -f -- ${=1} && _ret=0
} }
__git_zsh_bash_func () __git_zsh_bash_func ()
@ -223,10 +232,8 @@ _git ()
if (( $+functions[__${service}_zsh_main] )); then if (( $+functions[__${service}_zsh_main] )); then
__${service}_zsh_main __${service}_zsh_main
elif (( $+functions[__${service}_main] )); then else
emulate ksh -c __${service}_main emulate ksh -c __${service}_main
elif (( $+functions[_${service}] )); then
emulate ksh -c _${service}
fi fi
let _ret && _default && _ret=0 let _ret && _default && _ret=0

File diff suppressed because it is too large Load diff

View file

@ -219,7 +219,7 @@ __git_ps1_show_upstream ()
if [[ -n "$count" && -n "$name" ]]; then if [[ -n "$count" && -n "$name" ]]; then
__git_ps1_upstream_name=$(git rev-parse \ __git_ps1_upstream_name=$(git rev-parse \
--abbrev-ref "$upstream" 2>/dev/null) --abbrev-ref "$upstream" 2>/dev/null)
if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then if [ "$pcmode" = yes ] && [ "$ps1_expanded" = yes ]; then
p="$p \${__git_ps1_upstream_name}" p="$p \${__git_ps1_upstream_name}"
else else
p="$p ${__git_ps1_upstream_name}" p="$p ${__git_ps1_upstream_name}"
@ -237,7 +237,7 @@ __git_ps1_show_upstream ()
# to build a gitstring. # to build a gitstring.
__git_ps1_colorize_gitstring () __git_ps1_colorize_gitstring ()
{ {
if [[ -n ${ZSH_VERSION-} ]]; then if [[ -n "${ZSH_VERSION-}" ]]; then
local c_red='%F{red}' local c_red='%F{red}'
local c_green='%F{green}' local c_green='%F{green}'
local c_lblue='%F{blue}' local c_lblue='%F{blue}'
@ -255,7 +255,7 @@ __git_ps1_colorize_gitstring ()
local flags_color="$c_lblue" local flags_color="$c_lblue"
local branch_color="" local branch_color=""
if [ $detached = no ]; then if [ "$detached" = no ]; then
branch_color="$ok_color" branch_color="$ok_color"
else else
branch_color="$bad_color" branch_color="$bad_color"
@ -508,13 +508,13 @@ __git_ps1 ()
# NO color option unless in PROMPT_COMMAND mode or it's Zsh # NO color option unless in PROMPT_COMMAND mode or it's Zsh
if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then if [ "$pcmode" = yes ] || [ -n "${ZSH_VERSION-}" ]; then
__git_ps1_colorize_gitstring __git_ps1_colorize_gitstring
fi fi
fi fi
b=${b##refs/heads/} b=${b##refs/heads/}
if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then if [ "$pcmode" = yes ] && [ "$ps1_expanded" = yes ]; then
__git_ps1_branch_name=$b __git_ps1_branch_name=$b
b="\${__git_ps1_branch_name}" b="\${__git_ps1_branch_name}"
fi fi
@ -522,7 +522,7 @@ __git_ps1 ()
local f="$w$i$s$u" local f="$w$i$s$u"
local gitstring="$c$b${f:+$z$f}$r$p" local gitstring="$c$b${f:+$z$f}$r$p"
if [ $pcmode = yes ]; then if [ "$pcmode" = yes ]; then
if [ "${__git_printf_supports_v-}" != yes ]; then if [ "${__git_printf_supports_v-}" != yes ]; then
gitstring=$(printf -- "$printf_format" "$gitstring") gitstring=$(printf -- "$printf_format" "$gitstring")
else else

View file

@ -0,0 +1,9 @@
# glassfish
The glassfish plugin adds completion for the `asadmin` utility, a command to manage
[Oracle GlassFish](https://docs.oracle.com/cd/E18930_01/html/821-2416/giobi.html) servers.
To use it, add `glassfish` to the plugins array in your zshrc file:
```zsh
plugins=(... glassfish)
```

View file

@ -1,3 +0,0 @@
# if there is a user named 'glassfish' on the system, we'll assume
# that is the user asadmin should be run as
# grep -e '^glassfish' /etc/passwd > /dev/null && alias asadmin='sudo -u glassfish asadmin'

View file

@ -0,0 +1,38 @@
# gnu-utils plugin
This plugin binds GNU coreutils to their default names, so that you don't have
to call them using their prefixed name, which starts with `g`. This is useful
in systems which don't have GNU coreutils installed by default, mainly macOS
or FreeBSD, which use BSD coreutils.
To use it, add `gnu-utils` to the plugins array in your zshrc file:
```zsh
plugins=(... gnu-utils)
```
The plugin works by changing the path that the command hash points to, so
instead of `ls` pointing to `/bin/ls`, it points to wherever `gls` is
installed.
Since `hash -rf` or `rehash` refreshes the command hashes, it also wraps
`hash` and `rehash` so that the coreutils binding is always done again
after calling these two commands.
Look at the source code of the plugin to see which GNU coreutils are tried
to rebind. Open an issue if there are some missing.
## Other methods
The plugin also documents two other ways to do this:
1. Using a function wrapper, such that, for example, there exists a function
named `ls` which calls `gls` instead. Since functions have a higher preference
than commands, this ends up calling the GNU coreutil. It has also a higher
preference over shell builtins (`gecho` is called instead of the builtin `echo`).
2. Using an alias. This has an even higher preference than functions, but they
could be overridden because of a user setting.
## Author
- [Sorin Ionescu](https://github.com/sorin-ionescu).

View file

@ -5,8 +5,11 @@
# VERSION: 1.0.0 # VERSION: 1.0.0
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Detect if GNU coreutils are installed by looking for gwhoami
if [[ ! -x "${commands[gwhoami]}" ]]; then
return
fi
if [[ -x "${commands[gwhoami]}" ]]; then
__gnu_utils() { __gnu_utils() {
emulate -L zsh emulate -L zsh
local gcmds local gcmds
@ -36,31 +39,29 @@ if [[ -x "${commands[gwhoami]}" ]]; then
gcmds+=('gsed' 'gtar' 'gtime') gcmds+=('gsed' 'gtar' 'gtime')
for gcmd in "${gcmds[@]}"; do for gcmd in "${gcmds[@]}"; do
# # Do nothing if the command isn't found
(( ${+commands[$gcmd]} )) || continue
# This method allows for builtin commands to be primary but it's # This method allows for builtin commands to be primary but it's
# lost if hash -r or rehash -f is executed. Thus, those two # lost if hash -r or rehash -f is executed. Thus, those two
# functions have to be wrapped. # functions have to be wrapped.
# #
(( ${+commands[$gcmd]} )) && hash ${gcmd[2,-1]}=${commands[$gcmd]} hash ${gcmd[2,-1]}=${commands[$gcmd]}
#
# This method generates wrapper functions. # This method generates wrapper functions.
# It will override shell builtins. # It will override shell builtins.
# #
# (( ${+commands[$gcmd]} )) && \
# eval "function $gcmd[2,-1]() { \"${prefix}/${gcmd//"["/"\\["}\" \"\$@\"; }" # eval "function $gcmd[2,-1]() { \"${prefix}/${gcmd//"["/"\\["}\" \"\$@\"; }"
#
# This method is inflexible since the aliases are at risk of being # This method is inflexible since the aliases are at risk of being
# overridden resulting in the BSD coreutils being called. # overridden resulting in the BSD coreutils being called.
# #
# (( ${+commands[$gcmd]} )) && \
# alias "$gcmd[2,-1]"="${prefix}/${gcmd//"["/"\\["}" # alias "$gcmd[2,-1]"="${prefix}/${gcmd//"["/"\\["}"
done done
return 0 return 0
} }
__gnu_utils; __gnu_utils
function hash() { function hash() {
if [[ "$*" =~ "-(r|f)" ]]; then if [[ "$*" =~ "-(r|f)" ]]; then
@ -79,5 +80,4 @@ if [[ -x "${commands[gwhoami]}" ]]; then
builtin rehash "$@" builtin rehash "$@"
fi fi
} }
fi

View file

@ -1 +1 @@
The go plugin is deprecated. Use the [golang plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/golang) instead. The go plugin is deprecated. Use the [golang plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/golang) instead.

View file

@ -7,7 +7,7 @@ gradle-or-gradlew() {
echo "executing gradlew instead of gradle"; echo "executing gradlew instead of gradle";
./gradlew "$@"; ./gradlew "$@";
else else
gradle "$@"; command gradle "$@";
fi fi
} }
@ -181,3 +181,4 @@ _gradlew_tasks () {
############################################################################ ############################################################################
compdef _gradle_tasks gradle compdef _gradle_tasks gradle
compdef _gradlew_tasks gradlew compdef _gradlew_tasks gradlew
compdef _gradlew_tasks gw

View file

@ -9,7 +9,7 @@ You can also use K and J in VI mode or ^P and ^N in EMACS mode for the same.
[1]: https://fishshell.com [1]: https://fishshell.com
[2]: https://www.zsh.org/mla/users/2009/msg00818.html [2]: https://www.zsh.org/mla/users/2009/msg00818.html
[3]: https://sourceforge.net/projects/fizsh/ [3]: https://sourceforge.net/projects/fizsh/
[4]: https://github.com/robbyrussell/oh-my-zsh/pull/215 [4]: https://github.com/ohmyzsh/ohmyzsh/pull/215
[5]: https://github.com/zsh-users/zsh-history-substring-search [5]: https://github.com/zsh-users/zsh-history-substring-search
[6]: https://github.com/zsh-users/zsh-syntax-highlighting [6]: https://github.com/zsh-users/zsh-syntax-highlighting

Some files were not shown because too many files have changed in this diff Show more