Unverified Commit 18ee5dff authored by Marc Cornellà's avatar Marc Cornellà Committed by GitHub

Merge branch 'master' into clipboard

parents d81cd753 368198b7
--- ---
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. ...@@ -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.
...@@ -11,16 +11,16 @@ an issue where no sections have been filled will be deleted without comment. ...@@ -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.
...@@ -5,8 +5,6 @@ labels: 'Type: support' ...@@ -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
-->
## 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:
...
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"]
}
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
...@@ -4,3 +4,5 @@ custom/ ...@@ -4,3 +4,5 @@ custom/
# temp files directories # temp files directories
cache/ cache/
log/ log/
*.swp
.DS_Store
...@@ -31,7 +31,7 @@ your problem. ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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.
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
......
...@@ -12,16 +12,18 @@ Once installed, your terminal shell will become the talk of the town _or your mo ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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: ...@@ -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=( ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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
......
...@@ -54,7 +54,7 @@ function detect-clipboard() { ...@@ -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
......
...@@ -71,3 +71,6 @@ if [[ $COMPLETION_WAITING_DOTS = true ]]; then ...@@ -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
...@@ -3,11 +3,12 @@ function zsh_stats() { ...@@ -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() { ...@@ -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() { ...@@ -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
} }
# #
......
...@@ -12,11 +12,21 @@ function git_prompt_info() { ...@@ -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() { ...@@ -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
}
...@@ -22,7 +22,7 @@ env_default 'PAGER' 'less' ...@@ -22,7 +22,7 @@ env_default 'PAGER' 'less'
env_default 'LESS' '-R' env_default 'LESS' '-R'
## super user alias ## super user alias
alias _='sudo' alias _='sudo '
## more intelligent acking for ubuntu users ## more intelligent acking for ubuntu users
if which ack-grep &> /dev/null; then if which ack-grep &> /dev/null; then
...@@ -31,10 +31,5 @@ else ...@@ -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
...@@ -75,8 +75,9 @@ function omz_termsupport_preexec { ...@@ -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 ...@@ -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
...@@ -32,8 +32,8 @@ fi ...@@ -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,19 +97,7 @@ done ...@@ -97,19 +97,7 @@ done
unset config_file unset config_file
# Load the theme # Load the theme
if [[ "$ZSH_THEME" == "random" ]]; then if [ ! "$ZSH_THEME" = "" ]; 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 [ -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"
elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then
...@@ -117,5 +105,4 @@ else ...@@ -117,5 +105,4 @@ else
else else
source "$ZSH/themes/$ZSH_THEME.zsh-theme" source "$ZSH/themes/$ZSH_THEME.zsh-theme"
fi fi
fi
fi fi
# 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'
```
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
## 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` |
...@@ -9,6 +9,7 @@ alias arco='arc cover' ...@@ -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'
......
# 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
(( $+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
......
...@@ -10,7 +10,8 @@ function asp() { ...@@ -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
......
...@@ -7,23 +7,25 @@ ...@@ -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,9 +34,9 @@ if [[ "$OSTYPE" = darwin* ]] ; then ...@@ -32,9 +34,9 @@ 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
echo "~$((timeremaining / 60)):$((timeremaining % 60))" echo "~$((timeremaining / 60)):$((timeremaining % 60))"
...@@ -45,39 +47,36 @@ if [[ "$OSTYPE" = darwin* ]] ; then ...@@ -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 ...@@ -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%}"
else fi
echo "∞" }
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 fi
} }
else
# Empty functions so we don't cause errors in prompts
function battery_pct_remaining() { function battery_pct_remaining() {
if ! battery_is_charging; then
battery_pct
else
echo "External Power"
fi
} }
function battery_time_remaining() { 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() { function battery_pct_prompt() {
local battery_pct color
battery_pct=$(battery_pct_remaining)
if battery_is_charging; then
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
} }
else
# Empty functions so we don't cause errors in prompts
function battery_is_charging { false }
function battery_pct \
battery_pct_remaining \
battery_time_remaining \
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//\%/\%\%}
} }
...@@ -15,7 +15,7 @@ ...@@ -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 ...@@ -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`
......
...@@ -27,6 +27,7 @@ bundled_commands=( ...@@ -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() { ...@@ -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() { ...@@ -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
......
# 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.
#
# 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
# 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` |
...@@ -2,489 +2,367 @@ ...@@ -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
typeset -A opt_args local -a command_scope_spec common parallel features msgfmt triple target registry
local -a state line state_descr # These are set by _arguments
# leading items in parentheses are an exclusion list for the arguments following that arg typeset -A opt_args
# See: http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-Functions
# - => exclude all other options common=(
# 1 => exclude positional arg 1 '(-q --quiet)*'{-v,--verbose}'[use verbose output]'
# * => exclude all other args '(-q --quiet -v --verbose)'{-q,--quiet}'[no output printed to stdout]'
# +blah => exclude +blah '-Z+[pass unstable (nightly-only) flags to cargo]: :_cargo_unstable_flags'
_arguments \ '--frozen[require that Cargo.lock and cache are up-to-date]'
'(- 1 *)'{-h,--help}'[show help message]' \ '--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
# See: http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-Functions
# - => exclude all other options
# 1 => exclude positional arg 1
# * => exclude all other args
# +blah => exclude +blah
_arguments -s -S -C $common \
'(- 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_cmds(){ _cargo_installed_crates() {
local -a commands;commands=( local expl
'bench:execute all benchmarks of a local package' _description crates expl 'crate'
'build:compile the current package' compadd "$@" "$expl[@]" - ${${${(f)"$(cargo install --list)"}:# *}%% *}
'check:check the current package without compiling'
'clean:remove generated artifacts'
'doc:build package documentation'
'fetch:fetch package dependencies'
'generate-lockfile:create lockfile'
'git-checkout:git checkout'
'help:get help for commands'
'init:create new package in current directory'
'install:install a Rust binary'
'locate-project:print "Cargo.toml" location'
'login:login to remote server'
'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(){ _cargo_cmds() {
local -a commands;commands=($(cargo --list)) local -a commands
_describe -t all-commands 'all commands' commands # This uses Parameter Expansion Flags, which are a built-in Zsh feature.
# See more: http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags
# and http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion
#
# # How this work?
#
# First it splits the result of `cargo --list` at newline, then it removes the first line.
# Then it removes indentation (4 whitespaces) before each items. (Note the x## pattern [1]).
# Then it replaces those spaces between item and description with a `:`
#
# [1]: https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org#patterns
commands=( ${${${(M)"${(f)$(_call_program commands cargo --list)}":# *}/ ##/}/ ##/:} )
_describe -t commands 'command' 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() ...@@ -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
...@@ -17,10 +17,10 @@ Plugin for displaying images on the terminal using the the `catimg.sh` script pr ...@@ -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
$ $
``` ```
......
# 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
```
# 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.
# 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)
```
# 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 |
# 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
```
...@@ -16,8 +16,8 @@ EOF ...@@ -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() { ...@@ -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 "$@"
} }
...@@ -6,30 +6,43 @@ Colorize will highlight the content based on the filename extension. If it can't ...@@ -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
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: ### Requirements
`ZSH_COLORIZE_STYLE="colorful"` This plugin requires that at least one of the following tools is installed:
## Usage * [Chroma](https://github.com/alecthomas/chroma)
* [Pygments](https://pygments.org/download/)
* `ccat <file> [files]`: colorize the contents of the file (or files, if more than one are provided). ### Colorize tool
If no arguments are passed it will colorize the standard input or stdin.
* `cless <file> [files]`: colorize the contents of the file (or files, if more than one are provided) and 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:
open less. If no arguments are passed it will colorize the standard input or stdin.
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. ZSH_COLORIZE_TOOL=chroma
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 ### 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:
```
ZSH_COLORIZE_STYLE="colorful"
```
## Usage
* `ccat <file> [files]`: colorize the contents of the file (or files, if more than one are provided).
If no files are passed it will colorize the standard input.
You have to install Pygments first: [pygments.org](http://pygments.org/download/) * `cless [less-options] <file> [files]`: colorize the contents of the file (or files, if more than one are provided) and open less.
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.
# 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 return 1
fi fi
}
# If the environment varianle ZSH_COLORIZE_STYLE colorize_cat() {
if ! colorize_check_requirements; then
return 1
fi
# 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"
}
trap 'cleanup' EXIT HUP TERM INT
while (( $# != 0 )); do #TODO: filter out less opts # This variable tells less to pipe every file through the specified command
tmp_file="$(mktemp -t "tmp.colorize.XXXX.$(sed 's/\//./g' <<< "$1")")" # (see the man page of less INPUT PREPROCESSOR).
tmp_files+=("$tmp_file") # 'zsh -ic "colorize_cat %s 2> /dev/null"' would not work for huge files like
colorize_via_pygmentize "$1" > "$tmp_file" # the ~/.zsh_history. For such files the tty of the preprocessor will be supended.
shift 1 # Therefore we must source this file to make colorize_cat available in the
done # 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'"
less -f "${tmp_files[@]}" # 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 "$@"
}
if [ -t 0 ]; then
_cless "$@"
else
# The input is not associated with a terminal, therefore colorize_cat will
# colorize this input and pass it to less.
# 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.
# 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
}
# 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
...@@ -50,6 +50,7 @@ alias mv='mv -i' ...@@ -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
......
# 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)
```
# 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
......
# 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
```
...@@ -35,36 +35,30 @@ _dash() { ...@@ -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
......
...@@ -72,7 +72,7 @@ if [[ $use_sudo -eq 1 ]]; then ...@@ -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 ...@@ -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 ...@@ -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' ...@@ -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() { ...@@ -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 () { ...@@ -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 () { ...@@ -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}'
} }
...@@ -15,10 +15,10 @@ This plugin enables directory navigation similar to using back and forward on br ...@@ -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
$ $
``` ```
......
...@@ -53,7 +53,8 @@ function push_future() { ...@@ -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...
......
...@@ -11,7 +11,8 @@ if [[ -f ${dirstack_file} ]] && [[ ${#dirstack[*]} -eq 0 ]] ; then ...@@ -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
......
...@@ -374,7 +374,8 @@ _managepy-commands() { ...@@ -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.\\
......
## 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
...@@ -32,6 +32,8 @@ PORT=3001 ...@@ -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 ...@@ -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.
......
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
......
# .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. |
# 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'
# 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.
...@@ -20,7 +20,8 @@ _emacsfun() ...@@ -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
......
...@@ -2,7 +2,7 @@ ...@@ -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
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
......
# 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>
```
...@@ -20,10 +20,10 @@ Alias plugin for encoding or decoding using `base64` command ...@@ -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
......
...@@ -25,23 +25,32 @@ plugins=(... extract) ...@@ -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.
...@@ -3,5 +3,5 @@ ...@@ -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
...@@ -40,14 +40,24 @@ extract() { ...@@ -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() { ...@@ -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
......
...@@ -4,10 +4,19 @@ ...@@ -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 \ ...@@ -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 ...@@ -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
......
# 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 |
# 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)
################################################################################
# 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() { ...@@ -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() { ...@@ -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
# #
......
# 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)
```
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.
## 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 |
#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
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"
...@@ -62,6 +62,10 @@ Available search contexts are: ...@@ -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)**
......
...@@ -27,6 +27,17 @@ alias typescript='frontend typescript' ...@@ -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() { ...@@ -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() { ...@@ -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
......
test -d "${FZF_BASE}" && fzf_base="${FZF_BASE}" 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
if [[ -z "${fzf_base}" ]]; then test -d "${FZF_BASE}" && fzf_base="${FZF_BASE}"
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
...@@ -20,38 +29,72 @@ if [[ -z "${fzf_base}" ]]; then ...@@ -20,38 +29,72 @@ if [[ -z "${fzf_base}" ]]; then
fi fi
fi fi
fi fi
fi fi
if [[ -n "${fzf_base}" ]]; then
# Fix fzf shell directory for Archlinux package if [[ -d "${fzf_base}" ]]; then
if [[ ! -d "${fzf_base}/shell" ]] && [[ -f /etc/arch-release ]]; then # Fix fzf shell directory for Arch Linux, NixOS or Void Linux packages
if [[ ! -d "${fzf_base}/shell" ]]; 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
return 1
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
# 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"
else 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"\ 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 "Please add \`export FZF_BASE=/path/to/fzf/install/dir\` to your .zshrc" >&2
fi }
# 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 fzf_base fzf_shell dir fzfdirs unset -f setup_using_debian_package setup_using_base_dir indicate_error
# 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)
```
# 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.
#####################################################
# 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
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 { ...@@ -18,10 +19,18 @@ function git-auto-fetch {
echo "${fg_bold[red]}disabled${reset_color}") echo "${fg_bold[red]}disabled${reset_color}")
} }
eval "override-git-auto-fetch-$(declare -f zle-line-init)" # Override zle-line-init if it exists
if (( $+functions[zle-line-init] )); then
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
# 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.
# -*- 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 "$@"
# 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
...@@ -20,9 +20,10 @@ function precmd_update_git_vars() { ...@@ -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
......
...@@ -4,26 +4,21 @@ from __future__ import print_function ...@@ -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 # get tagname
m = re.search('tag: .*[,\)]', output) tags_cmd = ['git', 'for-each-ref', '--points-at=HEAD', '--count=2', '--sort=-version:refname', '--format=%(refname:short)', 'refs/tags']
if m: tags = check_output(tags_cmd).split()
tagname = 'tags/' + output[m.start()+len('tag: '): m.end()-1]
if tagname: if tags:
return tagname.replace(' ', '') return tags[0] + ('+' if len(tags) > 1 else '')
elif hash_: elif hash_:
return hash_ return hash_
return None return None
......
# 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.
...@@ -11,7 +11,7 @@ plugins=(... git) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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 |
......
...@@ -42,7 +42,7 @@ alias gap='git apply' ...@@ -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' ...@@ -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' ...@@ -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' ...@@ -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
}
...@@ -11,5 +11,5 @@ plugins=(... gitfast) ...@@ -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.
...@@ -30,7 +30,7 @@ if [ -z "$script" ]; then ...@@ -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 ...@@ -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 () ...@@ -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 () ...@@ -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
......
...@@ -29,13 +29,16 @@ ...@@ -29,13 +29,16 @@
# tell the completion to use commit completion. This also works with aliases # tell the completion to use commit completion. This also works with aliases
# of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '". # of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '".
# #
# Compatible with bash 3.2.57.
#
# You can set the following environment variables to influence the behavior of # You can set the following environment variables to influence the behavior of
# the completion routines: # the completion routines:
# #
# GIT_COMPLETION_CHECKOUT_NO_GUESS # GIT_COMPLETION_CHECKOUT_NO_GUESS
# #
# When set to "1", do not include "DWIM" suggestions in git-checkout # When set to "1", do not include "DWIM" suggestions in git-checkout
# completion (e.g., completing "foo" when "origin/foo" exists). # and git-switch completion (e.g., completing "foo" when "origin/foo"
# exists).
case "$COMP_WORDBREAKS" in case "$COMP_WORDBREAKS" in
*:*) : great ;; *:*) : great ;;
...@@ -92,6 +95,70 @@ __git () ...@@ -92,6 +95,70 @@ __git ()
${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev/null ${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev/null
} }
# Removes backslash escaping, single quotes and double quotes from a word,
# stores the result in the variable $dequoted_word.
# 1: The word to dequote.
__git_dequote ()
{
local rest="$1" len ch
dequoted_word=""
while test -n "$rest"; do
len=${#dequoted_word}
dequoted_word="$dequoted_word${rest%%[\\\'\"]*}"
rest="${rest:$((${#dequoted_word}-$len))}"
case "${rest:0:1}" in
\\)
ch="${rest:1:1}"
case "$ch" in
$'\n')
;;
*)
dequoted_word="$dequoted_word$ch"
;;
esac
rest="${rest:2}"
;;
\')
rest="${rest:1}"
len=${#dequoted_word}
dequoted_word="$dequoted_word${rest%%\'*}"
rest="${rest:$((${#dequoted_word}-$len+1))}"
;;
\")
rest="${rest:1}"
while test -n "$rest" ; do
len=${#dequoted_word}
dequoted_word="$dequoted_word${rest%%[\\\"]*}"
rest="${rest:$((${#dequoted_word}-$len))}"
case "${rest:0:1}" in
\\)
ch="${rest:1:1}"
case "$ch" in
\"|\\|\$|\`)
dequoted_word="$dequoted_word$ch"
;;
$'\n')
;;
*)
dequoted_word="$dequoted_word\\$ch"
;;
esac
rest="${rest:2}"
;;
\")
rest="${rest:1}"
break
;;
esac
done
;;
esac
done
}
# The following function is based on code from: # The following function is based on code from:
# #
# bash_completion - programmable completion functions for bash 3.2+ # bash_completion - programmable completion functions for bash 3.2+
...@@ -264,9 +331,32 @@ __gitcomp () ...@@ -264,9 +331,32 @@ __gitcomp ()
case "$cur_" in case "$cur_" in
--*=) --*=)
;; ;;
--no-*)
local c i=0 IFS=$' \t\n'
for c in $1; do
if [[ $c == "--" ]]; then
continue
fi
c="$c${4-}"
if [[ $c == "$cur_"* ]]; then
case $c in
--*=*|*.) ;;
*) c="$c " ;;
esac
COMPREPLY[i++]="${2-}$c"
fi
done
;;
*) *)
local c i=0 IFS=$' \t\n' local c i=0 IFS=$' \t\n'
for c in $1; do for c in $1; do
if [[ $c == "--" ]]; then
c="--no-...${4-}"
if [[ $c == "$cur_"* ]]; then
COMPREPLY[i++]="${2-}$c "
fi
break
fi
c="$c${4-}" c="$c${4-}"
if [[ $c == "$cur_"* ]]; then if [[ $c == "$cur_"* ]]; then
case $c in case $c in
...@@ -280,6 +370,48 @@ __gitcomp () ...@@ -280,6 +370,48 @@ __gitcomp ()
esac esac
} }
# Clear the variables caching builtins' options when (re-)sourcing
# the completion script.
if [[ -n ${ZSH_VERSION-} ]]; then
unset $(set |sed -ne 's/^\(__gitcomp_builtin_[a-zA-Z0-9_][a-zA-Z0-9_]*\)=.*/\1/p') 2>/dev/null
else
unset $(compgen -v __gitcomp_builtin_)
fi
# This function is equivalent to
#
# __gitcomp "$(git xxx --git-completion-helper) ..."
#
# except that the output is cached. Accept 1-3 arguments:
# 1: the git command to execute, this is also the cache key
# 2: extra options to be added on top (e.g. negative forms)
# 3: options to be excluded
__gitcomp_builtin ()
{
# spaces must be replaced with underscore for multi-word
# commands, e.g. "git remote add" becomes remote_add.
local cmd="$1"
local incl="$2"
local excl="$3"
local var=__gitcomp_builtin_"${cmd/-/_}"
local options
eval "options=\$$var"
if [ -z "$options" ]; then
# leading and trailing spaces are significant to make
# option removal work correctly.
options=" $incl $(__git ${cmd/_/ } --git-completion-helper) " || return
for i in $excl; do
options="${options/ $i / }"
done
eval "$var=\"$options\""
fi
__gitcomp "$options"
}
# Variation of __gitcomp_nl () that appends to the existing list of # Variation of __gitcomp_nl () that appends to the existing list of
# completion candidates, COMPREPLY. # completion candidates, COMPREPLY.
__gitcomp_nl_append () __gitcomp_nl_append ()
...@@ -303,6 +435,24 @@ __gitcomp_nl () ...@@ -303,6 +435,24 @@ __gitcomp_nl ()
__gitcomp_nl_append "$@" __gitcomp_nl_append "$@"
} }
# Fills the COMPREPLY array with prefiltered paths without any additional
# processing.
# Callers must take care of providing only paths that match the current path
# to be completed and adding any prefix path components, if necessary.
# 1: List of newline-separated matching paths, complete with all prefix
# path components.
__gitcomp_file_direct ()
{
local IFS=$'\n'
COMPREPLY=($1)
# use a hack to enable file mode in bash < 4
compopt -o filenames +o nospace 2>/dev/null ||
compgen -f /non-existing-dir/ >/dev/null ||
true
}
# Generates completion reply with compgen from newline-separated possible # Generates completion reply with compgen from newline-separated possible
# completion filenames. # completion filenames.
# It accepts 1 to 3 arguments: # It accepts 1 to 3 arguments:
...@@ -322,7 +472,8 @@ __gitcomp_file () ...@@ -322,7 +472,8 @@ __gitcomp_file ()
# use a hack to enable file mode in bash < 4 # use a hack to enable file mode in bash < 4
compopt -o filenames +o nospace 2>/dev/null || compopt -o filenames +o nospace 2>/dev/null ||
compgen -f /non-existing-dir/ > /dev/null compgen -f /non-existing-dir/ >/dev/null ||
true
} }
# Execute 'git ls-files', unless the --committable option is specified, in # Execute 'git ls-files', unless the --committable option is specified, in
...@@ -332,10 +483,12 @@ __gitcomp_file () ...@@ -332,10 +483,12 @@ __gitcomp_file ()
__git_ls_files_helper () __git_ls_files_helper ()
{ {
if [ "$2" == "--committable" ]; then if [ "$2" == "--committable" ]; then
__git -C "$1" diff-index --name-only --relative HEAD __git -C "$1" -c core.quotePath=false diff-index \
--name-only --relative HEAD -- "${3//\\/\\\\}*"
else else
# NOTE: $2 is not quoted in order to support multiple options # NOTE: $2 is not quoted in order to support multiple options
__git -C "$1" ls-files --exclude-standard $2 __git -C "$1" -c core.quotePath=false ls-files \
--exclude-standard $2 -- "${3//\\/\\\\}*"
fi fi
} }
...@@ -346,17 +499,103 @@ __git_ls_files_helper () ...@@ -346,17 +499,103 @@ __git_ls_files_helper ()
# If provided, only files within the specified directory are listed. # If provided, only files within the specified directory are listed.
# Sub directories are never recursed. Path must have a trailing # Sub directories are never recursed. Path must have a trailing
# slash. # slash.
# 3: List only paths matching this path component (optional).
__git_index_files () __git_index_files ()
{ {
local root="${2-.}" file local root="$2" match="$3"
__git_ls_files_helper "$root" "$1" "$match" |
awk -F / -v pfx="${2//\\/\\\\}" '{
paths[$1] = 1
}
END {
for (p in paths) {
if (substr(p, 1, 1) != "\"") {
# No special characters, easy!
print pfx p
continue
}
# The path is quoted.
p = dequote(p)
if (p == "")
continue
# Even when a directory name itself does not contain
# any special characters, it will still be quoted if
# any of its (stripped) trailing path components do.
# Because of this we may have seen the same direcory
# both quoted and unquoted.
if (p in paths)
# We have seen the same directory unquoted,
# skip it.
continue
else
print pfx p
}
}
function dequote(p, bs_idx, out, esc, esc_idx, dec) {
# Skip opening double quote.
p = substr(p, 2)
# Interpret backslash escape sequences.
while ((bs_idx = index(p, "\\")) != 0) {
out = out substr(p, 1, bs_idx - 1)
esc = substr(p, bs_idx + 1, 1)
p = substr(p, bs_idx + 2)
if ((esc_idx = index("abtvfr\"\\", esc)) != 0) {
# C-style one-character escape sequence.
out = out substr("\a\b\t\v\f\r\"\\",
esc_idx, 1)
} else if (esc == "n") {
# Uh-oh, a newline character.
# We cant reliably put a pathname
# containing a newline into COMPREPLY,
# and the newline would create a mess.
# Skip this path.
return ""
} else {
# Must be a \nnn octal value, then.
dec = esc * 64 + \
substr(p, 1, 1) * 8 + \
substr(p, 2, 1)
out = out sprintf("%c", dec)
p = substr(p, 3)
}
}
# Drop closing double quote, if there is one.
# (There isnt any if this is a directory, as it was
# already stripped with the trailing path components.)
if (substr(p, length(p), 1) == "\"")
out = out substr(p, 1, length(p) - 1)
else
out = out p
return out
}'
}
# __git_complete_index_file requires 1 argument:
# 1: the options to pass to ls-file
#
# The exception is --committable, which finds the files appropriate commit.
__git_complete_index_file ()
{
local dequoted_word pfx="" cur_
__git_dequote "$cur"
__git_ls_files_helper "$root" "$1" | case "$dequoted_word" in
while read -r file; do ?*/*)
case "$file" in pfx="${dequoted_word%/*}/"
?*/*) echo "${file%%/*}" ;; cur_="${dequoted_word##*/}"
*) echo "$file" ;; ;;
*)
cur_="$dequoted_word"
esac esac
done | sort | uniq
__gitcomp_file_direct "$(__git_index_files "$1" "$pfx" "$cur_")"
} }
# Lists branches from the local repository. # Lists branches from the local repository.
...@@ -439,7 +678,7 @@ __git_refs () ...@@ -439,7 +678,7 @@ __git_refs ()
track="" track=""
;; ;;
*) *)
for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD; do
case "$i" in case "$i" in
$match*) $match*)
if [ -e "$dir/$i" ]; then if [ -e "$dir/$i" ]; then
...@@ -594,7 +833,7 @@ __git_is_configured_remote () ...@@ -594,7 +833,7 @@ __git_is_configured_remote ()
__git_list_merge_strategies () __git_list_merge_strategies ()
{ {
git merge -s help 2>&1 | LANG=C LC_ALL=C git merge -s help 2>&1 |
sed -n -e '/[Aa]vailable strategies are: /,/^$/{ sed -n -e '/[Aa]vailable strategies are: /,/^$/{
s/\.$// s/\.$//
s/.*:// s/.*://
...@@ -616,9 +855,14 @@ __git_compute_merge_strategies () ...@@ -616,9 +855,14 @@ __git_compute_merge_strategies ()
__git_merge_strategies=$(__git_list_merge_strategies) __git_merge_strategies=$(__git_list_merge_strategies)
} }
__git_merge_strategy_options="ours theirs subtree subtree= patience
histogram diff-algorithm= ignore-space-change ignore-all-space
ignore-space-at-eol renormalize no-renormalize no-renames
find-renames find-renames= rename-threshold="
__git_complete_revlist_file () __git_complete_revlist_file ()
{ {
local pfx ls ref cur_="$cur" local dequoted_word pfx ls ref cur_="$cur"
case "$cur_" in case "$cur_" in
*..?*:*) *..?*:*)
return return
...@@ -626,14 +870,18 @@ __git_complete_revlist_file () ...@@ -626,14 +870,18 @@ __git_complete_revlist_file ()
?*:*) ?*:*)
ref="${cur_%%:*}" ref="${cur_%%:*}"
cur_="${cur_#*:}" cur_="${cur_#*:}"
case "$cur_" in
__git_dequote "$cur_"
case "$dequoted_word" in
?*/*) ?*/*)
pfx="${cur_%/*}" pfx="${dequoted_word%/*}"
cur_="${cur_##*/}" cur_="${dequoted_word##*/}"
ls="$ref:$pfx" ls="$ref:$pfx"
pfx="$pfx/" pfx="$pfx/"
;; ;;
*) *)
cur_="$dequoted_word"
ls="$ref" ls="$ref"
;; ;;
esac esac
...@@ -643,21 +891,10 @@ __git_complete_revlist_file () ...@@ -643,21 +891,10 @@ __git_complete_revlist_file ()
*) pfx="$ref:$pfx" ;; *) pfx="$ref:$pfx" ;;
esac esac
__gitcomp_nl "$(__git ls-tree "$ls" \ __gitcomp_file "$(__git ls-tree "$ls" \
| sed '/^100... blob /{ | sed 's/^.* //
s,^.* ,, s/$//')" \
s,$, , "$pfx" "$cur_"
}
/^120000 blob /{
s,^.* ,,
s,$, ,
}
/^040000 tree /{
s,^.* ,,
s,$,/,
}
s/^.* //')" \
"$pfx" "$cur_" ""
;; ;;
*...*) *...*)
pfx="${cur_%...*}..." pfx="${cur_%...*}..."
...@@ -675,26 +912,6 @@ __git_complete_revlist_file () ...@@ -675,26 +912,6 @@ __git_complete_revlist_file ()
esac esac
} }
# __git_complete_index_file requires 1 argument:
# 1: the options to pass to ls-file
#
# The exception is --committable, which finds the files appropriate commit.
__git_complete_index_file ()
{
local pfx="" cur_="$cur"
case "$cur_" in
?*/*)
pfx="${cur_%/*}"
cur_="${cur_##*/}"
pfx="${pfx}/"
;;
esac
__gitcomp_file "$(__git_index_files "$1" ${pfx:+"$pfx"})" "$pfx" "$cur_"
}
__git_complete_file () __git_complete_file ()
{ {
__git_complete_revlist_file __git_complete_revlist_file
...@@ -726,6 +943,7 @@ __git_complete_remote_or_refspec () ...@@ -726,6 +943,7 @@ __git_complete_remote_or_refspec ()
*) ;; *) ;;
esac esac
;; ;;
--multiple) no_complete_refspec=1; break ;;
-*) ;; -*) ;;
*) remote="$i"; break ;; *) remote="$i"; break ;;
esac esac
...@@ -785,136 +1003,30 @@ __git_complete_strategy () ...@@ -785,136 +1003,30 @@ __git_complete_strategy ()
-s|--strategy) -s|--strategy)
__gitcomp "$__git_merge_strategies" __gitcomp "$__git_merge_strategies"
return 0 return 0
;;
-X)
__gitcomp "$__git_merge_strategy_options"
return 0
;;
esac esac
case "$cur" in case "$cur" in
--strategy=*) --strategy=*)
__gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}" __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"
return 0 return 0
;; ;;
--strategy-option=*)
__gitcomp "$__git_merge_strategy_options" "" "${cur##--strategy-option=}"
return 0
;;
esac esac
return 1 return 1
} }
__git_commands () {
if test -n "${GIT_TESTING_COMMAND_COMPLETION:-}"
then
printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}"
else
git help -a|egrep '^ [a-zA-Z0-9]'
fi
}
__git_list_all_commands ()
{
local i IFS=" "$'\n'
for i in $(__git_commands)
do
case $i in
*--*) : helper pattern;;
*) echo $i;;
esac
done
}
__git_all_commands= __git_all_commands=
__git_compute_all_commands () __git_compute_all_commands ()
{ {
test -n "$__git_all_commands" || test -n "$__git_all_commands" ||
__git_all_commands=$(__git_list_all_commands) __git_all_commands=$(__git --list-cmds=main,others,alias,nohelpers)
}
__git_list_porcelain_commands ()
{
local i IFS=" "$'\n'
__git_compute_all_commands
for i in $__git_all_commands
do
case $i in
*--*) : helper pattern;;
applymbox) : ask gittus;;
applypatch) : ask gittus;;
archimport) : import;;
cat-file) : plumbing;;
check-attr) : plumbing;;
check-ignore) : plumbing;;
check-mailmap) : plumbing;;
check-ref-format) : plumbing;;
checkout-index) : plumbing;;
column) : internal helper;;
commit-tree) : plumbing;;
count-objects) : infrequent;;
credential) : credentials;;
credential-*) : credentials helper;;
cvsexportcommit) : export;;
cvsimport) : import;;
cvsserver) : daemon;;
daemon) : daemon;;
diff-files) : plumbing;;
diff-index) : plumbing;;
diff-tree) : plumbing;;
fast-import) : import;;
fast-export) : export;;
fsck-objects) : plumbing;;
fetch-pack) : plumbing;;
fmt-merge-msg) : plumbing;;
for-each-ref) : plumbing;;
hash-object) : plumbing;;
http-*) : transport;;
index-pack) : plumbing;;
init-db) : deprecated;;
local-fetch) : plumbing;;
ls-files) : plumbing;;
ls-remote) : plumbing;;
ls-tree) : plumbing;;
mailinfo) : plumbing;;
mailsplit) : plumbing;;
merge-*) : plumbing;;
mktree) : plumbing;;
mktag) : plumbing;;
pack-objects) : plumbing;;
pack-redundant) : plumbing;;
pack-refs) : plumbing;;
parse-remote) : plumbing;;
patch-id) : plumbing;;
prune) : plumbing;;
prune-packed) : plumbing;;
quiltimport) : import;;
read-tree) : plumbing;;
receive-pack) : plumbing;;
remote-*) : transport;;
rerere) : plumbing;;
rev-list) : plumbing;;
rev-parse) : plumbing;;
runstatus) : plumbing;;
sh-setup) : internal;;
shell) : daemon;;
show-ref) : plumbing;;
send-pack) : plumbing;;
show-index) : plumbing;;
ssh-*) : transport;;
stripspace) : plumbing;;
symbolic-ref) : plumbing;;
unpack-file) : plumbing;;
unpack-objects) : plumbing;;
update-index) : plumbing;;
update-ref) : plumbing;;
update-server-info) : daemon;;
upload-archive) : plumbing;;
upload-pack) : plumbing;;
write-tree) : plumbing;;
var) : infrequent;;
verify-pack) : infrequent;;
verify-tag) : plumbing;;
*) echo $i;;
esac
done
}
__git_porcelain_commands=
__git_compute_porcelain_commands ()
{
test -n "$__git_porcelain_commands" ||
__git_porcelain_commands=$(__git_list_porcelain_commands)
} }
# Lists all set config variables starting with the given section prefix, # Lists all set config variables starting with the given section prefix,
...@@ -932,11 +1044,6 @@ __git_pretty_aliases () ...@@ -932,11 +1044,6 @@ __git_pretty_aliases ()
__git_get_config_variables "pretty" __git_get_config_variables "pretty"
} }
__git_aliases ()
{
__git_get_config_variables "alias"
}
# __git_aliased_command requires 1 argument # __git_aliased_command requires 1 argument
__git_aliased_command () __git_aliased_command ()
{ {
...@@ -1072,12 +1179,14 @@ __git_count_arguments () ...@@ -1072,12 +1179,14 @@ __git_count_arguments ()
} }
__git_whitespacelist="nowarn warn error error-all fix" __git_whitespacelist="nowarn warn error error-all fix"
__git_patchformat="mbox stgit stgit-series hg mboxrd"
__git_am_inprogress_options="--skip --continue --resolved --abort --quit --show-current-patch"
_git_am () _git_am ()
{ {
__git_find_repo_path __git_find_repo_path
if [ -d "$__git_repo_path"/rebase-apply ]; then if [ -d "$__git_repo_path"/rebase-apply ]; then
__gitcomp "--skip --continue --resolved --abort" __gitcomp "$__git_am_inprogress_options"
return return
fi fi
case "$cur" in case "$cur" in
...@@ -1085,13 +1194,13 @@ _git_am () ...@@ -1085,13 +1194,13 @@ _git_am ()
__gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}" __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
return return
;; ;;
--patch-format=*)
__gitcomp "$__git_patchformat" "" "${cur##--patch-format=}"
return
;;
--*) --*)
__gitcomp " __gitcomp_builtin am "" \
--3way --committer-date-is-author-date --ignore-date "$__git_am_inprogress_options"
--ignore-whitespace --ignore-space-change
--interactive --keep --no-utf8 --signoff --utf8
--whitespace= --scissors
"
return return
esac esac
} }
...@@ -1104,14 +1213,7 @@ _git_apply () ...@@ -1104,14 +1213,7 @@ _git_apply ()
return return
;; ;;
--*) --*)
__gitcomp " __gitcomp_builtin apply
--stat --numstat --summary --check --index
--cached --index-info --reverse --reject --unidiff-zero
--apply --no-add --exclude=
--ignore-whitespace --ignore-space-change
--whitespace= --inaccurate-eof --verbose
--recount --directory=
"
return return
esac esac
} }
...@@ -1119,11 +1221,12 @@ _git_apply () ...@@ -1119,11 +1221,12 @@ _git_apply ()
_git_add () _git_add ()
{ {
case "$cur" in case "$cur" in
--chmod=*)
__gitcomp "+x -x" "" "${cur##--chmod=}"
return
;;
--*) --*)
__gitcomp " __gitcomp_builtin add
--interactive --refresh --patch --update --dry-run
--ignore-errors --intent-to-add --force --edit --chmod=
"
return return
esac esac
...@@ -1182,6 +1285,8 @@ _git_bisect () ...@@ -1182,6 +1285,8 @@ _git_bisect ()
esac esac
} }
__git_ref_fieldlist="refname objecttype objectsize objectname upstream push HEAD symref"
_git_branch () _git_branch ()
{ {
local i c=1 only_local_ref="n" has_r="n" local i c=1 only_local_ref="n" has_r="n"
...@@ -1200,13 +1305,7 @@ _git_branch () ...@@ -1200,13 +1305,7 @@ _git_branch ()
__git_complete_refs --cur="${cur##--set-upstream-to=}" __git_complete_refs --cur="${cur##--set-upstream-to=}"
;; ;;
--*) --*)
__gitcomp " __gitcomp_builtin branch
--color --no-color --verbose --abbrev= --no-abbrev
--track --no-track --contains --no-contains --merged --no-merged
--set-upstream-to= --edit-description --list
--unset-upstream --delete --move --copy --remotes
--column --no-column --sort= --points-at
"
;; ;;
*) *)
if [ $only_local_ref = "y" -a $has_r = "n" ]; then if [ $only_local_ref = "y" -a $has_r = "n" ]; then
...@@ -1247,11 +1346,7 @@ _git_checkout () ...@@ -1247,11 +1346,7 @@ _git_checkout ()
__gitcomp "diff3 merge" "" "${cur##--conflict=}" __gitcomp "diff3 merge" "" "${cur##--conflict=}"
;; ;;
--*) --*)
__gitcomp " __gitcomp_builtin checkout
--quiet --ours --theirs --track --no-track --merge
--conflict= --orphan --patch --detach --ignore-skip-worktree-bits
--recurse-submodules --no-recurse-submodules
"
;; ;;
*) *)
# check if --track, --no-track, or --no-guess was specified # check if --track, --no-track, or --no-guess was specified
...@@ -1266,21 +1361,22 @@ _git_checkout () ...@@ -1266,21 +1361,22 @@ _git_checkout ()
esac esac
} }
_git_cherry () __git_cherry_pick_inprogress_options="--continue --quit --abort"
{
__git_complete_refs
}
_git_cherry_pick () _git_cherry_pick ()
{ {
__git_find_repo_path __git_find_repo_path
if [ -f "$__git_repo_path"/CHERRY_PICK_HEAD ]; then if [ -f "$__git_repo_path"/CHERRY_PICK_HEAD ]; then
__gitcomp "--continue --quit --abort" __gitcomp "$__git_cherry_pick_inprogress_options"
return return
fi fi
__git_complete_strategy && return
case "$cur" in case "$cur" in
--*) --*)
__gitcomp "--edit --no-commit --signoff --strategy= --mainline" __gitcomp_builtin cherry-pick "" \
"$__git_cherry_pick_inprogress_options"
;; ;;
*) *)
__git_complete_refs __git_complete_refs
...@@ -1292,7 +1388,7 @@ _git_clean () ...@@ -1292,7 +1388,7 @@ _git_clean ()
{ {
case "$cur" in case "$cur" in
--*) --*)
__gitcomp "--dry-run --quiet" __gitcomp_builtin clean
return return
;; ;;
esac esac
...@@ -1305,26 +1401,7 @@ _git_clone () ...@@ -1305,26 +1401,7 @@ _git_clone ()
{ {
case "$cur" in case "$cur" in
--*) --*)
__gitcomp " __gitcomp_builtin clone
--local
--no-hardlinks
--shared
--reference
--quiet
--no-checkout
--bare
--mirror
--origin
--upload-pack
--template=
--depth
--single-branch
--no-tags
--branch
--recurse-submodules
--no-single-branch
--shallow-submodules
"
return return
;; ;;
esac esac
...@@ -1357,16 +1434,7 @@ _git_commit () ...@@ -1357,16 +1434,7 @@ _git_commit ()
return return
;; ;;
--*) --*)
__gitcomp " __gitcomp_builtin commit
--all --author= --signoff --verify --no-verify
--edit --no-edit
--amend --include --only --interactive
--dry-run --reuse-message= --reedit-message=
--reset-author --file= --message= --template=
--cleanup= --untracked-files --untracked-files=
--verbose --quiet --fixup= --squash=
--patch --short --date --allow-empty
"
return return
esac esac
...@@ -1382,11 +1450,7 @@ _git_describe () ...@@ -1382,11 +1450,7 @@ _git_describe ()
{ {
case "$cur" in case "$cur" in
--*) --*)
__gitcomp " __gitcomp_builtin describe
--all --tags --contains --abbrev= --candidates=
--exact-match --debug --long --match --always --first-parent
--exclude --dirty --broken
"
return return
esac esac
__git_complete_refs __git_complete_refs
...@@ -1411,7 +1475,7 @@ __git_diff_common_options="--stat --numstat --shortstat --summary ...@@ -1411,7 +1475,7 @@ __git_diff_common_options="--stat --numstat --shortstat --summary
--dirstat --dirstat= --dirstat-by-file --dirstat --dirstat= --dirstat-by-file
--dirstat-by-file= --cumulative --dirstat-by-file= --cumulative
--diff-algorithm= --diff-algorithm=
--submodule --submodule= --submodule --submodule= --ignore-submodules
" "
_git_diff () _git_diff ()
...@@ -1439,7 +1503,8 @@ _git_diff () ...@@ -1439,7 +1503,8 @@ _git_diff ()
} }
__git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff __git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff
tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc codecompare tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc
codecompare smerge
" "
_git_difftool () _git_difftool ()
...@@ -1452,11 +1517,11 @@ _git_difftool () ...@@ -1452,11 +1517,11 @@ _git_difftool ()
return return
;; ;;
--*) --*)
__gitcomp "--cached --staged --pickaxe-all --pickaxe-regex __gitcomp_builtin difftool "$__git_diff_common_options
--base --ours --theirs --base --cached --ours --theirs
--no-renames --diff-filter= --find-copies-harder --pickaxe-all --pickaxe-regex
--relative --ignore-submodules --relative --staged
--tool=" "
return return
;; ;;
esac esac
...@@ -1465,12 +1530,6 @@ _git_difftool () ...@@ -1465,12 +1530,6 @@ _git_difftool ()
__git_fetch_recurse_submodules="yes on-demand no" __git_fetch_recurse_submodules="yes on-demand no"
__git_fetch_options="
--quiet --verbose --append --upload-pack --force --keep --depth=
--tags --no-tags --all --prune --dry-run --recurse-submodules=
--unshallow --update-shallow
"
_git_fetch () _git_fetch ()
{ {
case "$cur" in case "$cur" in
...@@ -1478,21 +1537,21 @@ _git_fetch () ...@@ -1478,21 +1537,21 @@ _git_fetch ()
__gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}" __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
return return
;; ;;
--filter=*)
__gitcomp "blob:none blob:limit= sparse:oid=" "" "${cur##--filter=}"
return
;;
--*) --*)
__gitcomp "$__git_fetch_options" __gitcomp_builtin fetch
return return
;; ;;
esac esac
__git_complete_remote_or_refspec __git_complete_remote_or_refspec
} }
__git_format_patch_options=" __git_format_patch_extra_options="
--stdout --attach --no-attach --thread --thread= --no-thread --full-index --not --all --no-prefix --src-prefix=
--numbered --start-number --numbered-files --keep-subject --signoff --dst-prefix= --notes
--signature --no-signature --in-reply-to= --cc= --full-index --binary
--not --all --cover-letter --no-prefix --src-prefix= --dst-prefix=
--inline --suffix= --ignore-if-in-upstream --subject-prefix=
--output-directory --reroll-count --to= --quiet --notes
" "
_git_format_patch () _git_format_patch ()
...@@ -1505,7 +1564,7 @@ _git_format_patch () ...@@ -1505,7 +1564,7 @@ _git_format_patch ()
return return
;; ;;
--*) --*)
__gitcomp "$__git_format_patch_options" __gitcomp_builtin format-patch "$__git_format_patch_extra_options"
return return
;; ;;
esac esac
...@@ -1516,20 +1575,7 @@ _git_fsck () ...@@ -1516,20 +1575,7 @@ _git_fsck ()
{ {
case "$cur" in case "$cur" in
--*) --*)
__gitcomp " __gitcomp_builtin fsck
--tags --root --unreachable --cache --no-reflogs --full
--strict --verbose --lost-found --name-objects
"
return
;;
esac
}
_git_gc ()
{
case "$cur" in
--*)
__gitcomp "--prune --aggressive"
return return
;; ;;
esac esac
...@@ -1585,21 +1631,7 @@ _git_grep () ...@@ -1585,21 +1631,7 @@ _git_grep ()
case "$cur" in case "$cur" in
--*) --*)
__gitcomp " __gitcomp_builtin grep
--cached
--text --ignore-case --word-regexp --invert-match
--full-name --line-number
--extended-regexp --basic-regexp --fixed-strings
--perl-regexp
--threads
--files-with-matches --name-only
--files-without-match
--max-depth
--count
--and --or --not --all-match
--break --heading --show-function --function-context
--untracked --no-index
"
return return
;; ;;
esac esac
...@@ -1617,17 +1649,16 @@ _git_help () ...@@ -1617,17 +1649,16 @@ _git_help ()
{ {
case "$cur" in case "$cur" in
--*) --*)
__gitcomp "--all --guides --info --man --web" __gitcomp_builtin help
return return
;; ;;
esac esac
__git_compute_all_commands if test -n "$GIT_TESTING_ALL_COMMAND_LIST"
__gitcomp "$__git_all_commands $(__git_aliases) then
attributes cli core-tutorial cvs-migration __gitcomp "$GIT_TESTING_ALL_COMMAND_LIST $(__git --list-cmds=alias,list-guide) gitk"
diffcore everyday gitk glossary hooks ignore modules else
namespaces repository-layout revisions tutorial tutorial-2 __gitcomp "$(__git --list-cmds=main,nohelpers,alias,list-guide) gitk"
workflows fi
"
} }
_git_init () _git_init ()
...@@ -1640,7 +1671,7 @@ _git_init () ...@@ -1640,7 +1671,7 @@ _git_init ()
return return
;; ;;
--*) --*)
__gitcomp "--quiet --bare --template= --shared --shared=" __gitcomp_builtin init
return return
;; ;;
esac esac
...@@ -1650,13 +1681,7 @@ _git_ls_files () ...@@ -1650,13 +1681,7 @@ _git_ls_files ()
{ {
case "$cur" in case "$cur" in
--*) --*)
__gitcomp "--cached --deleted --modified --others --ignored __gitcomp_builtin ls-files
--stage --directory --no-empty-directory --unmerged
--killed --exclude= --exclude-from=
--exclude-per-directory= --exclude-standard
--error-unmatch --with-tree= --full-name
--abbrev --ignored --exclude-per-directory
"
return return
;; ;;
esac esac
...@@ -1670,7 +1695,7 @@ _git_ls_remote () ...@@ -1670,7 +1695,7 @@ _git_ls_remote ()
{ {
case "$cur" in case "$cur" in
--*) --*)
__gitcomp "--heads --tags --refs --get-url --symref" __gitcomp_builtin ls-remote
return return
;; ;;
esac esac
...@@ -1679,6 +1704,13 @@ _git_ls_remote () ...@@ -1679,6 +1704,13 @@ _git_ls_remote ()
_git_ls_tree () _git_ls_tree ()
{ {
case "$cur" in
--*)
__gitcomp_builtin ls-tree
return
;;
esac
__git_complete_file __git_complete_file
} }
...@@ -1705,8 +1737,8 @@ __git_log_shortlog_options=" ...@@ -1705,8 +1737,8 @@ __git_log_shortlog_options="
--all-match --invert-grep --all-match --invert-grep
" "
__git_log_pretty_formats="oneline short medium full fuller email raw format:" __git_log_pretty_formats="oneline short medium full fuller email raw format: mboxrd"
__git_log_date_formats="relative iso8601 rfc2822 short local default raw" __git_log_date_formats="relative iso8601 iso8601-strict rfc2822 short local default raw unix format:"
_git_log () _git_log ()
{ {
...@@ -1794,22 +1826,13 @@ _git_log () ...@@ -1794,22 +1826,13 @@ _git_log ()
__git_complete_revlist __git_complete_revlist
} }
# Common merge options shared by git-merge(1) and git-pull(1).
__git_merge_options="
--no-commit --no-stat --log --no-log --squash --strategy
--commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
--verify-signatures --no-verify-signatures --gpg-sign
--quiet --verbose --progress --no-progress
"
_git_merge () _git_merge ()
{ {
__git_complete_strategy && return __git_complete_strategy && return
case "$cur" in case "$cur" in
--*) --*)
__gitcomp "$__git_merge_options __gitcomp_builtin merge
--rerere-autoupdate --no-rerere-autoupdate --abort --continue"
return return
esac esac
__git_complete_refs __git_complete_refs
...@@ -1823,7 +1846,7 @@ _git_mergetool () ...@@ -1823,7 +1846,7 @@ _git_mergetool ()
return return
;; ;;
--*) --*)
__gitcomp "--tool= --prompt --no-prompt" __gitcomp "--tool= --prompt --no-prompt --gui --no-gui"
return return
;; ;;
esac esac
...@@ -1833,7 +1856,7 @@ _git_merge_base () ...@@ -1833,7 +1856,7 @@ _git_merge_base ()
{ {
case "$cur" in case "$cur" in
--*) --*)
__gitcomp "--octopus --independent --is-ancestor --fork-point" __gitcomp_builtin merge-base
return return
;; ;;
esac esac
...@@ -1844,7 +1867,7 @@ _git_mv () ...@@ -1844,7 +1867,7 @@ _git_mv ()
{ {
case "$cur" in case "$cur" in
--*) --*)
__gitcomp "--dry-run" __gitcomp_builtin mv
return return
;; ;;
esac esac
...@@ -1858,19 +1881,14 @@ _git_mv () ...@@ -1858,19 +1881,14 @@ _git_mv ()
fi fi
} }
_git_name_rev ()
{
__gitcomp "--tags --all --stdin"
}
_git_notes () _git_notes ()
{ {
local subcommands='add append copy edit list prune remove show' local subcommands='add append copy edit get-ref list merge prune remove show'
local subcommand="$(__git_find_on_cmdline "$subcommands")" local subcommand="$(__git_find_on_cmdline "$subcommands")"
case "$subcommand,$cur" in case "$subcommand,$cur" in
,--*) ,--*)
__gitcomp '--ref' __gitcomp_builtin notes
;; ;;
,*) ,*)
case "$prev" in case "$prev" in
...@@ -1882,21 +1900,14 @@ _git_notes () ...@@ -1882,21 +1900,14 @@ _git_notes ()
;; ;;
esac esac
;; ;;
add,--reuse-message=*|append,--reuse-message=*|\ *,--reuse-message=*|*,--reedit-message=*)
add,--reedit-message=*|append,--reedit-message=*)
__git_complete_refs --cur="${cur#*=}" __git_complete_refs --cur="${cur#*=}"
;; ;;
add,--*|append,--*) *,--*)
__gitcomp '--file= --message= --reedit-message= __gitcomp_builtin notes_$subcommand
--reuse-message='
;;
copy,--*)
__gitcomp '--stdin'
;;
prune,--*)
__gitcomp '--dry-run --verbose'
;; ;;
prune,*) prune,*|get-ref,*)
# this command does not take a ref, do not complete it
;; ;;
*) *)
case "$prev" in case "$prev" in
...@@ -1920,12 +1931,8 @@ _git_pull () ...@@ -1920,12 +1931,8 @@ _git_pull ()
return return
;; ;;
--*) --*)
__gitcomp " __gitcomp_builtin pull
--rebase --no-rebase
--autostash --no-autostash
$__git_merge_options
$__git_fetch_options
"
return return
;; ;;
esac esac
...@@ -1975,28 +1982,37 @@ _git_push () ...@@ -1975,28 +1982,37 @@ _git_push ()
__git_complete_force_with_lease "${cur##--force-with-lease=}" __git_complete_force_with_lease "${cur##--force-with-lease=}"
return return
;; ;;
--*)
__gitcomp_builtin push
return
;;
esac
__git_complete_remote_or_refspec
}
_git_range_diff ()
{
case "$cur" in
--*) --*)
__gitcomp " __gitcomp "
--all --mirror --tags --dry-run --force --verbose --creation-factor= --no-dual-color
--quiet --prune --delete --follow-tags $__git_diff_common_options
--receive-pack= --repo= --set-upstream
--force-with-lease --force-with-lease= --recurse-submodules=
" "
return return
;; ;;
esac esac
__git_complete_remote_or_refspec __git_complete_revlist
} }
_git_rebase () _git_rebase ()
{ {
__git_find_repo_path __git_find_repo_path
if [ -f "$__git_repo_path"/rebase-merge/interactive ]; then if [ -f "$__git_repo_path"/rebase-merge/interactive ]; then
__gitcomp "--continue --skip --abort --quit --edit-todo" __gitcomp "--continue --skip --abort --quit --edit-todo --show-current-patch"
return return
elif [ -d "$__git_repo_path"/rebase-apply ] || \ elif [ -d "$__git_repo_path"/rebase-apply ] || \
[ -d "$__git_repo_path"/rebase-merge ]; then [ -d "$__git_repo_path"/rebase-merge ]; then
__gitcomp "--continue --skip --abort --quit" __gitcomp "--continue --skip --abort --quit --show-current-patch"
return return
fi fi
__git_complete_strategy && return __git_complete_strategy && return
...@@ -2008,7 +2024,7 @@ _git_rebase () ...@@ -2008,7 +2024,7 @@ _git_rebase ()
--*) --*)
__gitcomp " __gitcomp "
--onto --merge --strategy --interactive --onto --merge --strategy --interactive
--preserve-merges --stat --no-stat --rebase-merges --preserve-merges --stat --no-stat
--committer-date-is-author-date --ignore-date --committer-date-is-author-date --ignore-date
--ignore-whitespace --whitespace= --ignore-whitespace --whitespace=
--autosquash --no-autosquash --autosquash --no-autosquash
...@@ -2016,6 +2032,7 @@ _git_rebase () ...@@ -2016,6 +2032,7 @@ _git_rebase ()
--autostash --no-autostash --autostash --no-autostash
--verify --no-verify --verify --no-verify
--keep-empty --root --force-rebase --no-ff --keep-empty --root --force-rebase --no-ff
--rerere-autoupdate
--exec --exec
" "
...@@ -2077,16 +2094,16 @@ _git_send_email () ...@@ -2077,16 +2094,16 @@ _git_send_email ()
return return
;; ;;
--*) --*)
__gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to __gitcomp_builtin send-email "--annotate --bcc --cc --cc-cmd --chain-reply-to
--compose --confirm= --dry-run --envelope-sender --compose --confirm= --dry-run --envelope-sender
--from --identity --from --identity
--in-reply-to --no-chain-reply-to --no-signed-off-by-cc --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
--no-suppress-from --no-thread --quiet --no-suppress-from --no-thread --quiet --reply-to
--signed-off-by-cc --smtp-pass --smtp-server --signed-off-by-cc --smtp-pass --smtp-server
--smtp-server-port --smtp-encryption= --smtp-user --smtp-server-port --smtp-encryption= --smtp-user
--subject --suppress-cc= --suppress-from --thread --to --subject --suppress-cc= --suppress-from --thread --to
--validate --no-validate --validate --no-validate
$__git_format_patch_options" $__git_format_patch_extra_options"
return return
;; ;;
esac esac
...@@ -2119,11 +2136,7 @@ _git_status () ...@@ -2119,11 +2136,7 @@ _git_status ()
return return
;; ;;
--*) --*)
__gitcomp " __gitcomp_builtin status
--short --branch --porcelain --long --verbose
--untracked-files= --ignore-submodules= --ignored
--column= --no-column
"
return return
;; ;;
esac esac
...@@ -2148,6 +2161,44 @@ _git_status () ...@@ -2148,6 +2161,44 @@ _git_status ()
__git_complete_index_file "$complete_opt" __git_complete_index_file "$complete_opt"
} }
_git_switch ()
{
case "$cur" in
--conflict=*)
__gitcomp "diff3 merge" "" "${cur##--conflict=}"
;;
--*)
__gitcomp_builtin switch
;;
*)
# check if --track, --no-track, or --no-guess was specified
# if so, disable DWIM mode
local track_opt="--track" only_local_ref=n
if [ "$GIT_COMPLETION_CHECKOUT_NO_GUESS" = "1" ] ||
[ -n "$(__git_find_on_cmdline "--track --no-track --no-guess")" ]; then
track_opt=''
fi
# explicit --guess enables DWIM mode regardless of
# $GIT_COMPLETION_CHECKOUT_NO_GUESS
if [ -n "$(__git_find_on_cmdline "--guess")" ]; then
track_opt='--track'
fi
if [ -z "$(__git_find_on_cmdline "-d --detach")" ]; then
only_local_ref=y
else
# --guess --detach is invalid combination, no
# dwim will be done when --detach is specified
track_opt=
fi
if [ $only_local_ref = y -a -z "$track_opt" ]; then
__gitcomp_direct "$(__git_heads "" "$cur" " ")"
else
__git_complete_refs $track_opt
fi
;;
esac
}
__git_config_get_set_variables () __git_config_get_set_variables ()
{ {
local prevword word config_file= c=$cword local prevword word config_file= c=$cword
...@@ -2170,9 +2221,24 @@ __git_config_get_set_variables () ...@@ -2170,9 +2221,24 @@ __git_config_get_set_variables ()
__git config $config_file --name-only --list __git config $config_file --name-only --list
} }
__git_config_vars=
__git_compute_config_vars ()
{
test -n "$__git_config_vars" ||
__git_config_vars="$(git help --config-for-completion | sort | uniq)"
}
_git_config () _git_config ()
{ {
case "$prev" in local varname
if [ "${BASH_VERSINFO[0]:-0}" -ge 4 ]; then
varname="${prev,,}"
else
varname="$(echo "$prev" |tr A-Z a-z)"
fi
case "$varname" in
branch.*.remote|branch.*.pushremote) branch.*.remote|branch.*.pushremote)
__gitcomp_nl "$(__git_remotes)" __gitcomp_nl "$(__git_remotes)"
return return
...@@ -2182,7 +2248,7 @@ _git_config () ...@@ -2182,7 +2248,7 @@ _git_config ()
return return
;; ;;
branch.*.rebase) branch.*.rebase)
__gitcomp "false true preserve interactive" __gitcomp "false true merges preserve interactive"
return return
;; ;;
remote.pushdefault) remote.pushdefault)
...@@ -2228,7 +2294,7 @@ _git_config () ...@@ -2228,7 +2294,7 @@ _git_config ()
return return
;; ;;
diff.submodule) diff.submodule)
__gitcomp "log short" __gitcomp "$__git_diff_submodule_formats"
return return
;; ;;
help.format) help.format)
...@@ -2239,7 +2305,7 @@ _git_config () ...@@ -2239,7 +2305,7 @@ _git_config ()
__gitcomp "$__git_log_date_formats" __gitcomp "$__git_log_date_formats"
return return
;; ;;
sendemail.aliasesfiletype) sendemail.aliasfiletype)
__gitcomp "mutt mailrc pine elm gnus" __gitcomp "mutt mailrc pine elm gnus"
return return
;; ;;
...@@ -2265,32 +2331,25 @@ _git_config () ...@@ -2265,32 +2331,25 @@ _git_config ()
esac esac
case "$cur" in case "$cur" in
--*) --*)
__gitcomp " __gitcomp_builtin config
--system --global --local --file=
--list --replace-all
--get --get-all --get-regexp
--add --unset --unset-all
--remove-section --rename-section
--name-only
"
return return
;; ;;
branch.*.*) branch.*.*)
local pfx="${cur%.*}." cur_="${cur##*.}" local pfx="${cur%.*}." cur_="${cur##*.}"
__gitcomp "remote pushremote merge mergeoptions rebase" "$pfx" "$cur_" __gitcomp "remote pushRemote merge mergeOptions rebase" "$pfx" "$cur_"
return return
;; ;;
branch.*) branch.*)
local pfx="${cur%.*}." cur_="${cur#*.}" local pfx="${cur%.*}." cur_="${cur#*.}"
__gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")" __gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")"
__gitcomp_nl_append $'autosetupmerge\nautosetuprebase\n' "$pfx" "$cur_" __gitcomp_nl_append $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_"
return return
;; ;;
guitool.*.*) guitool.*.*)
local pfx="${cur%.*}." cur_="${cur##*.}" local pfx="${cur%.*}." cur_="${cur##*.}"
__gitcomp " __gitcomp "
argprompt cmd confirm needsfile noconsole norescan argPrompt cmd confirm needsFile noConsole noRescan
prompt revprompt revunmerged title prompt revPrompt revUnmerged title
" "$pfx" "$cur_" " "$pfx" "$cur_"
return return
;; ;;
...@@ -2319,14 +2378,14 @@ _git_config () ...@@ -2319,14 +2378,14 @@ _git_config ()
local pfx="${cur%.*}." cur_="${cur##*.}" local pfx="${cur%.*}." cur_="${cur##*.}"
__gitcomp " __gitcomp "
url proxy fetch push mirror skipDefaultUpdate url proxy fetch push mirror skipDefaultUpdate
receivepack uploadpack tagopt pushurl receivepack uploadpack tagOpt pushurl
" "$pfx" "$cur_" " "$pfx" "$cur_"
return return
;; ;;
remote.*) remote.*)
local pfx="${cur%.*}." cur_="${cur#*.}" local pfx="${cur%.*}." cur_="${cur#*.}"
__gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "." __gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
__gitcomp_nl_append "pushdefault" "$pfx" "$cur_" __gitcomp_nl_append "pushDefault" "$pfx" "$cur_"
return return
;; ;;
url.*.*) url.*.*)
...@@ -2334,332 +2393,14 @@ _git_config () ...@@ -2334,332 +2393,14 @@ _git_config ()
__gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_" __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_"
return return
;; ;;
*.*)
__git_compute_config_vars
__gitcomp "$__git_config_vars"
;;
*)
__git_compute_config_vars
__gitcomp "$(echo "$__git_config_vars" | sed 's/\.[^ ]*/./g')"
esac esac
__gitcomp "
add.ignoreErrors
advice.amWorkDir
advice.commitBeforeMerge
advice.detachedHead
advice.implicitIdentity
advice.pushAlreadyExists
advice.pushFetchFirst
advice.pushNeedsForce
advice.pushNonFFCurrent
advice.pushNonFFMatching
advice.pushUpdateRejected
advice.resolveConflict
advice.rmHints
advice.statusHints
advice.statusUoption
advice.ignoredHook
alias.
am.keepcr
am.threeWay
apply.ignorewhitespace
apply.whitespace
branch.autosetupmerge
branch.autosetuprebase
browser.
clean.requireForce
color.branch
color.branch.current
color.branch.local
color.branch.plain
color.branch.remote
color.decorate.HEAD
color.decorate.branch
color.decorate.remoteBranch
color.decorate.stash
color.decorate.tag
color.diff
color.diff.commit
color.diff.frag
color.diff.func
color.diff.meta
color.diff.new
color.diff.old
color.diff.plain
color.diff.whitespace
color.grep
color.grep.context
color.grep.filename
color.grep.function
color.grep.linenumber
color.grep.match
color.grep.selected
color.grep.separator
color.interactive
color.interactive.error
color.interactive.header
color.interactive.help
color.interactive.prompt
color.pager
color.showbranch
color.status
color.status.added
color.status.changed
color.status.header
color.status.localBranch
color.status.nobranch
color.status.remoteBranch
color.status.unmerged
color.status.untracked
color.status.updated
color.ui
commit.cleanup
commit.gpgSign
commit.status
commit.template
commit.verbose
core.abbrev
core.askpass
core.attributesfile
core.autocrlf
core.bare
core.bigFileThreshold
core.checkStat
core.commentChar
core.compression
core.createObject
core.deltaBaseCacheLimit
core.editor
core.eol
core.excludesfile
core.fileMode
core.fsyncobjectfiles
core.gitProxy
core.hideDotFiles
core.hooksPath
core.ignoreStat
core.ignorecase
core.logAllRefUpdates
core.loosecompression
core.notesRef
core.packedGitLimit
core.packedGitWindowSize
core.packedRefsTimeout
core.pager
core.precomposeUnicode
core.preferSymlinkRefs
core.preloadindex
core.protectHFS
core.protectNTFS
core.quotepath
core.repositoryFormatVersion
core.safecrlf
core.sharedRepository
core.sparseCheckout
core.splitIndex
core.sshCommand
core.symlinks
core.trustctime
core.untrackedCache
core.warnAmbiguousRefs
core.whitespace
core.worktree
credential.helper
credential.useHttpPath
credential.username
credentialCache.ignoreSIGHUP
diff.autorefreshindex
diff.external
diff.ignoreSubmodules
diff.mnemonicprefix
diff.noprefix
diff.renameLimit
diff.renames
diff.statGraphWidth
diff.submodule
diff.suppressBlankEmpty
diff.tool
diff.wordRegex
diff.algorithm
difftool.
difftool.prompt
fetch.recurseSubmodules
fetch.unpackLimit
format.attach
format.cc
format.coverLetter
format.from
format.headers
format.numbered
format.pretty
format.signature
format.signoff
format.subjectprefix
format.suffix
format.thread
format.to
gc.
gc.aggressiveDepth
gc.aggressiveWindow
gc.auto
gc.autoDetach
gc.autopacklimit
gc.logExpiry
gc.packrefs
gc.pruneexpire
gc.reflogexpire
gc.reflogexpireunreachable
gc.rerereresolved
gc.rerereunresolved
gc.worktreePruneExpire
gitcvs.allbinary
gitcvs.commitmsgannotation
gitcvs.dbTableNamePrefix
gitcvs.dbdriver
gitcvs.dbname
gitcvs.dbpass
gitcvs.dbuser
gitcvs.enabled
gitcvs.logfile
gitcvs.usecrlfattr
guitool.
gui.blamehistoryctx
gui.commitmsgwidth
gui.copyblamethreshold
gui.diffcontext
gui.encoding
gui.fastcopyblame
gui.matchtrackingbranch
gui.newbranchtemplate
gui.pruneduringfetch
gui.spellingdictionary
gui.trustmtime
help.autocorrect
help.browser
help.format
http.lowSpeedLimit
http.lowSpeedTime
http.maxRequests
http.minSessions
http.noEPSV
http.postBuffer
http.proxy
http.sslCipherList
http.sslVersion
http.sslCAInfo
http.sslCAPath
http.sslCert
http.sslCertPasswordProtected
http.sslKey
http.sslVerify
http.useragent
i18n.commitEncoding
i18n.logOutputEncoding
imap.authMethod
imap.folder
imap.host
imap.pass
imap.port
imap.preformattedHTML
imap.sslverify
imap.tunnel
imap.user
init.templatedir
instaweb.browser
instaweb.httpd
instaweb.local
instaweb.modulepath
instaweb.port
interactive.singlekey
log.date
log.decorate
log.showroot
mailmap.file
man.
man.viewer
merge.
merge.conflictstyle
merge.log
merge.renameLimit
merge.renormalize
merge.stat
merge.tool
merge.verbosity
mergetool.
mergetool.keepBackup
mergetool.keepTemporaries
mergetool.prompt
notes.displayRef
notes.rewrite.
notes.rewrite.amend
notes.rewrite.rebase
notes.rewriteMode
notes.rewriteRef
pack.compression
pack.deltaCacheLimit
pack.deltaCacheSize
pack.depth
pack.indexVersion
pack.packSizeLimit
pack.threads
pack.window
pack.windowMemory
pager.
pretty.
pull.octopus
pull.twohead
push.default
push.followTags
rebase.autosquash
rebase.stat
receive.autogc
receive.denyCurrentBranch
receive.denyDeleteCurrent
receive.denyDeletes
receive.denyNonFastForwards
receive.fsckObjects
receive.unpackLimit
receive.updateserverinfo
remote.pushdefault
remotes.
repack.usedeltabaseoffset
rerere.autoupdate
rerere.enabled
sendemail.
sendemail.aliasesfile
sendemail.aliasfiletype
sendemail.bcc
sendemail.cc
sendemail.cccmd
sendemail.chainreplyto
sendemail.confirm
sendemail.envelopesender
sendemail.from
sendemail.identity
sendemail.multiedit
sendemail.signedoffbycc
sendemail.smtpdomain
sendemail.smtpencryption
sendemail.smtppass
sendemail.smtpserver
sendemail.smtpserveroption
sendemail.smtpserverport
sendemail.smtpuser
sendemail.suppresscc
sendemail.suppressfrom
sendemail.thread
sendemail.to
sendemail.tocmd
sendemail.validate
sendemail.smtpbatchsize
sendemail.smtprelogindelay
showbranch.default
status.relativePaths
status.showUntrackedFiles
status.submodulesummary
submodule.
tar.umask
transfer.unpackLimit
url.
user.email
user.name
user.signingkey
web.browser
branch. remote.
"
} }
_git_remote () _git_remote ()
...@@ -2672,7 +2413,7 @@ _git_remote () ...@@ -2672,7 +2413,7 @@ _git_remote ()
if [ -z "$subcommand" ]; then if [ -z "$subcommand" ]; then
case "$cur" in case "$cur" in
--*) --*)
__gitcomp "--verbose" __gitcomp_builtin remote
;; ;;
*) *)
__gitcomp "$subcommands" __gitcomp "$subcommands"
...@@ -2683,33 +2424,33 @@ _git_remote () ...@@ -2683,33 +2424,33 @@ _git_remote ()
case "$subcommand,$cur" in case "$subcommand,$cur" in
add,--*) add,--*)
__gitcomp "--track --master --fetch --tags --no-tags --mirror=" __gitcomp_builtin remote_add
;; ;;
add,*) add,*)
;; ;;
set-head,--*) set-head,--*)
__gitcomp "--auto --delete" __gitcomp_builtin remote_set-head
;; ;;
set-branches,--*) set-branches,--*)
__gitcomp "--add" __gitcomp_builtin remote_set-branches
;; ;;
set-head,*|set-branches,*) set-head,*|set-branches,*)
__git_complete_remote_or_refspec __git_complete_remote_or_refspec
;; ;;
update,--*) update,--*)
__gitcomp "--prune" __gitcomp_builtin remote_update
;; ;;
update,*) update,*)
__gitcomp "$(__git_get_config_variables "remotes")" __gitcomp "$(__git_remotes) $(__git_get_config_variables "remotes")"
;; ;;
set-url,--*) set-url,--*)
__gitcomp "--push --add --delete" __gitcomp_builtin remote_set-url
;; ;;
get-url,--*) get-url,--*)
__gitcomp "--push --all" __gitcomp_builtin remote_get-url
;; ;;
prune,--*) prune,--*)
__gitcomp "--dry-run" __gitcomp_builtin remote_prune
;; ;;
*) *)
__gitcomp_nl "$(__git_remotes)" __gitcomp_nl "$(__git_remotes)"
...@@ -2720,8 +2461,12 @@ _git_remote () ...@@ -2720,8 +2461,12 @@ _git_remote ()
_git_replace () _git_replace ()
{ {
case "$cur" in case "$cur" in
--format=*)
__gitcomp "short medium long" "" "${cur##--format=}"
return
;;
--*) --*)
__gitcomp "--edit --graft --format= --list --delete" __gitcomp_builtin replace
return return
;; ;;
esac esac
...@@ -2745,26 +2490,42 @@ _git_reset () ...@@ -2745,26 +2490,42 @@ _git_reset ()
case "$cur" in case "$cur" in
--*) --*)
__gitcomp "--merge --mixed --hard --soft --patch --keep" __gitcomp_builtin reset
return return
;; ;;
esac esac
__git_complete_refs __git_complete_refs
} }
_git_restore ()
{
case "$cur" in
--conflict=*)
__gitcomp "diff3 merge" "" "${cur##--conflict=}"
;;
--source=*)
__git_complete_refs --cur="${cur##--source=}"
;;
--*)
__gitcomp_builtin restore
;;
esac
}
__git_revert_inprogress_options="--continue --quit --abort"
_git_revert () _git_revert ()
{ {
__git_find_repo_path __git_find_repo_path
if [ -f "$__git_repo_path"/REVERT_HEAD ]; then if [ -f "$__git_repo_path"/REVERT_HEAD ]; then
__gitcomp "--continue --quit --abort" __gitcomp "$__git_revert_inprogress_options"
return return
fi fi
__git_complete_strategy && return
case "$cur" in case "$cur" in
--*) --*)
__gitcomp " __gitcomp_builtin revert "" \
--edit --mainline --no-edit --no-commit --signoff "$__git_revert_inprogress_options"
--strategy= --strategy-option=
"
return return
;; ;;
esac esac
...@@ -2775,7 +2536,7 @@ _git_rm () ...@@ -2775,7 +2536,7 @@ _git_rm ()
{ {
case "$cur" in case "$cur" in
--*) --*)
__gitcomp "--cached --dry-run --ignore-unmatch --quiet" __gitcomp_builtin rm
return return
;; ;;
esac esac
...@@ -2833,12 +2594,7 @@ _git_show_branch () ...@@ -2833,12 +2594,7 @@ _git_show_branch ()
{ {
case "$cur" in case "$cur" in
--*) --*)
__gitcomp " __gitcomp_builtin show-branch
--all --remotes --topo-order --date-order --current --more=
--list --independent --merge-base --no-name
--color --no-color
--sha1-name --sparse --topics --reflog
"
return return
;; ;;
esac esac
...@@ -2848,13 +2604,21 @@ _git_show_branch () ...@@ -2848,13 +2604,21 @@ _git_show_branch ()
_git_stash () _git_stash ()
{ {
local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked' local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
local subcommands='push save list show apply clear drop pop create branch' local subcommands='push list show apply clear drop pop create branch'
local subcommand="$(__git_find_on_cmdline "$subcommands")" local subcommand="$(__git_find_on_cmdline "$subcommands save")"
if [ -n "$(__git_find_on_cmdline "-p")" ]; then
subcommand="push"
fi
if [ -z "$subcommand" ]; then if [ -z "$subcommand" ]; then
case "$cur" in case "$cur" in
--*) --*)
__gitcomp "$save_opts" __gitcomp "$save_opts"
;; ;;
sa*)
if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
__gitcomp "save"
fi
;;
*) *)
if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then
__gitcomp "$subcommands" __gitcomp "$subcommands"
...@@ -2875,6 +2639,9 @@ _git_stash () ...@@ -2875,6 +2639,9 @@ _git_stash ()
drop,--*) drop,--*)
__gitcomp "--quiet" __gitcomp "--quiet"
;; ;;
list,--*)
__gitcomp "--name-status --oneline --patch-with-stat"
;;
show,--*|branch,--*) show,--*|branch,--*)
;; ;;
branch,*) branch,*)
...@@ -2899,7 +2666,7 @@ _git_submodule () ...@@ -2899,7 +2666,7 @@ _git_submodule ()
{ {
__git_has_doubledash && return __git_has_doubledash && return
local subcommands="add status init deinit update summary foreach sync" local subcommands="add status init deinit update set-branch summary foreach sync absorbgitdirs"
local subcommand="$(__git_find_on_cmdline "$subcommands")" local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then if [ -z "$subcommand" ]; then
case "$cur" in case "$cur" in
...@@ -2930,6 +2697,9 @@ _git_submodule () ...@@ -2930,6 +2697,9 @@ _git_submodule ()
--force --rebase --merge --reference --depth --recursive --jobs --force --rebase --merge --reference --depth --recursive --jobs
" "
;; ;;
set-branch,--*)
__gitcomp "--default --branch"
;;
summary,--*) summary,--*)
__gitcomp "--cached --files --summary-limit" __gitcomp "--cached --files --summary-limit"
;; ;;
...@@ -3045,7 +2815,7 @@ _git_tag () ...@@ -3045,7 +2815,7 @@ _git_tag ()
while [ $c -lt $cword ]; do while [ $c -lt $cword ]; do
i="${words[c]}" i="${words[c]}"
case "$i" in case "$i" in
-d|-v) -d|--delete|-v|--verify)
__gitcomp_direct "$(__git_tags "" "$cur" " ")" __gitcomp_direct "$(__git_tags "" "$cur" " ")"
return return
;; ;;
...@@ -3071,11 +2841,7 @@ _git_tag () ...@@ -3071,11 +2841,7 @@ _git_tag ()
case "$cur" in case "$cur" in
--*) --*)
__gitcomp " __gitcomp_builtin tag
--list --delete --verify --annotate --message --file
--sign --cleanup --local-user --force --column --sort=
--contains --no-contains --points-at --merged --no-merged --create-reflog
"
;; ;;
esac esac
} }
...@@ -3087,23 +2853,26 @@ _git_whatchanged () ...@@ -3087,23 +2853,26 @@ _git_whatchanged ()
_git_worktree () _git_worktree ()
{ {
local subcommands="add list lock prune unlock" local subcommands="add list lock move prune remove unlock"
local subcommand="$(__git_find_on_cmdline "$subcommands")" local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then if [ -z "$subcommand" ]; then
__gitcomp "$subcommands" __gitcomp "$subcommands"
else else
case "$subcommand,$cur" in case "$subcommand,$cur" in
add,--*) add,--*)
__gitcomp "--detach" __gitcomp_builtin worktree_add
;; ;;
list,--*) list,--*)
__gitcomp "--porcelain" __gitcomp_builtin worktree_list
;; ;;
lock,--*) lock,--*)
__gitcomp "--reason" __gitcomp_builtin worktree_lock
;; ;;
prune,--*) prune,--*)
__gitcomp "--dry-run --expire --verbose" __gitcomp_builtin worktree_prune
;;
remove,--*)
__gitcomp "--force"
;; ;;
*) *)
;; ;;
...@@ -3111,6 +2880,52 @@ _git_worktree () ...@@ -3111,6 +2880,52 @@ _git_worktree ()
fi fi
} }
__git_complete_common () {
local command="$1"
case "$cur" in
--*)
__gitcomp_builtin "$command"
;;
esac
}
__git_cmds_with_parseopt_helper=
__git_support_parseopt_helper () {
test -n "$__git_cmds_with_parseopt_helper" ||
__git_cmds_with_parseopt_helper="$(__git --list-cmds=parseopt)"
case " $__git_cmds_with_parseopt_helper " in
*" $1 "*)
return 0
;;
*)
return 1
;;
esac
}
__git_complete_command () {
local command="$1"
local completion_func="_git_${command//-/_}"
if ! declare -f $completion_func >/dev/null 2>/dev/null &&
declare -f _completion_loader >/dev/null 2>/dev/null
then
_completion_loader "git-$command"
fi
if declare -f $completion_func >/dev/null 2>/dev/null
then
$completion_func
return 0
elif __git_support_parseopt_helper "$command"
then
__git_complete_common "$command"
return 0
else
return 1
fi
}
__git_main () __git_main ()
{ {
local i c=1 command __git_dir __git_repo_path local i c=1 command __git_dir __git_repo_path
...@@ -3164,20 +2979,24 @@ __git_main () ...@@ -3164,20 +2979,24 @@ __git_main ()
--help --help
" "
;; ;;
*) __git_compute_porcelain_commands *)
__gitcomp "$__git_porcelain_commands $(__git_aliases)" ;; if test -n "$GIT_TESTING_PORCELAIN_COMMAND_LIST"
then
__gitcomp "$GIT_TESTING_PORCELAIN_COMMAND_LIST"
else
__gitcomp "$(__git --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config)"
fi
;;
esac esac
return return
fi fi
local completion_func="_git_${command//-/_}" __git_complete_command "$command" && return
declare -f $completion_func >/dev/null 2>/dev/null && $completion_func && return
local expansion=$(__git_aliased_command "$command") local expansion=$(__git_aliased_command "$command")
if [ -n "$expansion" ]; then if [ -n "$expansion" ]; then
words[1]=$expansion words[1]=$expansion
completion_func="_git_${expansion//-/_}" __git_complete_command "$expansion"
declare -f $completion_func >/dev/null 2>/dev/null && $completion_func
fi fi
} }
...@@ -3205,7 +3024,10 @@ __gitk_main () ...@@ -3205,7 +3024,10 @@ __gitk_main ()
__git_complete_revlist __git_complete_revlist
} }
if [[ -n ${ZSH_VERSION-} ]]; then if [[ -n ${ZSH_VERSION-} ]] &&
# Don't define these functions when sourced from 'git-completion.zsh',
# it has its own implementations.
[[ -z ${GIT_SOURCING_ZSH_COMPLETION-} ]]; then
echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2 echo "WARNING: this script is deprecated, please see git-completion.zsh" 1>&2
autoload -U +X compinit && compinit autoload -U +X compinit && compinit
...@@ -3254,13 +3076,22 @@ if [[ -n ${ZSH_VERSION-} ]]; then ...@@ -3254,13 +3076,22 @@ if [[ -n ${ZSH_VERSION-} ]]; then
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 () _git ()
...@@ -3315,6 +3146,6 @@ __git_complete gitk __gitk_main ...@@ -3315,6 +3146,6 @@ __git_complete gitk __gitk_main
# when the user has tab-completed the executable name and consequently # when the user has tab-completed the executable name and consequently
# included the '.exe' suffix. # included the '.exe' suffix.
# #
if [[ "$OSTYPE" = cygwin* ]]; then if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
__git_complete git.exe __git_main __git_complete git.exe __git_main
fi fi
...@@ -219,7 +219,7 @@ __git_ps1_show_upstream () ...@@ -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 () ...@@ -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 () ...@@ -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 () ...@@ -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 () ...@@ -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
......
# 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)
```
# 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'
\ No newline at end of file
# 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).
...@@ -5,9 +5,12 @@ ...@@ -5,9 +5,12 @@
# 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
local gcmd local gcmd
...@@ -36,48 +39,45 @@ if [[ -x "${commands[gwhoami]}" ]]; then ...@@ -36,48 +39,45 @@ 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
builtin hash "$@" builtin hash "$@"
__gnu_utils __gnu_utils
else else
builtin hash "$@" builtin hash "$@"
fi fi
} }
function rehash() { function rehash() {
if [[ "$*" =~ "-f" ]]; then if [[ "$*" =~ "-f" ]]; then
builtin rehash "$@" builtin rehash "$@"
__gnu_utils __gnu_utils
else else
builtin rehash "$@" builtin rehash "$@"
fi fi
} }
fi
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.
...@@ -7,7 +7,7 @@ gradle-or-gradlew() { ...@@ -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 () { ...@@ -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
...@@ -9,7 +9,7 @@ You can also use K and J in VI mode or ^P and ^N in EMACS mode for the same. ...@@ -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
......
# hitokoto plugin
Displays a random quote taken from [hitokoto.cn](https://v1.hitokoto.cn/)
Created by [Sinrimin](https://github.com/sinrimin)
## Usage
Add the plugin to the plugins array in your zshrc file and restart zsh:
```zsh
plugins=(... hitokoto)
```
Then, run `hitokoto` to get a new random quote.
if ! (( $+commands[curl] )); then
echo "hitokoto plugin needs curl to work" >&2
return
fi
function hitokoto {
emulate -L zsh
Q=$(curl -s --connect-timeout 2 "https://v1.hitokoto.cn" | jq -j '.hitokoto+"\t"+.from')
TXT=$(echo "$Q" | awk -F '\t' '{print $1}')
WHO=$(echo "$Q" | awk -F '\t' '{print $2}')
[[ -n "$WHO" && -n "$TXT" ]] && print -P "%F{3}${WHO}%f: “%F{5}${TXT}%f”"
}
# Homestead basic command completion # Homestead basic command completion
_homestead_get_command_list () { _homestead_get_command_list () {
homestead --no-ansi | sed "1,/Available commands/d" | awk '/^ +[a-z]+/ { print $1 }' homestead --no-ansi | sed -E "1,/(Available|Common) commands/d" | awk '/^ +[a-z]+/ { print $1 }'
} }
_homestead () { _homestead () {
......
# Ionic plugin
This plugin adds completion for the [Ionic CLI](https://ionicframework.com/docs/cli),
as well as some aliases for common Ionic commands.
To use it, add `ionic` to the plugins array in your zshrc file:
```zsh
plugins=(... ionic)
```
## Aliases
| Alias | Command | Description |
|-------|--------------------------------------|------------------------------------------------------------------|
| iv | `ionic --version` | Check Ionic version |
| ih | `ionic --help` | Ionic help command |
| ist | `ionic start` | Create a new project |
| ii | `ionic info` | Print system/environment info |
| is | `ionic serve` | Start a local dev server for app dev/testing |
| icba | `ionic cordova build android` | Build web assets and prepare app for android platform targets |
| icbi | `ionic cordova build ios` | Build web assets and prepare app for ios platform targets |
| icra | `ionic cordova run android` | Run an Ionic project on a connected android device |
| icri | `ionic cordova run ios` | Run an Ionic project on a connected ios device |
| icrsa | `ionic cordova resources android` | Automatically create icon and splash screen resources for android|
| icrsi | `ionic cordova resources ios` | Automatically create icon and splash screen resources for ios |
| icpaa | `ionic cordova platform add android` | Add Cordova android platform targets |
| icpai | `ionic cordova platform add ios` | Add Cordova ios platform targets |
| icpra | `ionic cordova platform rm android` | Remove Cordova platform targets |
| icpri | `ionic cordova platform rm ios` | Remove Cordova platform targets |
alias iv="ionic --version"
alias ih="ionic --help"
alias ist="ionic start"
alias ii="ionic info"
alias is="ionic serve"
alias icba="ionic cordova build android"
alias icbi="ionic cordova build ios"
alias icra="ionic cordova run android"
alias icri="ionic cordova run ios"
alias icrsa="ionic cordova resources android"
alias icrsi="ionic cordova resources ios"
alias icpaa="ionic cordova platform add android"
alias icpai="ionic cordova platform add ios"
alias icpra="ionic cordova platform rm android"
alias icpri="ionic cordova platform rm ios"
...@@ -15,7 +15,7 @@ if [[ $FOUND_JENV -eq 0 ]]; then ...@@ -15,7 +15,7 @@ if [[ $FOUND_JENV -eq 0 ]]; then
fi fi
if [[ $FOUND_JENV -eq 1 ]]; then if [[ $FOUND_JENV -eq 1 ]]; then
export PATH="${jenvdir}/bin:$PATH" (( $+commands[jenv] )) || export PATH="${jenvdir}/bin:$PATH"
eval "$(jenv init - zsh)" eval "$(jenv init - zsh)"
function jenv_prompt_info() { jenv version-name 2>/dev/null } function jenv_prompt_info() { jenv version-name 2>/dev/null }
......
# JFrog CLI
This plugin provides completion for [JFrog CLI](https://github.com/jfrog/jfrog-cli).
JFrog CLI provides a simple interface that automates access to [Artifactory](https://jfrog.com/artifactory), [Xray](https://jfrog.com/xray), [Bintray](https://jfrog.com/bintray) and [Mission Control](https://jfrog.com/mission-control) through their respective REST APIs.
To use it, add `jfrog` to the plugins array in your zshrc file:
```zsh
plugins=(... jfrog)
```
_jfrog() {
local -a opts
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}")
_describe 'values' opts
if [[ $compstate[nmatches] -eq 0 && $words[$CURRENT] != -* ]]; then
_files
fi
}
compdef _jfrog jfrog
\ No newline at end of file
## JHBuild # JHBuild
This plugin adds some [JHBuild](https://developer.gnome.org/jhbuild/) aliases.
To use it, add `jhbuild` to the plugins array of your zshrc file:
```zsh
plugins=(... jhbuild)
```
**Maintainer:** [Miguel Vaello](https://github.com/miguxbe) **Maintainer:** [Miguel Vaello](https://github.com/miguxbe)
This plugin adds some jhbuild aliases and increase the completion function provided by zsh. ## Aliases
| Alias | Command |
|---------|---------------------------|
| `jh` | `jhbuild` |
| `jhb` | `jhbuild build` |
| `jhbo` | `jhbuild buildone` |
| `jhckb` | `jhbuild checkbranches` |
| `jhckm` | `jhbuild checkmodulesets` |
| `jhi` | `jhbuild info` |
| `jhl` | `jhbuild list` |
| `jhc` | `jhbuild clean` |
| `jhco` | `jhbuild cleanone` |
| `jhm` | `jhbuild make` |
| `jhr` | `jhbuild run` |
| `jhrd` | `jhbuild rdepends` |
| `jhsd` | `jhbuild sysdeps` |
| `jhu` | `jhbuild update` |
| `jhuo` | `jhbuild updateone` |
| `jhun` | `jhbuild uninstall` |
| `jhsh` | `jhbuild shell` |
| `jht` | `jhbuild tinderbox` |
# Aliases # JHBuild Aliases
#
# Base
alias jh='jhbuild' alias jh='jhbuild'
# Build # Build
alias jhb='jhbuild build' alias jhb='jhbuild build'
...@@ -7,12 +8,14 @@ alias jhbo='jhbuild buildone' ...@@ -7,12 +8,14 @@ alias jhbo='jhbuild buildone'
# Checks # Checks
alias jhckb='jhbuild checkbranches' alias jhckb='jhbuild checkbranches'
alias jhckm='jhbuild checkmodulesets' alias jhckm='jhbuild checkmodulesets'
# Info & list # Info & List
alias jhi='jhbuild info' alias jhi='jhbuild info'
alias jhl='jhbuild list' alias jhl='jhbuild list'
# Clean # Clean
alias jhc='jhbuild clean' alias jhc='jhbuild clean'
alias jhco='jhbuild cleanone' alias jhco='jhbuild cleanone'
# Make
alias jhm='jhbuild make'
# Run # Run
alias jhr='jhbuild run' alias jhr='jhbuild run'
# Depends # Depends
...@@ -23,6 +26,7 @@ alias jhu='jhbuild update' ...@@ -23,6 +26,7 @@ alias jhu='jhbuild update'
alias jhuo='jhbuild updateone' alias jhuo='jhbuild updateone'
# Uninstall # Uninstall
alias jhun='jhbuild uninstall' alias jhun='jhbuild uninstall'
# Shell
alias jhsh='jhbuild shell'
# Tinderbox
alias jht='jhbuild tinderbox'
# JRuby plugin
This plugin adds aliases for [JRuby](https://www.jruby.org/).
To use it, add `jruby` to the plugins array in your zshrc file:
```zsh
plugins=(... jruby)
```
## Requirements
This plugin assumes you already have jruby installed and available in your [path](https://www.jruby.org/getting-started).
## Aliases
| Alias | Command |
| ------------ | ---------------------------------------------------------------- |
| `jrspec` | `jruby --debug -S rspec --debug` |
| `jprofile` | `jruby --profile.api -S rspec` |
| `jexec` | `jruby -S` |
...@@ -11,9 +11,10 @@ if [[ $(whence node) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METH ...@@ -11,9 +11,10 @@ if [[ $(whence node) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METH
alias urlencode_json='xargs -0 node -e "console.log(encodeURIComponent(process.argv[1]))"' alias urlencode_json='xargs -0 node -e "console.log(encodeURIComponent(process.argv[1]))"'
alias urldecode_json='xargs -0 node -e "console.log(decodeURIComponent(process.argv[1]))"' alias urldecode_json='xargs -0 node -e "console.log(decodeURIComponent(process.argv[1]))"'
elif [[ $(whence python) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METHOD" = "xpython" ) ]]; then elif [[ $(whence python) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METHOD" = "xpython" ) ]]; then
alias pp_json='python -mjson.tool' alias pp_json='python -c "import sys; del sys.path[0]; import runpy; runpy._run_module_as_main(\"json.tool\")"'
alias is_json='python -c " alias is_json='python -c "
import json, sys; import sys; del sys.path[0];
import json;
try: try:
json.loads(sys.stdin.read()) json.loads(sys.stdin.read())
except ValueError, e: except ValueError, e:
...@@ -22,11 +23,13 @@ else: ...@@ -22,11 +23,13 @@ else:
print True print True
sys.exit(0)"' sys.exit(0)"'
alias urlencode_json='python -c " alias urlencode_json='python -c "
import urllib, json, sys; import sys; del sys.path[0];
import urllib, json;
print urllib.quote_plus(sys.stdin.read()) print urllib.quote_plus(sys.stdin.read())
sys.exit(0)"' sys.exit(0)"'
alias urldecode_json='python -c " alias urldecode_json='python -c "
import urllib, json, sys; import sys; del sys.path[0];
import urllib, json;
print urllib.unquote_plus(sys.stdin.read()) print urllib.unquote_plus(sys.stdin.read())
sys.exit(0)"' sys.exit(0)"'
elif [[ $(whence ruby) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METHOD" = "xruby" ) ]]; then elif [[ $(whence ruby) != "" && ( "x$JSONTOOLS_METHOD" = "x" || "x$JSONTOOLS_METHOD" = "xruby" ) ]]; then
......
...@@ -17,3 +17,15 @@ plugins=(... jump) ...@@ -17,3 +17,15 @@ plugins=(... jump)
| `mark [mark-name]` | Create a mark with the given name or with the name of the current directory if none is provided | | `mark [mark-name]` | Create a mark with the given name or with the name of the current directory if none is provided |
| `unmark <mark-name>` | Remove the given mark | | `unmark <mark-name>` | Remove the given mark |
| `marks` | List the existing marks and the directories they point to | | `marks` | List the existing marks and the directories they point to |
## Key bindings
Pressing `CTRL`+`G` substitutes the written mark name for the full path of the mark.
For example, with a mark named `mymark` pointing to `/path/to/my/mark`:
```zsh
$ cp /tmp/file mymark<C-g>
```
will become:
```zsh
$ cp /tmp/file /path/to/my/mark
```
...@@ -9,33 +9,34 @@ ...@@ -9,33 +9,34 @@
export MARKPATH=$HOME/.marks export MARKPATH=$HOME/.marks
jump() { jump() {
cd -P "$MARKPATH/$1" 2>/dev/null || {echo "No such mark: $1"; return 1} builtin cd -P "$MARKPATH/$1" 2>/dev/null || {echo "No such mark: $1"; return 1}
} }
mark() { mark() {
if [[ ( $# == 0 ) || ( "$1" == "." ) ]]; then if [[ $# -eq 0 || "$1" = "." ]]; then
MARK=$(basename "$PWD") MARK=${PWD:t}
else else
MARK="$1" MARK="$1"
fi fi
if read -q \?"Mark $PWD as ${MARK}? (y/n) "; then if read -q "?Mark $PWD as ${MARK}? (y/n) "; then
mkdir -p "$MARKPATH"; ln -sfn "$PWD" "$MARKPATH/$MARK" command mkdir -p "$MARKPATH"
command ln -sfn "$PWD" "$MARKPATH/$MARK"
fi fi
} }
unmark() { unmark() {
rm -i "$MARKPATH/$1" LANG= command rm -i "$MARKPATH/$1"
} }
marks() { marks() {
local max=0 local link max=0
for link in $MARKPATH/*(@); do for link in $MARKPATH/{,.}*(@N); do
if [[ ${#link:t} -gt $max ]]; then if [[ ${#link:t} -gt $max ]]; then
max=${#link:t} max=${#link:t}
fi fi
done done
local printf_markname_template="$(printf -- "%%%us " "$max")" local printf_markname_template="$(printf -- "%%%us " "$max")"
for link in $MARKPATH/*(@); do for link in $MARKPATH/{,.}*(@N); do
local markname="$fg[cyan]${link:t}$reset_color" local markname="$fg[cyan]${link:t}$reset_color"
local markpath="$fg[blue]$(readlink $link)$reset_color" local markpath="$fg[blue]$(readlink $link)$reset_color"
printf -- "$printf_markname_template" "$markname" printf -- "$printf_markname_template" "$markname"
...@@ -44,21 +45,15 @@ marks() { ...@@ -44,21 +45,15 @@ marks() {
} }
_completemarks() { _completemarks() {
if [[ $(ls "${MARKPATH}" | wc -l) -gt 1 ]]; then reply=("${MARKPATH}"/{,.}*(@N:t))
reply=($(ls $MARKPATH/**/*(-) | grep : | sed -E 's/(.*)\/([_a-zA-Z0-9\.\-]*):$/\2/g'))
else
if readlink -e "${MARKPATH}"/* &>/dev/null; then
reply=($(ls "${MARKPATH}"))
fi
fi
} }
compctl -K _completemarks jump compctl -K _completemarks jump
compctl -K _completemarks unmark compctl -K _completemarks unmark
_mark_expansion() { _mark_expansion() {
setopt extendedglob setopt localoptions extendedglob
autoload -U modify-current-argument autoload -U modify-current-argument
modify-current-argument '$(readlink "$MARKPATH/$ARG")' modify-current-argument '$(readlink "$MARKPATH/$ARG" || echo "$ARG")'
} }
zle -N _mark_expansion zle -N _mark_expansion
bindkey "^g" _mark_expansion bindkey "^g" _mark_expansion
...@@ -15,7 +15,7 @@ function _start_agent() { ...@@ -15,7 +15,7 @@ function _start_agent() {
zstyle -a :omz:plugins:keychain options options zstyle -a :omz:plugins:keychain options options
# start keychain... # start keychain...
keychain ${^options:-} --agents ${agents:-gpg} ${^identities} keychain ${^options:-} --agents ${agents:-gpg} ${^identities} --host $SHORT_HOST
# Get the filenames to store/lookup the environment from # Get the filenames to store/lookup the environment from
_keychain_env_sh="$HOME/.keychain/$SHORT_HOST-sh" _keychain_env_sh="$HOME/.keychain/$SHORT_HOST-sh"
......
# knife plugin
This plugin adds completion for [knife](https://docs.chef.io/knife.html), a command-line tool
to interact with [Chef](https://chef.io), a platform to automate and manage infrastructure via
code.
To use it, add `knife` to the plugins array in your zshrc file:
```zsh
plugins=(... knife)
```
## Options
- `KNIFE_RELATIVE_PATH`: if set to `true`, the completion script will look for local cookbooks
under the `cookbooks` folder in the chef root directory. It has preference over the other two
options below. **Default:** empty.
- `KNIFE_COOKBOOK_PATH`: if set, it points to the folder that contains local cookbooks, for
example: `/path/to/my/chef/cookbooks`. **Default:** `cookbook_path` field in `knife.rb`
(see below).
- `KNIFE_CONF_PATH`: variable pointing to the `knife.rb` configuration file, for example
`/path/to/my/.chef/knife.rb`. Only used if `$KNIFE_COOKBOOK_PATH` isn't set. If it exists,
`$PWD/.chef/knife.rb` is used instead. Otherwise, if it's set, its value is used.
**Default**: `$HOME/.chef/knife.rb`.
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
# Read around where these are used for more detail. # Read around where these are used for more detail.
# These flags should be available everywhere according to man knife # These flags should be available everywhere according to man knife
knife_general_flags=( --help --server-url --key --config --editor --format --log_level --logfile --no-editor --user --print-after --version --yes ) knife_general_flags=(--help --server-url --key --config --editor --format --log_level --logfile --no-editor --user --print-after --version --yes)
# knife has a very special syntax, some example calls are: # knife has a very special syntax, some example calls are:
# knife status # knife status
...@@ -25,8 +25,8 @@ _knife() { ...@@ -25,8 +25,8 @@ _knife() {
typeset -A opt_args typeset -A opt_args
cloudproviders=(bluebox ec2 rackspace slicehost terremark) cloudproviders=(bluebox ec2 rackspace slicehost terremark)
_arguments \ _arguments \
'1: :->knifecmd'\ '1: :->knifecmd' \
'2: :->knifesubcmd'\ '2: :->knifesubcmd' \
'3: :->knifesubcmd2' \ '3: :->knifesubcmd2' \
'4: :->knifesubcmd3' \ '4: :->knifesubcmd3' \
'5: :->knifesubcmd4' \ '5: :->knifesubcmd4' \
...@@ -38,7 +38,7 @@ _knife() { ...@@ -38,7 +38,7 @@ _knife() {
;; ;;
knifesubcmd) knifesubcmd)
case $words[2] in case $words[2] in
(bluebox|ec2|rackspace|slicehost|terremark) bluebox|ec2|rackspace|slicehost|terremark)
compadd "$@" server images compadd "$@" server images
;; ;;
client) client)
...@@ -76,6 +76,7 @@ _knife() { ...@@ -76,6 +76,7 @@ _knife() {
;; ;;
*) *)
_arguments '2:Subsubcommands:($(_knife_options1))' _arguments '2:Subsubcommands:($(_knife_options1))'
;;
esac esac
;; ;;
knifesubcmd2) knifesubcmd2)
...@@ -89,10 +90,10 @@ _knife() { ...@@ -89,10 +90,10 @@ _knife() {
site) site)
compadd "$@" vendor show share search download list unshare compadd "$@" vendor show share search download list unshare
;; ;;
(show|delete|edit) show|delete|edit)
_arguments '3:Subsubcommands:($(_chef_$words[2]s_remote))' _arguments '3:Subsubcommands:($(_chef_$words[2]s_remote))'
;; ;;
(upload|test) upload|test)
_arguments '3:Subsubcommands:($(_chef_$words[2]s_local) --all)' _arguments '3:Subsubcommands:($(_chef_$words[2]s_local) --all)'
;; ;;
list) list)
...@@ -103,6 +104,7 @@ _knife() { ...@@ -103,6 +104,7 @@ _knife() {
;; ;;
*) *)
_arguments '3:Subsubcommands:($(_knife_options2))' _arguments '3:Subsubcommands:($(_knife_options2))'
;;
esac esac
;; ;;
knifesubcmd3) knifesubcmd3)
...@@ -113,12 +115,14 @@ _knife() { ...@@ -113,12 +115,14 @@ _knife() {
versioncomp=1 versioncomp=1
_arguments '4:Cookbookversions:($(_cookbook_versions) latest)' _arguments '4:Cookbookversions:($(_cookbook_versions) latest)'
;; ;;
(node|client|role) node|client|role)
compadd "$@" --attribute compadd "$@" --attribute
;;
esac esac
;;
esac esac
case $words[4] in case $words[4] in
(show|edit) show|edit)
_arguments '4:Subsubsubcommands:($(_chef_$words[2]_$words[3]s_remote))' _arguments '4:Subsubsubcommands:($(_chef_$words[2]_$words[3]s_remote))'
;; ;;
file) file)
...@@ -134,6 +138,7 @@ _knife() { ...@@ -134,6 +138,7 @@ _knife() {
;; ;;
*) *)
_arguments '*:Subsubcommands:($(_knife_options3))' _arguments '*:Subsubcommands:($(_knife_options3))'
;;
esac esac
;; ;;
list) list)
...@@ -141,17 +146,18 @@ _knife() { ...@@ -141,17 +146,18 @@ _knife() {
;; ;;
*) *)
_arguments '*:Subsubcommands:($(_knife_options3))' _arguments '*:Subsubcommands:($(_knife_options3))'
;;
esac esac
;; ;;
knifesubcmd4) knifesubcmd4)
if (( versioncomp > 0 )); then if ((versioncomp > 0)); then
compadd "$@" attributes definitions files libraries providers recipes resources templates compadd "$@" attributes definitions files libraries providers recipes resources templates
else else
case $words[5] in case $words[5] in
file) file)
_arguments '*:directory:_path_files -/ -W "$(_chef_root)/data_bags" -qS \ ' _arguments '*:directory:_path_files -/ -W "$(_chef_root)/data_bags" -qS \ '
;; ;;
*) _arguments '*:Subsubcommands:($(_knife_options2))' *) _arguments '*:Subsubcommands:($(_knife_options2))' ;;
esac esac
fi fi
;; ;;
...@@ -162,21 +168,23 @@ _knife() { ...@@ -162,21 +168,23 @@ _knife() {
;; ;;
*) *)
_arguments '*:Subsubcommands:($(_knife_options3))' _arguments '*:Subsubcommands:($(_knife_options3))'
;;
esac esac
;;
esac esac
} }
# Helper functions to provide the argument completion for several depths of commands # Helper functions to provide the argument completion for several depths of commands
_knife_options1() { _knife_options1() {
( for line in $( knife $words[2] --help | grep -v "^knife" ); do echo $line | grep "\-\-"; done ) (for line in $(knife $words[2] --help | grep -v "^knife"); do echo $line | grep "\-\-"; done)
} }
_knife_options2() { _knife_options2() {
( for line in $( knife $words[2] $words[3] --help | grep -v "^knife" ); do echo $line | grep "\-\-"; done ) (for line in $(knife $words[2] $words[3] --help | grep -v "^knife"); do echo $line | grep "\-\-"; done)
} }
_knife_options3() { _knife_options3() {
( for line in $( knife $words[2] $words[3] $words[4] --help | grep -v "^knife" ); do echo $line | grep "\-\-"; done ) (for line in $(knife $words[2] $words[3] $words[4] --help | grep -v "^knife"); do echo $line | grep "\-\-"; done)
} }
# The chef_x_remote functions use knife to get a list of objects of type x on the server # The chef_x_remote functions use knife to get a list of objects of type x on the server
...@@ -217,7 +225,7 @@ _chef_cookbooks_local() { ...@@ -217,7 +225,7 @@ _chef_cookbooks_local() {
if [ -f ./.chef/knife.rb ]; then if [ -f ./.chef/knife.rb ]; then
knife_rb="./.chef/knife.rb" knife_rb="./.chef/knife.rb"
fi fi
local cookbook_path=${KNIFE_COOKBOOK_PATH:-$(grep cookbook_path $knife_rb | awk 'BEGIN {FS = "[" }; {print $2}' | sed 's/\,//g' | sed "s/'//g" | sed 's/\(.*\)]/\1/' )} local cookbook_path=${KNIFE_COOKBOOK_PATH:-$(grep cookbook_path $knife_rb | awk 'BEGIN {FS = "[" }; {print $2}' | sed 's/\,//g' | sed "s/'//g" | sed 's/\(.*\)]/\1/')}
fi fi
(for i in $cookbook_path; do ls $i; done) (for i in $cookbook_path; do ls $i; done)
} }
...@@ -229,10 +237,9 @@ _cookbook_versions() { ...@@ -229,10 +237,9 @@ _cookbook_versions() {
# Searches up from current directory to find the closest folder that has a .chef folder # Searches up from current directory to find the closest folder that has a .chef folder
# Useful for the knife upload/from file commands # Useful for the knife upload/from file commands
_chef_root () { _chef_root() {
directory="$PWD" directory="$PWD"
while [ $directory != '/' ] while [ $directory != '/' ]; do
do
test -e "$directory/.chef" && echo "$directory" && return test -e "$directory/.chef" && echo "$directory" && return
directory="${directory:h}" directory="${directory:h}"
done done
......
# knife_ssh plugin
This plugin adds a `knife_ssh` function as well as completion for it, to allow
connecting via ssh to servers managed with [Chef](https://www.chef.io/).
To use it, add `knife_ssh` to the plugins array in your zshrc file:
```zsh
plugins=(... knife_ssh)
```
The plugin creates a cache of the Chef node list via `knife`, and stores it
in `$HOME/.knife_comp~`, when first triggering knife_ssh completion.
**Requirements:** `knife` has to be installed.
function knife_ssh() { function knife_ssh() {
grep -q $1 ~/.knife_comp~ 2> /dev/null || rm -f ~/.knife_comp~; grep -q $1 ~/.knife_comp~ 2> /dev/null || rm -f ~/.knife_comp~
ssh $(knife node show $1 | awk '/IP:/{print $2}') ssh $(knife node show $1 | awk '/IP:/{print $2}')
} }
_knife_ssh() { _knife_ssh() {
if hash knife 2>/dev/null; then if hash knife 2>/dev/null; then
if [[ ! -f ~/.knife_comp~ ]]; then if [[ ! -f ~/.knife_comp~ ]]; then
echo "\nGenerating ~/.knife_comp~..." >/dev/stderr echo "\nGenerating ~/.knife_comp~..." >&2
knife node list > ~/.knife_comp~ knife node list > ~/.knife_comp~
fi fi
compadd $(<~/.knife_comp~) compadd $(< ~/.knife_comp~)
else else
echo "Could not find knife" > /dev/stderr; echo "Could not find knife" >&2
fi fi
} }
......
...@@ -53,10 +53,13 @@ plugins=( ...@@ -53,10 +53,13 @@ plugins=(
kube-ps1 kube-ps1
) )
# After the "source Oh My Zsh" line
PROMPT=$PROMPT'$(kube_ps1) ' PROMPT=$PROMPT'$(kube_ps1) '
# Or in double quotes, don't forget to escape
PROMPT=$PROMPT"\$(kube_ps1) "
``` ```
Note: the `PROMPT` example above was tested with the theme `robbyrussell` Note: The `PROMPT` example above was tested with the theme `robbyrussell`.
## Enabling / Disabling on the current shell ## Enabling / Disabling on the current shell
......
...@@ -14,7 +14,7 @@ fi ...@@ -14,7 +14,7 @@ fi
alias k=kubectl alias k=kubectl
# Execute a kubectl command against all namespaces # Execute a kubectl command against all namespaces
alias kca='f(){ kubectl "$@" --all-namespaces; unset -f f; }; f' alias kca='_kca(){ kubectl "$@" --all-namespaces; unset -f _kca; }; _kca'
# Apply a YML file # Apply a YML file
alias kaf='kubectl apply -f' alias kaf='kubectl apply -f'
...@@ -37,6 +37,7 @@ alias kdelf='kubectl delete -f' ...@@ -37,6 +37,7 @@ alias kdelf='kubectl delete -f'
# Pod management. # Pod management.
alias kgp='kubectl get pods' alias kgp='kubectl get pods'
alias kgpa='kubectl get pods --all-namespaces'
alias kgpw='kgp --watch' alias kgpw='kgp --watch'
alias kgpwide='kgp -o wide' alias kgpwide='kgp -o wide'
alias kep='kubectl edit pods' alias kep='kubectl edit pods'
...@@ -48,6 +49,7 @@ alias kgpl='kgp -l' ...@@ -48,6 +49,7 @@ alias kgpl='kgp -l'
# Service management. # Service management.
alias kgs='kubectl get svc' alias kgs='kubectl get svc'
alias kgsa='kubectl get svc --all-namespaces'
alias kgsw='kgs --watch' alias kgsw='kgs --watch'
alias kgswide='kgs -o wide' alias kgswide='kgs -o wide'
alias kes='kubectl edit svc' alias kes='kubectl edit svc'
...@@ -56,6 +58,7 @@ alias kdels='kubectl delete svc' ...@@ -56,6 +58,7 @@ alias kdels='kubectl delete svc'
# Ingress management # Ingress management
alias kgi='kubectl get ingress' alias kgi='kubectl get ingress'
alias kgia='kubectl get ingress --all-namespaces'
alias kei='kubectl edit ingress' alias kei='kubectl edit ingress'
alias kdi='kubectl describe ingress' alias kdi='kubectl describe ingress'
alias kdeli='kubectl delete ingress' alias kdeli='kubectl delete ingress'
...@@ -69,17 +72,20 @@ alias kcn='kubectl config set-context $(kubectl config current-context) --namesp ...@@ -69,17 +72,20 @@ alias kcn='kubectl config set-context $(kubectl config current-context) --namesp
# ConfigMap management # ConfigMap management
alias kgcm='kubectl get configmaps' alias kgcm='kubectl get configmaps'
alias kgcma='kubectl get configmaps --all-namespaces'
alias kecm='kubectl edit configmap' alias kecm='kubectl edit configmap'
alias kdcm='kubectl describe configmap' alias kdcm='kubectl describe configmap'
alias kdelcm='kubectl delete configmap' alias kdelcm='kubectl delete configmap'
# Secret management # Secret management
alias kgsec='kubectl get secret' alias kgsec='kubectl get secret'
alias kgseca='kubectl get secret --all-namespaces'
alias kdsec='kubectl describe secret' alias kdsec='kubectl describe secret'
alias kdelsec='kubectl delete secret' alias kdelsec='kubectl delete secret'
# Deployment management. # Deployment management.
alias kgd='kubectl get deployment' alias kgd='kubectl get deployment'
alias kgda='kubectl get deployment --all-namespaces'
alias kgdw='kgd --watch' alias kgdw='kgd --watch'
alias kgdwide='kgd -o wide' alias kgdwide='kgd -o wide'
alias ked='kubectl edit deployment' alias ked='kubectl edit deployment'
...@@ -98,6 +104,7 @@ alias kru='kubectl rollout undo' ...@@ -98,6 +104,7 @@ alias kru='kubectl rollout undo'
# Statefulset management. # Statefulset management.
alias kgss='kubectl get statefulset' alias kgss='kubectl get statefulset'
alias kgssa='kubectl get statefulset --all-namespaces'
alias kgssw='kgss --watch' alias kgssw='kgss --watch'
alias kgsswide='kgss -o wide' alias kgsswide='kgss -o wide'
alias kess='kubectl edit statefulset' alias kess='kubectl edit statefulset'
...@@ -115,7 +122,13 @@ alias kgaa='kubectl get all --all-namespaces' ...@@ -115,7 +122,13 @@ alias kgaa='kubectl get all --all-namespaces'
# Logs # Logs
alias kl='kubectl logs' alias kl='kubectl logs'
alias kl1h='kubectl logs --since 1h'
alias kl1m='kubectl logs --since 1m'
alias kl1s='kubectl logs --since 1s'
alias klf='kubectl logs -f' alias klf='kubectl logs -f'
alias klf1h='kubectl logs --since 1h -f'
alias klf1m='kubectl logs --since 1m -f'
alias klf1s='kubectl logs --since 1s -f'
# File copy # File copy
alias kcp='kubectl cp' alias kcp='kubectl cp'
...@@ -128,6 +141,7 @@ alias kdelno='kubectl delete node' ...@@ -128,6 +141,7 @@ alias kdelno='kubectl delete node'
# PVC management. # PVC management.
alias kgpvc='kubectl get pvc' alias kgpvc='kubectl get pvc'
alias kgpvca='kubectl get pvc --all-namespaces'
alias kgpvcw='kgpvc --watch' alias kgpvcw='kgpvc --watch'
alias kepvc='kubectl edit pvc' alias kepvc='kubectl edit pvc'
alias kdpvc='kubectl describe pvc' alias kdpvc='kubectl describe pvc'
......
...@@ -29,6 +29,12 @@ plugins=(... laravel) ...@@ -29,6 +29,12 @@ plugins=(... laravel)
| `pamc` | `php artisan make:controller` | | `pamc` | `php artisan make:controller` |
| `pams` | `php artisan make:seeder` | | `pams` | `php artisan make:seeder` |
| `pamt` | `php artisan make:test` | | `pamt` | `php artisan make:test` |
| `pamfa` | `php artisan make:factory` |
| `pamp` | `php artisan make:policy` |
| `pame` | `php artisan make:event` |
| `pamj` | `php artisan make:job` |
| `paml` | `php artisan make:listener` |
| `pamn` | `php artisan make:notification` |
## Clears ## Clears
...@@ -38,3 +44,14 @@ plugins=(... laravel) ...@@ -38,3 +44,14 @@ plugins=(... laravel)
| `pacoc` | `php artisan config:clear` | | `pacoc` | `php artisan config:clear` |
| `pavic` | `php artisan view:clear` | | `pavic` | `php artisan view:clear` |
| `paroc` | `php artisan route:clear` | | `paroc` | `php artisan route:clear` |
## Queues
| Alias | Description |
|:-:|:-:|
| `paqf` | `php artisan queue:failed` |
| `paqft` | `php artisan queue:failed-table` |
| `paql` | `php artisan queue:listen` |
| `paqr` | `php artisan queue:retry` |
| `paqt` | `php artisan queue:table` |
| `paqw` | `php artisan queue:work` |
...@@ -17,6 +17,13 @@ alias pamm='php artisan make:model' ...@@ -17,6 +17,13 @@ alias pamm='php artisan make:model'
alias pamc='php artisan make:controller' alias pamc='php artisan make:controller'
alias pams='php artisan make:seeder' alias pams='php artisan make:seeder'
alias pamt='php artisan make:test' alias pamt='php artisan make:test'
alias pamfa='php artisan make:factory'
alias pamp='php artisan make:policy'
alias pame='php artisan make:event'
alias pamj='php artisan make:job'
alias paml='php artisan make:listener'
alias pamn='php artisan make:notification'
alias pampp='php artisan make:provider'
# Clears # Clears
...@@ -24,3 +31,11 @@ alias pacac='php artisan cache:clear' ...@@ -24,3 +31,11 @@ alias pacac='php artisan cache:clear'
alias pacoc='php artisan config:clear' alias pacoc='php artisan config:clear'
alias pavic='php artisan view:clear' alias pavic='php artisan view:clear'
alias paroc='php artisan route:clear' alias paroc='php artisan route:clear'
# queues
alias paqf='php artisan queue:failed'
alias paqft='php artisan queue:failed-table'
alias paql='php artisan queue:listen'
alias paqr='php artisan queue:retry'
alias paqt='php artisan queue:table'
alias paqw='php artisan queue:work'
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
typeset -g ZSH_LAST_WORKING_DIRECTORY typeset -g ZSH_LAST_WORKING_DIRECTORY
# Updates the last directory once directory is changed # Updates the last directory once directory is changed
chpwd_functions+=(chpwd_last_working_dir) autoload -U add-zsh-hook
add-zsh-hook chpwd chpwd_last_working_dir
chpwd_last_working_dir() { chpwd_last_working_dir() {
if [ "$ZSH_SUBSHELL" = 0 ]; then if [ "$ZSH_SUBSHELL" = 0 ]; then
local cache_file="$ZSH_CACHE_DIR/last-working-dir" local cache_file="$ZSH_CACHE_DIR/last-working-dir"
......
# Leiningen plugin
This plugin adds completions for the [Leiningen](https://leiningen.org/) Clojure build tool.
To use it, add `lein` to the plugins array in your zshrc file:
```zsh
plugins=(... lein)
```
...@@ -13,10 +13,10 @@ Plugin for adding catspeak aliases, because why not ...@@ -13,10 +13,10 @@ Plugin for adding catspeak aliases, because why not
) )
``` ```
2. Reload the source file or restart your Terminal session: 2. Restart your terminal session or restart the shell:
```console ```console
$ source ~/.zshrc $ exec zsh
$ $
``` ```
...@@ -61,7 +61,7 @@ Plugin for adding catspeak aliases, because why not ...@@ -61,7 +61,7 @@ Plugin for adding catspeak aliases, because why not
| `violenz` | `git rebase` | | `violenz` | `git rebase` |
| `visible` | `echo` | | `visible` | `echo` |
| `wtf` | `dmesg` | | `wtf` | `dmesg` |
| `yolo` | `git commit -m "$(curl -s https://whatthecommit.com/index.txt)"` | | `yolo` | `git commit -m "$(curl -s http://whatthecommit.com/index.txt)"` |
## Usage Examples ## Usage Examples
...@@ -78,6 +78,6 @@ nowai u=r,go= some.file ...@@ -78,6 +78,6 @@ nowai u=r,go= some.file
# ssh root@catserver.org # ssh root@catserver.org
pwned root@catserver.org pwned root@catserver.org
# git commit -m "$(curl -s https://whatthecommit.com/index.txt)" # git commit -m "$(curl -s http://whatthecommit.com/index.txt)"
yolo yolo
``` ```
...@@ -45,7 +45,7 @@ alias bringz='git pull' ...@@ -45,7 +45,7 @@ alias bringz='git pull'
alias chicken='git add' alias chicken='git add'
alias oanward='git commit -m' alias oanward='git commit -m'
alias ooanward='git commit -am' alias ooanward='git commit -am'
alias yolo='git commit -m "$(curl -s https://whatthecommit.com/index.txt)"' alias yolo='git commit -m "$(curl -s http://whatthecommit.com/index.txt)"'
alias letcat='git checkout' alias letcat='git checkout'
alias violenz='git rebase' alias violenz='git rebase'
...@@ -41,6 +41,8 @@ subcmds=( ...@@ -41,6 +41,8 @@ subcmds=(
'patch' 'patch'
'pkg' 'pkg'
'provides' 'provides'
'rdependents'
'rdeps'
'rpmpackage' 'rpmpackage'
'search' 'search'
'selfupdate' 'selfupdate'
......
## Magic Enter plugin
This plugin makes your enter key magical, by binding commonly used commands to it.
To use it, add `magic-enter` to the plugins array in your zshrc file. You can set the
commands to be run in your .zshrc, before the line containing plugins. If no command
is specified in a git directory, `git status` is executed; in other directories, `ls`.
```zsh
# defaults
MAGIC_ENTER_GIT_COMMAND='git status -u .'
MAGIC_ENTER_OTHER_COMMAND='ls -lh .'
plugins=(... magic-enter)
```
**Maintainer:** [@dufferzafar](https://github.com/dufferzafar)
## Magic Enter
**Maintainer:** [@dufferzafar](https://github.com/dufferzafar)
Makes your enter key magical, by binding commonly used commands to it.
You can set the commands to be run in your .zshrc, before the line containing plugins!
```bash
MAGIC_ENTER_GIT_COMMAND='git status -u .'
MAGIC_ENTER_OTHER_COMMAND='ls -lh .'
plugins=(magic-enter)
```
## Introduction ## Introduction
The [meteor plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/meteor) provides many The [meteor plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/meteor) provides many
[useful aliases](#aliases) as well as completion for the `meteor` command. [useful aliases](#aliases) as well as completion for the `meteor` command.
Enable it by adding `meteor` to the plugins array in your zshrc file: Enable it by adding `meteor` to the plugins array in your zshrc file:
......
# MicroK8s plugin
This plugin provides completion and useful aliases for [MicroK8s](https://microk8s.io/).
To use it, add `microk8s` to the plugins array in your zshrc file.
```zsh
plugins=(... microk8s)
```
## Aliases
| Alias | Command | Description |
|-------|------------------|----------------------------------------------------------------------------------------------------------|
| mco | microk8s.config | Shows the Kubernetes config file. |
| mct | microk8s.ctr | Interact with containerd CLI. |
| mdi | microk8s.disable | Disables an addon. |
| me | microk8s.enable | Enables an addon. |
| mh | microk8s.helm | Interact with Helm CLI. |
| mis | microk8s.istio | Interact with Istio CLI. |
| mk | microk8s.kubectl | Interact with Kubernetes CLI. |
| msp | microk8s.stop | Stops all Kubernetes services. |
| mst | microk8s.start | Starts MicroK8s after it is being stopped. |
| msts | microk8s.status | Provides an overview of the MicroK8s state (running / not running) as well as the set of enabled addons. |
\ No newline at end of file
# ---------------------------------------------------------- #
# Aliases and Completions for MicroK8s (https://microk8s.io) #
# Author: Shaun Tabone (https://github.com/xontab) #
# ---------------------------------------------------------- #
# Helper function to cache and load completions
_microk8s_cache_completion() {
local cache="${ZSH_CACHE_DIR}/microk8s_$(echo $1)_completion"
if [[ ! -f $cache ]]; then
$2 $cache
fi
[[ -f $cache ]] && source $cache
}
# ---------------------------------------------------------- #
# microk8s.enable #
# ALIAS: me #
# ---------------------------------------------------------- #
_microk8s_enable_get_command_list() {
microk8s.enable --help | tail -n +7 | awk '{$1=$1;print}'
}
_microk8s_enable() {
compadd -X "MicroK8s Addons" $(_microk8s_enable_get_command_list)
}
compdef _microk8s_enable microk8s.enable
alias me='microk8s.enable'
# ---------------------------------------------------------- #
# microk8s.disable #
# ALIAS: mdi #
# ---------------------------------------------------------- #
_microk8s_disable_get_command_list() {
microk8s.disable --help | tail -n +7 | awk '{$1=$1;print}'
}
_microk8s_disable() {
compadd -X "MicroK8s Addons" $(_microk8s_disable_get_command_list)
}
compdef _microk8s_disable microk8s.disable
alias mdi='microk8s.disable'
# ---------------------------------------------------------- #
# microk8s.kubectl #
# ALIAS: mk #
# ---------------------------------------------------------- #
_microk8s_kubectl_completion() {
if [ $commands[microk8s.kubectl] ]; then
microk8s.kubectl 2>/dev/null >/dev/null && microk8s.kubectl completion zsh | sed 's/__start_kubectl kubectl/__start_kubectl microk8s.kubectl/g' >$1
fi
}
_microk8s_cache_completion 'kubectl' _microk8s_kubectl_completion
alias mk='microk8s.kubectl'
# ---------------------------------------------------------- #
# microk8s.helm #
# ALIAS: mh #
# ---------------------------------------------------------- #
_microk8s_helm_completion() {
if [ $commands[microk8s.helm] ]; then
microk8s.helm completion zsh | sed 's/__start_helm helm/__start_helm microk8s.helm/g' >$1
fi
}
_microk8s_cache_completion 'helm' _microk8s_helm_completion
alias mh='microk8s.helm'
# ---------------------------------------------------------- #
# Other Aliases #
# ---------------------------------------------------------- #
alias mco='microk8s.config'
alias mct='microk8s.ctr'
alias mis='microk8s.istio'
alias mst='microk8s.start'
alias msts='microk8s.status'
alias msp='microk8s.stop'
...@@ -55,4 +55,4 @@ has colored output, so this function will be soon removed from the plugin. ...@@ -55,4 +55,4 @@ has colored output, so this function will be soon removed from the plugin.
### Known bugs ### Known bugs
It has a bug where it will swallow mvn prompts for user input, _e.g._ when using It has a bug where it will swallow mvn prompts for user input, _e.g._ when using
`archetype:generate`. See [#5052](https://github.com/robbyrussell/oh-my-zsh/issues/5052). `archetype:generate`. See [#5052](https://github.com/ohmyzsh/ohmyzsh/issues/5052).
...@@ -267,6 +267,8 @@ function listMavenCompletions { ...@@ -267,6 +267,8 @@ function listMavenCompletions {
stage:copy stage:copy
# toolchain # toolchain
toolchain:toolchain toolchain:toolchain
#liberty
liberty:clean-server liberty:compile-jsp liberty:configure-arquillian liberty:create-server liberty:debug liberty:debug-server liberty:deploy liberty:dev liberty:display-url liberty:dump-server liberty:install-apps liberty:install-feature liberty:install-server liberty:java-dump-server liberty:package-server liberty:run liberty:run-server liberty:server-status liberty:start liberty:start-server liberty:status liberty:stop liberty:stop-server liberty:test-start-server liberty:test-stop-server liberty:undeploy liberty:uninstall-feature
# options # options
"-Dmaven.test.skip=true" -DskipTests -DskipITs -Dmaven.surefire.debug -DenableCiProfile "-Dpmd.skip=true" "-Dcheckstyle.skip=true" "-Dtycho.mode=maven" "-Dmaven.test.failure.ignore=true" "-DgroupId=" "-DartifactId=" "-Dversion=" "-Dpackaging=jar" "-Dfile=" "-Dmaven.test.skip=true" -DskipTests -DskipITs -Dmaven.surefire.debug -DenableCiProfile "-Dpmd.skip=true" "-Dcheckstyle.skip=true" "-Dtycho.mode=maven" "-Dmaven.test.failure.ignore=true" "-DgroupId=" "-DartifactId=" "-Dversion=" "-Dpackaging=jar" "-Dfile="
......
# MySQL-Macports plugin
This plugin adds aliases for some of the commonly used [MySQL](https://www.mysql.com/) commands when installed using [MacPorts](https://www.macports.org/) on macOS.
To use it, add `mysql-macports` to the plugins array in your zshrc file:
```zsh
plugins=(... mysql-macports)
```
For instructions on how to install MySQL using MacPorts, read the [MacPorts wiki](https://trac.macports.org/wiki/howto/MySQL/).
## Aliases
| Alias | Command | Description |
| ------------ | --------------------------------------------------------- | ------------------------------------------ |
| mysqlstart | `sudo /opt/local/share/mysql5/mysql/mysql.server start` | Start the MySQL server. |
| mysqlstop | `sudo /opt/local/share/mysql5/mysql/mysql.server stop` | Stop the MySQL server. |
| mysqlrestart | `sudo /opt/local/share/mysql5/mysql/mysql.server restart` | Restart the MySQL server. |
| mysqlstatus | `mysqladmin5 -u root -p ping` | Check whether the MySQL server is running. |
# n98-magerun plugin
The swiss army knife for Magento developers, sysadmins and devops. The tool provides a huge set of well tested command line commands which save hours of work time.
The [n98-magerun plugin](https://github.com/netz98/n98-magerun) provides many
[useful aliases](#aliases) as well as completion for the `n98-magerun` command.
Enable it by adding `n98-magerun` to the plugins array in your zshrc file:
```zsh
plugins=(... n98-magerun)
```
## Aliases
| Alias | Command | Description |
| --------- | -------------------------------------------------- | --------------------------------------------------------------------------------- |
| n98 | `n98-magerun.phar` | The N98-Magerun phar-file (Version 1) |
| n98-2 | `n98-magerun2.phar` | The N98-Magerun phar-file (Version 2) |
| mage-get | `wget https://files.magerun.net/n98-magerun.phar` | Download the latest stable N98-Magerun phar-file from the file-server (Version 1) |
| mage2-get | `wget https://files.magerun.net/n98-magerun2.phar` | Download the latest stable N98-Magerun phar-file from the file-server (Version 2) |
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
# FILE: n98-magerun.plugin.zsh # FILE: n98-magerun.plugin.zsh
# DESCRIPTION: oh-my-zsh n98-magerun plugin file. Adapted from composer plugin # DESCRIPTION: oh-my-zsh n98-magerun plugin file. Adapted from composer plugin
# AUTHOR: Andrew Dwyer (andrewrdwyer at gmail dot com) # AUTHOR: Andrew Dwyer (andrewrdwyer at gmail dot com)
# VERSION: 1.0.0 # AUTHOR: Jisse Reitsma (jisse at yireo dot com)
# VERSION: 1.1.0
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# n98-magerun basic command completion # n98-magerun basic command completion
...@@ -24,11 +25,18 @@ _n98_magerun () { ...@@ -24,11 +25,18 @@ _n98_magerun () {
compdef _n98_magerun n98-magerun.phar compdef _n98_magerun n98-magerun.phar
compdef _n98_magerun n98-magerun compdef _n98_magerun n98-magerun
compdef _n98_magerun n98-magerun2.phar
compdef _n98_magerun n98-magerun2
# Aliases # Aliases
alias n98='n98-magerun.phar' alias n98='n98-magerun.phar'
alias mage='n98-magerun.phar' alias mage='n98-magerun.phar'
alias magefl='n98-magerun.phar cache:flush' alias magerun='n98-magerun.phar'
alias n98-2='n98-magerun2.phar'
alias mage2='n98-magerun2.phar'
alias magerun2='n98-magerun2.phar'
# Install n98-magerun into the current directory # Install n98-magerun into the current directory
alias mage-get='wget https://raw.github.com/netz98/n98-magerun/master/n98-magerun.phar' alias mage-get='wget https://files.magerun.net/n98-magerun.phar'
alias mage2-get='wget https://files.magerun.net/n98-magerun2.phar'
## NG Plugin # ng plugin
This [ng plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/ng) This plugin adds autocompletion support for [Angular's CLI](https://github.com/angular/angular-cli)
adds completion support for Angular's CLI (named ng). (named `ng`).
Ng is hosted on [ng home](https://github.com/catull/angular-cli) To use it, add `ng` to the plugins array of your zshrc file:
It is used to generate Angular 2 app "stubs", build those apps, configure them,
test them, lint them etc.
Ahem, "stubs" is not what Angular engineers refer to the items ng can generate
for you.
"Stubs" can be any one of:
- class
- component
- directive
- enum
- module
- pipe
- route
- service
At the moment, `ng completion` creates a very rough completion for Zsh and
Bash.
It is missing most of the options and a few arguments.
In future, this plugin may be shortened to simply being
```zsh ```zsh
eval `ng completion` plugins=(... ng)
``` ```
There is hope this materialises in the 21st century.
### CONTRIBUTOR
- Carlo Dapor ([catull](https://github.com/catull))
# Nmap aliases plugin # Nmap plugin
Adds some useful aliases for nmap similar to the profiles in zenmap. Adds some useful aliases for [Nmap](https://nmap.org/) similar to the profiles in zenmap.
Nmap options are: To use it, add `nmap` to the plugins array in your zshrc file:
* -sS - TCP SYN scan
* -v - verbose
* -T1 - timing of scan. Options are paranoid (0), sneaky (1), polite (2), normal (3), aggressive (4), and insane (5)
* -sF - FIN scan (can sneak through non-stateful firewalls)
* -PE - ICMP echo discovery probe
* -PP - timestamp discovery probe
* -PY - SCTP init ping
* -g - use given number as source port
* -A - enable OS detection, version detection, script scanning, and traceroute (aggressive)
* -O - enable OS detection
* -sA - TCP ACK scan
* -F - fast scan
* --script=vulscan - also access vulnerabilities in target
## Aliases explained ```zsh
plugins=(... nmap)
```
* nmap_open_ports - Scan for open ports on target ## Aliases
* nmap_list_interfaces - List all network interfaces on host where the command runs
* nmap_slow - Slow scan that avoids to spam the targets logs
* nmap_fin - Scan to see if hosts are up with TCP FIN scan
* nmap_full - Aggressive full scan that scans all ports, tries to determine OS and service versions
* nmap_check_for_firewall - TCP ACK scan to check for firewall existence
* nmap_ping_through_firewall - Host discovery with SYN and ACK probes instead of just pings to avoid firewall
restrictions
* nmap_fast - Fast scan of the top 300 popular ports
* nmap_detect_versions - Detects versions of services and OS, runs on all ports
* nmap_check_for_vulns - Uses vulscan script to check target services for vulnerabilities
* nmap_full_udp - Same as full but via UDP
* nmap_traceroute - Try to traceroute using the most common ports
* nmap_full_with_scripts - Same as nmap_full but also runs all the scripts
* nmap_web_safe_osscan - Little "safer" scan for OS version as connecting to only HTTP and HTTPS ports doesn't look so attacking.
- `nmap_open_ports`: scan for open ports on target.
- `nmap_list_interfaces`: list all network interfaces on host where the command runs.
- `nmap_slow`: slow scan that avoids to spam the targets logs.
- `nmap_fin`: scan to see if hosts are up with TCP FIN scan.
- `nmap_full`: aggressive full scan that scans all ports, tries to determine OS and service versions.
- `nmap_check_for_firewall`: TCP ACK scan to check for firewall existence.
- `nmap_ping_through_firewall`: host discovery with SYN and ACK probes instead of just pings to avoid firewall restrictions.
- `nmap_fast`: fast scan of the top 300 popular ports.
- `nmap_detect_versions`: detects versions of services and OS, runs on all ports.
- `nmap_check_for_vulns`: uses vulscan script to check target services for vulnerabilities.
- `nmap_full_udp`: same as full but via UDP.
- `nmap_traceroute`: try to traceroute using the most common ports.
- `nmap_full_with_scripts`: same as nmap_full but also runs all the scripts.
- `nmap_web_safe_osscan`: little "safer" scan for OS version as connecting to only HTTP and HTTPS ports doesn't look so attacking.
- `nmap_ping_scan`: ICMP scan for active hosts.
...@@ -29,4 +29,4 @@ alias nmap_full_udp="sudo nmap -sS -sU -T4 -A -v -PE -PS22,25,80 -PA21,23,80,443 ...@@ -29,4 +29,4 @@ alias nmap_full_udp="sudo nmap -sS -sU -T4 -A -v -PE -PS22,25,80 -PA21,23,80,443
alias nmap_traceroute="sudo nmap -sP -PE -PS22,25,80 -PA21,23,80,3389 -PU -PO --traceroute " alias nmap_traceroute="sudo nmap -sP -PE -PS22,25,80 -PA21,23,80,3389 -PU -PO --traceroute "
alias nmap_full_with_scripts="sudo nmap -sS -sU -T4 -A -v -PE -PP -PS21,22,23,25,80,113,31339 -PA80,113,443,10042 -PO --script all " alias nmap_full_with_scripts="sudo nmap -sS -sU -T4 -A -v -PE -PP -PS21,22,23,25,80,113,31339 -PA80,113,443,10042 -PO --script all "
alias nmap_web_safe_osscan="sudo nmap -p 80,443 -O -v --osscan-guess --fuzzy " alias nmap_web_safe_osscan="sudo nmap -p 80,443 -O -v --osscan-guess --fuzzy "
alias nmap_ping_scan="nmap -n -sP"
(( $+commands[npm] )) && { (( $+commands[npm] )) && {
__NPM_COMPLETION_FILE="${ZSH_CACHE_DIR:-$ZSH/cache}/npm_completion" rm -f "${ZSH_CACHE_DIR:-$ZSH/cache}/npm_completion"
if [[ ! -f $__NPM_COMPLETION_FILE ]]; then _npm_completion() {
npm completion >! $__NPM_COMPLETION_FILE 2>/dev/null local si=$IFS
[[ $? -ne 0 ]] && rm -f $__NPM_COMPLETION_FILE compadd -- $(COMP_CWORD=$((CURRENT-1)) \
fi COMP_LINE=$BUFFER \
COMP_POINT=0 \
[[ -f $__NPM_COMPLETION_FILE ]] && source $__NPM_COMPLETION_FILE npm completion -- "${words[@]}" \
2>/dev/null)
unset __NPM_COMPLETION_FILE IFS=$si
}
compdef _npm_completion npm
} }
# Install dependencies globally # Install dependencies globally
......
# OC - OpenShift CLI
This plugin provides autocompletion for [OC](https://docs.openshift.com/container-platform/3.7/cli_reference/index.html) commands, building, managing and updating operations.
To use it, add `oc` to the plugins array of your zshrc file:
```bash
plugins=(... oc)
```
## Contributors
+ [kevinkirkup](https://github.com/kevinkirkup) - Plugin Author
...@@ -43,7 +43,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ...@@ -43,7 +43,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
## Commands ## Commands
| Command | Description | | Command | Description |
| :-------------- | :-------------------------------------------------- | | :-------------- | :---------------------------------------------------- |
| `tab` | Open the current directory in a new tab | | `tab` | Open the current directory in a new tab |
| `split_tab` | Split the current terminal tab horizontally | | `split_tab` | Split the current terminal tab horizontally |
| `vsplit_tab` | Split the current terminal tab vertically | | `vsplit_tab` | Split the current terminal tab vertically |
...@@ -56,6 +56,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ...@@ -56,6 +56,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
| `man-preview` | Open a specified man page in Preview app | | `man-preview` | Open a specified man page in Preview app |
| `showfiles` | Show hidden files | | `showfiles` | Show hidden files |
| `hidefiles` | Hide the hidden files | | `hidefiles` | Hide the hidden files |
| `itunes` | Control iTunes. Use `itunes -h` for usage details | | `itunes` | DEPRECATED. Use `music` from macOS Catalina on |
| `music` | Control Apple Music. Use `music -h` for usage details |
| `spotify` | Control Spotify and search by artist, album, track… | | `spotify` | Control Spotify and search by artist, album, track… |
| `rmdsstore` | Remove .DS\_Store files recursively in a directory | | `rmdsstore` | Remove .DS\_Store files recursively in a directory |
...@@ -219,7 +219,19 @@ function vncviewer() { ...@@ -219,7 +219,19 @@ function vncviewer() {
} }
# iTunes control function # iTunes control function
function itunes() { function itunes music() {
local APP_NAME=Music
autoload is-at-least
if is-at-least 10.15 $(sw_vers -productVersion); then
if [[ $0 = itunes ]]; then
echo >&2 The itunes function name is deprecated. Use \`music\' instead.
return 1
fi
else
APP_NAME=iTunes
fi
local opt=$1 local opt=$1
local playlist=$2 local playlist=$2
shift shift
...@@ -236,7 +248,7 @@ function itunes() { ...@@ -236,7 +248,7 @@ function itunes() {
opt="$opt track" opt="$opt track"
;; ;;
vol) vol)
local new_volume volume=$(osascript -e 'tell application "iTunes" to get sound volume') local new_volume volume=$(osascript -e "tell application \"$APP_NAME\" to get sound volume")
if [[ $# -eq 0 ]]; then if [[ $# -eq 0 ]]; then
echo "Current volume is ${volume}." echo "Current volume is ${volume}."
return 0 return 0
...@@ -252,8 +264,8 @@ function itunes() { ...@@ -252,8 +264,8 @@ function itunes() {
;; ;;
playlist) playlist)
# Inspired by: https://gist.github.com/nakajijapan/ac8b45371064ae98ea7f # Inspired by: https://gist.github.com/nakajijapan/ac8b45371064ae98ea7f
if [[ ! -z "$playlist" ]]; then if [[ ! -z "$playlist" ]]; then
osascript -e 'tell application "iTunes"' -e "set new_playlist to \"$playlist\" as string" -e "play playlist new_playlist" -e "end tell" 2>/dev/null; osascript -e "tell application \"$APP_NAME\"" -e "set new_playlist to \"$playlist\" as string" -e "play playlist new_playlist" -e "end tell" 2>/dev/null;
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
opt="play" opt="play"
else else
...@@ -264,13 +276,13 @@ if [[ ! -z "$playlist" ]]; then ...@@ -264,13 +276,13 @@ if [[ ! -z "$playlist" ]]; then
fi fi
;; ;;
playing|status) playing|status)
local state=`osascript -e 'tell application "iTunes" to player state as string'` local state=`osascript -e "tell application \"$APP_NAME\" to player state as string"`
if [[ "$state" = "playing" ]]; then if [[ "$state" = "playing" ]]; then
currenttrack=`osascript -e 'tell application "iTunes" to name of current track as string'` currenttrack=`osascript -e "tell application \"$APP_NAME\" to name of current track as string"`
currentartist=`osascript -e 'tell application "iTunes" to artist of current track as string'` currentartist=`osascript -e "tell application \"$APP_NAME\" to artist of current track as string"`
echo -E "Listening to $fg[yellow]$currenttrack$reset_color by $fg[yellow]$currentartist$reset_color"; echo -E "Listening to $fg[yellow]$currenttrack$reset_color by $fg[yellow]$currentartist$reset_color";
else else
echo "iTunes is" $state; echo "$APP_NAME is" $state;
fi fi
return 0 return 0
;; ;;
...@@ -284,7 +296,7 @@ if [[ ! -z "$playlist" ]]; then ...@@ -284,7 +296,7 @@ if [[ ! -z "$playlist" ]]; then
if [[ -n "$state" && ! "$state" =~ "^(on|off|toggle)$" ]] if [[ -n "$state" && ! "$state" =~ "^(on|off|toggle)$" ]]
then then
print "Usage: itunes shuffle [on|off|toggle]. Invalid option." print "Usage: $0 shuffle [on|off|toggle]. Invalid option."
return 1 return 1
fi fi
...@@ -305,14 +317,14 @@ EOF ...@@ -305,14 +317,14 @@ EOF
esac esac
;; ;;
""|-h|--help) ""|-h|--help)
echo "Usage: itunes <option>" echo "Usage: $0 <option>"
echo "option:" echo "option:"
echo "\tlaunch|play|pause|stop|rewind|resume|quit" echo "\tlaunch|play|pause|stop|rewind|resume|quit"
echo "\tmute|unmute\tcontrol volume set" echo "\tmute|unmute\tcontrol volume set"
echo "\tnext|previous\tplay next or previous track" echo "\tnext|previous\tplay next or previous track"
echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer." echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer."
echo "\tvol [0-100|up|down]\tGet or set the volume. 0 to 100 sets the volume. 'up' / 'down' increases / decreases by 10 points. No argument displays current volume." echo "\tvol [0-100|up|down]\tGet or set the volume. 0 to 100 sets the volume. 'up' / 'down' increases / decreases by 10 points. No argument displays current volume."
echo "\tplaying|status\tShow what song is currently playing in iTunes." echo "\tplaying|status\tShow what song is currently playing in Music."
echo "\tplaylist [playlist name]\t Play specific playlist" echo "\tplaylist [playlist name]\t Play specific playlist"
echo "\thelp\tshow this message and exit" echo "\thelp\tshow this message and exit"
return 0 return 0
...@@ -322,7 +334,7 @@ EOF ...@@ -322,7 +334,7 @@ EOF
return 1 return 1
;; ;;
esac esac
osascript -e "tell application \"iTunes\" to $opt" osascript -e "tell application \"$APP_NAME\" to $opt"
} }
# Spotify control function # Spotify control function
......
...@@ -148,11 +148,11 @@ if [ $# = 0 ]; then ...@@ -148,11 +148,11 @@ if [ $# = 0 ]; then
else else
if [ ! -d /Applications/Spotify.app ] && [ ! -d $HOME/Applications/Spotify.app ]; then if [ ! -d /Applications/Spotify.app ] && [ ! -d $HOME/Applications/Spotify.app ]; then
echo "The Spotify application must be installed." echo "The Spotify application must be installed."
exit 1 return 1
fi fi
if [ $(osascript -e 'application "Spotify" is running') = "false" ]; then if [ $(osascript -e 'application "Spotify" is running') = "false" ]; then
osascript -e 'tell application "Spotify" to activate' || exit 1 osascript -e 'tell application "Spotify" to activate' || return 1
sleep 2 sleep 2
fi fi
fi fi
...@@ -170,12 +170,12 @@ while [ $# -gt 0 ]; do ...@@ -170,12 +170,12 @@ while [ $# -gt 0 ]; do
if [ -z "${CLIENT_ID}" ]; then if [ -z "${CLIENT_ID}" ]; then
cecho "Invalid Client ID, please update ${USER_CONFIG_FILE}"; cecho "Invalid Client ID, please update ${USER_CONFIG_FILE}";
showAPIHelp; showAPIHelp;
exit 1; return 1
fi fi
if [ -z "${CLIENT_SECRET}" ]; then if [ -z "${CLIENT_SECRET}" ]; then
cecho "Invalid Client Secret, please update ${USER_CONFIG_FILE}"; cecho "Invalid Client Secret, please update ${USER_CONFIG_FILE}";
showAPIHelp; showAPIHelp;
exit 1; return 1
fi fi
SHPOTIFY_CREDENTIALS=$(printf "${CLIENT_ID}:${CLIENT_SECRET}" | base64 | tr -d "\n"|tr -d '\r'); SHPOTIFY_CREDENTIALS=$(printf "${CLIENT_ID}:${CLIENT_SECRET}" | base64 | tr -d "\n"|tr -d '\r');
SPOTIFY_PLAY_URI=""; SPOTIFY_PLAY_URI="";
...@@ -194,7 +194,7 @@ while [ $# -gt 0 ]; do ...@@ -194,7 +194,7 @@ while [ $# -gt 0 ]; do
cecho "Autorization failed, please check ${USER_CONFG_FILE}" cecho "Autorization failed, please check ${USER_CONFG_FILE}"
cecho "${SPOTIFY_TOKEN_RESPONSE_DATA}" cecho "${SPOTIFY_TOKEN_RESPONSE_DATA}"
showAPIHelp showAPIHelp
exit 1 return 1
fi fi
SPOTIFY_ACCESS_TOKEN=$( \ SPOTIFY_ACCESS_TOKEN=$( \
printf "${SPOTIFY_TOKEN_RESPONSE_DATA}" \ printf "${SPOTIFY_TOKEN_RESPONSE_DATA}" \
...@@ -307,7 +307,7 @@ while [ $# -gt 0 ]; do ...@@ -307,7 +307,7 @@ while [ $# -gt 0 ]; do
"quit" ) cecho "Quitting Spotify."; "quit" ) cecho "Quitting Spotify.";
osascript -e 'tell application "Spotify" to quit'; osascript -e 'tell application "Spotify" to quit';
exit 0 ;; break ;;
"next" ) cecho "Going to next track." ; "next" ) cecho "Going to next track." ;
osascript -e 'tell application "Spotify" to next track'; osascript -e 'tell application "Spotify" to next track';
...@@ -358,7 +358,7 @@ while [ $# -gt 0 ]; do ...@@ -358,7 +358,7 @@ while [ $# -gt 0 ]; do
echo " vol down # Decreases the volume by 10%."; echo " vol down # Decreases the volume by 10%.";
echo " vol [amount] # Sets the volume to an amount between 0 and 100."; echo " vol [amount] # Sets the volume to an amount between 0 and 100.";
echo " vol # Shows the current Spotify volume."; echo " vol # Shows the current Spotify volume.";
exit 1; return 1
fi fi
osascript -e "tell application \"Spotify\" to set sound volume to $newvol"; osascript -e "tell application \"Spotify\" to set sound volume to $newvol";
...@@ -468,9 +468,10 @@ while [ $# -gt 0 ]; do ...@@ -468,9 +468,10 @@ while [ $# -gt 0 ]; do
"help" ) "help" )
showHelp; showHelp;
break ;; break ;;
* ) * )
showHelp; showHelp;
exit 1; return 1 ;;
esac esac
done done
......
# otp plugin
This plugin allows you to create one-time passwords using [`oathtool`](https://www.nongnu.org/oath-toolkit/man-oathtool.html),
able to replace MFA devices. The oathtool key is kept in a GPG-encrypted file so the codes
can only be generated by a user able to decrypt it.
To use it, add `otp` to the plugins array in your zshrc file:
```zsh
plugins=(... otp)
```
Provided aliases:
- `otp_add_device`: creates a new encrypted storage for an oathtool key and stores it
on the disk. For encrypting the key, it will ask for a GPG user ID (your GPG key's
email address). Then the OTP key needs to be pasted, followed by a CTRL+D character
inserted on an empty line.
- `ot`: generates a MFA code based on the given key and copies it to the clipboard
(on Linux it relies on xsel, on MacOS X it uses pbcopy instead).
The plugin uses `$HOME/.otp` to store its internal files.
...@@ -12,32 +12,23 @@ function ot () { ...@@ -12,32 +12,23 @@ function ot () {
return 1 return 1
fi fi
if [[ `uname` == 'Darwin' ]] then # MacOS X
export COPY_CMD='pbcopy'
elif command -v xsel > /dev/null 2>&1; then # Any Unix with xsel installed
export COPY_CMD='xsel --clipboard --input'
else
COPY_CMD='true' COPY_CMD='true'
fi
if [[ "x$1" == "x" ]]; then if [[ -z "$1" ]]; then
echo "usage: otpw <profile.name>" echo "usage: $0 <profile.name>"
return 1 return 1
elif [ ! -f $OTP_HOME/$1.otp.asc ]; then elif [ ! -f $OTP_HOME/$1.otp.asc ]; then
echo "missing profile $1, you might need to create it first using otp_add_device" echo "missing profile $1, you might need to create it first using otp_add_device"
return 1 return 1
else else
totpkey=$(gpg --decrypt $OTP_HOME/$1.otp.asc) totpkey=$(gpg --decrypt $OTP_HOME/$1.otp.asc)
oathtool --totp --b $totpkey | tee /dev/stderr | `echo $COPY_CMD` oathtool --totp --b $totpkey | tee /dev/stderr | clipcopy
if [[ $COPY_CMD == 'true' ]] then
echo "Note: you might consider installing xsel for clipboard integration"
fi
fi fi
} }
function otp_add_device () { function otp_add_device () {
if [[ "x$1" == "x" ]] then if [[ "x$1" == "x" ]] then
echo "usage: otp_add <profile.name>" echo "usage: $0 <profile.name>"
return 1 return 1
else else
echo "Enter an email address attached to your GPG private key, then paste the secret configuration key followed by ^D" echo "Enter an email address attached to your GPG private key, then paste the secret configuration key followed by ^D"
......
# pass
This plugin provides completion for the [pass](https://www.passwordstore.org/) password manager.
To use it, add `pass` to the plugins array in your zshrc file.
```
plugins=(... pass)
```
## Configuration
### Multiple repositories
If you use multiple repositories, you can configure completion like this:
```zsh
compdef _pass workpass
zstyle ':completion::complete:workpass::' prefix "$HOME/work/pass"
workpass() {
PASSWORD_STORE_DIR=$HOME/work/pass pass $@
}
```
# Paver
This plugin adds completion for the `paver` command-line tool of [Paver](https://pythonhosted.org/Paver/).
To use it, add `paver` to the plugins array of your zshrc file:
```zsh
plugins=(... paver)
```
The completion function creates a cache of paver tasks with the name `.paver_tasks`,
in the current working directory. It regenerates that cache when the `pavement.py`
changes.
_paver_does_target_list_need_generating () { _paver_does_target_list_need_generating () {
[ ! -f .paver_targets ] && return 0; [ ! -f .paver_targets ] && return 0
[ pavement.py -nt .paver_targets ] && return 0; [ pavement.py -nt .paver_targets ] && return 0
return 1; return 1
} }
_paver () { _paver () {
......
## percol ## percol
Provides some useful function to make [percol](https://github.com/mooz/percol) work with zsh history and [jump plugin](https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/jump/jump.plugin.zsh) Provides some useful function to make [percol](https://github.com/mooz/percol) work with zsh history and [jump plugin](https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/jump/jump.plugin.zsh)
### Requirements ### Requirements
...@@ -8,7 +8,7 @@ Provides some useful function to make [percol](https://github.com/mooz/percol) w ...@@ -8,7 +8,7 @@ Provides some useful function to make [percol](https://github.com/mooz/percol) w
pip install percol pip install percol
``` ```
And [jump](https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/jump/jump.plugin.zsh) for `oh-my-zsh` is a optional requirement. And [jump](https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/jump/jump.plugin.zsh) for `oh-my-zsh` is a optional requirement.
### Usage ### Usage
......
# Perl
This plugin adds [perl](https://www.perl.org/) useful aliases/functions.
To use it, add `perl` to the plugins array in your zshrc file:
```zsh
plugins=(... perl)
```
## Aliases
| Aliases | Command | Description |
| :------------ | :----------------- | :------------------------------------- |
| pbi | `perlbrew install` | Install specific perl version |
| pbl | `perlbrew list` | List all perl version installed |
| pbo | `perlbrew off` | Go back to the system perl |
| pbs | `perlbrew switch` | Turn it back on |
| pbu | `perlbrew use` | Use specific version of perl |
| pd | `perldoc` | Show the perl documentation |
| ple | `perl -wlne` | Use perl like awk/sed |
| latest-perl | `curl ...` | Show the latest stable release of Perl |
## Functions
* `newpl`: creates a basic Perl script file and opens it with $EDITOR.
* `pgs`: Perl Global Substitution: `pgs <find_pattern> <replace_pattern> <filename>`
Looks for `<find_pattern>` and replaces it with `<replace_pattern>` in `<filename>`.
* `prep`: Perl grep, because 'grep -P' is terrible: `prep <pattern> [<filename>]`
Lets you work with pipes or files (if no `<filename>` provided, use stdin).
## Requirements
In order to make this work, you will need to have perl installed.
More info on the usage and install: https://www.perl.org/get.html
# Phing plugin
This plugin adds autocompletion for [`phing`](https://github.com/phingofficial/phing) targets.
To use it, add `phing` to the plugins array of your `.zshrc` file:
```
plugins=(... eecms)
```
# pip plugin
This plugin adds completion for [pip](https://pip.pypa.io/en/latest/),
the Python package manager.
To use it, add `pip` to the plugins array in your zshrc file:
```zsh
plugins=(... pip)
```
## pip cache
The pip plugin caches the names of available pip packages from the PyPI index.
To trigger the caching process, try to complete `pip install`,
or you can run `zsh-pip-cache-packages` directly.
To reset the cache, run `zsh-pip-clear-cache` and it will be rebuilt next
the next time you autocomplete `pip install`.
...@@ -23,7 +23,8 @@ _togglePipenvShell() { ...@@ -23,7 +23,8 @@ _togglePipenvShell() {
fi fi
fi fi
} }
chpwd_functions+=(_togglePipenvShell) autoload -U add-zsh-hook
add-zsh-hook chpwd _togglePipenvShell
# Aliases # Aliases
alias pch="pipenv check" alias pch="pipenv check"
......
# pod
This plugin adds completion for [`CocoaPods`](https://cocoapods.org/).
CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects.
To use it, add `pod` to the plugins array in your zshrc file:
```zsh
plugins=(... pod)
```
# pow plugin
This plugin adds completion and commands for [pow](http://pow.cx/), a
zero-configuration Rack server for macOS.
To use it, add pow to the plugins array of your zshrc file:
```sh
plugins=(... pow)
```
## Commands
- `kapow` will restart an app.
```bash
kapow myapp
```
- `kaput` will show the standard output from any pow app.
- `repow` will restart the pow process.
# Powder
This plugin provides completion for [powder](https://github.com/powder-rb/powder/).
To use it, add powder to the plugins array of your zshrc file:
```
plugins=(... powder)
```
# powify plugin
This plugin adds autocompletion for [powify](https://github.com/sethvargo/powify),
an easy-to-use wrapper for Basecamp's [pow](https://github.com/basecamp/pow).
To use it, add powify to the plugins array of your zshrc file:
```sh
plugins=(... powify)
```
# profiles plugin
This plugin allows you to create separate configuration files for zsh based
on your long hostname (including the domain).
To use it, add profiles to the plugins array of your zshrc file:
```sh
plugins=(... profiles)
```
It takes your `$HOST` variable and looks for files named according to the
domain parts in `$ZSH_CUSTOM/profiles/` directory.
For example, for `HOST=host.domain.com`, it will try to load the following files,
in this order:
```text
$ZSH_CUSTOM/profiles/com
$ZSH_CUSTOM/profiles/domain.com
$ZSH_CUSTOM/profiles/host.domain.com
```
This means that if there are conflicting settings on those files, the one to take
precedence will be the last applied, i.e. the one in host.domain.com.
# pyenv
This plugin looks for [pyenv](https://github.com/pyenv/pyenv), a Simple Python version
management system, and loads it if it's found. It also loads pyenv-virtualenv, a pyenv
plugin to manage virtualenv, if it's found.
To use it, add `pyenv` to the plugins array in your zshrc file:
```zsh
plugins=(... pyenv)
```
## Functions
- `pyenv_prompt_info`: displays the Python version in use by pyenv; or the global Python
version, if pyenv wasn't found.
# This plugin loads pyenv into the current shell and provides prompt info via # This plugin loads pyenv into the current shell and provides prompt info via
# the 'pyenv_prompt_info' function. Also loads pyenv-virtualenv if available. # the 'pyenv_prompt_info' function. Also loads pyenv-virtualenv if available.
FOUND_PYENV=$+commands[pyenv] # Load pyenv only if command not already available
command -v pyenv &> /dev/null && FOUND_PYENV=1 || FOUND_PYENV=0
if [[ $FOUND_PYENV -ne 1 ]]; then if [[ $FOUND_PYENV -ne 1 ]]; then
pyenvdirs=("$HOME/.pyenv" "/usr/local/pyenv" "/opt/pyenv" "/usr/local/opt/pyenv") pyenvdirs=("$HOME/.pyenv" "/usr/local/pyenv" "/opt/pyenv" "/usr/local/opt/pyenv")
......
...@@ -14,3 +14,4 @@ plugins=(... python) ...@@ -14,3 +14,4 @@ plugins=(... python)
| `pyfind` | Finds .py files recursively in the current directory | | `pyfind` | Finds .py files recursively in the current directory |
| `pyclean [dirs]` | Deletes byte-code and cache files from a list of directories or the current one | | `pyclean [dirs]` | Deletes byte-code and cache files from a list of directories or the current one |
| `pygrep <text>` | Looks for `text` in .py files | | `pygrep <text>` | Looks for `text` in .py files |
| `ipython` | Runs the appropriate `ipython` version according to the activated virtualenv |
# Find python file # Find python file
alias pyfind='find . -name "*.py"' alias pyfind='find . -name "*.py"'
# Remove python compiled byte-code and mypy cache in either current directory or in a # Remove python compiled byte-code and mypy/pytest cache in either the current
# list of specified directories # directory or in a list of specified directories (including sub directories).
function pyclean() { function pyclean() {
ZSH_PYCLEAN_PLACES=${*:-'.'} ZSH_PYCLEAN_PLACES=${*:-'.'}
find ${ZSH_PYCLEAN_PLACES} -type f -name "*.py[co]" -delete find ${ZSH_PYCLEAN_PLACES} -type f -name "*.py[co]" -delete
find ${ZSH_PYCLEAN_PLACES} -type d -name "__pycache__" -delete find ${ZSH_PYCLEAN_PLACES} -type d -name "__pycache__" -delete
find ${ZSH_PYCLEAN_PLACES} -type d -name ".mypy_cache" -delete find ${ZSH_PYCLEAN_PLACES} -depth -type d -name ".mypy_cache" -exec rm -r "{}" +
find ${ZSH_PYCLEAN_PLACES} -depth -type d -name ".pytest_cache" -exec rm -r "{}" +
} }
# Grep among .py files # Grep among .py files
alias pygrep='grep --include="*.py"' alias pygrep='grep -r --include="*.py"'
# Run proper IPython regarding current virtualenv (if any)
alias ipython="python -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'"
...@@ -18,7 +18,7 @@ plugins=(... rails) ...@@ -18,7 +18,7 @@ plugins=(... rails)
| `rcs` | `rails console --sandbox` | Test code in a sandbox, without changing any data | | `rcs` | `rails console --sandbox` | Test code in a sandbox, without changing any data |
| `rd` | `rails destroy` | Undo a generate operation | | `rd` | `rails destroy` | Undo a generate operation |
| `rdb` | `rails dbconsole` | Interact with your db from the console | | `rdb` | `rails dbconsole` | Interact with your db from the console |
| `rgen` | `rails generate` | Generate boilerplate code | | `rgen`| `rails generate` | Generate boilerplate code |
| `rgm` | `rails generate migration` | Generate a db migration | | `rgm` | `rails generate migration` | Generate a db migration |
| `rp` | `rails plugin` | Run a Rails plugin command | | `rp` | `rails plugin` | Run a Rails plugin command |
| `ru` | `rails runner` | Run Ruby code in the context of Rails | | `ru` | `rails runner` | Run Ruby code in the context of Rails |
...@@ -44,7 +44,7 @@ plugins=(... rails) ...@@ -44,7 +44,7 @@ plugins=(... rails)
| `rlc` | `rake log:clear` | Clear Rails logs | | `rlc` | `rake log:clear` | Clear Rails logs |
| `rn` | `rake notes` | Search for notes (`FIXME`, `TODO`) in code comments | | `rn` | `rake notes` | Search for notes (`FIXME`, `TODO`) in code comments |
| `rr` | `rake routes` | List all defined routes | | `rr` | `rake routes` | List all defined routes |
| `rrg` | `rake routes | grep` | List and filter the defined routes | | `rrg` | `rake routes \| grep` | List and filter the defined routes |
| `rt` | `rake test` | Run Rails tests | | `rt` | `rake test` | Run Rails tests |
| `rmd` | `rake middleware` | Interact with Rails middlewares | | `rmd` | `rake middleware` | Interact with Rails middlewares |
| `rsts` | `rake stats` | Print code statistics | | `rsts` | `rake stats` | Print code statistics |
......
...@@ -17,7 +17,7 @@ function _rake_command () { ...@@ -17,7 +17,7 @@ function _rake_command () {
bin/stubs/rake $@ bin/stubs/rake $@
elif [ -e "bin/rake" ]; then elif [ -e "bin/rake" ]; then
bin/rake $@ bin/rake $@
elif type bundle &> /dev/null && [ -e "Gemfile" ]; then elif type bundle &> /dev/null && ([ -e "Gemfile" ] || [ -e "gems.rb" ]); then
bundle exec rake $@ bundle exec rake $@
else else
command rake $@ command rake $@
......
# Rake plugin
This plugin adds support for [rake](https://ruby.github.io/rake/), the Ruby
build tool or Ruby Make.
To use it, add `rake` to the plugins array in your zshrc file:
```zsh
plugins=(... rake)
```
## Aliases
The plugin aliases the rake command so you can pass arguments when invoking rake tasks
without having to escape the brackets, i.e., you can run
```
rake namespace:task['argument']
```
instead of having to do
```
rake namespace:task\['argument'\]
```
| Alias | Command | Description |
|--------|--------------------------------|-----------------------------------------------|
| rake | `noglob rake` | Allows unescaped square brackets |
| brake | `noglob bundle exec rake` | Same as above but call rake using bundler |
| srake | `noglob sudo rake` | Same as rake but using sudo |
| sbrake | `noglob sudo bundle exec rake` | Same as above but using both sudo and bundler |
## Jim Weirich
The plugin also aliases `rake` to [`jimweirich`](https://github.com/jimweirich), author of Rake
and big time contributor to the Ruby open source community. He passed away in 2014:
> Thank you Jim for everything you contributed to the Ruby and open source community
> over the years. We will miss you dearly. — [**@robbyrussell**](https://github.com/ohmyzsh/ohmyzsh/commit/598a9c6f990756386517d66b6bcf77e53791e905)
# rbenv plugin
The primary job of this plugin is to provide `rbenv_prompt_info` which can be added to your theme to include Ruby
version and gemset information into your prompt.
Some functionality of this plugin will not work unless you also have the rbenv plugin *gemset* installed.
https://github.com/jf/rbenv-gemset
To use it, add `rbenv` to the plugins array in your zshrc file:
```zsh
plugins=(... rbenv)
```
## Alias
| Alias | Command | Description |
|----------------|---------------------|----------------------------------|
| rubies | `rbenv versions` | List the installed Ruby versions |
| gemsets | `rbenv gemset list` | List the existing gemsets |
## Functions
* `current_ruby`: The version of Ruby currently being used.
* `current_gemset`: The name of the current gemset.
* `gems`: Lists installed gems with enhanced formatting and color.
* `rbenv_prompt_info`: For adding information to your prompt. Format: `<ruby version>@<current gemset>`.
# rbfu plugin
This plugin starts [rbfu](https://github.com/hmans/rbfu), a minimal Ruby version
manager, and adds some useful functions.
To use it, add `rbfu` to the plugins array in your zshrc file:
```zsh
plugins=(... rbfu)
```
**Note: `rbfu` is deprecated and should no longer be used.**
## Functions
- `rbfu-rubies`: lists all installed rubies available to rbfu.
- `rvm_prompt_info`: shows the Ruby version being used with rbfu.
...@@ -39,6 +39,9 @@ plugins=(... react-native) ...@@ -39,6 +39,9 @@ plugins=(... react-native)
| **rniosxs** | `react-native run-ios --simulator "iPhone Xs"` | | **rniosxs** | `react-native run-ios --simulator "iPhone Xs"` |
| **rniosxsm** | `react-native run-ios --simulator "iPhone Xs Max"` | | **rniosxsm** | `react-native run-ios --simulator "iPhone Xs Max"` |
| **rniosxr** | `react-native run-ios --simulator "iPhone Xʀ"` | | **rniosxr** | `react-native run-ios --simulator "iPhone Xʀ"` |
| **rnios11** | `react-native run-ios --simulator "iPhone 11"` |
| **rnios11p** | `react-native run-ios --simulator "iPhone 11 Pro"` |
| **rnios11pm** | `react-native run-ios --simulator "iPhone 11 Pro Max"` |
| _iPad_ | | | _iPad_ | |
| **rnipad2** | `react-native run-ios --simulator "iPad 2"` | | **rnipad2** | `react-native run-ios --simulator "iPad 2"` |
| **rnipad5** | `react-native run-ios --simulator "iPad (5th generation)"` | | **rnipad5** | `react-native run-ios --simulator "iPad (5th generation)"` |
......
...@@ -24,6 +24,10 @@ alias rniosx='react-native run-ios --simulator "iPhone X"' ...@@ -24,6 +24,10 @@ alias rniosx='react-native run-ios --simulator "iPhone X"'
alias rniosxs='react-native run-ios --simulator "iPhone Xs"' alias rniosxs='react-native run-ios --simulator "iPhone Xs"'
alias rniosxsm='react-native run-ios --simulator "iPhone Xs Max"' alias rniosxsm='react-native run-ios --simulator "iPhone Xs Max"'
alias rniosxr='react-native run-ios --simulator "iPhone Xʀ"' alias rniosxr='react-native run-ios --simulator "iPhone Xʀ"'
alias rnios11='react-native run-ios --simulator "iPhone 11"'
alias rnios11p='react-native run-ios --simulator "iPhone 11 Pro"'
alias rnios11pm='react-native run-ios --simulator "iPhone 11 Pro Max"'
# iPad # iPad
alias rnipad2='react-native run-ios --simulator "iPad 2"' alias rnipad2='react-native run-ios --simulator "iPad 2"'
......
# rebar plugin
This plugin adds completions for the [rebar](https://www.rebar3.org/) Erlang build tool.
To use it, add `rebar` to the plugins array in your zshrc file:
```zsh
plugins=(... rebar)
```
# Redis-CLI
This plugin adds [redis-cli](https://redis.io/topics/rediscli) completion, based off of Homebrew completion.
To use it, add `redis-cli` to the plugins array in your zshrc file:
```zsh
plugins=(... redis-cli)
```
## Requirements
In order to make this work, you will need to have redis installed.
More info on the usage and install: https://redis.io/topics/quickstart
...@@ -16,3 +16,15 @@ compdef _repo ru='repo upload' ...@@ -16,3 +16,15 @@ compdef _repo ru='repo upload'
alias rst='repo status' alias rst='repo status'
compdef _repo rst='repo status' compdef _repo rst='repo status'
alias rsto='repo status -o'
compdef _repo rsto='repo status -o'
alias rfa='repo forall -c'
compdef _repo rfa='repo forall -c'
alias rfap='repo forall -p -c'
compdef _repo rfap='repo forall -p -c'
alias rinf='repo info'
compdef _repo rinf='repo info'
...@@ -8,6 +8,6 @@ To use it, add `ripgrep` to the plugins array in your zshrc file: ...@@ -8,6 +8,6 @@ To use it, add `ripgrep` to the plugins array in your zshrc file:
plugins=(... ripgrep) plugins=(... ripgrep)
``` ```
Completion is taken from the ripgrep release [`0.10.0`](https://github.com/BurntSushi/ripgrep/releases/tag/0.10.0). Completion is taken from the ripgrep release [`11.0.2`](https://github.com/BurntSushi/ripgrep/releases/tag/11.0.2).
Updated on September 27th, 2018. Updated on August 16th, 2019.
...@@ -3,6 +3,12 @@ ...@@ -3,6 +3,12 @@
## ##
# zsh completion function for ripgrep # zsh completion function for ripgrep
# #
# Run ci/test_complete.sh after building to ensure that the options supported by
# this function stay in synch with the `rg` binary.
#
# For convenience, a completion reference guide is included at the bottom of
# this file.
#
# Originally based on code from the zsh-users project — see copyright notice # Originally based on code from the zsh-users project — see copyright notice
# below. # below.
...@@ -37,6 +43,7 @@ _rg() { ...@@ -37,6 +43,7 @@ _rg() {
+ '(exclusive)' # Misc. fully exclusive options + '(exclusive)' # Misc. fully exclusive options
'(: * -)'{-h,--help}'[display help information]' '(: * -)'{-h,--help}'[display help information]'
'(: * -)'{-V,--version}'[display version information]' '(: * -)'{-V,--version}'[display version information]'
'(: * -)'--pcre2-version'[print the version of PCRE2 used by ripgrep, if available]'
+ '(buffered)' # buffering options + '(buffered)' # buffering options
'--line-buffered[force line buffering]' '--line-buffered[force line buffering]'
...@@ -79,7 +86,7 @@ _rg() { ...@@ -79,7 +86,7 @@ _rg() {
+ '(file-name)' # File-name options + '(file-name)' # File-name options
{-H,--with-filename}'[show file name for matches]' {-H,--with-filename}'[show file name for matches]'
"--no-filename[don't show file name for matches]" {-I,--no-filename}"[don't show file name for matches]"
+ '(file-system)' # File system options + '(file-system)' # File system options
"--one-file-system[don't descend into directories on other file systems]" "--one-file-system[don't descend into directories on other file systems]"
...@@ -97,6 +104,10 @@ _rg() { ...@@ -97,6 +104,10 @@ _rg() {
'*'{-g+,--glob=}'[include/exclude files matching specified glob]:glob' '*'{-g+,--glob=}'[include/exclude files matching specified glob]:glob'
'*--iglob=[include/exclude files matching specified case-insensitive glob]:glob' '*--iglob=[include/exclude files matching specified case-insensitive glob]:glob'
+ '(glob-case-insensitive)' # File-glob case sensitivity options
'--glob-case-insensitive[treat -g/--glob patterns case insensitively]'
$no'--no-glob-case-insensitive[treat -g/--glob patterns case sensitively]'
+ '(heading)' # Heading options + '(heading)' # Heading options
'(pretty-vimgrep)--heading[show matches grouped by file name]' '(pretty-vimgrep)--heading[show matches grouped by file name]'
"(pretty-vimgrep)--no-heading[don't show matches grouped by file name]" "(pretty-vimgrep)--no-heading[don't show matches grouped by file name]"
...@@ -105,9 +116,17 @@ _rg() { ...@@ -105,9 +116,17 @@ _rg() {
'--hidden[search hidden files and directories]' '--hidden[search hidden files and directories]'
$no"--no-hidden[don't search hidden files and directories]" $no"--no-hidden[don't search hidden files and directories]"
+ '(hybrid)' # hybrid regex options
'--auto-hybrid-regex[dynamically use PCRE2 if necessary]'
$no"--no-auto-hybrid-regex[don't dynamically use PCRE2 if necessary]"
+ '(ignore)' # Ignore-file options + '(ignore)' # Ignore-file options
"(--no-ignore-global --no-ignore-parent --no-ignore-vcs)--no-ignore[don't respect ignore files]" "(--no-ignore-global --no-ignore-parent --no-ignore-vcs --no-ignore-dot)--no-ignore[don't respect ignore files]"
$no'(--ignore-global --ignore-parent --ignore-vcs)--ignore[respect ignore files]' $no'(--ignore-global --ignore-parent --ignore-vcs --ignore-dot)--ignore[respect ignore files]'
+ '(ignore-file-case-insensitive)' # Ignore-file case sensitivity options
'--ignore-file-case-insensitive[process ignore files case insensitively]'
$no'--no-ignore-file-case-insensitive[process ignore files case sensitively]'
+ '(ignore-global)' # Global ignore-file options + '(ignore-global)' # Global ignore-file options
"--no-ignore-global[don't respect global ignore files]" "--no-ignore-global[don't respect global ignore files]"
...@@ -121,6 +140,10 @@ _rg() { ...@@ -121,6 +140,10 @@ _rg() {
"--no-ignore-vcs[don't respect version control ignore files]" "--no-ignore-vcs[don't respect version control ignore files]"
$no'--ignore-vcs[respect version control ignore files]' $no'--ignore-vcs[respect version control ignore files]'
+ '(ignore-dot)' # .ignore-file options
"--no-ignore-dot[don't respect .ignore files]"
$no'--ignore-dot[respect .ignore files]'
+ '(json)' # JSON options + '(json)' # JSON options
'--json[output results in JSON Lines format]' '--json[output results in JSON Lines format]'
$no"--no-json[don't output results in JSON Lines format]" $no"--no-json[don't output results in JSON Lines format]"
...@@ -134,6 +157,10 @@ _rg() { ...@@ -134,6 +157,10 @@ _rg() {
$no"--no-crlf[don't use CRLF as line terminator]" $no"--no-crlf[don't use CRLF as line terminator]"
'(text)--null-data[use NUL as line terminator]' '(text)--null-data[use NUL as line terminator]'
+ '(max-columns-preview)' # max column preview options
'--max-columns-preview[show preview for long lines (with -M)]'
$no"--no-max-columns-preview[don't show preview for long lines (with -M)]"
+ '(max-depth)' # Directory-depth options + '(max-depth)' # Directory-depth options
'--max-depth=[specify max number of directories to descend]:number of directories' '--max-depth=[specify max number of directories to descend]:number of directories'
'!--maxdepth=:number of directories' '!--maxdepth=:number of directories'
...@@ -213,6 +240,8 @@ _rg() { ...@@ -213,6 +240,8 @@ _rg() {
+ '(text)' # Binary-search options + '(text)' # Binary-search options
{-a,--text}'[search binary files as if they were text]' {-a,--text}'[search binary files as if they were text]'
"--binary[search binary files, don't print binary data]"
$no"--no-binary[don't search binary files]"
$no"(--null-data)--no-text[don't search binary files as if they were text]" $no"(--null-data)--no-text[don't search binary files as if they were text]"
+ '(threads)' # Thread-count options + '(threads)' # Thread-count options
...@@ -364,7 +393,7 @@ _rg_encodings() { ...@@ -364,7 +393,7 @@ _rg_encodings() {
shift{-,_}jis csshiftjis {,x-}sjis ms_kanji ms932 shift{-,_}jis csshiftjis {,x-}sjis ms_kanji ms932
utf{,-}8 utf-16{,be,le} unicode-1-1-utf-8 utf{,-}8 utf-16{,be,le} unicode-1-1-utf-8
windows-{31j,874,949,125{0..8}} dos-874 tis-620 ansi_x3.4-1968 windows-{31j,874,949,125{0..8}} dos-874 tis-620 ansi_x3.4-1968
x-user-defined auto x-user-defined auto none
) )
_wanted encodings expl encoding compadd -a "$@" - _encodings _wanted encodings expl encoding compadd -a "$@" - _encodings
...@@ -382,6 +411,156 @@ _rg_types() { ...@@ -382,6 +411,156 @@ _rg_types() {
_rg "$@" _rg "$@"
################################################################################
# ZSH COMPLETION REFERENCE
#
# For the convenience of developers who aren't especially familiar with zsh
# completion functions, a brief reference guide follows. This is in no way
# comprehensive; it covers just enough of the basic structure, syntax, and
# conventions to help someone make simple changes like adding new options. For
# more complete documentation regarding zsh completion functions, please see the
# following:
#
# * http://zsh.sourceforge.net/Doc/Release/Completion-System.html
# * https://github.com/zsh-users/zsh/blob/master/Etc/completion-style-guide
#
# OVERVIEW
#
# Most zsh completion functions are defined in terms of `_arguments`, which is a
# shell function that takes a series of argument specifications. The specs for
# `rg` are stored in an array, which is common for more complex functions; the
# elements of the array are passed to `_arguments` on invocation.
#
# ARGUMENT-SPECIFICATION SYNTAX
#
# The following is a contrived example of the argument specs for a simple tool:
#
# '(: * -)'{-h,--help}'[display help information]'
# '(-q -v --quiet --verbose)'{-q,--quiet}'[decrease output verbosity]'
# '!(-q -v --quiet --verbose)--silent'
# '(-q -v --quiet --verbose)'{-v,--verbose}'[increase output verbosity]'
# '--color=[specify when to use colors]:when:(always never auto)'
# '*:example file:_files'
#
# Although there may appear to be six specs here, there are actually nine; we
# use brace expansion to combine specs for options that go by multiple names,
# like `-q` and `--quiet`. This is customary, and ties in with the fact that zsh
# merges completion possibilities together when they have the same description.
#
# The first line defines the option `-h`/`--help`. With most tools, it isn't
# useful to complete anything after `--help` because it effectively overrides
# all others; the `(: * -)` at the beginning of the spec tells zsh not to
# complete any other operands (`:` and `*`) or options (`-`) after this one has
# been used. The `[...]` at the end associates a description with `-h`/`--help`;
# as mentioned, zsh will see the identical descriptions and merge these options
# together when offering completion possibilities.
#
# The next line defines `-q`/`--quiet`. Here we don't want to suppress further
# completions entirely, but we don't want to offer `-q` if `--quiet` has been
# given (since they do the same thing), nor do we want to offer `-v` (since it
# doesn't make sense to be quiet and verbose at the same time). We don't need to
# tell zsh not to offer `--quiet` a second time, since that's the default
# behaviour, but since this line expands to two specs describing `-q` *and*
# `--quiet` we do need to explicitly list all of them here.
#
# The next line defines a hidden option `--silent` — maybe it's a deprecated
# synonym for `--quiet`. The leading `!` indicates that zsh shouldn't offer this
# option during completion. The benefit of providing a spec for an option that
# shouldn't be completed is that, if someone *does* use it, we can correctly
# suppress completion of other options afterwards.
#
# The next line defines `-v`/`--verbose`; this works just like `-q`/`--quiet`.
#
# The next line defines `--color`. In this example, `--color` doesn't have a
# corresponding short option, so we don't need to use brace expansion. Further,
# there are no other options it's exclusive with (just itself), so we don't need
# to define those at the beginning. However, it does take a mandatory argument.
# The `=` at the end of `--color=` indicates that the argument may appear either
# like `--color always` or like `--color=always`; this is how most GNU-style
# command-line tools work. The corresponding short option would normally use `+`
# — for example, `-c+` would allow either `-c always` or `-calways`. For this
# option, the arguments are known ahead of time, so we can simply list them in
# parentheses at the end (`when` is used as the description for the argument).
#
# The last line defines an operand (a non-option argument). In this example, the
# operand can be used any number of times (the leading `*`), and it should be a
# file path, so we tell zsh to call the `_files` function to complete it. The
# `example file` in the middle is the description to use for this operand; we
# could use a space instead to accept the default provided by `_files`.
#
# GROUPING ARGUMENT SPECIFICATIONS
#
# Newer versions of zsh support grouping argument specs together. All specs
# following a `+` and then a group name are considered to be members of the
# named group. Grouping is useful mostly for organisational purposes; it makes
# the relationship between different options more obvious, and makes it easier
# to specify exclusions.
#
# We could rewrite our example above using grouping as follows:
#
# '(: * -)'{-h,--help}'[display help information]'
# '--color=[specify when to use colors]:when:(always never auto)'
# '*:example file:_files'
# + '(verbosity)'
# {-q,--quiet}'[decrease output verbosity]'
# '!--silent'
# {-v,--verbose}'[increase output verbosity]'
#
# Here we take advantage of a useful feature of spec grouping — when the group
# name is surrounded by parentheses, as in `(verbosity)`, it tells zsh that all
# of the options in that group are exclusive with each other. As a result, we
# don't need to manually list out the exclusions at the beginning of each
# option.
#
# Groups can also be referred to by name in other argument specs; for example:
#
# '(xyz)--aaa' '*: :_files'
# + xyz --xxx --yyy --zzz
#
# Here we use the group name `xyz` to tell zsh that `--xxx`, `--yyy`, and
# `--zzz` are not to be completed after `--aaa`. This makes the exclusion list
# much more compact and reusable.
#
# CONVENTIONS
#
# zsh completion functions generally adhere to the following conventions:
#
# * Use two spaces for indentation
# * Combine specs for options with different names using brace expansion
# * In combined specs, list the short option first (as in `{-a,--text}`)
# * Use `+` or `=` as described above for options that take arguments
# * Provide a description for all options, option-arguments, and operands
# * Capitalise/punctuate argument descriptions as phrases, not complete
# sentences — 'display help information', never 'Display help information.'
# (but still capitalise acronyms and proper names)
# * Write argument descriptions as verb phrases — 'display x', 'enable y',
# 'use z'
# * Word descriptions to make it clear when an option expects an argument;
# usually this is done with the word 'specify', as in 'specify x' or
# 'use specified x')
# * Write argument descriptions as tersely as possible — for example, articles
# like 'a' and 'the' should be omitted unless it would be confusing
#
# Other conventions currently used by this function:
#
# * Order argument specs alphabetically by group name, then option name
# * Group options that are directly related, mutually exclusive, or frequently
# referenced by other argument specs
# * Use only characters in the set [a-z0-9_-] in group names
# * Order exclusion lists as follows: short options, long options, groups
# * Use American English in descriptions
# * Use 'don't' in descriptions instead of 'do not'
# * Word descriptions for related options as similarly as possible. For example,
# `--foo[enable foo]` and `--no-foo[disable foo]`, or `--foo[use foo]` and
# `--no-foo[don't use foo]`
# * Word descriptions to make it clear when an option only makes sense with
# another option, usually by adding '(with -x)' to the end
# * Don't quote strings or variables unnecessarily. When quotes are required,
# prefer single-quotes to double-quotes
# * Prefix option specs with `$no` when the option serves only to negate the
# behaviour of another option that must be provided explicitly by the user.
# This prevents rarely used options from cluttering up the completion menu
################################################################################
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users # Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users
......
# rust
This plugin adds completion for [`rustc`](https://doc.rust-lang.org/rustc/index.html), the compiler for the Rust programming language.
To use it, add `rust` to the plugins array in your zshrc file:
```zsh
plugins=(... rust)
```
# Ruby Version Manager plugin
This plugin adds some utility functions and completions for [Ruby Version Manager](https://rvm.io/).
To use it, add `rvm` to the plugins array in your zshrc file:
```zsh
plugins=(... rvm)
```
## Functions
| Alias | Command |
|----------------|----------------------|
| `rb18` | `rvm use ruby-1.8.7` |
| `rb19` | `rvm use ruby-1.9.3` |
| `rb20` | `rvm use ruby-2.0.0` |
| `rb21` | `rvm use ruby-2.1.2` |
| `rvm-update` | `rvm get head` |
| `gems` | `gem list` |
# safe-paste
Preventing any code from actually running while pasting, so you have a chance to review what was actually pasted before running it.
To use it, add `safe-paste` to the plugins array in your zshrc file:
```zsh
plugins=(... safe-paste)
```
...@@ -271,7 +271,7 @@ _salt_comp(){ ...@@ -271,7 +271,7 @@ _salt_comp(){
fi fi
if _cache_invalid salt/salt_dir || ! _retrieve_cache salt/salt_dir; then if _cache_invalid salt/salt_dir || ! _retrieve_cache salt/salt_dir; then
salt_dir="${$(python2 -c 'import salt; print(salt.__file__);')%__init__*}" salt_dir="${$(python2 -c 'import sys; del sys.path[0]; import salt; print(salt.__file__);')%__init__*}"
_store_cache salt/salt_dir salt_dir _store_cache salt/salt_dir salt_dir
fi fi
} }
......
...@@ -17,16 +17,16 @@ plugins=(... sbt) ...@@ -17,16 +17,16 @@ plugins=(... sbt)
| sbcln | `sbt clean` | Deletes all generated files | | sbcln | `sbt clean` | Deletes all generated files |
| sbcc | `sbt clean compile` | Deletes generated files, compiles the main sources | | sbcc | `sbt clean compile` | Deletes generated files, compiles the main sources |
| sbco | `sbt console` | Starts Scala with the compiled sources and all dependencies | | sbco | `sbt console` | Starts Scala with the compiled sources and all dependencies |
| sbcq | `sbt console-quick` | Starts Scala with all dependencies | | sbcq | `sbt consoleQuick` | Starts Scala with all dependencies |
| sbcp | `sbt console-project` | Starts Scala with sbt and the build definitions | | sbcp | `sbt consoleProject` | Starts Scala with sbt and the build definitions |
| sbd | `sbt doc` | Generates API documentation for Scala source files | | sbd | `sbt doc` | Generates API documentation for Scala source files |
| sbdc | `sbt dist:clean` | Deletes the distribution packages | | sbdc | `sbt dist:clean` | Deletes the distribution packages |
| sbdi | `sbt dist` | Creates the distribution packages | | sbdi | `sbt dist` | Creates the distribution packages |
| sbgi | `sbt gen-idea` | Create Idea project files | | sbgi | `sbt genIdea` | Create Idea project files |
| sbp | `sbt publish` | Publishes artifacts to the repository | | sbp | `sbt publish` | Publishes artifacts to the repository |
| sbpl | `sbt publish-local` | Publishes artifacts to the local Ivy repository | | sbpl | `sbt publishLocal` | Publishes artifacts to the local Ivy repository |
| sbr | `sbt run` | Runs the main class for the project | | sbr | `sbt run` | Runs the main class for the project |
| sbrm | `sbt run-main` | Runs the specified main class for the project | | sbrm | `sbt runMain` | Runs the specified main class for the project |
| sbu | `sbt update` | Resolves and retrieves external dependencies | | sbu | `sbt update` | Resolves and retrieves external dependencies |
| sbx | `sbt test` | Compiles and runs all tests | | sbx | `sbt test` | Compiles and runs all tests |
| sba | `sbt assembly` | Create a fat JAR with all dependencies | | sba | `sbt assembly` | Create a fat JAR with all dependencies |
...@@ -6,23 +6,23 @@ _sbt_commands=( ...@@ -6,23 +6,23 @@ _sbt_commands=(
'clean:delete files produced by the build' 'clean:delete files produced by the build'
'compile:compile sources' 'compile:compile sources'
'console:start the Scala REPL with project classes on the classpath' 'console:start the Scala REPL with project classes on the classpath'
'console-quick:start the Scala REPL with project deps on the classpath' 'consoleQuick:start the Scala REPL with project deps on the classpath'
'console-project:start the Scala REPL w/sbt+build-def on the classpath' 'consoleProject:start the Scala REPL w/sbt+build-def on the classpath'
'dist:generate distribution artifacts' 'dist:generate distribution artifacts'
'dist\:clean:clean distribution artifacts' 'dist\:clean:clean distribution artifacts'
'doc:generate API documentation' 'doc:generate API documentation'
'gen-idea:generate Intellij Idea project files' 'genIdea:generate Intellij Idea project files'
'package:produce the main artifact, such as a binary jar' 'package:produce the main artifact, such as a binary jar'
'package-doc:produce a doc artifact, such as a jar containing API docs' 'packageDoc:produce a doc artifact, such as a jar containing API docs'
'package-src:produce a source artifact, such as a jar containing sources' 'packageSrc:produce a source artifact, such as a jar containing sources'
'publish:publish artifacts to a repository' 'publish:publish artifacts to a repository'
'publish-local:publish artifacts to the local repository' 'publishLocal:publish artifacts to the local repository'
'publish-m2:publish artifacts to the local Maven 2 repository' 'publishM2:publish artifacts to the local Maven 2 repository'
'run:run a main class' 'run:run a main class'
'run-main:run the main class selected by the first argument' 'runMain:run the main class selected by the first argument'
'test:execute all tests' 'test:execute all tests'
'test-only:execute the tests provided as arguments' 'testOnly:execute the tests provided as arguments'
'test-quick:execute previously failed tests' 'testQuick:execute previously failed tests'
'update:resolve and optionally retrieve dependencies' 'update:resolve and optionally retrieve dependencies'
) )
......
...@@ -9,17 +9,17 @@ ...@@ -9,17 +9,17 @@
alias sbc='sbt compile' alias sbc='sbt compile'
alias sbcc='sbt clean compile' alias sbcc='sbt clean compile'
alias sbco='sbt console' alias sbco='sbt console'
alias sbcq='sbt console-quick' alias sbcq='sbt consoleQuick'
alias sbcln='sbt clean' alias sbcln='sbt clean'
alias sbcp='sbt console-project' alias sbcp='sbt consoleProject'
alias sbd='sbt doc' alias sbd='sbt doc'
alias sbdc='sbt dist:clean' alias sbdc='sbt dist:clean'
alias sbdi='sbt dist' alias sbdi='sbt dist'
alias sbgi='sbt gen-idea' alias sbgi='sbt genIdea'
alias sbp='sbt publish' alias sbp='sbt publish'
alias sbpl='sbt publish-local' alias sbpl='sbt publishLocal'
alias sbr='sbt run' alias sbr='sbt run'
alias sbrm='sbt run-main' alias sbrm='sbt runMain'
alias sbu='sbt update' alias sbu='sbt update'
alias sbx='sbt test' alias sbx='sbt test'
alias sba='sbt assembly' alias sba='sbt assembly'
# screen
This plugin sets title and hardstatus of the tab window for [screen](https://www.gnu.org/software/screen/),
the terminal multiplexer.
To use it add `screen` to the plugins array in your zshrc file.
```zsh
plugins=(... screen)
```
# "Search files for Front-End"
This plugin adds a few functions for searching files used in Front-End web development.
To use it, add `sfffe` to the plugins array in your zshrc file:
```zsh
plugins=(... sfffe)
```
**Requires:** `ack`
## Functions
- `ajs`: look for string in `.js` files.
- `acss`: look for string in `.css` files.
- `fjs`: search for `.js` files under the current working directory.
- `fcss`: search for `.css` files under the current working directory.
# Singlechar plugin
This plugin adds single char shortcuts (and combinations) for some commands.
To use it, add `singlechar` to the plugins array of your zshrc file:
```
plugins=(... singlechar)
```
## Aliases
### CAT, GREP, CURL, WGET
| Alias | Command | Description |
|-------|------------------|-------------|
| y | `grep -Ri` | Find case-insensitive string in all files and directories, recursively. Follows symlinks. |
| n | `grep -Rvi` | Same as above but only show lines that don't match the string. |
| f | `grep -Rli` | Same as 'y' but only print the filenames where the string is found. |
| fn | `grep -Rlvi` | Same as above but only show files that don't contain the string. |
| f. | `find . \| grep` | Grep list of files in current directory |
| f: | `find` | 'find' command |
| p | `less` | 'less' command |
| m | `man` | 'man' command |
| d | `wget` | 'wget' command |
| u | `curl` | 'curl' command |
| c | `cat` | 'cat' command |
| w | `echo >` | Write arguments to file, overwriting it if it exists. |
| a | `echo >>` | Write arguments to file, appending them if the file exists. |
| w: | `cat >` | Write stdin to file, overwriting if it exists. |
| a: | `cat >>` | Write stdin to file, appending it if the file exists. |
### XARGS
These aliases are versions of the aliases above but using xargs. This can be used
by piping the arguments to the xargs aliases.
| Alias | Command | Description |
|-------|----------------------|---------------------------------|
| x | `xargs` | 'xargs' command |
| xy | `xargs grep -Ri` | Same as 'y' alias using xargs. |
| xn | `xargs grep -Rvi` | Same as 'n' alias using xargs. |
| xf | `xargs grep -Rli` | Same as 'f' alias using xargs. |
| xfn | `xargs grep -Rlvi` | Same as 'fn' alias using xargs. |
| xf. | `xargs find \| grep` | Same as 'f.' alias using xargs. |
| xf: | `xargs find` | Same as 'f:' alias using xargs. |
| xc | `xargs cat` | Same as 'c' alias using xargs. |
| xp | `xargs less` | Same as 'p' alias using xargs. |
| xm | `xargs man` | Same as 'm' alias using xargs. |
| xd | `xargs wget` | Same as 'd' alias using xargs. |
| xu | `xargs curl` | Same as 'u' alias using xargs. |
| xw | `xargs echo >` | Same as 'w' alias using xargs. |
| xa | `xargs echo >>` | Same as 'a' alias using xargs. |
| xw: | `xargs cat >` | Same as 'w:' alias using xargs. |
| xa: | `xargs >>` | Same as 'a:' alias using xargs. |
### SUDO
These aliases are versions of the aliases above in [CAT, GREP, CURL, WGET](#cat-grep-curl-wget)
but using sudo to run them with root permission.
| Alias | Command | Description |
|-------|-----------------------|--------------------------------|
| s | `sudo` | 'sudo' command |
| sy | `sudo grep -Ri` | Same as 'y' alias using sudo. |
| sn | `sudo grep -Riv` | Same as 'n' alias using sudo. |
| sf | `sudo grep -Rli` | Same as 'f' alias using sudo. |
| sfn | `sudo grep -Rlvi` | Same as 'fn' alias using sudo. |
| sf. | `sudo find . \| grep` | Same as 'f.' alias using sudo. |
| sf: | `sudo find` | Same as 'f:' alias using sudo. |
| sp | `sudo less` | Same as 'p' alias using sudo. |
| sm | `sudo man` | Same as 'm' alias using sudo. |
| sd | `sudo wget` | Same as 'd' alias using sudo. |
| sc | `sudo cat` | Same as 'c' alias using sudo. |
| sw | `sudo echo >` | Same as 'w' alias using sudo. |
| sa | `sudo echo >>` | Same as 'a' alias using sudo. |
| sw: | `sudo cat >` | Same as 'w:' alias using sudo. |
| sa: | `sudo cat >>` | Same as 'a:' alias using sudo. |
### SUDO-XARGS
Same as above but using both sudo and xargs.
| Alias | Command | Description |
|-------|---------------------------|---------------------------------|
| sx | `sudo xargs` | 'sudo xargs' command |
| sxy | `sudo xargs grep -Ri` | Same as 'xy' alias using sudo. |
| sxn | `sudo xargs grep -Riv` | Same as 'xn' alias using sudo. |
| sxf | `sudo xargs grep -li` | Same as 'xf' alias using sudo. |
| sxfn | `sudo xargs grep -lvi` | Same as 'xfn' alias using sudo. |
| sxf. | `sudo xargs find \| grep` | Same as 'xf.' alias using sudo. |
| sxf: | `sudo xargs find` | Same as 'xf:' alias using sudo. |
| sxp | `sudo xargs less` | Same as 'xp' alias using sudo. |
| sxm | `sudo xargs man` | Same as 'xm' alias using sudo. |
| sxd | `sudo xargs wget` | Same as 'xd' alias using sudo. |
| sxu | `sudo xargs curl` | Same as 'xu' alias using sudo. |
| sxc | `sudo xargs cat` | Same as 'xc' alias using sudo. |
| sxw | `sudo xargs echo >` | Same as 'xw' alias using sudo. |
| sxa | `sudo xargs echo >>` | Same as 'xa' alias using sudo. |
| sxw: | `sudo xargs cat >` | Same as 'xw:' alias using sudo. |
| sxa: | `sudo xargs cat >>` | Same as 'xa:' alias using sudo. |
## Options
The commands `grep`, `sudo`, `wget`, `curl`, and `less` can be configured to use other commands
via the setup variables below, before Oh My Zsh is sourced. If they are not set yet, they will
use their default values:
| Setup variable | Default value |
|----------------|---------------|
| GREP | `grep` |
| ROOT | `sudo` |
| WGET | `wget` |
| CURL | `curl` |
| PAGER | `less` |
## Author
- [Karolin Varner](https://github.com/koraa)
################################################################################
# FILE: singlechar.plugin.zsh
# DESCRIPTION: oh-my-zsh plugin file.
# AUTHOR: Michael Varner (musikmichael@web.de)
# VERSION: 1.0.0
#
# This plugin adds single char shortcuts (and combinations) for some commands.
#
################################################################################
########################### ###########################
# Settings # Settings
......
# Sprunge plugin
This plugin uploads data and fetch URL from the pastebin http://sprunge.us
To enable it, add 'sprunge' to your plugins:
```
plugins=(... sprunge)
```
## Usage
| Command | Description |
|------------------------------|-------------------------------------------|
| `sprunge filename.txt` | Uploads filename.txt |
| `sprunge "this is a string"` | Uploads plain text |
| `sprunge < filename.txt` | Redirects filename.txt content to sprunge |
| `echo data \| sprunge` | Any piped data will be uploaded |
Once sprunge has processed the input it will give you a unique HTTP address:
```
$ sprunge "hello"
http://sprunge.us/XxjnKz
```
## Notes
- Sprunge accepts piped data, stdin redirection, text strings as input or filenames.
Only one of these can be used at a time.
- Argument precedence goes as follows: stdin > piped input > text strings.
- If a filename is mispelled or doesn't have the necessary path description, it will NOT
generate an error, but instead treat it as a text string.
...@@ -2,12 +2,9 @@ ...@@ -2,12 +2,9 @@
# Created by the blogger at the URL below...I don't know where to find his/her name # Created by the blogger at the URL below...I don't know where to find his/her name
# Original found at https://www.shellperson.net/sprunge-pastebin-script/ # Original found at https://www.shellperson.net/sprunge-pastebin-script/
usage() { sprunge() {
description | fmt -s >&2 if [[ "$1" = --help ]]; then
} fmt -s >&2 << EOF
description() {
cat << HERE
DESCRIPTION DESCRIPTION
Upload data and fetch URL from the pastebin http://sprunge.us Upload data and fetch URL from the pastebin http://sprunge.us
...@@ -19,27 +16,23 @@ USAGE ...@@ -19,27 +16,23 @@ USAGE
piped_data | $0 piped_data | $0
NOTES NOTES
-------------------------------------------------------------------------- Input Methods:
* INPUT METHODS * $0 can accept piped data, STDIN redirection [< filename.txt], text strings following the command as arguments, or filenames as arguments. Only one of these methods can be used at a time, so please see the note on precedence. Also, note that using a pipe or STDIN redirection will treat tabs as spaces, or disregard them entirely (if they appear at the beginning of a line). So I suggest using a filename as an argument if tabs are important either to the function or readability of the code.
$0 can accept piped data, STDIN redirection [<filename.txt], text strings following the command as arguments, or filenames as arguments. Only one of these methods can be used at a time, so please see the note on precedence. Also, note that using a pipe or STDIN redirection will treat tabs as spaces, or disregard them entirely (if they appear at the beginning of a line). So I suggest using a filename as an argument if tabs are important either to the function or readability of the code.
* PRECEDENCE * Precedence:
STDIN redirection has precedence, then piped input, then a filename as an argument, and finally text strings as an arguments. STDIN redirection has precedence, then piped input, then a filename as an argument, and finally text strings as arguments. For example:
EXAMPLE: echo piped | $0 arguments.txt < stdin_redirection.txt
echo piped | "$0" arguments.txt < stdin_redirection.txt
In this example, the contents of file_as_stdin_redirection.txt would be uploaded. Both the piped_text and the file_as_argument.txt are ignored. If there is piped input and arguments, the arguments will be ignored, and the piped input uploaded. In this example, the contents of file_as_stdin_redirection.txt would be uploaded. Both the piped_text and the file_as_argument.txt are ignored. If there is piped input and arguments, the arguments will be ignored, and the piped input uploaded.
* FILENAMES * Filenames:
If a filename is misspelled or doesn't have the necessary path description, it will NOT generate an error, but will instead treat it as a text string and upload it. If a filename is misspelled or doesn't have the necessary path description, it will NOT generate an error, but will instead treat it as a text string and upload it.
--------------------------------------------------------------------------
HERE EOF
exit return
} fi
sprunge() {
if [ -t 0 ]; then if [ -t 0 ]; then
echo Running interactively, checking for arguments... >&2 echo Running interactively, checking for arguments... >&2
if [ "$*" ]; then if [ "$*" ]; then
...@@ -53,7 +46,8 @@ sprunge() { ...@@ -53,7 +46,8 @@ sprunge() {
fi | curl -F 'sprunge=<-' http://sprunge.us fi | curl -F 'sprunge=<-' http://sprunge.us
else else
echo No arguments found, printing USAGE and exiting. >&2 echo No arguments found, printing USAGE and exiting. >&2
usage sprunge --help
return 1
fi fi
else else
echo Using input from a pipe or STDIN redirection... >&2 echo Using input from a pipe or STDIN redirection... >&2
......
...@@ -12,7 +12,7 @@ function _start_agent() { ...@@ -12,7 +12,7 @@ function _start_agent() {
} }
function _add_identities() { function _add_identities() {
local id line sig local id line sig lines
local -a identities loaded_sigs loaded_ids not_loaded local -a identities loaded_sigs loaded_ids not_loaded
zstyle -a :omz:plugins:ssh-agent identities identities zstyle -a :omz:plugins:ssh-agent identities identities
...@@ -32,10 +32,12 @@ function _add_identities() { ...@@ -32,10 +32,12 @@ function _add_identities() {
fi fi
# get list of loaded identities' signatures and filenames # get list of loaded identities' signatures and filenames
for line in ${(f)"$(ssh-add -l)"}; do if lines=$(ssh-add -l); then
for line in ${(f)lines}; do
loaded_sigs+=${${(z)line}[2]} loaded_sigs+=${${(z)line}[2]}
loaded_ids+=${${(z)line}[3]} loaded_ids+=${${(z)line}[3]}
done done
fi
# add identities if not already loaded # add identities if not already loaded
for id in $identities; do for id in $identities; do
......
...@@ -15,10 +15,10 @@ alias stn=create_project ...@@ -15,10 +15,10 @@ alias stn=create_project
declare -a _sublime_paths declare -a _sublime_paths
if [[ "$OSTYPE" == linux* ]]; then if [[ "$OSTYPE" == linux* ]]; then
if [[ "$(uname -r)" = *Microsoft* ]]; then if [[ "$(uname -r)" = *icrosoft* ]]; then
_sublime_paths=( _sublime_paths=(
"$(wslpath -u 'C:\Program Files\Sublime Text 3\subl.exe')" "$(wslpath -u 'C:\Program Files\Sublime Text 3\subl.exe' 2>/dev/null)"
"$(wslpath -u 'C:\Program Files\Sublime Text 2\subl.exe')" "$(wslpath -u 'C:\Program Files\Sublime Text 2\subl.exe' 2>/dev/null)"
) )
else else
_sublime_paths=( _sublime_paths=(
......
...@@ -13,10 +13,10 @@ Easily prefix your current or previous commands with `sudo` by pressing <kbd>esc ...@@ -13,10 +13,10 @@ Easily prefix your current or previous commands with `sudo` by pressing <kbd>esc
) )
``` ```
2. Reload the source file or restart your Terminal session: 2. Restart your shell or restart your Terminal session:
```console ```console
$ source ~/.zshrc $ exec zsh
$ $
``` ```
......
...@@ -28,4 +28,6 @@ sudo-command-line() { ...@@ -28,4 +28,6 @@ sudo-command-line() {
} }
zle -N sudo-command-line zle -N sudo-command-line
# Defined shortcut keys: [Esc] [Esc] # Defined shortcut keys: [Esc] [Esc]
bindkey "\e\e" sudo-command-line bindkey -M emacs '\e\e' sudo-command-line
bindkey -M vicmd '\e\e' sudo-command-line
bindkey -M viins '\e\e' sudo-command-line
# supervisor plugin
This plugin adds tab-completion for `supervisord`/`supervisorctl` in [Supervisor](http://supervisord.org/).
Supervisor is a client/server system that allows its users to monitor and control a number
of processes on UNIX-like operating systems.
To use it, add `supervisor` to the plugins array in your zshrc file:
```zsh
plugins=(... supervisor)
```
These scripts are from [zshcompfunc4supervisor](https://bitbucket.org/hhatto/zshcompfunc4supervisor).
...@@ -112,6 +112,13 @@ _supervisorctl_start() { ...@@ -112,6 +112,13 @@ _supervisorctl_start() {
'*::supvervisor process:_get_supervisor_procs' '*::supvervisor process:_get_supervisor_procs'
} }
(( $+functions[_supervisorctl_restart] )) ||
_supervisorctl_restart() {
# TODO: add 'all'
_arguments -s \
'*::supvervisor process:_get_supervisor_procs'
}
(( $+functions[_supervisorctl_status] )) || (( $+functions[_supervisorctl_status] )) ||
_supervisorctl_status() { _supervisorctl_status() {
_arguments \ _arguments \
......
# svn-fast-info plugin
Faster alternative to the main SVN plugin implementation. Works with svn 1.6 and newer.
Use as a drop-in replacement to the svn plugin, not as complementary.
To use it, add `svn-fast-info` to the plugins array in your zshrc file:
```zsh
plugins=(... svn-fast-info)
```
It's faster because his efficient use of svn (single svn call) which saves a lot on a huge codebase
It displays the current status of the local files (added, deleted, modified, replaced, or else...)
Use `svn_prompt_info` method to display the svn repository status in your theme.
## Functions
- `svn_prompt_info`: displays all the available information regarding the status of the svn repository.
- `svn_repo_need_upgrade`: shows whether the repository needs upgrading. `svn_prompt_info` queries the
rest of functions or not based on the result of this function.
- `svn_current_branch_name`: shows the current branch.
- `svn_repo_root_name`: displays the repository root.
- `svn_current_revision`: shows the currently checked-out revision.
- `svn_status_info`: shows a bunch of symbols depending on the status of the files in the repository.
## Options
- `ZSH_THEME_SVN_PROMPT_PREFIX`: sequence displayed at the beginning of the prompt info output.
- `ZSH_THEME_SVN_PROMPT_SUFFIX`: sequence displayed at the end of the prompt info output.
- `ZSH_THEME_SVN_PROMPT_CLEAN`: sequence displayed when the status of the repository is clean.
- `ZSH_THEME_SVN_PROMPT_ADDITIONS`: sequence displayed if there are added files in the repository.
**Default:** `+`.
- `ZSH_THEME_SVN_PROMPT_DELETIONS`: sequence displayed if there are deleted files in the repository.
**Default:** `✖`.
- `ZSH_THEME_SVN_PROMPT_MODIFICATIONS`: sequence displayed if there are modified files in the repository.
**Default:** `✎`.
- `ZSH_THEME_SVN_PROMPT_REPLACEMENTS`: sequence displayed if there are replaced files in the repository.
**Default:** `∿`.
- `ZSH_THEME_SVN_PROMPT_UNTRACKED`: sequence displayed if there are untracked files in the repository.
**Default:** `?`.
- `ZSH_THEME_SVN_PROMPT_DIRTY`: sequence displayed if the repository is dirty.
**Default:** `!`.
# vim:ft=zsh ts=2 sw=2 sts=2 et
#
# Faster alternative to the current SVN plugin implementation.
#
# Works with svn 1.6, 1.7, 1.8.
# Use `svn_prompt_info` method to enquire the svn data.
# It's faster because his efficient use of svn (single svn call) which saves a lot on a huge codebase
# It displays the current status of the local files (added, deleted, modified, replaced, or else...)
#
# Use as a drop-in replacement of the svn plugin not as complementary plugin
function svn_prompt_info() { function svn_prompt_info() {
local info local info
info=$(svn info 2>&1) || return 1; # capture stdout and stderr info=$(svn info 2>&1) || return 1 # capture stdout and stderr
local repo_need_upgrade=$(svn_repo_need_upgrade $info) local repo_need_upgrade=$(svn_repo_need_upgrade $info)
if [[ -n $repo_need_upgrade ]]; then if [[ -n $repo_need_upgrade ]]; then
...@@ -27,7 +16,6 @@ function svn_prompt_info() { ...@@ -27,7 +16,6 @@ function svn_prompt_info() {
printf '%s%s%s%s %s%s%s:%s%s%s%s' \ printf '%s%s%s%s %s%s%s:%s%s%s%s' \
"$ZSH_PROMPT_BASE_COLOR" \ "$ZSH_PROMPT_BASE_COLOR" \
"$ZSH_THEME_SVN_PROMPT_PREFIX" \ "$ZSH_THEME_SVN_PROMPT_PREFIX" \
\
"$(svn_status_info $info)" \ "$(svn_status_info $info)" \
"$ZSH_PROMPT_BASE_COLOR" \ "$ZSH_PROMPT_BASE_COLOR" \
\ \
...@@ -37,14 +25,13 @@ function svn_prompt_info() { ...@@ -37,14 +25,13 @@ function svn_prompt_info() {
\ \
"$(svn_current_revision $info)" \ "$(svn_current_revision $info)" \
"$ZSH_PROMPT_BASE_COLOR" \ "$ZSH_PROMPT_BASE_COLOR" \
\
"$ZSH_THEME_SVN_PROMPT_SUFFIX" \ "$ZSH_THEME_SVN_PROMPT_SUFFIX" \
"$ZSH_PROMPT_BASE_COLOR" "$ZSH_PROMPT_BASE_COLOR"
fi fi
} }
function svn_repo_need_upgrade() { function svn_repo_need_upgrade() {
grep -q "E155036" <<< ${1:-$(svn info 2> /dev/null)} && \ grep -q "E155036" <<< "${1:-$(svn info 2> /dev/null)}" && \
echo "E155036: upgrade repo with svn upgrade" echo "E155036: upgrade repo with svn upgrade"
} }
...@@ -63,12 +50,23 @@ function svn_current_revision() { ...@@ -63,12 +50,23 @@ function svn_current_revision() {
function svn_status_info() { function svn_status_info() {
local svn_status_string="$ZSH_THEME_SVN_PROMPT_CLEAN" local svn_status_string="$ZSH_THEME_SVN_PROMPT_CLEAN"
local svn_status="$(svn status 2> /dev/null)"; local svn_status="$(svn status 2> /dev/null)";
if command grep -E '^\s*A' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_ADDITIONS:-+}"; fi if command grep -E '^\s*A' &> /dev/null <<< $svn_status; then
if command grep -E '^\s*D' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_DELETIONS:-}"; fi svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_ADDITIONS:-+}"
if command grep -E '^\s*M' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_MODIFICATIONS:-}"; fi fi
if command grep -E '^\s*[R~]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_REPLACEMENTS:-}"; fi if command grep -E '^\s*D' &> /dev/null <<< $svn_status; then
if command grep -E '^\s*\?' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_UNTRACKED:-?}"; fi svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_DELETIONS:-}"
if command grep -E '^\s*[CI!L]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_DIRTY:-!}"; fi fi
if command grep -E '^\s*M' &> /dev/null <<< $svn_status; then
svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_MODIFICATIONS:-}"
fi
if command grep -E '^\s*[R~]' &> /dev/null <<< $svn_status; then
svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_REPLACEMENTS:-}"
fi
if command grep -E '^\s*\?' &> /dev/null <<< $svn_status; then
svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_UNTRACKED:-?}"
fi
if command grep -E '^\s*[CI!L]' &> /dev/null <<< $svn_status; then
svn_status_string="$svn_status_string${ZSH_THEME_SVN_PROMPT_DIRTY:-!}"
fi
echo $svn_status_string echo $svn_status_string
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
## Description ## Description
This plugin provides a few utilities that make you faster on your daily work with the [Swift Package Manager](https://github.com/apple/swift-package-manager), as well as autocompletion for Swift 5.0. This plugin provides a few utilities that make you faster on your daily work with the [Swift Package Manager](https://github.com/apple/swift-package-manager), as well as autocompletion for Swift 5.1.
To start using it, add the `swiftpm` plugin to your `plugins` array in `~/.zshrc`: To start using it, add the `swiftpm` plugin to your `plugins` array in `~/.zshrc`:
......
...@@ -82,13 +82,15 @@ _swift_build() { ...@@ -82,13 +82,15 @@ _swift_build() {
"(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]" "(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]"
"--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]" "--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]"
"--static-swift-stdlib[Link Swift stdlib statically]" "--static-swift-stdlib[Link Swift stdlib statically]"
"--enable-llbuild-library[Enable building with the llbuild library]"
"--force-resolved-versions[]" "--force-resolved-versions[]"
"--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]" "--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
"--enable-index-store[Enable indexing-while-building feature]" "--enable-index-store[Enable indexing-while-building feature]"
"--disable-index-store[Disable indexing-while-building feature]" "--disable-index-store[Disable indexing-while-building feature]"
"--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]" "--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
"--enable-parseable-module-interfaces[]" "--enable-parseable-module-interfaces[]"
"--trace-resolver[]"
"(--jobs -j)"{--jobs,-j}"[The number of jobs to spawn in parallel during the build process]:The number of jobs to spawn in parallel during the build process: "
"--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]"
"--build-tests[Build both source and test targets]" "--build-tests[Build both source and test targets]"
"--product[Build the specified product]:Build the specified product: " "--product[Build the specified product]:Build the specified product: "
"--target[Build the specified target]:Build the specified target: " "--target[Build the specified target]:Build the specified target: "
...@@ -125,13 +127,15 @@ _swift_run() { ...@@ -125,13 +127,15 @@ _swift_run() {
"(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]" "(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]"
"--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]" "--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]"
"--static-swift-stdlib[Link Swift stdlib statically]" "--static-swift-stdlib[Link Swift stdlib statically]"
"--enable-llbuild-library[Enable building with the llbuild library]"
"--force-resolved-versions[]" "--force-resolved-versions[]"
"--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]" "--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
"--enable-index-store[Enable indexing-while-building feature]" "--enable-index-store[Enable indexing-while-building feature]"
"--disable-index-store[Disable indexing-while-building feature]" "--disable-index-store[Disable indexing-while-building feature]"
"--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]" "--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
"--enable-parseable-module-interfaces[]" "--enable-parseable-module-interfaces[]"
"--trace-resolver[]"
"(--jobs -j)"{--jobs,-j}"[The number of jobs to spawn in parallel during the build process]:The number of jobs to spawn in parallel during the build process: "
"--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]"
"--skip-build[Skip building the executable product]" "--skip-build[Skip building the executable product]"
"--build-tests[Build both source and test targets]" "--build-tests[Build both source and test targets]"
"--repl[Launch Swift REPL for the package]" "--repl[Launch Swift REPL for the package]"
...@@ -166,13 +170,15 @@ _swift_package() { ...@@ -166,13 +170,15 @@ _swift_package() {
"(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]" "(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]"
"--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]" "--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]"
"--static-swift-stdlib[Link Swift stdlib statically]" "--static-swift-stdlib[Link Swift stdlib statically]"
"--enable-llbuild-library[Enable building with the llbuild library]"
"--force-resolved-versions[]" "--force-resolved-versions[]"
"--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]" "--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
"--enable-index-store[Enable indexing-while-building feature]" "--enable-index-store[Enable indexing-while-building feature]"
"--disable-index-store[Disable indexing-while-building feature]" "--disable-index-store[Disable indexing-while-building feature]"
"--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]" "--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
"--enable-parseable-module-interfaces[]" "--enable-parseable-module-interfaces[]"
"--trace-resolver[]"
"(--jobs -j)"{--jobs,-j}"[The number of jobs to spawn in parallel during the build process]:The number of jobs to spawn in parallel during the build process: "
"--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]"
'(-): :->command' '(-): :->command'
'(-)*:: :->arg' '(-)*:: :->arg'
) )
...@@ -181,49 +187,61 @@ _swift_package() { ...@@ -181,49 +187,61 @@ _swift_package() {
(command) (command)
local modes local modes
modes=( modes=(
'update:Update package dependencies' 'completion-tool:Completion tool (for shell completions)'
'dump-package:Print parsed Package.swift as JSON'
'describe:Describe the current package' 'describe:Describe the current package'
'resolve:Resolve package dependencies' 'clean:Delete build artifacts'
'tools-version:Manipulate tools version of the current package'
'unedit:Remove a package from editable mode'
'show-dependencies:Print the resolved dependency graph' 'show-dependencies:Print the resolved dependency graph'
'init:Initialize a new package'
'unedit:Remove a package from editable mode'
'tools-version:Manipulate tools version of the current package'
'fetch:' 'fetch:'
'dump-package:Print parsed Package.swift as JSON' 'resolve:Resolve package dependencies'
'reset:Reset the complete cache/build directory'
'generate-xcodeproj:Generates an Xcode project'
'edit:Put a package in editable mode' 'edit:Put a package in editable mode'
'config:Manipulate configuration of the package' 'config:Manipulate configuration of the package'
'completion-tool:Completion tool (for shell completions)' 'update:Update package dependencies'
'clean:Delete build artifacts'
'generate-xcodeproj:Generates an Xcode project'
'reset:Reset the complete cache/build directory'
'init:Initialize a new package'
) )
_describe "mode" modes _describe "mode" modes
;; ;;
(arg) (arg)
case ${words[1]} in case ${words[1]} in
(update) (completion-tool)
_swift_package_update _swift_package_completion-tool
;;
(dump-package)
_swift_package_dump-package
;; ;;
(describe) (describe)
_swift_package_describe _swift_package_describe
;; ;;
(resolve) (clean)
_swift_package_resolve _swift_package_clean
;; ;;
(tools-version) (show-dependencies)
_swift_package_tools-version _swift_package_show-dependencies
;;
(init)
_swift_package_init
;; ;;
(unedit) (unedit)
_swift_package_unedit _swift_package_unedit
;; ;;
(show-dependencies) (tools-version)
_swift_package_show-dependencies _swift_package_tools-version
;; ;;
(fetch) (fetch)
_swift_package_fetch _swift_package_fetch
;; ;;
(dump-package) (resolve)
_swift_package_dump-package _swift_package_resolve
;;
(reset)
_swift_package_reset
;;
(generate-xcodeproj)
_swift_package_generate-xcodeproj
;; ;;
(edit) (edit)
_swift_package_edit _swift_package_edit
...@@ -231,27 +249,22 @@ _swift_package() { ...@@ -231,27 +249,22 @@ _swift_package() {
(config) (config)
_swift_package_config _swift_package_config
;; ;;
(completion-tool) (update)
_swift_package_completion-tool _swift_package_update
;;
(clean)
_swift_package_clean
;;
(generate-xcodeproj)
_swift_package_generate-xcodeproj
;;
(reset)
_swift_package_reset
;;
(init)
_swift_package_init
;; ;;
esac esac
;; ;;
esac esac
} }
_swift_package_update() { _swift_package_completion-tool() {
arguments=(
": :{_values '' 'generate-bash-script[generate Bash completion script]' 'generate-zsh-script[generate Bash completion script]' 'list-dependencies[list all dependencies' names]' 'list-executables[list all executables' names]'}"
)
_arguments $arguments && return
}
_swift_package_dump-package() {
arguments=( arguments=(
) )
_arguments $arguments && return _arguments $arguments && return
...@@ -264,20 +277,23 @@ _swift_package_describe() { ...@@ -264,20 +277,23 @@ _swift_package_describe() {
_arguments $arguments && return _arguments $arguments && return
} }
_swift_package_resolve() { _swift_package_clean() {
arguments=( arguments=(
":The name of the package to resolve:_swift_dependency"
"--version[The version to resolve at]:The version to resolve at: "
"--branch[The branch to resolve at]:The branch to resolve at: "
"--revision[The revision to resolve at]:The revision to resolve at: "
) )
_arguments $arguments && return _arguments $arguments && return
} }
_swift_package_tools-version() { _swift_package_show-dependencies() {
arguments=( arguments=(
"--set[Set tools version of package to the given value]:Set tools version of package to the given value: " "--format[text|dot|json|flatlist]: :{_values '' 'text[list dependencies using text format]' 'dot[list dependencies using dot format]' 'json[list dependencies using JSON format]'}"
"--set-current[Set tools version of package to the current tools version in use]" )
_arguments $arguments && return
}
_swift_package_init() {
arguments=(
"--type[empty|library|executable|system-module|manifest]: :{_values '' 'empty[generates an empty project]' 'library[generates project for a dynamic library]' 'executable[generates a project for a cli executable]' 'system-module[generates a project for a system module]'}"
"--name[Provide custom package name]:Provide custom package name: "
) )
_arguments $arguments && return _arguments $arguments && return
} }
...@@ -290,9 +306,10 @@ _swift_package_unedit() { ...@@ -290,9 +306,10 @@ _swift_package_unedit() {
_arguments $arguments && return _arguments $arguments && return
} }
_swift_package_show-dependencies() { _swift_package_tools-version() {
arguments=( arguments=(
"--format[text|dot|json|flatlist]: :{_values '' 'text[list dependencies using text format]' 'dot[list dependencies using dot format]' 'json[list dependencies using JSON format]'}" "--set[Set tools version of package to the given value]:Set tools version of package to the given value: "
"--set-current[Set tools version of package to the current tools version in use]"
) )
_arguments $arguments && return _arguments $arguments && return
} }
...@@ -303,8 +320,30 @@ _swift_package_fetch() { ...@@ -303,8 +320,30 @@ _swift_package_fetch() {
_arguments $arguments && return _arguments $arguments && return
} }
_swift_package_dump-package() { _swift_package_resolve() {
arguments=( arguments=(
":The name of the package to resolve:_swift_dependency"
"--version[The version to resolve at]:The version to resolve at: "
"--branch[The branch to resolve at]:The branch to resolve at: "
"--revision[The revision to resolve at]:The revision to resolve at: "
)
_arguments $arguments && return
}
_swift_package_reset() {
arguments=(
)
_arguments $arguments && return
}
_swift_package_generate-xcodeproj() {
arguments=(
"--xcconfig-overrides[Path to xcconfig file]:Path to xcconfig file:_files"
"--enable-code-coverage[Enable code coverage in the generated project]"
"--output[Path where the Xcode project should be generated]:Path where the Xcode project should be generated:_files"
"--legacy-scheme-generator[Use the legacy scheme generator]"
"--watch[Watch for changes to the Package manifest to regenerate the Xcode project]"
"--skip-extra-files[Do not add file references for extra files to the generated Xcode project]"
) )
_arguments $arguments && return _arguments $arguments && return
} }
...@@ -330,8 +369,8 @@ _swift_package_config() { ...@@ -330,8 +369,8 @@ _swift_package_config() {
local modes local modes
modes=( modes=(
'unset-mirror:Remove an existing mirror' 'unset-mirror:Remove an existing mirror'
'set-mirror:Set a mirror for a dependency'
'get-mirror:Print mirror configuration for the given package dependency' 'get-mirror:Print mirror configuration for the given package dependency'
'set-mirror:Set a mirror for a dependency'
) )
_describe "mode" modes _describe "mode" modes
;; ;;
...@@ -340,12 +379,12 @@ _swift_package_config() { ...@@ -340,12 +379,12 @@ _swift_package_config() {
(unset-mirror) (unset-mirror)
_swift_package_config_unset-mirror _swift_package_config_unset-mirror
;; ;;
(set-mirror)
_swift_package_config_set-mirror
;;
(get-mirror) (get-mirror)
_swift_package_config_get-mirror _swift_package_config_get-mirror
;; ;;
(set-mirror)
_swift_package_config_set-mirror
;;
esac esac
;; ;;
esac esac
...@@ -359,14 +398,6 @@ _swift_package_config_unset-mirror() { ...@@ -359,14 +398,6 @@ _swift_package_config_unset-mirror() {
_arguments $arguments && return _arguments $arguments && return
} }
_swift_package_config_set-mirror() {
arguments=(
"--package-url[The package dependency url]:The package dependency url: "
"--mirror-url[The mirror url]:The mirror url: "
)
_arguments $arguments && return
}
_swift_package_config_get-mirror() { _swift_package_config_get-mirror() {
arguments=( arguments=(
"--package-url[The package dependency url]:The package dependency url: " "--package-url[The package dependency url]:The package dependency url: "
...@@ -374,41 +405,16 @@ _swift_package_config_get-mirror() { ...@@ -374,41 +405,16 @@ _swift_package_config_get-mirror() {
_arguments $arguments && return _arguments $arguments && return
} }
_swift_package_completion-tool() { _swift_package_config_set-mirror() {
arguments=(
": :{_values '' 'generate-bash-script[generate Bash completion script]' 'generate-zsh-script[generate Bash completion script]' 'list-dependencies[list all dependencies' names]' 'list-executables[list all executables' names]'}"
)
_arguments $arguments && return
}
_swift_package_clean() {
arguments=(
)
_arguments $arguments && return
}
_swift_package_generate-xcodeproj() {
arguments=(
"--xcconfig-overrides[Path to xcconfig file]:Path to xcconfig file:_files"
"--enable-code-coverage[Enable code coverage in the generated project]"
"--output[Path where the Xcode project should be generated]:Path where the Xcode project should be generated:_files"
"--legacy-scheme-generator[Use the legacy scheme generator]"
"--watch[Watch for changes to the Package manifest to regenerate the Xcode project]"
"--skip-extra-files[Do not add file references for extra files to the generated Xcode project]"
)
_arguments $arguments && return
}
_swift_package_reset() {
arguments=( arguments=(
"--package-url[The package dependency url]:The package dependency url: "
"--mirror-url[The mirror url]:The mirror url: "
) )
_arguments $arguments && return _arguments $arguments && return
} }
_swift_package_init() { _swift_package_update() {
arguments=( arguments=(
"--type[empty|library|executable|system-module]: :{_values '' 'empty[generates an empty project]' 'library[generates project for a dynamic library]' 'executable[generates a project for a cli executable]' 'system-module[generates a project for a system module]'}"
"--name[Provide custom package name]:Provide custom package name: "
) )
_arguments $arguments && return _arguments $arguments && return
} }
...@@ -440,13 +446,15 @@ _swift_test() { ...@@ -440,13 +446,15 @@ _swift_test() {
"(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]" "(--verbose -v)"{--verbose,-v}"[Increase verbosity of informational output]"
"--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]" "--no-static-swift-stdlib[Do not link Swift stdlib statically \[default\]]"
"--static-swift-stdlib[Link Swift stdlib statically]" "--static-swift-stdlib[Link Swift stdlib statically]"
"--enable-llbuild-library[Enable building with the llbuild library]"
"--force-resolved-versions[]" "--force-resolved-versions[]"
"--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]" "--disable-automatic-resolution[Disable automatic resolution if Package.resolved file is out-of-date]"
"--enable-index-store[Enable indexing-while-building feature]" "--enable-index-store[Enable indexing-while-building feature]"
"--disable-index-store[Disable indexing-while-building feature]" "--disable-index-store[Disable indexing-while-building feature]"
"--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]" "--enable-pubgrub-resolver[\[Experimental\] Enable the new Pubgrub dependency resolver]"
"--enable-parseable-module-interfaces[]" "--enable-parseable-module-interfaces[]"
"--trace-resolver[]"
"(--jobs -j)"{--jobs,-j}"[The number of jobs to spawn in parallel during the build process]:The number of jobs to spawn in parallel during the build process: "
"--enable-test-discovery[Enable test discovery on platforms without Objective-C runtime]"
"--skip-build[Skip building the test target]" "--skip-build[Skip building the test target]"
"(--list-tests -l)"{--list-tests,-l}"[Lists test methods in specifier format]" "(--list-tests -l)"{--list-tests,-l}"[Lists test methods in specifier format]"
"--generate-linuxmain[Generate LinuxMain.swift entries for the package]" "--generate-linuxmain[Generate LinuxMain.swift entries for the package]"
......
...@@ -28,8 +28,8 @@ alias mkdir='mkdir -pv' ...@@ -28,8 +28,8 @@ alias mkdir='mkdir -pv'
alias psmem='ps -e -orss=,args= | sort -b -k1,1n' alias psmem='ps -e -orss=,args= | sort -b -k1,1n'
alias psmem10='ps -e -orss=,args= | sort -b -k1,1n| head -10' alias psmem10='ps -e -orss=,args= | sort -b -k1,1n| head -10'
# get top process eating cpu if not work try excute : export LC_ALL='C' # get top process eating cpu if not work try excute : export LC_ALL='C'
alias pscpu='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1 -nr' alias pscpu='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr'
alias pscpu10='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1 -nr | head -10' alias pscpu10='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr | head -10'
# top10 of the history # top10 of the history
alias hist10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10' alias hist10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
......
...@@ -51,3 +51,44 @@ plugins=(... systemd) ...@@ -51,3 +51,44 @@ plugins=(... systemd)
You can use the above aliases as `--user` by using the prefix `scu` instead of `sc`. You can use the above aliases as `--user` by using the prefix `scu` instead of `sc`.
For example: `scu-list-units` will be aliased to `systemctl --user list-units`. For example: `scu-list-units` will be aliased to `systemctl --user list-units`.
### Unit Status Prompt
You can add a token to your prompt in a similar way to the gitfast plugin. To add the token
to your prompt, drop `$(systemd_prompt_info [unit]...)` into your prompt (more than one unit
may be specified).
The plugin will add the following to your prompt for each `$unit`.
```
<prefix><unit>:<active|notactive><suffix>
```
You can control these parts with the following variables:
- `<prefix>`: Set `$ZSH_THEME_SYSTEMD_PROMPT_PREFIX`.
- `<suffix>`: Set `$ZSH_THEME_SYSTEMD_PROMPT_SUFFIX`.
- `<unit>`: name passed as parameter to the function. If you want it to be in ALL CAPS,
you can set the variable `$ZSH_THEME_SYSTEMD_PROMPT_CAPS` to a non-empty string.
- `<active>`: shown if the systemd unit is active.
Set `$ZSH_THEME_SYSTEMD_PROMPT_ACTIVE`.
- `<notactive>`: shown if the systemd unit is *not* active.
Set `$ZSH_THEME_SYSTEMD_PROMPT_NOTACTIVE`.
For example, if your prompt contains `PROMPT='$(systemd_prompt_info dhcpd httpd)'` and you set the following variables:
```
ZSH_THEME_SYSTEMD_PROMPT_PREFIX="["
ZSH_THEME_SYSTEMD_PROMPT_SUFFIX="]"
ZSH_THEME_SYSTEMD_PROMPT_ACTIVE="+"
ZSH_THEME_SYSTEMD_PROMPT_NOTACTIVE="X"
ZSH_THEME_SYSTEMD_PROMPT_CAPS=1
```
If `dhcpd` is running, and `httpd` is not, then your prompt will look like this:
```
[DHCPD: +][HTTPD: X]
```
user_commands=( user_commands=(
list-units is-active status show help list-unit-files cat
is-enabled list-jobs show-environment cat list-timers) get-default
help
is-active
is-enabled
is-failed
is-system-running
list-dependencies
list-jobs
list-sockets
list-timers
list-unit-files
list-units
show
show-environment
status)
sudo_commands=( sudo_commands=(
start stop reload restart try-restart isolate kill add-requires
reset-failed enable disable reenable preset mask unmask add-wants
link load cancel set-environment unset-environment cancel
edit) daemon-reexec
daemon-reload
default
disable
edit
emergency
enable
halt
hibernate
hybrid-sleep
import-environment
isolate
kexec
kill
link
list-machines
load
mask
poweroff
preset
preset-all
reboot
reenable
reload
reload-or-restart
reset-failed
rescue
restart
revert
set-default
set-environment
set-property
start
stop
suspend
switch-root
try-reload-or-restart
try-restart
unmask
unset-environment)
for c in $user_commands; do; alias sc-$c="systemctl $c"; done for c in $user_commands; do; alias sc-$c="systemctl $c"; done
for c in $sudo_commands; do; alias sc-$c="sudo systemctl $c"; done for c in $sudo_commands; do; alias sc-$c="sudo systemctl $c"; done
...@@ -20,3 +73,18 @@ alias sc-mask-now="sc-mask --now" ...@@ -20,3 +73,18 @@ alias sc-mask-now="sc-mask --now"
alias scu-enable-now="scu-enable --now" alias scu-enable-now="scu-enable --now"
alias scu-disable-now="scu-disable --now" alias scu-disable-now="scu-disable --now"
alias scu-mask-now="scu-mask --now" alias scu-mask-now="scu-mask --now"
function systemd_prompt_info {
local unit
for unit in $@; do
echo -n "$ZSH_THEME_SYSTEMD_PROMPT_PREFIX"
[[ -n "$ZSH_THEME_SYSTEMD_PROMPT_CAPS" ]] && echo "${(U)unit}:" || echo "$unit:"
if systemctl is-active $unit &>/dev/null; then
echo -n "$ZSH_THEME_SYSTEMD_PROMPT_ACTIVE"
else
echo -n "$ZSH_THEME_SYSTEMD_PROMPT_NOTACTIVE"
fi
echo -n "$ZSH_THEME_SYSTEMD_PROMPT_SUFFIX"
done
}
# This file is intentionally empty.
#
# The terminalapp plugin is deprecated and may be removed in a future release.
# Its functionality has been folded in to the core lib/termsupport.zsh, which
# is loaded for all users. You can remove terminalapp from your $plugins list
# once all your systems are updated to the current version of Oh My Zsh.
# Terminitor plugin
This plugin adds completions for the [Terminitor](https://github.com/achiurizo/terminitor) development workflow setup tool.
To use it, add `terminitor` to the plugins array in your zshrc file:
```zsh
plugins=(... terminitor)
```
#compdef terraform #compdef terraform
local -a _terraform_cmds local -a _terraform_cmds opt_args
_terraform_cmds=( _terraform_cmds=(
'apply:Builds or changes infrastructure' 'apply:Builds or changes infrastructure'
'console:Interactive console for Terraform interpolations' 'console:Interactive console for Terraform interpolations'
...@@ -16,13 +16,21 @@ _terraform_cmds=( ...@@ -16,13 +16,21 @@ _terraform_cmds=(
'push:Upload this Terraform module to Atlas to run' 'push:Upload this Terraform module to Atlas to run'
'refresh:Update local state file against real resources' 'refresh:Update local state file against real resources'
'show:Inspect Terraform state or plan' 'show:Inspect Terraform state or plan'
'state:Advanced state management'
'taint:Manually mark a resource for recreation' 'taint:Manually mark a resource for recreation'
'untaint:Manually unmark a resource as tainted' 'untaint:Manually unmark a resource as tainted'
'validate:Validates the Terraform files' 'validate:Validates the Terraform files'
'version:Prints the Terraform version' 'version:Prints the Terraform version'
'workspace:Workspace management' 'workspace:Workspace management'
'0.12upgrade:Rewrites pre-0.12 module source code for v0.12'
) )
__012upgrade() {
_arguments \
'-yes[Skip the initial introduction messages and interactive confirmation. This can be used to run this command in batch from a script.]' \
'-force[ Override the heuristic that attempts to detect if a configuration is already written for v0.12 or later. Some of the transformations made by this command are not idempotent, so re-running against the same module may change the meanings expressions in the module.]'
}
__apply() { __apply() {
_arguments \ _arguments \
'-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \ '-backup=[(path) Path to backup the existing state file before modifying. Defaults to the "-state-out" path with ".backup" extension. Set to "-" to disable backup.]' \
...@@ -35,7 +43,7 @@ __apply() { ...@@ -35,7 +43,7 @@ __apply() {
'-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \ '-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \
'-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]' \ '-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]' \
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \ '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \
'-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]' \ '-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
'-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \ '-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
'-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]' '-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]'
} }
...@@ -59,7 +67,7 @@ __destroy() { ...@@ -59,7 +67,7 @@ __destroy() {
'-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \ '-refresh=[(true) Update state prior to checking for differences. This has no effect if a plan file is given to apply.]' \
'-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]' \ '-state=[(terraform.tfstate) Path to read and save state (unless state-out is specified).]' \
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \ '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \
'-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]' \ '-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
'-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \ '-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
'-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]' '-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]'
} }
...@@ -140,7 +148,7 @@ __plan() { ...@@ -140,7 +148,7 @@ __plan() {
'-parallelism=[(10) Limit the number of concurrent operations.]' \ '-parallelism=[(10) Limit the number of concurrent operations.]' \
'-refresh=[(true) Update state prior to checking for differences.]' \ '-refresh=[(true) Update state prior to checking for differences.]' \
'-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]' \ '-state=[(statefile) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]' \
'-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]' \ '-target=[(resource) Resource to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
'-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \ '-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
'-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]' \ '-var-file=[(foo) Set variables in the Terraform configuration from a file. If "terraform.tfvars" or any ".auto.tfvars" files are present, they will be automatically loaded.]' \
} }
...@@ -172,7 +180,7 @@ __refresh() { ...@@ -172,7 +180,7 @@ __refresh() {
'-no-color[If specified, output will not contain any color.]' \ '-no-color[If specified, output will not contain any color.]' \
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \ '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
'-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \ '-state-out=[(path) Path to write state to that is different than "-state". This can be used to preserve the old state.]' \
'-target=[(resource) A Resource Address to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]' \ '-target=[(resource) A Resource Address to target. Operation will be limited to this resource and its dependencies. This flag can be used multiple times.]:target:__statelist' \
'-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \ '-var[("foo=bar") Set a variable in the Terraform configuration. This flag can be set multiple times.]' \
'-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" is present, it will be automatically loaded if this flag is not specified.]' '-var-file=[(path) Set variables in the Terraform configuration from a file. If "terraform.tfvars" is present, it will be automatically loaded if this flag is not specified.]'
} }
...@@ -183,6 +191,70 @@ __show() { ...@@ -183,6 +191,70 @@ __show() {
'-no-color[If specified, output will not contain any color.]' '-no-color[If specified, output will not contain any color.]'
} }
__state() {
local -a __state_cmds
__state_cmds=(
'list:List resources in the state'
'mv:Move an item in the state'
'pull:Pull current state and output to stdout'
'push:Update remote state from a local state file'
'rm:Remove instances from the state'
'show:Show a resource in the state'
)
_describe -t state "state commands" __state_cmds
}
__state_list() {
_arguments \
'-state=[(path) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]' \
'-id=[(id) Filters the results to include only instances whose resource types have an attribute named id whose value equals the given id string.]' \
"*:address:__statelist"
}
__state_mv() {
_arguments \
"-dry-run[If set, prints out what would've been moved but doesn't actually move anything.]" \
"-backup=[(path) Path where Terraform should write the backup for the original state. This can't be disabled. If not set, Terraform will write it to the same path as the statefile with a \".backup\" extension.]:file:_files" \
"-backup-out=[(path) Path where Terraform should write the backup for the destination state. This can't be disabled. If not set, Terraform will write it to the same path as the destination state file with a backup extension. This only needs to be specified if -state-out is set to a different path than -state.]:file:_files" \
"-lock=[(true|false) Lock the state files when locking is supported.]:lock:(true false)" \
"-lock-timeout=[(seconds) Duration to retry a state lock.]" \
'-state=[(path) Path to the source state file. Defaults to the configured backend, or "terraform.tfstate"]:file:_files' \
"-state-out=[(path) Path to the destination state file to write to. If this isn't specified, the source state file will be used. This can be a new or existing path.]:file:_files" \
"::" \
":source:__statelist" \
":destination: "
}
__state_push() {
_arguments \
"-force[Write the state even if lineages don't match or the remote serial is higher.]" \
'-lock=[(true|false) Lock the state file when locking is supported.]:lock:(true false)' \
"-lock-timeout=[(seconds) Duration to retry a state lock.]" \
"::" \
":destination:_files"
}
__state_rm() {
_arguments \
"-dry-run[If set, prints out what would've been removed but doesn't actually remove anything.]" \
"-backup=[(path) Path where Terraform should write the backup for the original state.]:file:_files" \
"-lock=[(true|false) Lock the state files when locking is supported.]:lock:(true false)" \
"-lock-timeout=[(seconds) Duration to retry a state lock.]" \
'-state=[(path) Path to the state file to update. Defaults to the current workspace state.]:file:_files' \
"*:address:__statelist"
}
__state_show() {
_arguments \
'-state=[(path) Path to a Terraform state file to use to look up Terraform-managed resources. By default it will use the state "terraform.tfstate" if it exists.]' \
"*:address:__statelist"
}
__statelist() {
compadd $(terraform state list $opt_args[-state])
}
__taint() { __taint() {
_arguments \ _arguments \
'-allow-missing[If specified, the command will succeed (exit code 0) even if the resource is missing.]' \ '-allow-missing[If specified, the command will succeed (exit code 0) even if the resource is missing.]' \
...@@ -192,7 +264,8 @@ __taint() { ...@@ -192,7 +264,8 @@ __taint() {
'-module=[(path) The module path where the resource lives. By default this will be root. Child modules can be specified by names. Ex. "consul" or "consul.vpc" (nested modules).]' \ '-module=[(path) The module path where the resource lives. By default this will be root. Child modules can be specified by names. Ex. "consul" or "consul.vpc" (nested modules).]' \
'-no-color[If specified, output will not contain any color.]' \ '-no-color[If specified, output will not contain any color.]' \
'-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \ '-state=[(path) Path to read and save state (unless state-out is specified). Defaults to "terraform.tfstate".]' \
'-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]' '-state-out=[(path) Path to write updated state file. By default, the "-state" path will be used.]' \
"*:address:__statelist"
} }
__untaint() { __untaint() {
...@@ -236,6 +309,8 @@ fi ...@@ -236,6 +309,8 @@ fi
local -a _command_args local -a _command_args
case "$words[1]" in case "$words[1]" in
0.12upgrade)
__012upgrade ;;
apply) apply)
__apply ;; __apply ;;
console) console)
...@@ -264,6 +339,14 @@ case "$words[1]" in ...@@ -264,6 +339,14 @@ case "$words[1]" in
__refresh ;; __refresh ;;
show) show)
__show ;; __show ;;
state)
test $CURRENT -lt 3 && __state
[[ $words[2] = "list" ]] && __state_list
[[ $words[2] = "mv" ]] && __state_mv
[[ $words[2] = "push" ]] && __state_push
[[ $words[2] = "rm" ]] && __state_rm
[[ $words[2] = "show" ]] && __state_show
;;
taint) taint)
__taint ;; __taint ;;
untaint) untaint)
......
...@@ -6,4 +6,4 @@ ...@@ -6,4 +6,4 @@
Press `ESC` twice to correct previous console command. Press `ESC` twice to correct previous console command.
## Notes ## Notes
`Esc`-`Esc` key binding conflicts with [sudo](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/sudo) plugin. `Esc`-`Esc` key binding conflicts with [sudo](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/sudo) plugin.
...@@ -15,4 +15,6 @@ fuck-command-line() { ...@@ -15,4 +15,6 @@ fuck-command-line() {
} }
zle -N fuck-command-line zle -N fuck-command-line
# Defined shortcut keys: [Esc] [Esc] # Defined shortcut keys: [Esc] [Esc]
bindkey "\e\e" fuck-command-line bindkey -M emacs '\e\e' fuck-command-line
bindkey -M vicmd '\e\e' fuck-command-line
bindkey -M viins '\e\e' fuck-command-line
#compdef theme
_arguments "1: :($(lstheme | tr "\n" " "))"
function theme function theme {
{ : ${1:=random} # Use random theme if none provided
if [ -z "$1" ] || [ "$1" = "random" ]; then
themes=($ZSH/themes/*zsh-theme) if [[ -f "$ZSH_CUSTOM/$1.zsh-theme" ]]; then
N=${#themes[@]} source "$ZSH_CUSTOM/$1.zsh-theme"
((N=(RANDOM%N)+1)) elif [[ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]]; then
RANDOM_THEME=${themes[$N]}
source "$RANDOM_THEME"
echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
else
if [ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]
then
source "$ZSH_CUSTOM/themes/$1.zsh-theme" source "$ZSH_CUSTOM/themes/$1.zsh-theme"
else elif [[ -f "$ZSH/themes/$1.zsh-theme" ]]; then
source "$ZSH/themes/$1.zsh-theme" source "$ZSH/themes/$1.zsh-theme"
else
echo "$0: Theme '$1' not found"
return 1
fi fi
fi
} }
function lstheme function _theme {
{ _arguments "1: :($(lstheme))"
}
compdef _theme theme
function lstheme {
# Resources: # Resources:
# http://zsh.sourceforge.net/Doc/Release/Expansion.html#Modifiers # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Modifiers
# http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Qualifiers # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Qualifiers
print -l {$ZSH,$ZSH_CUSTOM}/themes/*.zsh-theme(N:t:r) print "$ZSH_CUSTOM"/*.zsh-theme(N:t:r) {"$ZSH_CUSTOM","$ZSH"}/themes/*.zsh-theme(N:t:r)
} }
# Thor plugin
This plugin adds completion for [Thor](http://whatisthor.com/),
a ruby toolkit for building powerful command-line interfaces.
To use it, add `thor` to the plugins array in your zshrc file:
```zsh
plugins=(... thor)
```
...@@ -25,5 +25,6 @@ __timer_display_timer_precmd() { ...@@ -25,5 +25,6 @@ __timer_display_timer_precmd() {
fi fi
} }
preexec_functions+=(__timer_save_time_preexec) autoload -U add-zsh-hook
precmd_functions+=(__timer_display_timer_precmd) add-zsh-hook preexec __timer_save_time_preexec
add-zsh-hook precmd __timer_display_timer_precmd
# tmux-cssh plugin
This plugin adds autocompletion for [`tmux-cssh`](https://github.com/zinic/tmux-cssh/).
To use it, add `tmux-cssh` to the plugins array in your zshrc file:
```zsh
plugins=(... tmux-cssh)
```
First upstream repo, now disappeared: https://github.com/dennishafemann/tmux-cssh.
...@@ -5,16 +5,16 @@ ...@@ -5,16 +5,16 @@
# Author: Manfred Touron (@moul) # Author: Manfred Touron (@moul)
_arguments \ _arguments \
'(-h --help)'{-h,--help}'[This help.]' \ '(-h --help)'{-h,--help}'[This help.]' \
'(-u --user)'{-u,--user}'[User to use.]' \ '(-u --user)'{-u,--user}'[User to use.]' \
'(-c --certificate)'{-c,--certificate}'[Path to ssh-certificate to use.]' \ '(-c --certificate)'{-c,--certificate}'[Path to ssh-certificate to use.]' \
'(-sc --ssh)'{-sc,--ssh}'[SSH-connection-string, multiple.]' \ '(-sc --ssh)'{-sc,--ssh}'[SSH-connection-string, multiple.]' \
'(-sa --ssh)'{-sa,--ssh}'[SSH connection arguments, used on every session.]' \ '(-sa --ssh)'{-sa,--ssh}'[SSH connection arguments, used on every session.]' \
'(-ts --tmux)'{-ts,--tmux}'[Alternative tmux-session-name, default: tmux-cssh]' \ '(-ts --tmux)'{-ts,--tmux}'[Alternative tmux-session-name, default: tmux-cssh]' \
'(-ns --new)'{-ns,--new}'[Initializes a new session, like -ts \[name\].]' \ '(-ns --new)'{-ns,--new}'[Initializes a new session, like -ts \[name\].]' \
'(-q --quiet)'{-q,--quiet}'[Quiet-mode.]' \ '(-q --quiet)'{-q,--quiet}'[Quiet-mode.]' \
'(-f --filename)'{-f,--filename}'[Filename of textfile to get -sc connection-strings from, line separated.]' \ '(-f --filename)'{-f,--filename}'[Filename of textfile to get -sc connection-strings from, line separated.]' \
'(-cs --config)'{-cs,--config}'[Name of config-settings which should be get from config-file "$HOME/.tmux-cssh". Which can be a grep-regular expression to find the name(s).]' \ '(-cs --config)'{-cs,--config}'[Name of config-settings which should be get from config-file "$HOME/.tmux-cssh". Which can be a grep-regular expression to find the name(s).]' \
':hosts:_hosts' \ ':hosts:_hosts' \
'*:: :->subcmds' \ '*:: :->subcmds' \
&& return 0 && return 0
......
# tmux # tmux
This plugin provides aliases for [tmux](http://tmux.github.io/), the terminal multiplexer. This plugin provides aliases for [tmux](https://tmux.github.io/), the terminal multiplexer.
To use it add `tmux` to the plugins array in your zshrc file. To use it add `tmux` to the plugins array in your zshrc file.
```zsh ```zsh
...@@ -37,3 +37,5 @@ The plugin also supports the following - ...@@ -37,3 +37,5 @@ The plugin also supports the following -
| `ZSH_TMUX_ITERM2` | Sets the `-CC` option for iTerm2 tmux integration (default: `false`) | | `ZSH_TMUX_ITERM2` | Sets the `-CC` option for iTerm2 tmux integration (default: `false`) |
| `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `screen`) | | `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `screen`) |
| `ZSH_TMUX_FIXTERM_WITH_256COLOR` | `$TERM` to use for 256-color terminals (default: `screen-256color` | | `ZSH_TMUX_FIXTERM_WITH_256COLOR` | `$TERM` to use for 256-color terminals (default: `screen-256color` |
| `ZSH_TMUX_CONFIG` | Set the configuration path (default: `$HOME/.tmux.conf`) |
| `ZSH_TMUX_UNICODE` | Set `tmux -u` option to support unicode |
set -g default-terminal $ZSH_TMUX_TERM set -g default-terminal $ZSH_TMUX_TERM
source $HOME/.tmux.conf source-file $ZSH_TMUX_CONFIG
\ No newline at end of file
...@@ -34,6 +34,10 @@ alias tkss='tmux kill-session -t' ...@@ -34,6 +34,10 @@ alias tkss='tmux kill-session -t'
# Tmux states this should be screen-256color, but you may need to change it on # Tmux states this should be screen-256color, but you may need to change it on
# systems without the proper terminfo # systems without the proper terminfo
: ${ZSH_TMUX_FIXTERM_WITH_256COLOR:=screen-256color} : ${ZSH_TMUX_FIXTERM_WITH_256COLOR:=screen-256color}
# Set the configuration path
: ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf}
# Set -u option to support unicode
: ${ZSH_TMUX_UNICODE:=false}
# Determine if the terminal supports 256 colors # Determine if the terminal supports 256 colors
if [[ $terminfo[colors] == 256 ]]; then if [[ $terminfo[colors] == 256 ]]; then
...@@ -43,7 +47,8 @@ else ...@@ -43,7 +47,8 @@ else
fi fi
# Set the correct local config file to use. # Set the correct local config file to use.
if [[ "$ZSH_TMUX_ITERM2" == "false" && -e "$HOME/.tmux.conf" ]]; then if [[ "$ZSH_TMUX_ITERM2" == "false" && -e "$ZSH_TMUX_CONFIG" ]]; then
export ZSH_TMUX_CONFIG
export _ZSH_TMUX_FIXED_CONFIG="${0:h:a}/tmux.extra.conf" export _ZSH_TMUX_FIXED_CONFIG="${0:h:a}/tmux.extra.conf"
else else
export _ZSH_TMUX_FIXED_CONFIG="${0:h:a}/tmux.only.conf" export _ZSH_TMUX_FIXED_CONFIG="${0:h:a}/tmux.only.conf"
...@@ -59,13 +64,18 @@ function _zsh_tmux_plugin_run() { ...@@ -59,13 +64,18 @@ function _zsh_tmux_plugin_run() {
local -a tmux_cmd local -a tmux_cmd
tmux_cmd=(command tmux) tmux_cmd=(command tmux)
[[ "$ZSH_TMUX_ITERM2" == "true" ]] && tmux_cmd+=(-CC) [[ "$ZSH_TMUX_ITERM2" == "true" ]] && tmux_cmd+=(-CC)
[[ "$ZSH_TMUX_UNICODE" == "true" ]] && tmux_cmd+=(-u)
# Try to connect to an existing session. # Try to connect to an existing session.
[[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach
# If failed, just run tmux, fixing the TERM variable if requested. # If failed, just run tmux, fixing the TERM variable if requested.
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
[[ "$ZSH_TMUX_FIXTERM" == "true" ]] && tmux_cmd+=(-f "$_ZSH_TMUX_FIXED_CONFIG") if [[ "$ZSH_TMUX_FIXTERM" == "true" ]]; then
tmux_cmd+=(-f "$_ZSH_TMUX_FIXED_CONFIG")
elif [[ -e "$ZSH_TMUX_CONFIG" ]]; then
tmux_cmd+=(-f "$ZSH_TMUX_CONFIG")
fi
$tmux_cmd new-session $tmux_cmd new-session
fi fi
......
# Tugboat plugin
This plugin adds autocompletion for Tugboat, a command line tool for interacting with your
[DigitalOcean droplets](https://www.digitalocean.com/products/droplets/).
To use it, add it to the plugins array in your `~/.zshrc` file:
```zsh
plugins=(... tugboat)
```
Further documentation for Tugboat can be found in the [Tugboat repository](https://github.com/petems/tugboat).
...@@ -12,10 +12,10 @@ alias acp='apt-cache policy' ...@@ -12,10 +12,10 @@ alias acp='apt-cache policy'
#List all installed packages #List all installed packages
alias agli='apt list --installed' alias agli='apt list --installed'
# superuser operations ######################################################
# List available updates only # List available updates only
alias aglu='sudo apt-get -u upgrade --assume-no' alias aglu='apt list --upgradable'
# superuser operations ######################################################
alias afu='sudo apt-file update' alias afu='sudo apt-file update'
......
# UFW plugin
This plugin adds completion for managing everybody's favorite Uncomplicated Firewall (UFW),
a simple interface for managing iptables. Learn more about [`UFW`](https://wiki.ubuntu.com/UncomplicatedFirewall).
To use it, add ufw to the plugins array of your zshrc file:
```
plugins=(... ufw)
```
Some of the commands include:
* `allow <port>/<optional: protocol>` add an allow rule
* `default` set default policy
* `delete <port>/<optional: protocol>` delete RULE
* `deny <port>/<optional: protocol>` add deny rule
* `disable` disables the firewall
* `enable` enables the firewall
...@@ -21,9 +21,9 @@ Original idea and aliases: [Ruslan Spivak](https://ruslanspivak.wordpress.com/20 ...@@ -21,9 +21,9 @@ Original idea and aliases: [Ruslan Spivak](https://ruslanspivak.wordpress.com/20
## Examples ## Examples
```zsh ```zsh
urlencode 'https://github.com/robbyrussell/oh-my-zsh/search?q=urltools&type=Code' urlencode 'https://github.com/ohmyzsh/ohmyzsh/search?q=urltools&type=Code'
# returns https%3A%2F%2Fgithub.com%2Frobbyrussell%2Foh-my-zsh%2Fsearch%3Fq%3Durltools%26type%3DCode # returns https%3A%2F%2Fgithub.com%2Fohmyzsh%2Fohmyzsh%2Fsearch%3Fq%3Durltools%26type%3DCode
urldecode 'https%3A%2F%2Fgithub.com%2Frobbyrussell%2Foh-my-zsh%2Fsearch%3Fq%3Durltools%26type%3DCode' urldecode 'https%3A%2F%2Fgithub.com%2Fohmyzsh%2Fohmyzsh%2Fsearch%3Fq%3Durltools%26type%3DCode'
# returns https://github.com/robbyrussell/oh-my-zsh/search?q=urltools&type=Code # returns https://github.com/ohmyzsh/ohmyzsh/search?q=urltools&type=Code
``` ```
...@@ -12,11 +12,11 @@ if [[ $(whence node) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD ...@@ -12,11 +12,11 @@ if [[ $(whence node) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD
alias urlencode='node -e "console.log(encodeURIComponent(process.argv[1]))"' alias urlencode='node -e "console.log(encodeURIComponent(process.argv[1]))"'
alias urldecode='node -e "console.log(decodeURIComponent(process.argv[1]))"' alias urldecode='node -e "console.log(decodeURIComponent(process.argv[1]))"'
elif [[ $(whence python3) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xpython" ) ]]; then elif [[ $(whence python3) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xpython" ) ]]; then
alias urlencode='python3 -c "import sys, urllib.parse as up; print(up.quote_plus(sys.argv[1]))"' alias urlencode='python3 -c "import sys; del sys.path[0]; import urllib.parse as up; print(up.quote_plus(sys.argv[1]))"'
alias urldecode='python3 -c "import sys, urllib.parse as up; print(up.unquote_plus(sys.argv[1]))"' alias urldecode='python3 -c "import sys; del sys.path[0]; import urllib.parse as up; print(up.unquote_plus(sys.argv[1]))"'
elif [[ $(whence python2) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xpython" ) ]]; then elif [[ $(whence python2) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xpython" ) ]]; then
alias urlencode='python2 -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1])"' alias urlencode='python2 -c "import sys; del sys.path[0]; import urllib as ul; print ul.quote_plus(sys.argv[1])"'
alias urldecode='python2 -c "import sys, urllib as ul; print ul.unquote_plus(sys.argv[1])"' alias urldecode='python2 -c "import sys; del sys.path[0]; import urllib as ul; print ul.unquote_plus(sys.argv[1])"'
elif [[ $(whence xxd) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xshell" ) ]]; then elif [[ $(whence xxd) != "" && ( "x$URLTOOLS_METHOD" = "x" || "x$URLTOOLS_METHOD" = "xshell" ) ]]; then
function urlencode() {echo $@ | tr -d "\n" | xxd -plain | sed "s/\(..\)/%\1/g"} function urlencode() {echo $@ | tr -d "\n" | xxd -plain | sed "s/\(..\)/%\1/g"}
function urldecode() {printf $(echo -n $@ | sed 's/\\/\\\\/g;s/\(%\)\([0-9a-fA-F][0-9a-fA-F]\)/\\x\2/g')"\n"} function urldecode() {printf $(echo -n $@ | sed 's/\\/\\\\/g;s/\(%\)\([0-9a-fA-F][0-9a-fA-F]\)/\\x\2/g')"\n"}
......
...@@ -8,3 +8,33 @@ To use it, add `vagrant` to the plugins array in your zshrc file: ...@@ -8,3 +8,33 @@ To use it, add `vagrant` to the plugins array in your zshrc file:
plugins=(... vagrant) plugins=(... vagrant)
``` ```
## Aliases
| Alias | Command |
|---------|------------------------------|
| `vgi` | `vagrant init` |
| `vup` | `vagrant up` |
| `vd` | `vagrant destroy` |
| `vdf` | `vagrant destroy -f` |
| `vssh` | `vagrant ssh` |
| `vsshc` | `vagrant ssh-config` |
| `vrdp` | `vagrant rdp` |
| `vh` | `vagrant halt` |
| `vssp` | `vagrant suspend` |
| `vst` | `vagrant status` |
| `vre` | `vagrant resume` |
| `vgs` | `vagrant global-status` |
| `vpr` | `vagrant provision` |
| `vr` | `vagrant reload` |
| `vrp` | `vagrant reload --provision` |
| `vp` | `vagrant push` |
| `vsh` | `vagrant share` |
| `vba` | `vagrant box add` |
| `vbr` | `vagrant box remove` |
| `vbl` | `vagrant box list` |
| `vbo` | `vagrant box outdated` |
| `vbu` | `vagrant box update` |
| `vpli` | `vagrant plugin install` |
| `vpll` | `vagrant plugin list` |
| `vplun` | `vagrant plugin uninstall` |
| `vplu` | `vagrant plugin update` |
...@@ -69,8 +69,8 @@ __box_list () ...@@ -69,8 +69,8 @@ __box_list ()
__vm_list () __vm_list ()
{ {
_wanted application expl 'command' compadd $(command grep Vagrantfile -oe '^[^#]*\.vm\.define *[:"]\([a-zA-Z0-9_-]\+\)' 2>/dev/null | awk '{print substr($2, 2)}') _wanted application expl 'command' compadd $(command grep "${VAGRANT_CWD:-.}/Vagrantfile" -oe '^[^#]*\.vm\.define *[:"]\([a-zA-Z0-9_-]\+\)' 2>/dev/null | awk '{print substr($2, 2)}')
_wanted application expl 'command' compadd $(command ls .vagrant/machines/ 2>/dev/null) _wanted application expl 'command' compadd $(command ls "${VAGRANT_CWD:-.}/.vagrant/machines/" 2>/dev/null)
} }
__vagrant-box () __vagrant-box ()
......
alias vgi="vagrant init"
alias vup="vagrant up"
alias vd="vagrant destroy"
alias vdf="vagrant destroy -f"
alias vssh="vagrant ssh"
alias vsshc="vagrant ssh-config"
alias vrdp="vagrant rdp"
alias vh="vagrant halt"
alias vssp="vagrant suspend"
alias vst="vagrant status"
alias vre="vagrant resume"
alias vgs="vagrant global-status"
alias vpr="vagrant provision"
alias vr="vagrant reload"
alias vrp="vagrant reload --provision"
alias vp="vagrant push"
alias vsh="vagrant share"
alias vba="vagrant box add"
alias vbr="vagrant box remove"
alias vbl="vagrant box list"
alias vbo="vagrant box outdated"
alias vbu="vagrant box update"
alias vpli="vagrant plugin install"
alias vpll="vagrant plugin list"
alias vplun="vagrant plugin uninstall"
alias vplu="vagrant plugin update"
# Virtualenvwrapper plugin
This plugin loads Python's [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/) shell tools.
To use it, add `virtualenvwrapper` to the plugins array in your zshrc file:
```zsh
plugins=(... virtualenvwrapper)
```
## Usage
The plugin allows to automatically activate virtualenvs on cd into git repositories with a matching name:
```
➜ github $ cd ansible
(ansible) ➜ ansible git:(devel) $ cd docs
(ansible) ➜ docs git:(devel) $ cd ..
(ansible) ➜ ansible git:(devel) $ cd ..
➜ github $
```
We can override this by having a `.venv` file in the directory containing a differently named virtualenv:
```
➜ github $ cat ansible/.venv
myvirtualenv
➜ github $ cd ansible
(myvirtualenv) ➜ ansible git:(devel) $ cd ..
➜ github $
```
We can disable this behaviour by setting `DISABLE_VENV_CD=1` before Oh My Zsh is sourced:
```zsh
DISABLE_VENV_CD=1
plugins=(... virtualenvwrapper)
source $ZSH/oh-my-zsh.sh
```
virtualenvwrapper='virtualenvwrapper.sh' function {
virtualenvwrapper_lazy='virtualenvwrapper_lazy.sh' # search in these locations for the init script:
for f in $commands[virtualenvwrapper_lazy.sh] \
if (( $+commands[$virtualenvwrapper_lazy] )); then $commands[virtualenvwrapper.sh] \
function { /usr/share/virtualenvwrapper/virtualenvwrapper{_lazy,}.sh \
setopt local_options /usr/local/bin/virtualenvwrapper{_lazy,}.sh \
unsetopt equals /etc/bash_completion.d/virtualenvwrapper \
virtualenvwrapper=${${virtualenvwrapper_lazy}:c} /usr/share/bash-completion/completions/virtualenvwrapper
source ${${virtualenvwrapper_lazy}:c} do
[[ -z "$WORKON_HOME" ]] && WORKON_HOME="$HOME/.virtualenvs" if [[ -f $f ]]; then
} source $f
elif (( $+commands[$virtualenvwrapper] )); then
function {
setopt local_options
unsetopt equals
source ${${virtualenvwrapper}:c}
}
elif [[ -f "/usr/local/bin/virtualenvwrapper.sh" ]]; then
function {
setopt local_options
unsetopt equals
virtualenvwrapper="/usr/local/bin/virtualenvwrapper.sh"
source "/usr/local/bin/virtualenvwrapper.sh"
}
elif [[ -f "/etc/bash_completion.d/virtualenvwrapper" ]]; then
function {
setopt local_options
unsetopt equals
virtualenvwrapper="/etc/bash_completion.d/virtualenvwrapper"
source "/etc/bash_completion.d/virtualenvwrapper"
}
else
print "[oh-my-zsh] virtualenvwrapper plugin: Cannot find ${virtualenvwrapper}.\n"\
"Please install with \`pip install virtualenvwrapper\`" >&2
return return
fi fi
done
print "[oh-my-zsh] virtualenvwrapper plugin: Cannot find virtualenvwrapper.sh.\n"\
"Please install with \`pip install virtualenvwrapper\`" >&2
}
if ! type workon &>/dev/null; then if ! type workon &>/dev/null; then
print "[oh-my-zsh] virtualenvwrapper plugin: shell function 'workon' not defined.\n"\ print "[oh-my-zsh] virtualenvwrapper plugin: shell function 'workon' not defined.\n"\
"Please check ${virtualenvwrapper}" >&2 "Please check ${virtualenvwrapper}" >&2
return return
fi fi
if [[ "$WORKON_HOME" == "" ]]; then if [[ -z "$WORKON_HOME" ]]; then
print "[oh-my-zsh] \$WORKON_HOME is not defined so plugin virtualenvwrapper will not work" >&2 WORKON_HOME="$HOME/.virtualenvs"
return
fi fi
if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
...@@ -77,6 +58,12 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then ...@@ -77,6 +58,12 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
else else
ENV_NAME="" ENV_NAME=""
fi fi
if [[ -n $CD_VIRTUAL_ENV && "$ENV_NAME" != "$CD_VIRTUAL_ENV" ]]; then
# We've just left the repo, deactivate the environment
# Note: this only happens if the virtualenv was activated automatically
deactivate && unset CD_VIRTUAL_ENV
fi
if [[ "$ENV_NAME" != "" ]]; then if [[ "$ENV_NAME" != "" ]]; then
# Activate the environment only if it is not already active # Activate the environment only if it is not already active
if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then
...@@ -86,17 +73,12 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then ...@@ -86,17 +73,12 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME" source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME"
fi fi
fi fi
elif [[ -n $CD_VIRTUAL_ENV && -n $VIRTUAL_ENV ]]; then
# We've just left the repo, deactivate the environment
# Note: this only happens if the virtualenv was activated automatically
deactivate && unset CD_VIRTUAL_ENV
fi fi
fi fi
} }
# Append workon_cwd to the chpwd_functions array, so it will be called on cd # Append workon_cwd to the chpwd_functions array, so it will be called on cd
# http://zsh.sourceforge.net/Doc/Release/Functions.html # http://zsh.sourceforge.net/Doc/Release/Functions.html
if ! (( $chpwd_functions[(I)workon_cwd] )); then autoload -U add-zsh-hook
chpwd_functions+=(workon_cwd) add-zsh-hook chpwd workon_cwd
fi
fi fi
# VS code # VS Code
This plugin makes interaction between the command line and the code editor easier. This plugin makes interaction between the command line and the VS Code editor easier.
To start using it, add the `vscode` plugin to your `plugins` array in `~/.zshrc`: To start using it, add the `vscode` plugin to your `plugins` array in `~/.zshrc`:
...@@ -8,9 +8,20 @@ To start using it, add the `vscode` plugin to your `plugins` array in `~/.zshrc` ...@@ -8,9 +8,20 @@ To start using it, add the `vscode` plugin to your `plugins` array in `~/.zshrc`
plugins=(... vscode) plugins=(... vscode)
``` ```
If you are using [Visual Studio Code Insiders](https://code.visualstudio.com/insiders/), ## Requirements
add the following line in the oh-my-zsh settings section (between the `ZSH_THEME` and
the `plugins=()` line). This will make the plugin use the Insiders version instead. To use VS Code in the terminal **in macOS**, first you need to install the `code` command in the PATH,
otherwise you might receive this message: `zsh: command not found: code`.
[As the docs say](https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line), open
the Command Palette via (F1 or ⇧⌘P) and type shell command to find the Shell Command:
> Install 'code' command in PATH
## VS Code Insiders
🍏 **If you are only using [VS Code Insiders](https://code.visualstudio.com/insiders/), the plugin will automatically bind to your Insiders installation.**
But, if you have both Stable and Insiders versions and want to configure the plugin to just use the Insiders version, add the following line in the oh-my-zsh settings section (between the `ZSH_THEME` and the `plugins=()` line). This will make the plugin use the Insiders version instead.
```zsh ```zsh
ZSH_THEME=... ZSH_THEME=...
......
# VScode zsh plugin # VScode zsh plugin
# author: https://github.com/MarsiBarsi # Authors:
# https://github.com/MarsiBarsi (original author)
# https://github.com/babakks
# Use main Visual Studio Code version by default # Use the stable VS Code release, unless the Insiders version is the only
: ${VSCODE:=code} # available installation
if ! which code > /dev/null && which code-insiders > /dev/null; then
: ${VSCODE:=code-insiders}
else
: ${VSCODE:=code}
fi
# Define aliases
alias vsc="$VSCODE ." alias vsc="$VSCODE ."
alias vsca="$VSCODE --add" alias vsca="$VSCODE --add"
alias vscd="$VSCODE --diff" alias vscd="$VSCODE --diff"
......
...@@ -13,7 +13,7 @@ wd ...@@ -13,7 +13,7 @@ wd
### oh-my-zsh ### oh-my-zsh
`wd` comes bundled with [oh-my-zshell](https://github.com/robbyrussell/oh-my-zsh)! `wd` comes bundled with [oh-my-zshell](https://github.com/ohmyzsh/ohmyzsh)!
Just add the plugin in your `~/.zshrc` file: Just add the plugin in your `~/.zshrc` file:
...@@ -53,7 +53,7 @@ Run either in terminal: ...@@ -53,7 +53,7 @@ Run either in terminal:
#### Completion #### Completion
If you're NOT using [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh) and you want to utilize the zsh-completion feature, you will also need to add the path to your `wd` installation (`~/bin/wd` if you used the automatic installer) to your `fpath`. E.g. in your `~/.zshrc`: If you're NOT using [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh) and you want to utilize the zsh-completion feature, you will also need to add the path to your `wd` installation (`~/bin/wd` if you used the automatic installer) to your `fpath`. E.g. in your `~/.zshrc`:
fpath=(~/path/to/wd $fpath) fpath=(~/path/to/wd $fpath)
...@@ -85,7 +85,7 @@ Also, you may have to force a rebuild of `zcompdump` by running: ...@@ -85,7 +85,7 @@ Also, you may have to force a rebuild of `zcompdump` by running:
$ wd ... $ wd ...
This is a wrapper for the zsh `dirs` function. This is a wrapper for the zsh `dirs` function.
(You might need `setopt AUTO_PUSHD` in your `.zshrc` if you hare not using [oh-my-zshell](https://github.com/robbyrussell/oh-my-zsh)). (You might need `setopt AUTO_PUSHD` in your `.zshrc` if you hare not using [oh-my-zshell](https://github.com/ohmyzsh/ohmyzsh)).
* Remove warp point test point: * Remove warp point test point:
......
#!/bin/zsh
# WARP DIRECTORY # WARP DIRECTORY
# ============== # ==============
# oh-my-zsh plugin # oh-my-zsh plugin
# #
# @github.com/mfaerevaag/wd # @github.com/mfaerevaag/wd
wd() { eval "wd() { source '${0:A:h}/wd.sh' }"
. $ZSH/plugins/wd/wd.sh
}
...@@ -39,6 +39,7 @@ Available search contexts are: ...@@ -39,6 +39,7 @@ Available search contexts are:
| `qwant` | `https://www.qwant.com/?q=` | | `qwant` | `https://www.qwant.com/?q=` |
| `givero` | `https://www.givero.com/search?q=` | | `givero` | `https://www.givero.com/search?q=` |
| `stackoverflow` | `https://stackoverflow.com/search?q=` | | `stackoverflow` | `https://stackoverflow.com/search?q=` |
| `wolframalpha` | `https://wolframalpha.com/input?i=` |
Also there are aliases for bang-searching DuckDuckGo: Also there are aliases for bang-searching DuckDuckGo:
......
...@@ -19,6 +19,7 @@ function web_search() { ...@@ -19,6 +19,7 @@ function web_search() {
qwant "https://www.qwant.com/?q=" qwant "https://www.qwant.com/?q="
givero "https://www.givero.com/search?q=" givero "https://www.givero.com/search?q="
stackoverflow "https://stackoverflow.com/search?q=" stackoverflow "https://stackoverflow.com/search?q="
wolframalpha "https://www.wolframalpha.com/input/?i="
) )
# check whether the search engine is supported # check whether the search engine is supported
...@@ -55,6 +56,7 @@ alias goodreads='web_search goodreads' ...@@ -55,6 +56,7 @@ alias goodreads='web_search goodreads'
alias qwant='web_search qwant' alias qwant='web_search qwant'
alias givero='web_search givero' alias givero='web_search givero'
alias stackoverflow='web_search stackoverflow' alias stackoverflow='web_search stackoverflow'
alias wolframalpha='web_search wolframalpha'
#add your own !bang searches here #add your own !bang searches here
alias wiki='web_search duckduckgo \!w' alias wiki='web_search duckduckgo \!w'
......
...@@ -19,6 +19,7 @@ plugins=(... yarn) ...@@ -19,6 +19,7 @@ plugins=(... yarn)
| yap | `yarn add --peer` | Install a package in peerDependencies (`package.json`) | | yap | `yarn add --peer` | Install a package in peerDependencies (`package.json`) |
| yb | `yarn build` | Run the build script defined in `package.json` | | yb | `yarn build` | Run the build script defined in `package.json` |
| ycc | `yarn cache clean` | Clean yarn's global cache of packages | | ycc | `yarn cache clean` | Clean yarn's global cache of packages |
| yd | `yarn dev` | Run the dev script defined in `package.json` |
| yga | `yarn global add` | Install packages globally on your operating system | | yga | `yarn global add` | Install packages globally on your operating system |
| ygls | `yarn global list` | Lists global installed packages | | ygls | `yarn global list` | Lists global installed packages |
| ygrm | `yarn global remove` | Remove global installed packages from your OS | | ygrm | `yarn global remove` | Remove global installed packages from your OS |
...@@ -26,6 +27,7 @@ plugins=(... yarn) ...@@ -26,6 +27,7 @@ plugins=(... yarn)
| yh | `yarn help` | Show help for a yarn command | | yh | `yarn help` | Show help for a yarn command |
| yi | `yarn init` | Interactively creates or updates a package.json file | | yi | `yarn init` | Interactively creates or updates a package.json file |
| yin | `yarn install` | Install dependencies defined in `package.json` | | yin | `yarn install` | Install dependencies defined in `package.json` |
| yln | `yarn lint` | Run the lint script defined in `package.json` |
| yls | `yarn list` | List installed packages | | yls | `yarn list` | List installed packages |
| yout | `yarn outdated` | Check for outdated package dependencies | | yout | `yarn outdated` | Check for outdated package dependencies |
| yp | `yarn pack` | Create a compressed gzip archive of package dependencies | | yp | `yarn pack` | Create a compressed gzip archive of package dependencies |
...@@ -34,6 +36,10 @@ plugins=(... yarn) ...@@ -34,6 +36,10 @@ plugins=(... yarn)
| ys | `yarn serve` | Start the dev server | | ys | `yarn serve` | Start the dev server |
| yst | `yarn start` | Run the start script defined in `package.json` | | yst | `yarn start` | Run the start script defined in `package.json` |
| yt | `yarn test` | Run the test script defined in `package.json` | | yt | `yarn test` | Run the test script defined in `package.json` |
| ytc | `yarn test --coverage` | Run the test script defined in `package.json` with coverage |
| yuc | `yarn global upgrade && yarn cache clean` | Upgrade global packages and clean yarn's global cache | | yuc | `yarn global upgrade && yarn cache clean` | Upgrade global packages and clean yarn's global cache |
| yui | `yarn upgrade-interactive` | Prompt for which outdated packages to upgrade | | yui | `yarn upgrade-interactive` | Prompt for which outdated packages to upgrade |
| yup | `yarn upgrade` | Upgrade packages to their latest version | | yup | `yarn upgrade` | Upgrade packages to their latest version |
| yv | `yarn version` | Update the version of your package |
| yw | `yarn workspace` | Run a command within a single workspace. |
| yws | `yarn workspaces` | Run a command within all defined workspaces. |
...@@ -71,7 +71,7 @@ _global_commands=( ...@@ -71,7 +71,7 @@ _global_commands=(
'bin:Displays the location of the yarn bin folder' 'bin:Displays the location of the yarn bin folder'
'remove:Remove installed package from dependencies updating package.json' 'remove:Remove installed package from dependencies updating package.json'
'upgrade:Upgrades packages to their latest version based on the specified range' 'upgrade:Upgrades packages to their latest version based on the specified range'
'upgrade-interactive' 'upgrade-interactive:Interactively upgrade packages'
) )
_yarn_commands_scripts() { _yarn_commands_scripts() {
...@@ -81,9 +81,23 @@ _yarn_commands_scripts() { ...@@ -81,9 +81,23 @@ _yarn_commands_scripts() {
} }
_yarn_scripts() { _yarn_scripts() {
local -a scripts local -a commands binaries scripts
scripts=($(yarn run --json 2>/dev/null | sed -E '/Commands available|possibleCommands/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g' | tr , '\n' | sed -e 's/:/\\:/g')) local -a scriptNames scriptCommands
_describe 'script' scripts local i runJSON
runJSON=$(yarn run --json 2>/dev/null)
# Some sed utilities (e.g. Mac OS / BSD) don't interpret `\n` in a replacement
# pattern as a newline. See https://superuser.com/q/307165
binaries=($(sed -E '/Commands available/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g;s/:/\\:/g;s/,/\'$'\n/g' <<< "$runJSON"))
scriptNames=($(sed -E '/possibleCommands/!d;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g;s/:/\\:/g;s/,/\'$'\n/g' <<< "$runJSON"))
scriptCommands=("${(@f)$(sed -E '/possibleCommands/!d;s/.*"hints":\{(.+")\}.*/\1/;s/"[^"]+"://g;s/:/\\:/g;s/","/\'$'\n/g;s/(^"|"$)//g' <<< "$runJSON")}")
for (( i=1; i <= $#scriptNames; i++ )); do
scripts+=("${scriptNames[$i]}:${scriptCommands[$i]}")
done
commands=($scripts $binaries)
_describe 'command' commands
} }
_yarn_global_commands() { _yarn_global_commands() {
...@@ -240,7 +254,8 @@ _yarn() { ...@@ -240,7 +254,8 @@ _yarn() {
run) run)
_arguments \ _arguments \
'1: :_yarn_scripts' '1: :_yarn_scripts' \
'*:: :_default'
;; ;;
tag) tag)
...@@ -255,6 +270,11 @@ _yarn() { ...@@ -255,6 +270,11 @@ _yarn() {
'*:: :->team_args' '*:: :->team_args'
;; ;;
upgrade-interactive)
_arguments \
'--latest:use the version tagged latest in the registry:'
;;
version) version)
_arguments \ _arguments \
'--new-version:version:' \ '--new-version:version:' \
...@@ -266,6 +286,10 @@ _yarn() { ...@@ -266,6 +286,10 @@ _yarn() {
_arguments \ _arguments \
'1:query:_files' '1:query:_files'
;; ;;
*)
_default
;;
esac esac
;; ;;
esac esac
......
...@@ -4,6 +4,7 @@ alias yad="yarn add --dev" ...@@ -4,6 +4,7 @@ alias yad="yarn add --dev"
alias yap="yarn add --peer" alias yap="yarn add --peer"
alias yb="yarn build" alias yb="yarn build"
alias ycc="yarn cache clean" alias ycc="yarn cache clean"
alias yd="yarn dev"
alias yga="yarn global add" alias yga="yarn global add"
alias ygls="yarn global list" alias ygls="yarn global list"
alias ygrm="yarn global remove" alias ygrm="yarn global remove"
...@@ -11,6 +12,7 @@ alias ygu="yarn global upgrade" ...@@ -11,6 +12,7 @@ alias ygu="yarn global upgrade"
alias yh="yarn help" alias yh="yarn help"
alias yi="yarn init" alias yi="yarn init"
alias yin="yarn install" alias yin="yarn install"
alias yln="yarn lint"
alias yls="yarn list" alias yls="yarn list"
alias yout="yarn outdated" alias yout="yarn outdated"
alias yp="yarn pack" alias yp="yarn pack"
...@@ -19,6 +21,10 @@ alias yrun="yarn run" ...@@ -19,6 +21,10 @@ alias yrun="yarn run"
alias ys="yarn serve" alias ys="yarn serve"
alias yst="yarn start" alias yst="yarn start"
alias yt="yarn test" alias yt="yarn test"
alias ytc="yarn test --coverage"
alias yuc="yarn global upgrade && yarn cache clean" alias yuc="yarn global upgrade && yarn cache clean"
alias yui="yarn upgrade-interactive" alias yui="yarn upgrade-interactive"
alias yup="yarn upgrade" alias yup="yarn upgrade"
alias yv="yarn version"
alias yw="yarn workspace"
alias yws="yarn workspaces"
# Yii plugin
The plugin adds autocomplete commands and subcommands for [yii](https://www.yiiframework.com/).
To use it, add `yii` to the plugins array of your zshrc file:
```
plugins=(... yii)
```
## Aliases
| Alias | Command |
|--------|----------------------|
| yiic | `protected/yiic` |
...@@ -89,7 +89,7 @@ _z() { ...@@ -89,7 +89,7 @@ _z() {
if [ $? -ne 0 -a -f "$datafile" ]; then if [ $? -ne 0 -a -f "$datafile" ]; then
env rm -f "$tempfile" env rm -f "$tempfile"
else else
[ "$_Z_OWNER" ] && chown $_Z_OWNER:$(id -ng $_Z_OWNER) "$tempfile" [ "$_Z_OWNER" ] && chown $_Z_OWNER:"$(id -ng $_Z_OWNER)" "$tempfile"
env mv -f "$tempfile" "$datafile" || env rm -f "$tempfile" env mv -f "$tempfile" "$datafile" || env rm -f "$tempfile"
fi fi
...@@ -110,20 +110,21 @@ _z() { ...@@ -110,20 +110,21 @@ _z() {
else else
# list/go # list/go
local echo fnd last list opt typ
while [ "$1" ]; do case "$1" in while [ "$1" ]; do case "$1" in
--) while [ "$1" ]; do shift; local fnd="$fnd${fnd:+ }$1";done;; --) while [ "$1" ]; do shift; fnd="$fnd${fnd:+ }$1";done;;
-*) local opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in -*) opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in
c) local fnd="^$PWD $fnd";; c) fnd="^$PWD $fnd";;
e) local echo=1;; e) echo=1;;
h) echo "${_Z_CMD:-z} [-cehlrtx] args" >&2; return;; h) echo "${_Z_CMD:-z} [-cehlrtx] args" >&2; return;;
l) local list=1;; l) list=1;;
r) local typ="rank";; r) typ="rank";;
t) local typ="recent";; t) typ="recent";;
x) sed -i -e "\:^${PWD}|.*:d" "$datafile";; x) sed -i -e "\:^${PWD}|.*:d" "$datafile";;
esac; opt=${opt:1}; done;; esac; opt=${opt:1}; done;;
*) local fnd="$fnd${fnd:+ }$1";; *) fnd="$fnd${fnd:+ }$1";;
esac; local last=$1; [ "$#" -gt 0 ] && shift; done esac; last=$1; [ "$#" -gt 0 ] && shift; done
[ "$fnd" -a "$fnd" != "^$PWD " ] || local list=1 [ "$fnd" -a "$fnd" != "^$PWD " ] || list=1
# if we hit enter on a completion just go there # if we hit enter on a completion just go there
case "$last" in case "$last" in
...@@ -147,7 +148,7 @@ _z() { ...@@ -147,7 +148,7 @@ _z() {
function output(matches, best_match, common) { function output(matches, best_match, common) {
# list or return the desired directory # list or return the desired directory
if( list ) { if( list ) {
cmd = "sort -n >&2" cmd = "sort -g >&2"
for( x in matches ) { for( x in matches ) {
if( matches[x] ) { if( matches[x] ) {
printf "%-10s %s\n", matches[x], x | cmd printf "%-10s %s\n", matches[x], x | cmd
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
* `zcu` aliases `zeus cucumber` * `zcu` aliases `zeus cucumber`
* `zucumber` aliases `zeus cucumber` * `zucumber` aliases `zeus cucumber`
* `zwip` aliases `zeus cucumber --profile wip`
* `zspec` aliases `zeus rspec` * `zspec` aliases `zeus rspec`
......
...@@ -33,6 +33,7 @@ alias zunner='zeus runner' ...@@ -33,6 +33,7 @@ alias zunner='zeus runner'
# Cucumber # Cucumber
alias zcu='zeus cucumber' alias zcu='zeus cucumber'
alias zucumber='zeus cucumber' alias zucumber='zeus cucumber'
alias zwip='zeus cucumber --profile wip'
# Rspec # Rspec
alias zspec='zeus rspec' alias zspec='zeus rspec'
......
# zsh-interactive-cd
This plugin adds a fish-like interactive tab completion for the `cd` command.
To use it, add `zsh-interactive-cd` to the plugins array of your zshrc file:
```zsh
plugins=(... zsh-interactive-cd)
```
![demo](https://user-images.githubusercontent.com/1441704/74360670-cb202900-4dc5-11ea-9734-f60caf726e85.gif)
## Usage
Press tab for completion as usual, it'll launch fzf automatically. Check fzf’s [readme](https://github.com/junegunn/fzf#search-syntax) for more search syntax usage.
## Requirements
This plugin requires [fzf](https://github.com/junegunn/fzf). Install it by following
its [installation instructions](https://github.com/junegunn/fzf#installation).
## Author
[Henry Chang](https://github.com/changyuheng)
# Copyright (c) 2017 Henry Chang
__zic_fzf_prog() {
[ -n "$TMUX_PANE" ] && [ "${FZF_TMUX:-0}" != 0 ] && [ ${LINES:-40} -gt 15 ] \
&& echo "fzf-tmux -d${FZF_TMUX_HEIGHT:-40%}" || echo "fzf"
}
__zic_matched_subdir_list() {
local dir length seg starts_with_dir
if [[ "$1" == */ ]]; then
dir="$1"
if [[ "$dir" != / ]]; then
dir="${dir: : -1}"
fi
length=$(echo -n "$dir" | wc -c)
if [ "$dir" = "/" ]; then
length=0
fi
find -L "$dir" -mindepth 1 -maxdepth 1 -type d 2>/dev/null \
| cut -b $(( ${length} + 2 ))- | sed '/^$/d' | while read -r line; do
if [[ "${line[1]}" == "." ]]; then
continue
fi
echo "$line"
done
else
dir=$(dirname -- "$1")
length=$(echo -n "$dir" | wc -c)
if [ "$dir" = "/" ]; then
length=0
fi
seg=$(basename -- "$1")
starts_with_dir=$( \
find -L "$dir" -mindepth 1 -maxdepth 1 -type d \
2>/dev/null | cut -b $(( ${length} + 2 ))- | sed '/^$/d' \
| while read -r line; do
if [[ "${seg[1]}" != "." && "${line[1]}" == "." ]]; then
continue
fi
if [[ "$line" == "$seg"* ]]; then
echo "$line"
fi
done
)
if [ -n "$starts_with_dir" ]; then
echo "$starts_with_dir"
else
find -L "$dir" -mindepth 1 -maxdepth 1 -type d \
2>/dev/null | cut -b $(( ${length} + 2 ))- | sed '/^$/d' \
| while read -r line; do
if [[ "${seg[1]}" != "." && "${line[1]}" == "." ]]; then
continue
fi
if [[ "$line" == *"$seg"* ]]; then
echo "$line"
fi
done
fi
fi
}
_zic_list_generator() {
__zic_matched_subdir_list "${(Q)@[-1]}" | sort
}
_zic_complete() {
setopt localoptions nonomatch
local l matches fzf tokens base
l=$(_zic_list_generator $@)
if [ -z "$l" ]; then
zle ${__zic_default_completion:-expand-or-complete}
return
fi
fzf=$(__zic_fzf_prog)
if [ $(echo $l | wc -l) -eq 1 ]; then
matches=${(q)l}
else
matches=$(echo $l \
| FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} \
--reverse $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS \
--bind 'shift-tab:up,tab:down'" ${=fzf} \
| while read -r item; do
echo -n "${(q)item} "
done)
fi
matches=${matches% }
if [ -n "$matches" ]; then
tokens=(${(z)LBUFFER})
base="${(Q)@[-1]}"
if [[ "$base" != */ ]]; then
if [[ "$base" == */* ]]; then
base="$(dirname -- "$base")"
if [[ ${base[-1]} != / ]]; then
base="$base/"
fi
else
base=""
fi
fi
LBUFFER="${tokens[1]} "
if [ -n "$base" ]; then
base="${(q)base}"
if [ "${tokens[2][1]}" = "~" ]; then
base="${base/#$HOME/~}"
fi
LBUFFER="${LBUFFER}${base}"
fi
LBUFFER="${LBUFFER}${matches}/"
fi
zle redisplay
typeset -f zle-line-init >/dev/null && zle zle-line-init
}
zic-completion() {
setopt localoptions noshwordsplit noksh_arrays noposixbuiltins
local tokens cmd
tokens=(${(z)LBUFFER})
cmd=${tokens[1]}
if [[ "$LBUFFER" =~ "^\ *cd$" ]]; then
zle ${__zic_default_completion:-expand-or-complete}
elif [ "$cmd" = cd ]; then
_zic_complete ${tokens[2,${#tokens}]/#\~/$HOME}
else
zle ${__zic_default_completion:-expand-or-complete}
fi
}
[ -z "$__zic_default_completion" ] && {
binding=$(bindkey '^I')
# $binding[(s: :w)2]
# The command substitution and following word splitting to determine the
# default zle widget for ^I formerly only works if the IFS parameter contains
# a space via $binding[(w)2]. Now it specifically splits at spaces, regardless
# of IFS.
[[ $binding =~ 'undefined-key' ]] || __zic_default_completion=$binding[(s: :w)2]
unset binding
}
zle -N zic-completion
bindkey -M emacs '^I' zic-completion
bindkey -M viins '^I' zic-completion
...@@ -7,7 +7,7 @@ export ZSH=$HOME/.oh-my-zsh ...@@ -7,7 +7,7 @@ export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load --- if set to "random", it will # Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case, # load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME # to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes # See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="robbyrussell" ZSH_THEME="robbyrussell"
# Set list of themes to pick from when loading at random # Set list of themes to pick from when loading at random
......
...@@ -2,32 +2,41 @@ ...@@ -2,32 +2,41 @@
# Repo: https://github.com/andyfleming/oh-my-zsh # Repo: https://github.com/andyfleming/oh-my-zsh
# Direct Link: https://github.com/andyfleming/oh-my-zsh/blob/master/themes/af-magic.zsh-theme # Direct Link: https://github.com/andyfleming/oh-my-zsh/blob/master/themes/af-magic.zsh-theme
if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="green"; fi
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
# primary prompt # settings
PROMPT='$FG[237]------------------------------------------------------------%{$reset_color%} typeset +H return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
$FG[032]%~\ typeset +H my_gray="$FG[237]"
$(git_prompt_info) \ typeset +H my_orange="$FG[214]"
$FG[105]%(!.#.»)%{$reset_color%} '
PROMPT2='%{$fg[red]%}\ %{$reset_color%}'
RPS1='${return_code}'
# separator dashes size
function afmagic_dashes {
[[ -n "${VIRTUAL_ENV-}" && -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" && "$PS1" = \(* ]] \
&& echo $(( COLUMNS - ${#VIRTUAL_ENV} - 3 )) \
|| echo $COLUMNS
}
# color vars # primary prompt
eval my_gray='$FG[237]' PS1='$FG[237]${(l.$(afmagic_dashes)..-.)}%{$reset_color%}
eval my_orange='$FG[214]' $FG[032]%~$(git_prompt_info)$(hg_prompt_info) $FG[105]%(!.#.»)%{$reset_color%} '
PS2='%{$fg[red]%}\ %{$reset_color%}'
RPS1='${return_code}'
# right prompt # right prompt
if type "virtualenv_prompt_info" > /dev/null (( $+functions[virtualenv_prompt_info] )) && RPS1+='$(virtualenv_prompt_info)'
then RPS1+=' $my_gray%n@%m%{$reset_color%}%'
RPROMPT='$(virtualenv_prompt_info)$my_gray%n@%m%{$reset_color%}%'
else
RPROMPT='$my_gray%n@%m%{$reset_color%}%'
fi
# git settings # git settings
ZSH_THEME_GIT_PROMPT_PREFIX="$FG[075]($FG[078]" ZSH_THEME_GIT_PROMPT_PREFIX="$FG[075]($FG[078]"
ZSH_THEME_GIT_PROMPT_CLEAN="" ZSH_THEME_GIT_PROMPT_CLEAN=""
ZSH_THEME_GIT_PROMPT_DIRTY="$my_orange*%{$reset_color%}" ZSH_THEME_GIT_PROMPT_DIRTY="$my_orange*%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="$FG[075])%{$reset_color%}" ZSH_THEME_GIT_PROMPT_SUFFIX="$FG[075])%{$reset_color%}"
# hg settings
ZSH_THEME_HG_PROMPT_PREFIX="$FG[075]($FG[078]"
ZSH_THEME_HG_PROMPT_CLEAN=""
ZSH_THEME_HG_PROMPT_DIRTY="$my_orange*%{$reset_color%}"
ZSH_THEME_HG_PROMPT_SUFFIX="$FG[075])%{$reset_color%}"
# virtualenv settings
ZSH_THEME_VIRTUALENV_PREFIX=" $FG[075]["
ZSH_THEME_VIRTUALENV_SUFFIX="]%{$reset_color%}"
...@@ -141,20 +141,26 @@ prompt_git() { ...@@ -141,20 +141,26 @@ prompt_git() {
prompt_bzr() { prompt_bzr() {
(( $+commands[bzr] )) || return (( $+commands[bzr] )) || return
if (bzr status >/dev/null 2>&1); then
status_mod=`bzr status | head -n1 | grep "modified" | wc -m` # Test if bzr repository in directory hierarchy
status_all=`bzr status | head -n1 | wc -m` local dir="$PWD"
revision=`bzr log | head -n2 | tail -n1 | sed 's/^revno: //'` while [[ ! -d "$dir/.bzr" ]]; do
[[ "$dir" = "/" ]] && return
dir="${dir:h}"
done
local bzr_status status_mod status_all revision
if bzr_status=$(bzr status 2>&1); then
status_mod=$(echo -n "$bzr_status" | head -n1 | grep "modified" | wc -m)
status_all=$(echo -n "$bzr_status" | head -n1 | wc -m)
revision=$(bzr log -r-1 --log-format line | cut -d: -f1)
if [[ $status_mod -gt 0 ]] ; then if [[ $status_mod -gt 0 ]] ; then
prompt_segment yellow black prompt_segment yellow black "bzr@$revision ✚"
echo -n "bzr@"$revision "✚ "
else else
if [[ $status_all -gt 0 ]] ; then if [[ $status_all -gt 0 ]] ; then
prompt_segment yellow black prompt_segment yellow black "bzr@$revision"
echo -n "bzr@"$revision
else else
prompt_segment green black prompt_segment green black "bzr@$revision"
echo -n "bzr@"$revision
fi fi
fi fi
fi fi
......
# AVIT ZSH Theme # AVIT ZSH Theme
PROMPT=' # settings
$(_user_host)${_current_dir} $(git_prompt_info) $(_ruby_version) typeset +H _current_dir="%{$fg_bold[blue]%}%3~%{$reset_color%} "
%{$fg[$CARETCOLOR]%}▶%{$resetcolor%} ' typeset +H _return_status="%{$fg_bold[red]%}%(?..⍉)%{$reset_color%}"
typeset +H _hist_no="%{$fg[grey]%}%h%{$reset_color%}"
PROMPT2='%{$fg[$CARETCOLOR]%}◀%{$reset_color%} ' PROMPT='
$(_user_host)${_current_dir} $(git_prompt_info) $(ruby_prompt_info)
%{%(!.%F{red}.%F{white})%}▶%{$resetcolor%} '
RPROMPT='$(_vi_status)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}' PROMPT2='%{%(!.%F{red}.%F{white})%}◀%{$reset_color%} '
local _current_dir="%{$fg_bold[blue]%}%3~%{$reset_color%} " RPROMPT='$(vi_mode_prompt_info)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
local _return_status="%{$fg_bold[red]%}%(?..⍉)%{$reset_color%}"
local _hist_no="%{$fg[grey]%}%h%{$reset_color%}"
function _current_dir() {
local _max_pwd_length="65"
if [[ $(echo -n $PWD | wc -c) -gt ${_max_pwd_length} ]]; then
echo "%{$fg_bold[blue]%}%-2~ ... %3~%{$reset_color%} "
else
echo "%{$fg_bold[blue]%}%~%{$reset_color%} "
fi
}
function _user_host() { function _user_host() {
local me
if [[ -n $SSH_CONNECTION ]]; then if [[ -n $SSH_CONNECTION ]]; then
me="%n@%m" me="%n@%m"
elif [[ $LOGNAME != $USER ]]; then elif [[ $LOGNAME != $USER ]]; then
...@@ -32,61 +25,41 @@ function _user_host() { ...@@ -32,61 +25,41 @@ function _user_host() {
fi fi
} }
function _vi_status() {
if {echo $fpath | grep -q "plugins/vi-mode"}; then
echo "$(vi_mode_prompt_info)"
fi
}
function _ruby_version() {
if {echo $fpath | grep -q "plugins/rvm"}; then
echo "%{$fg[grey]%}$(rvm_prompt_info)%{$reset_color%}"
elif {echo $fpath | grep -q "plugins/rbenv"}; then
echo "%{$fg[grey]%}$(rbenv_prompt_info)%{$reset_color%}"
fi
}
# Determine the time since last commit. If branch is clean, # Determine the time since last commit. If branch is clean,
# use a neutral color, otherwise colors will vary according to time. # use a neutral color, otherwise colors will vary according to time.
function _git_time_since_commit() { function _git_time_since_commit() {
# Only proceed if there is actually a commit. local last_commit now seconds_since_last_commit
local minutes hours days years commit_age
# Only proceed if there is actually a commit.
if last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null); then if last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null); then
now=$(date +%s) now=$(date +%s)
seconds_since_last_commit=$((now-last_commit)) seconds_since_last_commit=$((now-last_commit))
# Totals # Totals
minutes=$((seconds_since_last_commit / 60)) minutes=$((seconds_since_last_commit / 60))
hours=$((seconds_since_last_commit/3600)) hours=$((minutes / 60))
days=$((hours / 24))
# Sub-hours and sub-minutes years=$((days / 365))
days=$((seconds_since_last_commit / 86400))
sub_hours=$((hours % 24)) if [[ $years -gt 0 ]]; then
sub_minutes=$((minutes % 60)) commit_age="${years}y$((days % 365 ))d"
elif [[ $days -gt 0 ]]; then
if [ $hours -ge 24 ]; then commit_age="${days}d$((hours % 24))h"
commit_age="${days}d" elif [[ $hours -gt 0 ]]; then
elif [ $minutes -gt 60 ]; then commit_age+="${hours}h$(( minutes % 60 ))m"
commit_age="${sub_hours}h${sub_minutes}m"
else else
commit_age="${minutes}m" commit_age="${minutes}m"
fi fi
color=$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL echo "${ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL}${commit_age}%{$reset_color%}"
echo "$color$commit_age%{$reset_color%}"
fi fi
} }
if [[ $USER == "root" ]]; then
CARETCOLOR="red"
else
CARETCOLOR="white"
fi
MODE_INDICATOR="%{$fg_bold[yellow]%}❮%{$reset_color%}%{$fg[yellow]%}❮❮%{$reset_color%}" MODE_INDICATOR="%{$fg_bold[yellow]%}❮%{$reset_color%}%{$fg[yellow]%}❮❮%{$reset_color%}"
# Git prompt settings
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}" ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}✗%{$reset_color%}" ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}✔%{$reset_color%}" ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}✔%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%}✚ " ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%}✚ "
...@@ -96,6 +69,10 @@ ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}▴ " ...@@ -96,6 +69,10 @@ ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}▴ "
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[cyan]%}§ " ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[cyan]%}§ "
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[white]%}◒ " ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[white]%}◒ "
# Ruby prompt settings
ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[grey]%}"
ZSH_THEME_RUBY_PROMPT_SUFFIX="%{$reset_color%}"
# Colors vary depending on time lapsed. # Colors vary depending on time lapsed.
ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}" ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}"
ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}" ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}"
......
...@@ -16,7 +16,7 @@ local venv_prompt='$(virtualenv_prompt_info)' ...@@ -16,7 +16,7 @@ local venv_prompt='$(virtualenv_prompt_info)'
ZSH_THEME_RVM_PROMPT_OPTIONS="i v g" ZSH_THEME_RVM_PROMPT_OPTIONS="i v g"
PROMPT="╭─${venv_prompt}${user_host}${current_dir}${rvm_ruby}${git_branch} PROMPT="╭─${user_host}${current_dir}${rvm_ruby}${git_branch}${venv_prompt}
╰─%B${user_symbol}%b " ╰─%B${user_symbol}%b "
RPROMPT="%B${return_code}%b" RPROMPT="%B${return_code}%b"
......
# neuralsanwich.zsh-theme if ! hg prompt 2>/dev/null; then
function hg_prompt_info { }
if [ "x$OH_MY_ZSH_HG" = "x" ]; then else
OH_MY_ZSH_HG="hg" function hg_prompt_info {
fi hg prompt --angle-brackets "\
function hg_prompt_info {
$OH_MY_ZSH_HG prompt --angle-brackets "\
< on %{$fg[magenta]%}<branch>%{$reset_color%}>\ < on %{$fg[magenta]%}<branch>%{$reset_color%}>\
< at %{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\ < at %{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\
%{$fg[green]%}<status|modified|unknown><update>%{$reset_color%}< %{$fg[green]%}<status|modified|unknown><update>%{$reset_color%}<
patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset_color%})|pre_unapplied(%{$fg_bold[black]%})|post_unapplied(%{$reset_color%})>>" 2>/dev/null patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset_color%})|pre_unapplied(%{$fg_bold[black]%})|post_unapplied(%{$reset_color%})>>" 2>/dev/null
} }
fi
function box_name { function box_name {
[ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-$HOST} [ -f ~/.box-name ] && cat ~/.box-name || echo ${SHORT_HOST:-$HOST}
...@@ -26,5 +24,9 @@ ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[red]%}?" ...@@ -26,5 +24,9 @@ ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[red]%}?"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[orange]%}!" ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[orange]%}!"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%})" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%})"
local return_status="%{$fg[red]%}%(?..✘)%{$reset_color%}" RPROMPT='%{$fg[red]%}%(?..✘)%{$reset_color%}'
RPROMPT='${return_status}$(battery_time_remaining) $(battery_pct_prompt)%{$reset_color%}'
# Add battery status if the battery plugin is enabled
if (( $+functions[battery_pct_prompt] )); then
RPROMPT+='$(battery_time_remaining) $(battery_pct_prompt)%{$reset_color%}'
fi
# Evan describes this sexy prompt as: "a skinny, topless prompt" # Evan's minimal prompt
PROMPT='%m :: %2~ %B»%b ' PROMPT='%m :: %2~ %B»%b '
# ZSH Theme - Preview: https://github.com/robbyrussell/oh-my-zsh/wiki/Themes#gallifrey # ZSH Theme - Preview: https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#gallifrey
return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
host_color="%(!.%{$fg[red]%}.%{$fg[green]%})" host_color="%(!.%{$fg[red]%}.%{$fg[green]%})"
......
# (( $+functions[battery_pct_prompt] )) || function battery_pct_prompt { }
# Kiwi ZSH Theme
#
PROMPT='%{$fg_bold[green]%}┌[%{$fg_bold[cyan]%}kiwish-4.2%{$fg_bold[green]%}]-(%{$fg_bold[white]%}%2~%{$fg_bold[green]%})-$(git_prompt_info)$(svn_prompt_info)$(battery_pct_prompt) PROMPT='%{$fg_bold[green]%}┌[%{$fg_bold[cyan]%}kiwish-4.2%{$fg_bold[green]%}]-(%{$fg_bold[white]%}%2~%{$fg_bold[green]%})-$(git_prompt_info)$(svn_prompt_info)$(battery_pct_prompt)
└> % %{$reset_color%}' └> % %{$reset_color%}'
......
PROMPT='%{$fg[yellow]%}λ %m %{$fg[green]%}%c %{$fg[yellow]%}→ $(git_prompt_info)%{$reset_color%}' PROMPT='%{$fg[yellow]%}λ %m %{$fg[green]%}%c %{$fg[yellow]%}→ $(git_prompt_info)$(hg_prompt_info)%{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="λ %{$fg[blue]%}git %{$fg[red]%}" ZSH_THEME_GIT_PROMPT_PREFIX="λ %{$fg[blue]%}git %{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg[yellow]%} → %{$reset_color%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg[yellow]%} → %{$reset_color%}"
ZSH_THEME_HG_PROMPT_PREFIX="λ %{$fg[blue]%}hg %{$fg[red]%}"
ZSH_THEME_HG_PROMPT_SUFFIX="%{$fg[yellow]%} → %{$reset_color%}"
...@@ -28,7 +28,8 @@ prompt_setup_pygmalion(){ ...@@ -28,7 +28,8 @@ prompt_setup_pygmalion(){
base_prompt_nocolor=$(echo "$base_prompt" | perl -pe "s/%\{[^}]+\}//g") base_prompt_nocolor=$(echo "$base_prompt" | perl -pe "s/%\{[^}]+\}//g")
post_prompt_nocolor=$(echo "$post_prompt" | perl -pe "s/%\{[^}]+\}//g") post_prompt_nocolor=$(echo "$post_prompt" | perl -pe "s/%\{[^}]+\}//g")
precmd_functions+=(prompt_pygmalion_precmd) autoload -U add-zsh-hook
add-zsh-hook precmd prompt_pygmalion_precmd
} }
prompt_pygmalion_precmd(){ prompt_pygmalion_precmd(){
...@@ -46,5 +47,3 @@ prompt_pygmalion_precmd(){ ...@@ -46,5 +47,3 @@ prompt_pygmalion_precmd(){
} }
prompt_setup_pygmalion prompt_setup_pygmalion
...@@ -12,7 +12,8 @@ prompt_setup_pygmalion(){ ...@@ -12,7 +12,8 @@ prompt_setup_pygmalion(){
base_prompt_nocolor=$(echo "$base_prompt" | perl -pe "s/%\{[^}]+\}//g") base_prompt_nocolor=$(echo "$base_prompt" | perl -pe "s/%\{[^}]+\}//g")
post_prompt_nocolor=$(echo "$post_prompt" | perl -pe "s/%\{[^}]+\}//g") post_prompt_nocolor=$(echo "$post_prompt" | perl -pe "s/%\{[^}]+\}//g")
precmd_functions+=(prompt_pygmalion_precmd) autoload -U add-zsh-hook
add-zsh-hook precmd prompt_pygmalion_precmd
} }
prompt_pygmalion_precmd(){ prompt_pygmalion_precmd(){
...@@ -30,5 +31,3 @@ prompt_pygmalion_precmd(){ ...@@ -30,5 +31,3 @@ prompt_pygmalion_precmd(){
} }
prompt_setup_pygmalion prompt_setup_pygmalion
# Make themes a unique array
typeset -Ua themes
if [[ "${(t)ZSH_THEME_RANDOM_CANDIDATES}" = array && ${#ZSH_THEME_RANDOM_CANDIDATES[@]} -gt 0 ]]; then
# Use ZSH_THEME_RANDOM_CANDIDATES if properly defined
themes=($ZSH_THEME_RANDOM_CANDIDATES)
else
# Look for themes in $ZSH_CUSTOM and $ZSH and add only the theme name
themes=(
"$ZSH_CUSTOM"/*.zsh-theme(N:t:r)
"$ZSH_CUSTOM"/themes/*.zsh-theme(N:t:r)
"$ZSH"/themes/*.zsh-theme(N:t:r)
)
# Remove blacklisted themes from the list
for theme in ${ZSH_THEME_RANDOM_BLACKLIST[@]}; do
themes=("${(@)themes:#$theme}")
done
fi
# Choose a theme out of the pool of candidates
N=${#themes[@]}
(( N = (RANDOM%N) + 1 ))
RANDOM_THEME="${themes[$N]}"
unset N themes theme
# Source theme
if [[ -f "$ZSH_CUSTOM/$RANDOM_THEME.zsh-theme" ]]; then
source "$ZSH_CUSTOM/$RANDOM_THEME.zsh-theme"
elif [[ -f "$ZSH_CUSTOM/themes/$RANDOM_THEME.zsh-theme" ]]; then
source "$ZSH_CUSTOM/themes/$RANDOM_THEME.zsh-theme"
elif [[ -f "$ZSH/themes/$RANDOM_THEME.zsh-theme" ]]; then
source "$ZSH/themes/$RANDOM_THEME.zsh-theme"
else
echo "[oh-my-zsh] Random theme '${RANDOM_THEME}' not found"
return 1
fi
echo "[oh-my-zsh] Random theme '${RANDOM_THEME}' loaded"
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )" PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
PROMPT='${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)' PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}" ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} " ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
......
# Sunrise theme for oh-my-zsh # Sunrise theme for oh-my-zsh
# Intended to be used with Solarized: http://ethanschoonover.com/solarized # Intended to be used with Solarized: https://ethanschoonover.com/solarized
# Color shortcuts # Color shortcuts
R=$fg_no_bold[red] R=$fg_no_bold[red]
......
#!/bin/sh #!/bin/sh
# #
# This script should be run via curl: # This script should be run via curl:
# 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)"
# or wget: # or wget:
# sh -c "$(wget -qO- https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" # sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# #
# As an alternative, you can first download the install script and run it afterwards: # As an alternative, you can first download the install script and run it afterwards:
# wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh # wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
# sh install.sh # sh install.sh
# #
# You can tweak the install behavior by setting variables when running the script. For # You can tweak the install behavior by setting variables when running the script. For
...@@ -15,17 +15,19 @@ ...@@ -15,17 +15,19 @@
# #
# Respects the following environment variables: # Respects the following environment variables:
# ZSH - path to the Oh My Zsh repository folder (default: $HOME/.oh-my-zsh) # ZSH - path to the Oh My Zsh repository folder (default: $HOME/.oh-my-zsh)
# REPO - name of the GitHub repo to install from (default: robbyrussell/oh-my-zsh) # REPO - name of the GitHub repo to install from (default: ohmyzsh/ohmyzsh)
# REMOTE - full remote URL of the git repo to install (default: GitHub via HTTPS) # REMOTE - full remote URL of the git repo to install (default: GitHub via HTTPS)
# BRANCH - branch to check out immediately after install (default: master) # BRANCH - branch to check out immediately after install (default: master)
# #
# Other options: # Other options:
# CHSH - 'no' means the installer will not change the default shell (default: yes) # CHSH - 'no' means the installer will not change the default shell (default: yes)
# RUNZSH - 'no' means the installer will not run zsh after the install (default: yes) # RUNZSH - 'no' means the installer will not run zsh after the install (default: yes)
# KEEP_ZSHRC - 'yes' means the installer will not replace an existing .zshrc (default: no)
# #
# You can also pass some arguments to the install script to set some these options: # You can also pass some arguments to the install script to set some these options:
# --skip-chsh: has the same behavior as setting CHSH to 'no' # --skip-chsh: has the same behavior as setting CHSH to 'no'
# --unattended: sets both CHSH and RUNZSH to 'no' # --unattended: sets both CHSH and RUNZSH to 'no'
# --keep-zshrc: sets KEEP_ZSHRC to 'yes'
# For example: # For example:
# sh install.sh --unattended # sh install.sh --unattended
# #
...@@ -33,13 +35,14 @@ set -e ...@@ -33,13 +35,14 @@ set -e
# Default settings # Default settings
ZSH=${ZSH:-~/.oh-my-zsh} ZSH=${ZSH:-~/.oh-my-zsh}
REPO=${REPO:-robbyrussell/oh-my-zsh} REPO=${REPO:-ohmyzsh/ohmyzsh}
REMOTE=${REMOTE:-https://github.com/${REPO}.git} REMOTE=${REMOTE:-https://github.com/${REPO}.git}
BRANCH=${BRANCH:-master} BRANCH=${BRANCH:-master}
# Other options # Other options
CHSH=${CHSH:-yes} CHSH=${CHSH:-yes}
RUNZSH=${RUNZSH:-yes} RUNZSH=${RUNZSH:-yes}
KEEP_ZSHRC=${KEEP_ZSHRC:-no}
command_exists() { command_exists() {
...@@ -90,7 +93,11 @@ setup_ohmyzsh() { ...@@ -90,7 +93,11 @@ setup_ohmyzsh() {
exit 1 exit 1
fi fi
git clone --depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || { git clone -c core.eol=lf -c core.autocrlf=false \
-c fsck.zeroPaddedFilemode=ignore \
-c fetch.fsck.zeroPaddedFilemode=ignore \
-c receive.fsck.zeroPaddedFilemode=ignore \
--depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || {
error "git clone of oh-my-zsh repo failed" error "git clone of oh-my-zsh repo failed"
exit 1 exit 1
} }
...@@ -107,6 +114,11 @@ setup_zshrc() { ...@@ -107,6 +114,11 @@ setup_zshrc() {
# Must use this exact name so uninstall.sh can find it # Must use this exact name so uninstall.sh can find it
OLD_ZSHRC=~/.zshrc.pre-oh-my-zsh OLD_ZSHRC=~/.zshrc.pre-oh-my-zsh
if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then
# Skip this if the user doesn't want to replace an existing .zshrc
if [ $KEEP_ZSHRC = yes ]; then
echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Keeping...${RESET}"
return
fi
if [ -e "$OLD_ZSHRC" ]; then if [ -e "$OLD_ZSHRC" ]; then
OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)" OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)"
if [ -e "$OLD_OLD_ZSHRC" ]; then if [ -e "$OLD_OLD_ZSHRC" ]; then
...@@ -125,10 +137,9 @@ setup_zshrc() { ...@@ -125,10 +137,9 @@ setup_zshrc() {
echo "${GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${RESET}" echo "${GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${RESET}"
cp "$ZSH/templates/zshrc.zsh-template" ~/.zshrc
sed "/^export ZSH=/ c\\ sed "/^export ZSH=/ c\\
export ZSH=\"$ZSH\" export ZSH=\"$ZSH\"
" ~/.zshrc > ~/.zshrc-omztemp " "$ZSH/templates/zshrc.zsh-template" > ~/.zshrc-omztemp
mv -f ~/.zshrc-omztemp ~/.zshrc mv -f ~/.zshrc-omztemp ~/.zshrc
echo echo
...@@ -165,6 +176,13 @@ setup_shell() { ...@@ -165,6 +176,13 @@ setup_shell() {
*) echo "Invalid choice. Shell change skipped."; return ;; *) echo "Invalid choice. Shell change skipped."; return ;;
esac esac
# Check if we're running on Termux
case "$PREFIX" in
*com.termux*) termux=true; zsh=zsh ;;
*) termux=false ;;
esac
if [ "$termux" != true ]; then
# Test for the right location of the "shells" file # Test for the right location of the "shells" file
if [ -f /etc/shells ]; then if [ -f /etc/shells ]; then
shells_file=/etc/shells shells_file=/etc/shells
...@@ -185,9 +203,10 @@ setup_shell() { ...@@ -185,9 +203,10 @@ setup_shell() {
return return
fi fi
fi fi
fi
# We're going to change the default shell, so back up the current one # We're going to change the default shell, so back up the current one
if [ -n $SHELL ]; then if [ -n "$SHELL" ]; then
echo $SHELL > ~/.shell.pre-oh-my-zsh echo $SHELL > ~/.shell.pre-oh-my-zsh
else else
grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh
...@@ -216,6 +235,7 @@ main() { ...@@ -216,6 +235,7 @@ main() {
case $1 in case $1 in
--unattended) RUNZSH=no; CHSH=no ;; --unattended) RUNZSH=no; CHSH=no ;;
--skip-chsh) CHSH=no ;; --skip-chsh) CHSH=no ;;
--keep-zshrc) KEEP_ZSHRC=yes ;;
esac esac
shift shift
done done
......
...@@ -25,12 +25,8 @@ if [ -e "$ZSHRC_ORIG" ]; then ...@@ -25,12 +25,8 @@ if [ -e "$ZSHRC_ORIG" ]; then
echo "Your original zsh config was restored." echo "Your original zsh config was restored."
fi fi
if hash chsh >/dev/null 2>&1; then if hash chsh >/dev/null 2>&1 && [ -f ~/.shell.pre-oh-my-zsh ]; then
if [ -f ~/.shell.pre-oh-my-zsh ]; then
old_shell=$(cat ~/.shell.pre-oh-my-zsh) old_shell=$(cat ~/.shell.pre-oh-my-zsh)
else
old_shell=/bin/bash
fi
echo "Switching your shell back to '$old_shell':" echo "Switching your shell back to '$old_shell':"
if chsh -s "$old_shell"; then if chsh -s "$old_shell"; then
rm -f ~/.shell.pre-oh-my-zsh rm -f ~/.shell.pre-oh-my-zsh
......
...@@ -20,9 +20,25 @@ else ...@@ -20,9 +20,25 @@ else
NORMAL="" NORMAL=""
fi fi
printf "${BLUE}%s${NORMAL}\n" "Updating Oh My Zsh"
cd "$ZSH" cd "$ZSH"
if git pull --rebase --stat origin master
# Set git-config values known to fix git errors
# Line endings (#4069)
git config core.eol lf
git config core.autocrlf false
# zeroPaddedFilemode fsck errors (#4963)
git config fsck.zeroPaddedFilemode ignore
git config fetch.fsck.zeroPaddedFilemode ignore
git config receive.fsck.zeroPaddedFilemode ignore
# Update upstream remote to ohmyzsh org
remote=$(git remote -v | awk '/https:\/\/github\.com\/robbyrussell\/oh-my-zsh\.git/{ print $1; exit }')
if [ -n "$remote" ]; then
git remote set-url "$remote" "https://github.com/ohmyzsh/ohmyzsh.git"
fi
printf "${BLUE}%s${NORMAL}\n" "Updating Oh My Zsh"
if git pull --rebase --autostash --stat origin master
then then
printf '%s' "$GREEN" printf '%s' "$GREEN"
printf '%s\n' ' __ __ ' printf '%s\n' ' __ __ '
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment