update oh my zsh
This commit is contained in:
parent
543addd2fb
commit
662ea60ee0
2
zsh/.oh-my-zsh/.gitignore
vendored
2
zsh/.oh-my-zsh/.gitignore
vendored
@ -1,7 +1,5 @@
|
||||
# custom files
|
||||
custom/
|
||||
!custom/plugins/example
|
||||
!custom/example.zsh
|
||||
|
||||
# temp files directories
|
||||
cache/
|
||||
|
@ -1,8 +1,10 @@
|
||||
# CONTRIBUTING GUIDELINES
|
||||
|
||||
Oh-My-Zsh is a community-driven project. Contribution is welcome, encouraged and appreciated.
|
||||
Oh-My-Zsh is a community-driven project. Contribution is welcome, encouraged, and appreciated.
|
||||
It is also essential for the development of the project.
|
||||
|
||||
First, please take a moment to review our [code of conduct](CODE_OF_CONDUCT.md).
|
||||
|
||||
These guidelines are an attempt at better addressing the huge amount of pending
|
||||
issues and pull requests. Please read them closely.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2009-2018 Robby Russell and contributors
|
||||
Copyright (c) 2009-2019 Robby Russell and 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
|
||||
|
@ -6,7 +6,7 @@ Oh My Zsh is an open source, community-driven framework for managing your [zsh](
|
||||
|
||||
Sounds boring. Let's try again.
|
||||
|
||||
__Oh My Zsh will not make you a 10x developer...but you might feel like one.__
|
||||
__Oh My Zsh will not make you a 10x developer...but you may feel like one.__
|
||||
|
||||
Once installed, your terminal shell will become the talk of the town _or your money back!_ With each keystroke in your command prompt, you'll take advantage of the hundreds of powerful plugins and beautiful themes. Strangers will come up to you in cafés and ask you, _"that is amazing! are you some sort of genius?"_
|
||||
|
||||
@ -18,10 +18,8 @@ To learn more, visit [ohmyz.sh](https://ohmyz.sh) and follow [@ohmyzsh](https://
|
||||
|
||||
### Prerequisites
|
||||
|
||||
__Disclaimer:__ _Oh My Zsh works best on macOS and Linux._
|
||||
|
||||
* 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)
|
||||
* 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/robbyrussell/oh-my-zsh/wiki/Installing-ZSH)
|
||||
* `curl` or `wget` should be installed
|
||||
* `git` should be installed
|
||||
|
||||
@ -38,7 +36,18 @@ sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/mas
|
||||
#### via wget
|
||||
|
||||
```shell
|
||||
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
|
||||
sh -c "$(wget -O- https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
|
||||
```
|
||||
|
||||
#### Manual inspection
|
||||
|
||||
It's a good idea to inspect the install script from projects you don't yet know. You can do
|
||||
that by downloading the install script first, looking through it so everything looks normal,
|
||||
then running it:
|
||||
|
||||
```shell
|
||||
curl -Lo install.sh https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh
|
||||
sh install.sh
|
||||
```
|
||||
|
||||
## Using Oh My Zsh
|
||||
@ -69,13 +78,15 @@ plugins=(
|
||||
)
|
||||
```
|
||||
|
||||
_Note that the plugins are separated by whitespace. **Do not** use commas between them._
|
||||
|
||||
#### Using Plugins
|
||||
|
||||
Most plugins (should! we're working on this) include a __README__, which documents how to use them.
|
||||
|
||||
### 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://wiki.github.com/robbyrussell/oh-my-zsh/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/robbyrussell/oh-my-zsh/wiki/Themes) on the wiki. Check them out!
|
||||
|
||||
#### Selecting a Theme
|
||||
|
||||
@ -124,16 +135,52 @@ If you're the type that likes to get their hands dirty, these sections might res
|
||||
|
||||
### Advanced Installation
|
||||
|
||||
Some users may want to change the default path, or manually install Oh My Zsh.
|
||||
Some users may want to manually install Oh My Zsh, or change the default path or other settings that
|
||||
the installer accepts (these settings are also documented at the top of the install script).
|
||||
|
||||
#### Custom Directory
|
||||
|
||||
The default location is `~/.oh-my-zsh` (hidden in your home directory)
|
||||
|
||||
If you'd like to change the install directory with the `ZSH` environment variable, either by running `export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline like this:
|
||||
If you'd like to change the install directory with the `ZSH` environment variable, either by running
|
||||
`export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline
|
||||
like this:
|
||||
|
||||
```shell
|
||||
export ZSH="$HOME/.dotfiles/oh-my-zsh"; sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
|
||||
ZSH="$HOME/.dotfiles/oh-my-zsh" sh install.sh
|
||||
```
|
||||
|
||||
#### Unattended install
|
||||
|
||||
If you're running the Oh My Zsh install script as part of an automated install, you can pass the
|
||||
flag `--unattended` to the `install.sh` script. This will have the effect of not trying to change
|
||||
the default shell, and also won't run `zsh` when the installation has finished.
|
||||
|
||||
```shell
|
||||
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" "" --unattended
|
||||
```
|
||||
|
||||
#### Installing from a forked 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
|
||||
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
|
||||
clone. You can use this setting if you want to install from a fork that is not on GitHub (GitLab,
|
||||
Bitbucket...) or if you want to clone with SSH instead of HTTPS (`git@github.com:user/project.git`).
|
||||
|
||||
_NOTE: it's incompatible with setting the `REPO` variable. This setting will take precedence._
|
||||
|
||||
- `BRANCH` (default: `master`): you can use this setting if you want to change the default branch to be
|
||||
checked out when cloning the repository. This might be useful for testing a Pull Request, or if you
|
||||
want to use a branch other than `master`.
|
||||
|
||||
For example:
|
||||
|
||||
```shell
|
||||
REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh
|
||||
```
|
||||
|
||||
#### Manual Installation
|
||||
@ -161,9 +208,11 @@ cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
|
||||
##### 4. Change your default shell
|
||||
|
||||
```shell
|
||||
chsh -s /bin/zsh
|
||||
chsh -s $(which zsh)
|
||||
```
|
||||
|
||||
You must log out from your user session and log back in to see this change.
|
||||
|
||||
##### 5. Initialize your new zsh configuration
|
||||
|
||||
Once you open up a new terminal window, it should load zsh with Oh My Zsh's configuration.
|
||||
@ -172,8 +221,10 @@ Once you open up a new terminal window, it should load zsh with Oh My Zsh's conf
|
||||
|
||||
If you have any hiccups installing, here are a few common fixes.
|
||||
|
||||
* You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after switching to `oh-my-zsh`.
|
||||
* If you installed manually or changed the install location, check the `ZSH` environment variable in `~/.zshrc`.
|
||||
* You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after
|
||||
switching to `oh-my-zsh`.
|
||||
* If you installed manually or changed the install location, check the `ZSH` environment variable in
|
||||
`~/.zshrc`.
|
||||
|
||||
### Custom Plugins and Themes
|
||||
|
||||
@ -213,12 +264,16 @@ Oh My Zsh isn't for everyone. We'll miss you, but we want to make this an easy b
|
||||
|
||||
If you want to uninstall `oh-my-zsh`, just run `uninstall_oh_my_zsh` from the command-line. It will remove itself and revert your previous `bash` or `zsh` configuration.
|
||||
|
||||
## Contributing
|
||||
## How do I contribute to Oh My Zsh?
|
||||
|
||||
Before you participate in our delightful community, please read the [code of conduct](CODE_OF_CONDUCT.md).
|
||||
|
||||
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.
|
||||
|
||||
See [Contributing](CONTRIBUTING.md) for more details.
|
||||
|
||||
### 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.
|
||||
@ -238,7 +293,7 @@ We're on the social media.
|
||||
|
||||
## Merchandise
|
||||
|
||||
We have [stickers](https://shop.planetargon.com/products/ohmyzsh-stickers-set-of-3-stickers) and [shirts](https://shop.planetargon.com/products/ohmyzsh-t-shirts) for you to show off your love of Oh My Zsh. Again, this will help you become the talk of the town!
|
||||
We have [stickers, shirts, and coffee mugs available](https://shop.planetargon.com/collections/oh-my-zsh?utm_source=github) for you to show off your love of Oh My Zsh. Again, you will become the talk of the town!
|
||||
|
||||
## License
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Christian Ludwig
|
||||
Copyright (c) 2014-2019 Christian Ludwig
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -30,6 +30,14 @@ If you're using [Zgen](https://github.com/tarjoilija/zgen), add
|
||||
|
||||
to your `.zshrc` with your other zgen plugin load commands.
|
||||
|
||||
### Zplugin
|
||||
|
||||
If you're using [Zplugin](https://github.com/zdharma/zplugin), add
|
||||
|
||||
`zplugin light "chrissicool/zsh-256color"`
|
||||
|
||||
to your `.zshrc` with your other zplugin load commands.
|
||||
|
||||
## Debugging
|
||||
|
||||
If the environment variable `$ZSH_256COLOR_DEBUG` is set to any value when the
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2014, Christian Ludwig
|
||||
# Copyright (c) 2014-2019, Christian Ludwig
|
||||
#
|
||||
# Set 256color terminal mode if available.
|
||||
|
||||
@ -19,7 +19,7 @@ _zsh_terminal_set_256color()
|
||||
|
||||
# Use (n-)curses binaries, if installed.
|
||||
if [[ -x "$( which toe )" ]] ; then
|
||||
if toe -a | egrep -q "^$TERM256" ; then
|
||||
if toe -a | egrep "^$TERM256" >/dev/null ; then
|
||||
_zsh_256color_debug "Found $TERM256 from (n-)curses binaries."
|
||||
export TERM="$TERM256"
|
||||
return
|
||||
|
@ -3,6 +3,8 @@ sudo: required
|
||||
|
||||
env:
|
||||
- ZSH=master
|
||||
- ZSH=5.7.1
|
||||
- ZSH=5.7
|
||||
- ZSH=5.6.2
|
||||
- ZSH=5.6.1
|
||||
- ZSH=5.6
|
||||
@ -33,7 +35,7 @@ env:
|
||||
- ZSH=4.3.12
|
||||
- ZSH=4.3.11
|
||||
|
||||
script: docker run -v $PWD:/work -w /work zshusers/zsh-${ZSH} /bin/sh -c 'install_packages make procps && make test'
|
||||
script: docker run -v $PWD:/work -w /work zshusers/zsh:${ZSH} /bin/sh -c 'install_packages make procps && make test'
|
||||
|
||||
notifications:
|
||||
webhooks:
|
||||
|
@ -11,16 +11,18 @@ The `main` highlighter
|
||||
|
||||
The following function `pz` is useful when working on the `main` highlighting:
|
||||
|
||||
pq() {
|
||||
```zsh
|
||||
pq() {
|
||||
(( $#argv )) || return 0
|
||||
print -r -l -- ${(qqqq)argv}
|
||||
}
|
||||
pz() {
|
||||
}
|
||||
pz() {
|
||||
local arg
|
||||
for arg; do
|
||||
pq ${(z)arg}
|
||||
done
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
It prints, for each argument, its token breakdown, similar to how the main
|
||||
loop of the `main` highlighter sees it.
|
||||
@ -32,17 +34,19 @@ Since the test harness empties `ZSH_HIGHLIGHT_STYLES` and the `brackets`
|
||||
highlighter interrogates `ZSH_HIGHLIGHT_STYLES` to determine how to highlight,
|
||||
tests must set the `bracket-level-#` keys themselves. For example:
|
||||
|
||||
ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
|
||||
ZSH_HIGHLIGHT_STYLES[bracket-level-2]=
|
||||
```zsh
|
||||
ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
|
||||
ZSH_HIGHLIGHT_STYLES[bracket-level-2]=
|
||||
|
||||
BUFFER='echo ({x})'
|
||||
BUFFER='echo ({x})'
|
||||
|
||||
expected_region_highlight=(
|
||||
expected_region_highlight=(
|
||||
"6 6 bracket-level-1" # (
|
||||
"7 7 bracket-level-2" # {
|
||||
"9 9 bracket-level-2" # }
|
||||
"10 10 bracket-level-1" # )
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
Testing the `pattern` and `regexp` highlighters
|
||||
-----------------------------------------------
|
||||
@ -53,20 +57,24 @@ cannot get the `ZSH_HIGHLIGHT_STYLES` keys. Therefore, when writing tests, use
|
||||
the style itself as third word (cf. the
|
||||
[documentation for `expected_region_highlight`](docs/highlighters.md)). For example:
|
||||
|
||||
ZSH_HIGHLIGHT_PATTERNS+=('rm -rf *' 'fg=white,bold,bg=red')
|
||||
```zsh
|
||||
ZSH_HIGHLIGHT_PATTERNS+=('rm -rf *' 'fg=white,bold,bg=red')
|
||||
|
||||
BUFFER='rm -rf /'
|
||||
BUFFER='rm -rf /'
|
||||
|
||||
expected_region_highlight=(
|
||||
expected_region_highlight=(
|
||||
"1 8 fg=white,bold,bg=red" # rm -rf /
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
Miscellany
|
||||
----------
|
||||
|
||||
If you work on the driver (`zsh-syntax-highlighting.zsh`), you may find the following zstyle useful:
|
||||
|
||||
zstyle ':completion:*:*:*:*:globbed-files' ignored-patterns {'*/',}zsh-syntax-highlighting.plugin.zsh
|
||||
```zsh
|
||||
zstyle ':completion:*:*:*:*:globbed-files' ignored-patterns {'*/',}zsh-syntax-highlighting.plugin.zsh
|
||||
```
|
||||
|
||||
IRC channel
|
||||
-----------
|
||||
|
@ -24,7 +24,7 @@ How to install
|
||||
[fedora-package]: https://apps.fedoraproject.org/packages/zsh-syntax-highlighting
|
||||
[fedora-package-alt]: https://bodhi.fedoraproject.org/updates/?packages=zsh-syntax-highlighting
|
||||
[obs-repository]: https://software.opensuse.org//download.html?project=shells%3Azsh-users%3Azsh-syntax-highlighting&package=zsh-syntax-highlighting
|
||||
[void-package]: https://github.com/voidlinux/void-packages/tree/master/srcpkgs/zsh-syntax-highlighting
|
||||
[void-package]: https://github.com/void-linux/void-packages/tree/master/srcpkgs/zsh-syntax-highlighting
|
||||
|
||||
See also [repology's cross-distro index](https://repology.org/metapackage/zsh-syntax-highlighting/versions)
|
||||
|
||||
@ -33,17 +33,23 @@ See also [repology's cross-distro index](https://repology.org/metapackage/zsh-sy
|
||||
|
||||
Simply clone this repository and source the script:
|
||||
|
||||
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
|
||||
echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
|
||||
```zsh
|
||||
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
|
||||
echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
|
||||
```
|
||||
|
||||
Then, enable syntax highlighting in the current interactive shell:
|
||||
|
||||
source ./zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||
```zsh
|
||||
source ./zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||
```
|
||||
|
||||
If `git` is not installed, download and extract a snapshot of the latest
|
||||
development tree from:
|
||||
|
||||
https://github.com/zsh-users/zsh-syntax-highlighting/archive/master.tar.gz
|
||||
```
|
||||
https://github.com/zsh-users/zsh-syntax-highlighting/archive/master.tar.gz
|
||||
```
|
||||
|
||||
Note the `source` command must be **at the end** of `~/.zshrc`.
|
||||
|
||||
@ -69,11 +75,15 @@ your `.zshrc`.
|
||||
|
||||
1. Clone this repository in oh-my-zsh's plugins directory:
|
||||
|
||||
% git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
|
||||
```zsh
|
||||
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
|
||||
```
|
||||
|
||||
2. Activate the plugin in `~/.zshrc`:
|
||||
|
||||
```zsh
|
||||
plugins=( [plugins...] zsh-syntax-highlighting)
|
||||
```
|
||||
|
||||
3. Restart zsh (such as by opening a new instance of your terminal emulator).
|
||||
|
||||
@ -104,10 +114,14 @@ Any of the above methods is suitable for a single-user installation,
|
||||
which requires no special privileges. If, however, you desire to install
|
||||
zsh-syntax-highlighting system-wide, you may do so by running
|
||||
|
||||
make install
|
||||
```zsh
|
||||
make install
|
||||
```
|
||||
|
||||
and directing your users to add
|
||||
|
||||
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||
```zsh
|
||||
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||
```
|
||||
|
||||
to their `.zshrc`s.
|
||||
|
@ -309,50 +309,66 @@ in this area.
|
||||
- incomplete sudo commands
|
||||
(a3047a912100, 2f05620b19ae)
|
||||
|
||||
```zsh
|
||||
sudo;
|
||||
sudo -u;
|
||||
```
|
||||
|
||||
- command words following reserved words
|
||||
(#207, #222, b397b12ac139 et seq, 6fbd2aa9579b et seq, 8b4adbd991b0)
|
||||
|
||||
```zsh
|
||||
if ls; then ls; else ls; fi
|
||||
repeat 10 do ls; done
|
||||
```
|
||||
|
||||
(The `ls` are now highlighted as a command.)
|
||||
|
||||
- comments (when `INTERACTIVE_COMMENTS` is set)
|
||||
(#163, #167, 693de99a9030)
|
||||
|
||||
```zsh
|
||||
echo Hello # comment
|
||||
```
|
||||
|
||||
- closing brackets of arithmetic expansion, subshells, and blocks
|
||||
(#226, a59f442d2d34, et seq)
|
||||
|
||||
```zsh
|
||||
(( foo ))
|
||||
( foo )
|
||||
{ foo }
|
||||
```
|
||||
|
||||
- command names enabled by the `PATH_DIRS` option
|
||||
(#228, 96ee5116b182)
|
||||
|
||||
```zsh
|
||||
# When ~/bin/foo/bar exists, is executable, ~/bin is in $PATH,
|
||||
# and 'setopt PATH_DIRS' is in effect
|
||||
foo/bar
|
||||
```
|
||||
|
||||
- parameter expansions with braces inside double quotes
|
||||
(#186, 6e3720f39d84)
|
||||
|
||||
```zsh
|
||||
echo "${foo}"
|
||||
```
|
||||
|
||||
- parameter expansions in command word
|
||||
(#101, 4fcfb15913a2)
|
||||
|
||||
```zsh
|
||||
x=/bin/ls
|
||||
$x -l
|
||||
```
|
||||
|
||||
- the command separators '|&', '&!', '&|'
|
||||
- the command separators '\|&', '&!', '&\|'
|
||||
|
||||
```zsh
|
||||
view file.pdf &! ls
|
||||
```
|
||||
|
||||
|
||||
## Fixed highlighting of:
|
||||
@ -360,23 +376,31 @@ in this area.
|
||||
- precommand modifiers at non-command-word position
|
||||
(#209, 2c9f8c8c95fa)
|
||||
|
||||
```zsh
|
||||
ls command foo
|
||||
```
|
||||
|
||||
- sudo commands with infix redirections
|
||||
(#221, be006aded590, 86e924970911)
|
||||
|
||||
```zsh
|
||||
sudo -u >/tmp/foo.out user ls
|
||||
```
|
||||
|
||||
- subshells; anonymous functions
|
||||
(#166, #194, 0d1bfbcbfa67, 9e178f9f3948)
|
||||
|
||||
```zsh
|
||||
(true)
|
||||
() { true }
|
||||
```
|
||||
|
||||
- parameter assignment statements with no command
|
||||
(#205, 01d7eeb3c713)
|
||||
|
||||
```zsh
|
||||
A=1;
|
||||
```
|
||||
|
||||
(The semicolon used to be highlighted as a mistake)
|
||||
|
||||
@ -467,69 +491,95 @@ in this area.
|
||||
|
||||
- suffix aliases (requires zsh 5.1.1 or newer):
|
||||
|
||||
```zsh
|
||||
alias -s png=display
|
||||
foo.png
|
||||
```
|
||||
|
||||
- prefix redirections:
|
||||
|
||||
```zsh
|
||||
<foo.txt cat
|
||||
```
|
||||
|
||||
- redirection operators:
|
||||
|
||||
```zsh
|
||||
echo > foo.txt
|
||||
```
|
||||
|
||||
- arithmetic evaluations:
|
||||
|
||||
```zsh
|
||||
(( 42 ))
|
||||
```
|
||||
|
||||
- $'' strings, including \x/\octal/\u/\U escapes
|
||||
|
||||
```zsh
|
||||
: $'foo\u0040bar'
|
||||
```
|
||||
|
||||
- multiline strings:
|
||||
|
||||
```zsh
|
||||
% echo "line 1
|
||||
line 2"
|
||||
```
|
||||
|
||||
- string literals that haven't been finished:
|
||||
|
||||
```zsh
|
||||
% echo "Hello, world
|
||||
|
||||
```
|
||||
- command words that involve tilde expansion:
|
||||
|
||||
```zsh
|
||||
% ~/bin/foo
|
||||
|
||||
```
|
||||
|
||||
## Fixed highlighting of:
|
||||
|
||||
- quoted command words:
|
||||
|
||||
```zsh
|
||||
% \ls
|
||||
```
|
||||
|
||||
- backslash escapes in "" strings:
|
||||
|
||||
```zsh
|
||||
% echo "\x41"
|
||||
```
|
||||
|
||||
- noglob after command separator:
|
||||
|
||||
```zsh
|
||||
% :; noglob echo *
|
||||
```
|
||||
|
||||
- glob after command separator, when the first command starts with 'noglob':
|
||||
|
||||
```zsh
|
||||
% noglob true; echo *
|
||||
```
|
||||
|
||||
- the region (vi visual mode / set-mark-command) (issue #165)
|
||||
|
||||
- redirection and command separators that would be highlighted as `path_approx`
|
||||
|
||||
```zsh
|
||||
% echo foo;‸
|
||||
% echo <‸
|
||||
```
|
||||
|
||||
(where `‸` represents the cursor location)
|
||||
|
||||
- escaped globbing (outside quotes)
|
||||
|
||||
```zsh
|
||||
% echo \*
|
||||
```
|
||||
|
||||
|
||||
## Other changes:
|
||||
|
@ -24,7 +24,9 @@ How to activate highlighters
|
||||
To activate an highlighter, add it to the `ZSH_HIGHLIGHT_HIGHLIGHTERS` array in
|
||||
`~/.zshrc`, for example:
|
||||
|
||||
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor)
|
||||
```zsh
|
||||
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor)
|
||||
```
|
||||
|
||||
By default, `$ZSH_HIGHLIGHT_HIGHLIGHTERS` is unset and only the `main`
|
||||
highlighter is active.
|
||||
@ -58,10 +60,12 @@ To create your own `acme` highlighter:
|
||||
This function must return 0 when the highlighter needs to be called and
|
||||
non-zero otherwise, for example:
|
||||
|
||||
```zsh
|
||||
_zsh_highlight_highlighter_acme_predicate() {
|
||||
# Call this highlighter in SVN working copies
|
||||
[[ -d .svn ]]
|
||||
}
|
||||
```
|
||||
|
||||
* Implement the `_zsh_highlight_highlighter_acme_paint` function.
|
||||
This function does the actual syntax highlighting, by calling
|
||||
@ -71,18 +75,22 @@ To create your own `acme` highlighter:
|
||||
`: ${ZSH_HIGHLIGHT_STYLES[key]:=value}`, being sure to prefix
|
||||
the key with your highlighter name and a colon. For example:
|
||||
|
||||
```zsh
|
||||
: ${ZSH_HIGHLIGHT_STYLES[acme:aurora]:=fg=green}
|
||||
|
||||
_zsh_highlight_highlighter_acme_paint() {
|
||||
# Colorize the whole buffer with the 'aurora' style
|
||||
_zsh_highlight_add_highlight 0 $#BUFFER acme:aurora
|
||||
}
|
||||
```
|
||||
|
||||
If you need to test which options the user has set, test `zsyh_user_options`
|
||||
with a sensible default if the option is not present in supported zsh
|
||||
versions. For example:
|
||||
|
||||
```zsh
|
||||
[[ ${zsyh_user_options[ignoreclosebraces]:-off} == on ]]
|
||||
```
|
||||
|
||||
The option name must be all lowercase with no underscores and not an alias.
|
||||
|
||||
@ -100,6 +108,8 @@ To create your own `acme` highlighter:
|
||||
|
||||
* Activate your highlighter in `~/.zshrc`:
|
||||
|
||||
```zsh
|
||||
ZSH_HIGHLIGHT_HIGHLIGHTERS+=(acme)
|
||||
```
|
||||
|
||||
* [Write tests](../tests/README.md).
|
||||
|
@ -16,11 +16,13 @@ This highlighter defines the following styles:
|
||||
To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`,
|
||||
for example in `~/.zshrc`:
|
||||
|
||||
# To define styles for nested brackets up to level 4
|
||||
ZSH_HIGHLIGHT_STYLES[bracket-level-1]='fg=blue,bold'
|
||||
ZSH_HIGHLIGHT_STYLES[bracket-level-2]='fg=red,bold'
|
||||
ZSH_HIGHLIGHT_STYLES[bracket-level-3]='fg=yellow,bold'
|
||||
ZSH_HIGHLIGHT_STYLES[bracket-level-4]='fg=magenta,bold'
|
||||
```zsh
|
||||
# To define styles for nested brackets up to level 4
|
||||
ZSH_HIGHLIGHT_STYLES[bracket-level-1]='fg=blue,bold'
|
||||
ZSH_HIGHLIGHT_STYLES[bracket-level-2]='fg=red,bold'
|
||||
ZSH_HIGHLIGHT_STYLES[bracket-level-3]='fg=yellow,bold'
|
||||
ZSH_HIGHLIGHT_STYLES[bracket-level-4]='fg=magenta,bold'
|
||||
```
|
||||
|
||||
The syntax for values is the same as the syntax of "types of highlighting" of
|
||||
the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
|
||||
|
@ -13,7 +13,9 @@ This highlighter defines the following styles:
|
||||
To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`,
|
||||
for example in `~/.zshrc`:
|
||||
|
||||
ZSH_HIGHLIGHT_STYLES[cursor]='bg=blue'
|
||||
```zsh
|
||||
ZSH_HIGHLIGHT_STYLES[cursor]='bg=blue'
|
||||
```
|
||||
|
||||
The syntax for values is the same as the syntax of "types of highlighting" of
|
||||
the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
|
||||
|
@ -13,7 +13,9 @@ This highlighter defines the following styles:
|
||||
To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`,
|
||||
for example in `~/.zshrc`:
|
||||
|
||||
ZSH_HIGHLIGHT_STYLES[line]='bold'
|
||||
```zsh
|
||||
ZSH_HIGHLIGHT_STYLES[line]='bold'
|
||||
```
|
||||
|
||||
The syntax for values is the same as the syntax of "types of highlighting" of
|
||||
the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
|
||||
|
@ -65,17 +65,19 @@ This highlighter defines the following styles:
|
||||
To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`,
|
||||
for example in `~/.zshrc`:
|
||||
|
||||
# Declare the variable
|
||||
typeset -A ZSH_HIGHLIGHT_STYLES
|
||||
```zsh
|
||||
# Declare the variable
|
||||
typeset -A ZSH_HIGHLIGHT_STYLES
|
||||
|
||||
# To differentiate aliases from other command types
|
||||
ZSH_HIGHLIGHT_STYLES[alias]='fg=magenta,bold'
|
||||
# To differentiate aliases from other command types
|
||||
ZSH_HIGHLIGHT_STYLES[alias]='fg=magenta,bold'
|
||||
|
||||
# To have paths colored instead of underlined
|
||||
ZSH_HIGHLIGHT_STYLES[path]='fg=cyan'
|
||||
# To have paths colored instead of underlined
|
||||
ZSH_HIGHLIGHT_STYLES[path]='fg=cyan'
|
||||
|
||||
# To disable highlighting of globbing expressions
|
||||
ZSH_HIGHLIGHT_STYLES[globbing]='none'
|
||||
# To disable highlighting of globbing expressions
|
||||
ZSH_HIGHLIGHT_STYLES[globbing]='none'
|
||||
```
|
||||
|
||||
The syntax for values is the same as the syntax of "types of highlighting" of
|
||||
the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
|
||||
@ -83,10 +85,12 @@ manual page][zshzle-Character-Highlighting].
|
||||
|
||||
#### Parameters
|
||||
|
||||
To avoid partial path lookups on a path, add the path to the `X_ZSH_HIGHLIGHT_DIRS_BLACKLIST` array.
|
||||
To avoid partial path lookups on a path, add the path to the `ZSH_HIGHLIGHT_DIRS_BLACKLIST` array.
|
||||
This interface is still experimental.
|
||||
|
||||
X_ZSH_HIGHLIGHT_DIRS_BLACKLIST+=(/mnt/slow_share)
|
||||
```zsh
|
||||
ZSH_HIGHLIGHT_DIRS_BLACKLIST+=(/mnt/slow_share)
|
||||
```
|
||||
|
||||
### Useless trivia
|
||||
|
||||
|
@ -9,11 +9,13 @@ This is the `pattern` highlighter, that highlights user-defined patterns.
|
||||
To use this highlighter, associate patterns with styles in the
|
||||
`ZSH_HIGHLIGHT_PATTERNS` associative array, for example in `~/.zshrc`:
|
||||
|
||||
# Declare the variable
|
||||
typeset -A ZSH_HIGHLIGHT_PATTERNS
|
||||
```zsh
|
||||
# Declare the variable
|
||||
typeset -A ZSH_HIGHLIGHT_PATTERNS
|
||||
|
||||
# To have commands starting with `rm -rf` in red:
|
||||
ZSH_HIGHLIGHT_PATTERNS+=('rm -rf *' 'fg=white,bold,bg=red')
|
||||
# To have commands starting with `rm -rf` in red:
|
||||
ZSH_HIGHLIGHT_PATTERNS+=('rm -rf *' 'fg=white,bold,bg=red')
|
||||
```
|
||||
|
||||
The syntax for values is the same as the syntax of "types of highlighting" of
|
||||
the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
|
||||
|
@ -10,8 +10,10 @@ patterns.
|
||||
To use this highlighter, associate regular expressions with styles in the
|
||||
`ZSH_HIGHLIGHT_REGEXP` associative array, for example in `~/.zshrc`:
|
||||
|
||||
typeset -A ZSH_HIGHLIGHT_PATTERNS
|
||||
ZSH_HIGHLIGHT_REGEXP+=('\bsudo\b' fg=123,bold)
|
||||
```zsh
|
||||
typeset -A ZSH_HIGHLIGHT_PATTERNS
|
||||
ZSH_HIGHLIGHT_REGEXP+=('\bsudo\b' fg=123,bold)
|
||||
```
|
||||
|
||||
This will highlight "sudo" only as a complete word, i.e., "sudo cmd", but not
|
||||
"sudoedit"
|
||||
|
@ -14,7 +14,9 @@ This highlighter defines the following styles:
|
||||
To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`,
|
||||
for example in `~/.zshrc`:
|
||||
|
||||
ZSH_HIGHLIGHT_STYLES[root]='bg=red'
|
||||
```zsh
|
||||
ZSH_HIGHLIGHT_STYLES[root]='bg=red'
|
||||
```
|
||||
|
||||
The syntax for values is the same as the syntax of "types of highlighting" of
|
||||
the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
|
||||
|
@ -73,8 +73,10 @@ _zsh_highlight_main_add_region_highlight() {
|
||||
integer start=$1 end=$2
|
||||
shift 2
|
||||
|
||||
(( highlighted_alias )) && return
|
||||
(( in_alias )) && highlighted_alias=1
|
||||
if (( in_alias )); then
|
||||
[[ $1 == unknown-token ]] && alias_style=unknown-token
|
||||
return
|
||||
fi
|
||||
|
||||
# The calculation was relative to $buf but region_highlight is relative to $BUFFER.
|
||||
(( start += buf_offset ))
|
||||
@ -173,6 +175,10 @@ _zsh_highlight_main__type() {
|
||||
REPLY=builtin
|
||||
elif (( $+commands[(e)$1] )); then
|
||||
REPLY=command
|
||||
# None of the special hashes had a match, so fall back to 'type -w', for
|
||||
# forward compatibility with future versions of zsh that may add new command
|
||||
# types.
|
||||
#
|
||||
# zsh 5.2 and older have a bug whereby running 'type -w ./sudo' implicitly
|
||||
# runs 'hash ./sudo=/usr/local/bin/./sudo' (assuming /usr/local/bin/sudo
|
||||
# exists and is in $PATH). Avoid triggering the bug, at the expense of
|
||||
@ -180,11 +186,15 @@ _zsh_highlight_main__type() {
|
||||
#
|
||||
# The first disjunct mimics the isrelative() C call from the zsh bug.
|
||||
elif { [[ $1 != */* ]] || is-at-least 5.3 } &&
|
||||
! builtin type -w -- $1 >/dev/null 2>&1; then
|
||||
# Add a subshell to avoid a zsh upstream bug; see issue #606.
|
||||
# ### Remove the subshell when we stop supporting zsh 5.7.1 (I assume 5.8 will have the bugfix).
|
||||
! (builtin type -w -- $1) >/dev/null 2>&1; then
|
||||
REPLY=none
|
||||
fi
|
||||
fi
|
||||
if ! (( $+REPLY )); then
|
||||
# zsh/parameter not available or had no matches.
|
||||
#
|
||||
# Note that 'type -w' will run 'rehash' implicitly.
|
||||
#
|
||||
# We 'unalias' in a subshell, so the parent shell is not affected.
|
||||
@ -287,7 +297,8 @@ _zsh_highlight_highlighter_main_paint()
|
||||
# that wouldn't be followed by a colon in a getopts specification.
|
||||
local flags_sans_argument
|
||||
# $precommand_options maps precommand name to values of $flags_with_argument and
|
||||
# $flags_sans_argument for that precommand, joined by a colon.
|
||||
# $flags_sans_argument for that precommand, joined by a colon. (The value is NOT
|
||||
# a getopt(3) spec, although it resembles one.)
|
||||
#
|
||||
# Currently, setting $flags_sans_argument is only important for commands that
|
||||
# have a non-empty $flags_with_argument; see test-data/precommand4.zsh.
|
||||
@ -305,6 +316,7 @@ _zsh_highlight_highlighter_main_paint()
|
||||
'nice' n: # as of current POSIX spec
|
||||
'pkexec' '' # doesn't take short options; immune to #121 because it's usually not passed --option flags
|
||||
'sudo' Cgprtu:AEHKPSVbhiklnsv # as of sudo 1.8.21p2
|
||||
'stdbuf' ioe:
|
||||
)
|
||||
|
||||
if [[ $zsyh_user_options[ignorebraces] == on || ${zsyh_user_options[ignoreclosebraces]:-off} == on ]]; then
|
||||
@ -343,6 +355,12 @@ _zsh_highlight_highlighter_main_paint()
|
||||
'!' # reserved word; unrelated to $histchars[1]
|
||||
)
|
||||
|
||||
if (( $+X_ZSH_HIGHLIGHT_DIRS_BLACKLIST )); then
|
||||
print >&2 'zsh-syntax-highlighting: X_ZSH_HIGHLIGHT_DIRS_BLACKLIST is deprecated. Please use ZSH_HIGHLIGHT_DIRS_BLACKLIST.'
|
||||
ZSH_HIGHLIGHT_DIRS_BLACKLIST=($X_ZSH_HIGHLIGHT_DIRS_BLACKLIST)
|
||||
unset X_ZSH_HIGHLIGHT_DIRS_BLACKLIST
|
||||
fi
|
||||
|
||||
_zsh_highlight_main_highlighter_highlight_list -$#PREBUFFER '' 1 "$PREBUFFER$BUFFER"
|
||||
|
||||
# end is a reserved word
|
||||
@ -367,15 +385,16 @@ _zsh_highlight_highlighter_main_paint()
|
||||
_zsh_highlight_main_highlighter_highlight_list()
|
||||
{
|
||||
integer start_pos end_pos=0 buf_offset=$1 has_end=$3
|
||||
# alias_style is the style to apply to an alias once in_alias=0
|
||||
# Usually 'alias' but set to 'unknown-token' if any word expanded from
|
||||
# the alias would be highlighted as unknown-token
|
||||
# last_alias is the last alias arg (lhs) expanded (if in an alias).
|
||||
# This allows for expanding alias ls='ls -l' while avoiding loops.
|
||||
local arg buf=$4 highlight_glob=true last_alias style
|
||||
local alias_style arg buf=$4 highlight_glob=true last_alias style
|
||||
local in_array_assignment=false # true between 'a=(' and the matching ')'
|
||||
# highlighted_alias is 1 when the alias arg has been highlighted with a non-alias style.
|
||||
# E.g. alias x=ls; x has been highlighted as alias AND command.
|
||||
# in_alias is equal to the number of shifts needed until arg=args[1] pops an
|
||||
# arg from BUFFER and not added by an alias.
|
||||
integer highlighted_alias=0 in_alias=0 len=$#buf
|
||||
integer in_alias=0 len=$#buf
|
||||
local -a match mbegin mend list_highlights
|
||||
# seen_alias is a map of aliases already seen to avoid loops like alias a=b b=a
|
||||
local -A seen_alias
|
||||
@ -448,7 +467,11 @@ _zsh_highlight_main_highlighter_highlight_list()
|
||||
shift args
|
||||
if (( in_alias )); then
|
||||
(( in_alias-- ))
|
||||
(( in_alias == 0 )) && highlighted_alias=0 last_alias= seen_alias=()
|
||||
if (( in_alias == 0 )); then
|
||||
last_alias= seen_alias=()
|
||||
# start_pos and end_pos are of the alias (previous $arg) here
|
||||
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $alias_style
|
||||
fi
|
||||
fi
|
||||
|
||||
# Initialize this_word and next_word.
|
||||
@ -525,6 +548,7 @@ _zsh_highlight_main_highlighter_highlight_list()
|
||||
# Avoid looping forever on alias a=b b=c c=b, but allow alias foo='foo bar'
|
||||
# Also mark insane aliases as unknown-token (cf. #263).
|
||||
if (( $+seen_alias[$arg] )) || [[ $arg == ?*=* ]]; then
|
||||
(( in_alias == 0 )) && in_alias=1
|
||||
_zsh_highlight_main_add_region_highlight $start_pos $end_pos unknown-token
|
||||
continue
|
||||
fi
|
||||
@ -533,11 +557,14 @@ _zsh_highlight_main_highlighter_highlight_list()
|
||||
_zsh_highlight_main__resolve_alias $arg
|
||||
local -a alias_args
|
||||
# Elision is desired in case alias x=''
|
||||
alias_args=( ${interactive_comments-${(z)REPLY}}
|
||||
${interactive_comments+${(zZ+c+)REPLY}} )
|
||||
if [[ $zsyh_user_options[interactivecomments] == on ]]; then
|
||||
alias_args=(${(zZ+c+)REPLY})
|
||||
else
|
||||
alias_args=(${(z)REPLY})
|
||||
fi
|
||||
args=( $alias_args $args )
|
||||
if (( in_alias == 0 )); then
|
||||
_zsh_highlight_main_add_region_highlight $start_pos $end_pos alias
|
||||
alias_style=alias
|
||||
# Add one because we will in_alias-- on the next loop iteration so
|
||||
# this iteration should be considered in in_alias as well
|
||||
(( in_alias += $#alias_args + 1 ))
|
||||
@ -896,6 +923,7 @@ _zsh_highlight_main_highlighter_highlight_list()
|
||||
fi
|
||||
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
|
||||
done
|
||||
(( in_alias == 1 )) && in_alias=0 _zsh_highlight_main_add_region_highlight $start_pos $end_pos $alias_style
|
||||
[[ "$proc_buf" = (#b)(#s)(([[:space:]]|\\$'\n')#) ]]
|
||||
REPLY=$(( end_pos + ${#match[1]} - 1 ))
|
||||
reply=($list_highlights)
|
||||
@ -944,7 +972,7 @@ _zsh_highlight_main_highlighter_check_path()
|
||||
tmp_path=$tmp_path:a
|
||||
|
||||
while [[ $tmp_path != / ]]; do
|
||||
[[ -n ${(M)X_ZSH_HIGHLIGHT_DIRS_BLACKLIST:#$tmp_path} ]] && return 1
|
||||
[[ -n ${(M)ZSH_HIGHLIGHT_DIRS_BLACKLIST:#$tmp_path} ]] && return 1
|
||||
tmp_path=$tmp_path:h
|
||||
done
|
||||
|
||||
@ -1035,9 +1063,10 @@ _zsh_highlight_main_highlighter_highlight_argument()
|
||||
highlights+=($reply)
|
||||
;;
|
||||
'$')
|
||||
if [[ $arg[i+1] != "'" ]]; then
|
||||
path_eligible=0
|
||||
fi
|
||||
if [[ $arg[i+1] == "'" ]]; then
|
||||
path_eligible=1
|
||||
_zsh_highlight_main_highlighter_highlight_dollar_quote $i
|
||||
(( i = REPLY ))
|
||||
highlights+=($reply)
|
||||
@ -1227,7 +1256,7 @@ _zsh_highlight_main_highlighter_highlight_double_quote()
|
||||
saved_reply=($reply)
|
||||
reply=()
|
||||
for 1 2 in $breaks; do
|
||||
reply+=($1 $2 $style)
|
||||
(( $1 != $2 )) && reply+=($1 $2 $style)
|
||||
done
|
||||
reply+=($saved_reply)
|
||||
REPLY=$i
|
||||
@ -1388,4 +1417,4 @@ else
|
||||
# Make sure the cache is unset
|
||||
unset _zsh_highlight_main__command_type_cache
|
||||
fi
|
||||
typeset -ga X_ZSH_HIGHLIGHT_DIRS_BLACKLIST
|
||||
typeset -ga ZSH_HIGHLIGHT_DIRS_BLACKLIST
|
||||
|
@ -33,6 +33,5 @@ alias x=$'# foo\npwd'
|
||||
BUFFER='x'
|
||||
|
||||
expected_region_highlight=(
|
||||
'1 1 alias' # x
|
||||
'1 1 comment' # x (#)
|
||||
'1 1 alias "issue #616"' # x
|
||||
)
|
||||
|
@ -33,6 +33,5 @@ alias x=$'# foo\npwd'
|
||||
BUFFER='x'
|
||||
|
||||
expected_region_highlight=(
|
||||
'1 1 alias' # x
|
||||
'1 1 unknown-token' # x (#)
|
||||
)
|
||||
|
@ -33,7 +33,6 @@ BUFFER='x file echo'
|
||||
|
||||
expected_region_highlight=(
|
||||
'1 1 alias' # x
|
||||
'1 1 builtin' # x (echo)
|
||||
'3 6 default' # file
|
||||
'8 11 builtin' # echo
|
||||
)
|
||||
|
@ -33,7 +33,6 @@ alias a=b b=c c=b
|
||||
BUFFER='a foo; :'
|
||||
|
||||
expected_region_highlight=(
|
||||
'1 1 alias' # a
|
||||
'1 1 unknown-token' # a (invalid alias loop)
|
||||
'3 5 default' # foo
|
||||
'6 6 commandseparator' # ;
|
||||
|
@ -35,7 +35,6 @@ BUFFER='a -u phy1729 echo; :'
|
||||
|
||||
expected_region_highlight=(
|
||||
'1 1 alias' # a
|
||||
'1 1 precommand' # a (sudo)
|
||||
'3 4 single-hyphen-option' # -u
|
||||
'6 12 default' # phy1729
|
||||
'14 17 builtin' # echo
|
||||
|
@ -34,7 +34,6 @@ BUFFER='a foo; :'
|
||||
|
||||
expected_region_highlight=(
|
||||
'1 1 alias' # a
|
||||
'1 1 builtin' # a (:)
|
||||
'3 5 default' # foo
|
||||
'6 6 commandseparator' # ;
|
||||
'8 8 builtin' # :
|
||||
|
@ -28,15 +28,14 @@
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
alias sdu='sudo -u'
|
||||
alias sudo_u='sudo -u'
|
||||
sudo(){}
|
||||
|
||||
BUFFER='sdu phy1729 echo foo'
|
||||
BUFFER='sudo_u phy1729 echo foo'
|
||||
|
||||
expected_region_highlight=(
|
||||
'1 3 alias' # sdu
|
||||
'1 3 precommand' # sdu (sudo)
|
||||
'5 11 default' # phy1729
|
||||
'13 16 commmand "issue #540"' # echo (not builtin)
|
||||
'18 20 default' # foo
|
||||
'1 6 alias' # sudo_u
|
||||
'8 14 default' # phy1729
|
||||
'17 19 command "issue #540"' # echo (not builtin)
|
||||
'21 23 default' # foo
|
||||
)
|
||||
|
@ -28,16 +28,15 @@
|
||||
# vim: ft=zsh sw=2 ts=2 et
|
||||
# -------------------------------------------------------------------------------------------------
|
||||
|
||||
alias sde='sudo -e'
|
||||
alias seu='sde -u'
|
||||
alias sudo_b='sudo -b'
|
||||
alias sudo_b_u='sudo_b -u'
|
||||
sudo(){}
|
||||
|
||||
BUFFER='seu phy1729 echo foo'
|
||||
BUFFER='sudo_b_u phy1729 echo foo'
|
||||
|
||||
expected_region_highlight=(
|
||||
'1 3 alias' # seu
|
||||
'1 3 precommand' # seu (sudo)
|
||||
'5 11 default' # phy1729
|
||||
'13 16 commmand "issue #540"' # echo (not builtin)
|
||||
'18 20 default' # foo
|
||||
'1 8 alias' # sudo_b_u
|
||||
'10 16 default' # phy1729
|
||||
'18 21 command "issue #540"' # echo (not builtin)
|
||||
'23 25 default' # foo
|
||||
)
|
||||
|
@ -32,7 +32,6 @@ BUFFER='x foo echo bar'
|
||||
|
||||
expected_region_highlight=(
|
||||
'1 1 alias' # x
|
||||
'1 1 redirection' # x (>)
|
||||
'3 5 default' # foo
|
||||
'7 10 builtin' # echo
|
||||
'12 14 default' # bar
|
||||
|
@ -34,6 +34,5 @@ BUFFER='echo bar'
|
||||
|
||||
expected_region_highlight=(
|
||||
'1 4 alias' # echo
|
||||
'1 4 builtin' # echo
|
||||
'6 8 default' # bar
|
||||
)
|
||||
|
@ -32,6 +32,5 @@ alias x=/
|
||||
BUFFER=$'x'
|
||||
|
||||
expected_region_highlight=(
|
||||
'1 1 alias' # x
|
||||
'1 1 unknown-token "issue #202"' # x (/)
|
||||
)
|
||||
|
@ -48,7 +48,6 @@ fi
|
||||
expected_region_highlight+=(
|
||||
"9 9 commandseparator" # ;
|
||||
"11 16 alias" # alias1
|
||||
"11 16 command" # alias1 (ls)
|
||||
"17 17 commandseparator" # ;
|
||||
"19 24 unknown-token" # alias2
|
||||
)
|
||||
|
@ -30,7 +30,7 @@
|
||||
mkdir foo
|
||||
touch foo/bar
|
||||
BUFFER=": foo/bar $PWD/foo foo/b"
|
||||
X_ZSH_HIGHLIGHT_DIRS_BLACKLIST=($PWD/foo $PWD/bar)
|
||||
ZSH_HIGHLIGHT_DIRS_BLACKLIST=($PWD/foo $PWD/bar)
|
||||
|
||||
expected_region_highlight=(
|
||||
'1 1 builtin' # :
|
||||
|
@ -32,6 +32,5 @@ BUFFER='x ls'
|
||||
|
||||
expected_region_highlight=(
|
||||
"1 1 alias" # x
|
||||
"1 1 precommand" # x (command)
|
||||
"3 4 command" # ls
|
||||
)
|
||||
|
@ -34,7 +34,6 @@ BUFFER='a;f;'
|
||||
|
||||
expected_region_highlight=(
|
||||
"1 1 alias" # a
|
||||
"1 1 builtin" # a (:)
|
||||
"2 2 commandseparator" # ;
|
||||
"3 3 function" # f
|
||||
"4 4 commandseparator" # ;
|
||||
|
@ -9,7 +9,7 @@
|
||||
`tig --abbrev=12 --abbrev-commit 0.4.1..upstream/master`
|
||||
- Remove `-dev` suffix from `./.version`;
|
||||
Commit that using `git commit -m "Tag version $(<.version)." .version`;
|
||||
Tag it using `git tag -m "Tag version $(<.version)"`;
|
||||
Tag it using `git tag -s -m "Tag version $(<.version)"`;
|
||||
Increment `./.version` and restore the `-dev` suffix;
|
||||
Commit that using `git commit -C b5c30ae52638e81a38fe5329081c5613d7bd6ca5 .version`.
|
||||
- Push with `git push && git push --tags`
|
||||
|
@ -38,17 +38,19 @@ computes `$region_highlight`), but will not affect subsequent tests. The
|
||||
current working directory of tests is set to a newly-created empty directory,
|
||||
which is automatically cleaned up after the test exits. For example:
|
||||
|
||||
setopt PATH_DIRS
|
||||
mkdir -p foo/bar
|
||||
touch foo/bar/testing-issue-228
|
||||
chmod +x foo/bar/testing-issue-228
|
||||
path+=( "$PWD"/foo )
|
||||
```zsh
|
||||
setopt PATH_DIRS
|
||||
mkdir -p foo/bar
|
||||
touch foo/bar/testing-issue-228
|
||||
chmod +x foo/bar/testing-issue-228
|
||||
path+=( "$PWD"/foo )
|
||||
|
||||
BUFFER='bar/testing-issue-228'
|
||||
BUFFER='bar/testing-issue-228'
|
||||
|
||||
expected_region_highlight=(
|
||||
expected_region_highlight=(
|
||||
"1 21 command" # bar/testing-issue-228
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
Writing new tests
|
||||
@ -56,7 +58,9 @@ Writing new tests
|
||||
|
||||
An experimental tool is available to generate test files:
|
||||
|
||||
zsh -f tests/generate.zsh 'ls -x' acme newfile
|
||||
```zsh
|
||||
zsh -f tests/generate.zsh 'ls -x' acme newfile
|
||||
```
|
||||
|
||||
This generates a `highlighters/acme/test-data/newfile.zsh` test file based on
|
||||
the current highlighting of the given `$BUFFER` (in this case, `ls -x`).
|
||||
@ -71,11 +75,15 @@ Highlighting test
|
||||
[`test-highlighting.zsh`](tests/test-highlighting.zsh) tests the correctness of
|
||||
the highlighting. Usage:
|
||||
|
||||
zsh test-highlighting.zsh <HIGHLIGHTER NAME>
|
||||
```zsh
|
||||
zsh test-highlighting.zsh <HIGHLIGHTER NAME>
|
||||
```
|
||||
|
||||
All tests may be run with
|
||||
|
||||
make test
|
||||
```zsh
|
||||
make test
|
||||
```
|
||||
|
||||
which will run all highlighting tests and report results in [TAP format][TAP].
|
||||
By default, the results of all tests will be printed; to show only "interesting"
|
||||
@ -91,8 +99,12 @@ Performance test
|
||||
[`test-perfs.zsh`](tests/test-perfs.zsh) measures the time spent doing the
|
||||
highlighting. Usage:
|
||||
|
||||
zsh test-perfs.zsh <HIGHLIGHTER NAME>
|
||||
```zsh
|
||||
zsh test-perfs.zsh <HIGHLIGHTER NAME>
|
||||
```
|
||||
|
||||
All tests may be run with
|
||||
|
||||
make perf
|
||||
```zsh
|
||||
make perf
|
||||
```
|
||||
|
@ -101,7 +101,7 @@ _zsh_highlight()
|
||||
typeset -r zsyh_user_options
|
||||
|
||||
emulate -L zsh
|
||||
setopt localoptions warncreateglobal
|
||||
setopt localoptions warncreateglobal nobashrematch
|
||||
local REPLY # don't leak $REPLY into global scope
|
||||
|
||||
# Do not highlight if there are more than 300 chars in the buffer. It's most
|
||||
@ -157,24 +157,25 @@ _zsh_highlight()
|
||||
# Re-apply zle_highlight settings
|
||||
|
||||
# region
|
||||
if (( REGION_ACTIVE == 1 )); then
|
||||
_zsh_highlight_apply_zle_highlight region standout "$MARK" "$CURSOR"
|
||||
elif (( REGION_ACTIVE == 2 )); then
|
||||
() {
|
||||
local needle=$'\n'
|
||||
(( REGION_ACTIVE )) || return
|
||||
integer min max
|
||||
if (( MARK > CURSOR )) ; then
|
||||
min=$CURSOR max=$MARK
|
||||
else
|
||||
min=$MARK max=$CURSOR
|
||||
fi
|
||||
if (( REGION_ACTIVE == 1 )); then
|
||||
[[ $KEYMAP = vicmd ]] && (( max++ ))
|
||||
elif (( REGION_ACTIVE == 2 )); then
|
||||
local needle=$'\n'
|
||||
# CURSOR and MARK are 0 indexed between letters like region_highlight
|
||||
# Do not include the newline in the highlight
|
||||
(( min = ${BUFFER[(Ib:min:)$needle]} ))
|
||||
(( max = ${BUFFER[(ib:max:)$needle]} - 1 ))
|
||||
fi
|
||||
_zsh_highlight_apply_zle_highlight region standout "$min" "$max"
|
||||
}
|
||||
fi
|
||||
|
||||
# yank / paste (zsh-5.1.1 and newer)
|
||||
(( $+YANK_ACTIVE )) && (( YANK_ACTIVE )) && _zsh_highlight_apply_zle_highlight paste standout "$YANK_START" "$YANK_END"
|
||||
@ -432,6 +433,12 @@ zmodload zsh/parameter 2>/dev/null || true
|
||||
# Initialize the array of active highlighters if needed.
|
||||
[[ $#ZSH_HIGHLIGHT_HIGHLIGHTERS -eq 0 ]] && ZSH_HIGHLIGHT_HIGHLIGHTERS=(main)
|
||||
|
||||
if (( $+X_ZSH_HIGHLIGHT_DIRS_BLACKLIST )); then
|
||||
print >&2 'zsh-syntax-highlighting: X_ZSH_HIGHLIGHT_DIRS_BLACKLIST is deprecated. Please use ZSH_HIGHLIGHT_DIRS_BLACKLIST.'
|
||||
ZSH_HIGHLIGHT_DIRS_BLACKLIST=($X_ZSH_HIGHLIGHT_DIRS_BLACKLIST)
|
||||
unset X_ZSH_HIGHLIGHT_DIRS_BLACKLIST
|
||||
fi
|
||||
|
||||
# Restore the aliases we unned
|
||||
eval "$zsh_highlight__aliases"
|
||||
builtin unset zsh_highlight__aliases
|
||||
|
@ -18,7 +18,7 @@ function handle_completion_insecurities() {
|
||||
insecure_dirs=( ${(f@):-"$(compaudit 2>/dev/null)"} )
|
||||
|
||||
# If no such directories exist, get us out of here.
|
||||
(( ! ${#insecure_dirs} )) && return
|
||||
[[ -z "${insecure_dirs}" ]] && return
|
||||
|
||||
# List ownership and permissions of all insecure directories.
|
||||
print "[oh-my-zsh] Insecure completion-dependent directories detected:"
|
||||
|
@ -21,7 +21,15 @@ alias 9='cd -9'
|
||||
|
||||
alias md='mkdir -p'
|
||||
alias rd=rmdir
|
||||
alias d='dirs -v | head -10'
|
||||
|
||||
function d () {
|
||||
if [[ -n $1 ]]; then
|
||||
dirs "$@"
|
||||
else
|
||||
dirs -v | head -10
|
||||
fi
|
||||
}
|
||||
compdef _dirs d
|
||||
|
||||
# List directory contents
|
||||
alias lsa='ls -lah'
|
||||
|
@ -21,7 +21,7 @@ function open_command() {
|
||||
case "$OSTYPE" in
|
||||
darwin*) open_cmd='open' ;;
|
||||
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 ""'
|
||||
[[ -e "$1" ]] && { 1="$(wslpath -w "${1:a}")" || return 1 }
|
||||
} ;;
|
||||
@ -31,12 +31,7 @@ function open_command() {
|
||||
;;
|
||||
esac
|
||||
|
||||
# don't use nohup on OSX
|
||||
if [[ "$OSTYPE" == darwin* ]]; then
|
||||
${=open_cmd} "$@" &>/dev/null
|
||||
else
|
||||
nohup ${=open_cmd} "$@" &>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
@ -79,7 +74,7 @@ function try_alias_value() {
|
||||
# 0 if the variable exists, 3 if it was set
|
||||
#
|
||||
function default() {
|
||||
test `typeset +m "$1"` && return 0
|
||||
(( $+parameters[$1] )) && return 0
|
||||
typeset -g "$1"="$2" && return 3
|
||||
}
|
||||
|
||||
@ -93,7 +88,7 @@ function default() {
|
||||
# 0 if the env variable exists, 3 if it was set
|
||||
#
|
||||
function env_default() {
|
||||
env | grep -q "^$1=" && return 0
|
||||
(( ${${(@f):-$(typeset +xg)}[(I)$1]} )) && return 0
|
||||
export "$1=$2" && return 3
|
||||
}
|
||||
|
||||
|
@ -10,13 +10,10 @@ function git_prompt_info() {
|
||||
|
||||
# Checks if working tree is dirty
|
||||
function parse_git_dirty() {
|
||||
local STATUS=''
|
||||
local STATUS
|
||||
local -a FLAGS
|
||||
FLAGS=('--porcelain')
|
||||
FLAGS=('--porcelain' '--ignore-submodules=dirty')
|
||||
if [[ "$(command git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then
|
||||
if [[ $POST_1_7_2_GIT -gt 0 ]]; then
|
||||
FLAGS+='--ignore-submodules=dirty'
|
||||
fi
|
||||
if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then
|
||||
FLAGS+='--untracked-files=no'
|
||||
fi
|
||||
@ -181,28 +178,6 @@ function git_prompt_status() {
|
||||
echo $STATUS
|
||||
}
|
||||
|
||||
# Compares the provided version of git to the version installed and on path
|
||||
# Outputs -1, 0, or 1 if the installed version is less than, equal to, or
|
||||
# greater than the input version, respectively.
|
||||
function git_compare_version() {
|
||||
local INPUT_GIT_VERSION INSTALLED_GIT_VERSION i
|
||||
INPUT_GIT_VERSION=(${(s/./)1})
|
||||
INSTALLED_GIT_VERSION=($(command git --version 2>/dev/null))
|
||||
INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]})
|
||||
|
||||
for i in {1..3}; do
|
||||
if [[ $INSTALLED_GIT_VERSION[$i] -gt $INPUT_GIT_VERSION[$i] ]]; then
|
||||
echo 1
|
||||
return 0
|
||||
fi
|
||||
if [[ $INSTALLED_GIT_VERSION[$i] -lt $INPUT_GIT_VERSION[$i] ]]; then
|
||||
echo -1
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
echo 0
|
||||
}
|
||||
|
||||
# Outputs the name of the current user
|
||||
# Usage example: $(git_current_user_name)
|
||||
function git_current_user_name() {
|
||||
@ -214,8 +189,3 @@ function git_current_user_name() {
|
||||
function git_current_user_email() {
|
||||
command git config user.email 2>/dev/null
|
||||
}
|
||||
|
||||
# This is unlikely to change so make it all statically assigned
|
||||
POST_1_7_2_GIT=$(git_compare_version "1.7.2")
|
||||
# Clean up the namespace slightly by removing the checker function
|
||||
unfunction git_compare_version
|
||||
|
@ -12,12 +12,12 @@ function omz_history {
|
||||
builtin fc "$@"
|
||||
else
|
||||
# unless a number is provided, show all history events (starting from 1)
|
||||
[[ ${@[-1]} = *[0-9]* ]] && builtin fc -l "$@" || builtin fc -l "$@" 1
|
||||
[[ ${@[-1]-} = *[0-9]* ]] && builtin fc -l "$@" || builtin fc -l "$@" 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Timestamp format
|
||||
case $HIST_STAMPS in
|
||||
case ${HIST_STAMPS-} in
|
||||
"mm/dd/yyyy") alias history='omz_history -f' ;;
|
||||
"dd.mm.yyyy") alias history='omz_history -E' ;;
|
||||
"yyyy-mm-dd") alias history='omz_history -i' ;;
|
||||
|
@ -1,7 +1,7 @@
|
||||
## Load smart urls if available
|
||||
# bracketed-paste-magic is known buggy in zsh 5.1.1 (only), so skip it there; see #4434
|
||||
autoload -Uz is-at-least
|
||||
if [[ $ZSH_VERSION != 5.1.1 ]]; then
|
||||
|
||||
# *-magic is known buggy in some versions; disable if so
|
||||
if [[ $DISABLE_MAGIC_FUNCTIONS != true ]]; then
|
||||
for d in $fpath; do
|
||||
if [[ -e "$d/url-quote-magic" ]]; then
|
||||
if is-at-least 5.1; then
|
||||
@ -22,8 +22,7 @@ env_default 'PAGER' 'less'
|
||||
env_default 'LESS' '-R'
|
||||
|
||||
## super user alias
|
||||
alias _='sudo'
|
||||
alias please='sudo'
|
||||
alias _='sudo '
|
||||
|
||||
## more intelligent acking for ubuntu users
|
||||
if which ack-grep &> /dev/null; then
|
||||
@ -32,10 +31,5 @@ else
|
||||
alias afind='ack -il'
|
||||
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
|
||||
setopt interactivecomments
|
||||
|
@ -10,9 +10,15 @@
|
||||
# Dummy implementations that return false to prevent command_not_found
|
||||
# errors with themes, that implement these functions
|
||||
# Real implementations will be used when the respective plugins are loaded
|
||||
function chruby_prompt_info hg_prompt_info pyenv_prompt_info \
|
||||
rbenv_prompt_info svn_prompt_info vi_mode_prompt_info \
|
||||
virtualenv_prompt_info jenv_prompt_info {
|
||||
function chruby_prompt_info \
|
||||
rbenv_prompt_info \
|
||||
hg_prompt_info \
|
||||
pyenv_prompt_info \
|
||||
svn_prompt_info \
|
||||
vi_mode_prompt_info \
|
||||
virtualenv_prompt_info \
|
||||
jenv_prompt_info \
|
||||
{
|
||||
return 1
|
||||
}
|
||||
|
||||
@ -22,10 +28,13 @@ function rvm_prompt_info() {
|
||||
[ -f $HOME/.rvm/bin/rvm-prompt ] || return 1
|
||||
local rvm_prompt
|
||||
rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${=ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null)
|
||||
[[ "${rvm_prompt}x" == "x" ]] && return 1
|
||||
echo "${ZSH_THEME_RVM_PROMPT_PREFIX:=(}${rvm_prompt}${ZSH_THEME_RVM_PROMPT_SUFFIX:=)}"
|
||||
[[ -z "${rvm_prompt}" ]] && return 1
|
||||
echo "${ZSH_THEME_RUBY_PROMPT_PREFIX}${rvm_prompt}${ZSH_THEME_RUBY_PROMPT_SUFFIX}"
|
||||
}
|
||||
|
||||
ZSH_THEME_RVM_PROMPT_OPTIONS="i v g"
|
||||
|
||||
|
||||
# use this to enable users to see their ruby version, no matter which
|
||||
# version management system they use
|
||||
function ruby_prompt_info() {
|
||||
|
@ -21,7 +21,7 @@ function title {
|
||||
print -Pn "\e]2;$2:q\a" # set window name
|
||||
print -Pn "\e]1;$1:q\a" # set tab name
|
||||
;;
|
||||
screen*)
|
||||
screen*|tmux*)
|
||||
print -Pn "\ek$1:q\e\\" # set screen hardstatus
|
||||
;;
|
||||
*)
|
||||
|
@ -19,7 +19,7 @@ if [[ "$DISABLE_LS_COLORS" != "true" ]]; then
|
||||
# coreutils, so prefer it to "gls".
|
||||
gls --color -d . &>/dev/null && alias ls='gls --color=tty'
|
||||
colorls -G -d . &>/dev/null && alias ls='colorls -G'
|
||||
elif [[ "$OSTYPE" == darwin* ]]; then
|
||||
elif [[ "$OSTYPE" == (darwin|freebsd)* ]]; then
|
||||
# this is a good alias, it works by default just using $LSCOLORS
|
||||
ls -G . &>/dev/null && alias ls='ls -G'
|
||||
|
||||
@ -45,11 +45,10 @@ setopt prompt_subst
|
||||
|
||||
[[ -n "$WINDOW" ]] && SCREEN_NO="%B$WINDOW%b " || SCREEN_NO=""
|
||||
|
||||
# Apply theming defaults
|
||||
PS1="%n@%m:%~%# "
|
||||
|
||||
# git theming default: Variables for theming the git info prompt
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="git:(" # Prefix at the very beginning of the prompt, before the branch name
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX=")" # At the very end of the prompt
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY="*" # Text to display if the branch is dirty
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN="" # Text to display if the branch is clean
|
||||
ZSH_THEME_RUBY_PROMPT_PREFIX="("
|
||||
ZSH_THEME_RUBY_PROMPT_SUFFIX=")"
|
||||
|
@ -29,21 +29,13 @@ if [[ -z "$ZSH_CUSTOM" ]]; then
|
||||
fi
|
||||
|
||||
|
||||
# Load all of the config files in ~/oh-my-zsh that end in .zsh
|
||||
# TIP: Add files you don't want in git to .gitignore
|
||||
for config_file ($ZSH/lib/*.zsh); do
|
||||
custom_config_file="${ZSH_CUSTOM}/lib/${config_file:t}"
|
||||
[ -f "${custom_config_file}" ] && config_file=${custom_config_file}
|
||||
source $config_file
|
||||
done
|
||||
|
||||
|
||||
is_plugin() {
|
||||
local base_dir=$1
|
||||
local name=$2
|
||||
test -f $base_dir/plugins/$name/$name.plugin.zsh \
|
||||
|| test -f $base_dir/plugins/$name/_$name
|
||||
}
|
||||
|
||||
# Add all defined plugins to fpath. This must be done
|
||||
# before running compinit.
|
||||
for plugin ($plugins); do
|
||||
@ -51,6 +43,8 @@ for plugin ($plugins); do
|
||||
fpath=($ZSH_CUSTOM/plugins/$plugin $fpath)
|
||||
elif is_plugin $ZSH $plugin; then
|
||||
fpath=($ZSH/plugins/$plugin $fpath)
|
||||
else
|
||||
echo "[oh-my-zsh] plugin '$plugin' not found"
|
||||
fi
|
||||
done
|
||||
|
||||
@ -68,17 +62,25 @@ if [ -z "$ZSH_COMPDUMP" ]; then
|
||||
fi
|
||||
|
||||
if [[ $ZSH_DISABLE_COMPFIX != true ]]; then
|
||||
source $ZSH/lib/compfix.zsh
|
||||
# If completion insecurities exist, warn the user
|
||||
if ! compaudit &>/dev/null; then
|
||||
handle_completion_insecurities
|
||||
fi
|
||||
# Load only from secure directories
|
||||
compinit -i -d "${ZSH_COMPDUMP}"
|
||||
compinit -i -C -d "${ZSH_COMPDUMP}"
|
||||
else
|
||||
# If the user wants it, load from all found directories
|
||||
compinit -u -d "${ZSH_COMPDUMP}"
|
||||
compinit -u -C -d "${ZSH_COMPDUMP}"
|
||||
fi
|
||||
|
||||
|
||||
# Load all of the config files in ~/oh-my-zsh that end in .zsh
|
||||
# TIP: Add files you don't want in git to .gitignore
|
||||
for config_file ($ZSH/lib/*.zsh); do
|
||||
custom_config_file="${ZSH_CUSTOM}/lib/${config_file:t}"
|
||||
[ -f "${custom_config_file}" ] && config_file=${custom_config_file}
|
||||
source $config_file
|
||||
done
|
||||
|
||||
# Load all of the plugins that were defined in ~/.zshrc
|
||||
for plugin ($plugins); do
|
||||
if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
|
||||
|
@ -49,7 +49,12 @@ _arguments \
|
||||
case "$state" in
|
||||
specify_device)
|
||||
_values -C 'devices' ${$(adb devices -l|awk 'NR>1&& $1 \
|
||||
{sub(/ +/," ",$0);gsub(":","\\:",$1); printf "%s[%s] ",$1, $NF}'):-""}
|
||||
{sub(/ +/," ",$0); \
|
||||
gsub(":","\\:",$1); \
|
||||
for(i=1;i<=NF;i++) {
|
||||
if($i ~ /model:/) { split($i,m,":") } \
|
||||
else if($i ~ /product:/) { split($i,p,":") } } \
|
||||
printf "%s[%s(%s)] ",$1, p[2], m[2]}'):-""}
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
@ -19,9 +19,8 @@ plugins=(... ansible)
|
||||
| `a` | command `ansible` |
|
||||
| `aconf` | command `ansible-config` |
|
||||
| `acon` | command `ansible-console` |
|
||||
| `aconn` | command `ansible-connection` |
|
||||
| `ainv` | command `ansible-inventory` |
|
||||
| `aplay` | command `ansible-playbook` |
|
||||
| `aplaybook` | command `ansible-playbook` |
|
||||
| `ainv` | command `ansible-inventory` |
|
||||
| `adoc` | command `ansible-doc` |
|
||||
| `agal` | command `ansible-galaxy` |
|
||||
|
@ -18,10 +18,9 @@ function ansible-role-init(){
|
||||
alias a='ansible '
|
||||
alias aconf='ansible-config '
|
||||
alias acon='ansible-console '
|
||||
alias aconn='ansible-connection '
|
||||
alias aver='ansible-version'
|
||||
alias arinit='ansible-role-init'
|
||||
alias aplay='ansible-playbook '
|
||||
alias aplaybook='ansible-playbook '
|
||||
alias ainv='ansible-inventory '
|
||||
alias adoc='ansible-doc '
|
||||
alias agal='ansible-galaxy '
|
||||
|
@ -14,7 +14,7 @@
|
||||
| yalocs | yay -Qs | Search for packages in the local database |
|
||||
| yalst | yay -Qe | List installed packages including from AUR (tagged as "local") |
|
||||
| yamir | yay -Syy | Force refresh of all package lists after updating mirrorlist |
|
||||
| yaorph | yay -Qtd | Remove orphans using yaourt |
|
||||
| yaorph | yay -Qtd | Remove orphans using yay |
|
||||
| yare | yay -R | Remove packages, keeping its settings and dependencies |
|
||||
| yarem | yay -Rns | Remove packages, including its settings and unneeded dependencies |
|
||||
| yarep | yay -Si | Display information about a package in the repositories |
|
||||
|
@ -1,9 +1,11 @@
|
||||
# Find where asdf should be installed
|
||||
ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
|
||||
ASDF_COMPLETIONS="$ASDF_DIR/completions"
|
||||
|
||||
# If not found, check for Homebrew package
|
||||
if [[ ! -d $ASDF_DIR ]] && (( $+commands[brew] )); then
|
||||
if [[ ! -f "$ASDF_DIR/asdf.sh" ]] && (( $+commands[brew] )); then
|
||||
ASDF_DIR="$(brew --prefix asdf)"
|
||||
ASDF_COMPLETIONS="$ASDF_DIR/etc/bash_completion.d"
|
||||
fi
|
||||
|
||||
# Load command
|
||||
@ -11,7 +13,7 @@ if [[ -f "$ASDF_DIR/asdf.sh" ]]; then
|
||||
. "$ASDF_DIR/asdf.sh"
|
||||
|
||||
# Load completions
|
||||
if [[ -f "$ASDF_DIR/completions/asdf.bash" ]]; then
|
||||
. "$ASDF_DIR/completions/asdf.bash"
|
||||
if [[ -f "$ASDF_COMPLETIONS/asdf.bash" ]]; then
|
||||
. "$ASDF_COMPLETIONS/asdf.bash"
|
||||
fi
|
||||
fi
|
||||
|
@ -1,23 +1,34 @@
|
||||
if [ $commands[autojump] ]; then # check if autojump is installed
|
||||
if [ -f $HOME/.autojump/etc/profile.d/autojump.zsh ]; then # manual user-local installation
|
||||
. $HOME/.autojump/etc/profile.d/autojump.zsh
|
||||
elif [ -f $HOME/.autojump/share/autojump/autojump.zsh ]; then # another manual user-local installation
|
||||
. $HOME/.autojump/share/autojump/autojump.zsh
|
||||
elif [ -f $HOME/.nix-profile/etc/profile.d/autojump.zsh ]; then # nix installation
|
||||
. $HOME/.nix-profile/etc/profile.d/autojump.zsh
|
||||
elif [ -f /run/current-system/sw/share/autojump/autojump.zsh ]; then # nixos installation
|
||||
. /run/current-system/sw/share/autojump/autojump.zsh
|
||||
elif [ -f /usr/share/autojump/autojump.zsh ]; then # debian and ubuntu package
|
||||
. /usr/share/autojump/autojump.zsh
|
||||
elif [ -f /etc/profile.d/autojump.zsh ]; then # manual installation
|
||||
. /etc/profile.d/autojump.zsh
|
||||
elif [ -f /etc/profile.d/autojump.sh ]; then # gentoo installation
|
||||
. /etc/profile.d/autojump.sh
|
||||
elif [ -f /usr/local/share/autojump/autojump.zsh ]; then # freebsd installation
|
||||
. /usr/local/share/autojump/autojump.zsh
|
||||
elif [ -f /opt/local/etc/profile.d/autojump.sh ]; then # mac os x with ports
|
||||
. /opt/local/etc/profile.d/autojump.sh
|
||||
elif [ $commands[brew] -a -f `brew --prefix`/etc/autojump.sh ]; then # mac os x with brew
|
||||
. `brew --prefix`/etc/autojump.sh
|
||||
declare -a autojump_paths
|
||||
autojump_paths=(
|
||||
$HOME/.autojump/etc/profile.d/autojump.zsh # manual installation
|
||||
$HOME/.autojump/share/autojump/autojump.zsh # manual installation
|
||||
$HOME/.nix-profile/etc/profile.d/autojump.sh # NixOS installation
|
||||
/run/current-system/sw/share/autojump/autojump.zsh # NixOS installation
|
||||
/usr/share/autojump/autojump.zsh # Debian and Ubuntu package
|
||||
/etc/profile.d/autojump.zsh # manual installation
|
||||
/etc/profile.d/autojump.sh # Gentoo installation
|
||||
/usr/local/share/autojump/autojump.zsh # FreeBSD installation
|
||||
/opt/local/etc/profile.d/autojump.sh # macOS with MacPorts
|
||||
/usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default)
|
||||
)
|
||||
|
||||
for file in $autojump_paths; do
|
||||
if [[ -f "$file" ]]; then
|
||||
source "$file"
|
||||
found=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# if no path found, try Homebrew
|
||||
if (( ! found && $+commands[brew] )); then
|
||||
file=$(brew --prefix)/etc/profile.d/autojump.sh
|
||||
if [[ -f "$file" ]]; then
|
||||
source "$file"
|
||||
found=1
|
||||
fi
|
||||
fi
|
||||
|
||||
(( ! found )) && echo '[oh-my-zsh] autojump script not found'
|
||||
|
||||
unset autojump_paths file found
|
||||
|
@ -1,8 +1,7 @@
|
||||
# aws
|
||||
|
||||
This plugin provides completion support for [awscli](https://docs.aws.amazon.com/cli/latest/reference/index.html)
|
||||
and a few utilities to manage AWS profiles: a function to change profiles with autocompletion support
|
||||
and a function to get the current AWS profile. The current AWS profile is also displayed in `RPROMPT`.
|
||||
and a few utilities to manage AWS profiles and display them in the prompt.
|
||||
|
||||
To use it, add `aws` to the plugins array in your zshrc file.
|
||||
|
||||
@ -12,9 +11,28 @@ plugins=(... aws)
|
||||
|
||||
## Plugin commands
|
||||
|
||||
* `asp <profile>`: Sets `AWS_PROFILE` and `AWS_DEFAULT_PROFILE` (legacy) to `<profile>`.
|
||||
It also adds it to your RPROMPT.
|
||||
* `asp [<profile>]`: sets `$AWS_PROFILE` and `$AWS_DEFAULT_PROFILE` (legacy) to `<profile>`.
|
||||
It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI.
|
||||
Run `asp` without arguments to clear the profile.
|
||||
|
||||
* `agp`: Gets the current value of `AWS_PROFILE`.
|
||||
* `agp`: gets the current value of `$AWS_PROFILE`.
|
||||
|
||||
* `aws_profiles`: Lists the available profiles in the file referenced in `AWS_CONFIG_FILE` (default: ~/.aws/config). Used to provide completion for the `asp` function.
|
||||
* `aws_change_access_key`: changes the AWS access key of a profile.
|
||||
|
||||
* `aws_profiles`: lists the available profiles in the `$AWS_CONFIG_FILE` (default: `~/.aws/config`).
|
||||
Used to provide completion for the `asp` function.
|
||||
|
||||
## Plugin options
|
||||
|
||||
* Set `SHOW_AWS_PROMPT=false` in your zshrc file if you want to prevent the plugin from modifying your RPROMPT.
|
||||
Some themes might overwrite the value of RPROMPT instead of appending to it, so they'll need to be fixed to
|
||||
see the AWS profile prompt.
|
||||
|
||||
## Theme
|
||||
|
||||
The plugin creates an `aws_prompt_info` function that you can use in your theme, which displays
|
||||
the current `$AWS_PROFILE`. It uses two variables to control how that is shown:
|
||||
|
||||
- ZSH_THEME_AWS_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to `<aws:`.
|
||||
|
||||
- ZSH_THEME_AWS_SUFFIX: sets the suffix of the AWS_PROFILE. Defaults to `>`.
|
||||
|
@ -1,49 +1,96 @@
|
||||
_homebrew-installed() {
|
||||
type brew &> /dev/null
|
||||
_xit=$?
|
||||
if [ $_xit -eq 0 ];then
|
||||
# ok , we have brew installed
|
||||
# speculatively we check default brew prefix
|
||||
if [ -h /usr/local/opt/awscli ];then
|
||||
_brew_prefix="/usr/local/opt/awscli"
|
||||
else
|
||||
# ok , it is not default prefix
|
||||
# this call to brew is expensive ( about 400 ms ), so at least let's make it only once
|
||||
_brew_prefix=$(brew --prefix awscli)
|
||||
fi
|
||||
return 0
|
||||
else
|
||||
return $_xit
|
||||
fi
|
||||
}
|
||||
|
||||
_awscli-homebrew-installed() {
|
||||
[ -r $_brew_prefix/libexec/bin/aws_zsh_completer.sh ] &> /dev/null
|
||||
}
|
||||
|
||||
function agp {
|
||||
function agp() {
|
||||
echo $AWS_PROFILE
|
||||
}
|
||||
|
||||
function asp {
|
||||
local rprompt=${RPROMPT/<aws:$(agp)>/}
|
||||
# AWS profile selection
|
||||
function asp() {
|
||||
if [[ -z "$1" ]]; then
|
||||
unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE
|
||||
echo AWS profile cleared.
|
||||
return
|
||||
fi
|
||||
|
||||
local available_profiles=($(aws_profiles))
|
||||
if [[ -z "${available_profiles[(r)$1]}" ]]; then
|
||||
echo "${fg[red]}Profile '$1' not found in '${AWS_CONFIG_FILE:-$HOME/.aws/config}'" >&2
|
||||
echo "Available profiles: ${(j:, :)available_profiles:-no profiles found}${reset_color}" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
export AWS_DEFAULT_PROFILE=$1
|
||||
export AWS_PROFILE=$1
|
||||
|
||||
export RPROMPT="<aws:$AWS_PROFILE>$rprompt"
|
||||
export AWS_EB_PROFILE=$1
|
||||
}
|
||||
|
||||
function aws_profiles {
|
||||
reply=($(grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/'))
|
||||
}
|
||||
compctl -K aws_profiles asp
|
||||
function aws_change_access_key() {
|
||||
if [[ -z "$1" ]]; then
|
||||
echo "usage: $0 <profile>"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if which aws_zsh_completer.sh &>/dev/null; then
|
||||
_aws_zsh_completer_path=$(which aws_zsh_completer.sh 2>/dev/null)
|
||||
elif _homebrew-installed && _awscli-homebrew-installed; then
|
||||
_aws_zsh_completer_path=$_brew_prefix/libexec/bin/aws_zsh_completer.sh
|
||||
echo Insert the credentials when asked.
|
||||
asp "$1" || return 1
|
||||
aws iam create-access-key
|
||||
aws configure --profile "$1"
|
||||
|
||||
echo You can now safely delete the old access key running \`aws iam delete-access-key --access-key-id ID\`
|
||||
echo Your current keys are:
|
||||
aws iam list-access-keys
|
||||
}
|
||||
|
||||
function aws_profiles() {
|
||||
[[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1
|
||||
grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/'
|
||||
}
|
||||
|
||||
function _aws_profiles() {
|
||||
reply=($(aws_profiles))
|
||||
}
|
||||
compctl -K _aws_profiles asp aws_change_access_key
|
||||
|
||||
# AWS prompt
|
||||
function aws_prompt_info() {
|
||||
[[ -z $AWS_PROFILE ]] && return
|
||||
echo "${ZSH_THEME_AWS_PREFIX:=<aws:}${AWS_PROFILE}${ZSH_THEME_AWS_SUFFIX:=>}"
|
||||
}
|
||||
|
||||
if [ "$SHOW_AWS_PROMPT" != false ]; then
|
||||
RPROMPT='$(aws_prompt_info)'"$RPROMPT"
|
||||
fi
|
||||
|
||||
[ -n "$_aws_zsh_completer_path" ] && [ -x $_aws_zsh_completer_path ] && source $_aws_zsh_completer_path
|
||||
unset _aws_zsh_completer_path
|
||||
|
||||
# Load awscli completions
|
||||
|
||||
function _awscli-homebrew-installed() {
|
||||
# check if Homebrew is installed
|
||||
(( $+commands[brew] )) || return 1
|
||||
|
||||
# speculatively check default brew prefix
|
||||
if [ -h /usr/local/opt/awscli ]; then
|
||||
_brew_prefix=/usr/local/opt/awscli
|
||||
else
|
||||
# ok, it is not in the default prefix
|
||||
# this call to brew is expensive (about 400 ms), so at least let's make it only once
|
||||
_brew_prefix=$(brew --prefix awscli)
|
||||
fi
|
||||
}
|
||||
|
||||
# get aws_zsh_completer.sh location from $PATH
|
||||
_aws_zsh_completer_path="$commands[aws_zsh_completer.sh]"
|
||||
|
||||
# otherwise check common locations
|
||||
if [[ -z $_aws_zsh_completer_path ]]; then
|
||||
# Homebrew
|
||||
if _awscli-homebrew-installed; then
|
||||
_aws_zsh_completer_path=$_brew_prefix/libexec/bin/aws_zsh_completer.sh
|
||||
# Ubuntu
|
||||
elif [[ -e /usr/share/zsh/vendor-completions/_awscli ]]; then
|
||||
_aws_zsh_completer_path=/usr/share/zsh/vendor-completions/_awscli
|
||||
# RPM
|
||||
else
|
||||
_aws_zsh_completer_path=/usr/share/zsh/site-functions/aws_zsh_completer.sh
|
||||
fi
|
||||
fi
|
||||
|
||||
[[ -r $_aws_zsh_completer_path ]] && source $_aws_zsh_completer_path
|
||||
unset _aws_zsh_completer_path _brew_prefix
|
||||
|
@ -7,6 +7,9 @@
|
||||
# Email: neuralsandwich@gmail.com #
|
||||
# Modified to add support for Apple Mac #
|
||||
###########################################
|
||||
# Author: J (927589452) #
|
||||
# Modified to add support for FreeBSD #
|
||||
###########################################
|
||||
|
||||
if [[ "$OSTYPE" = darwin* ]] ; then
|
||||
|
||||
@ -64,6 +67,52 @@ if [[ "$OSTYPE" = darwin* ]] ; then
|
||||
[[ $(ioreg -rc "AppleSmartBattery"| grep '^.*"IsCharging"\ =\ ' | sed -e 's/^.*"IsCharging"\ =\ //') == "Yes" ]]
|
||||
}
|
||||
|
||||
elif [[ "$OSTYPE" = freebsd* ]] ; then
|
||||
|
||||
function battery_is_charging() {
|
||||
[[ $(sysctl -n hw.acpi.battery.state) -eq 2 ]]
|
||||
}
|
||||
|
||||
function battery_pct() {
|
||||
if (( $+commands[sysctl] )) ; then
|
||||
echo "$(sysctl -n hw.acpi.battery.life)"
|
||||
fi
|
||||
}
|
||||
|
||||
function battery_pct_remaining() {
|
||||
if [ ! $(battery_is_charging) ] ; then
|
||||
battery_pct
|
||||
else
|
||||
echo "External Power"
|
||||
fi
|
||||
}
|
||||
|
||||
function battery_time_remaining() {
|
||||
remaining_time=$(sysctl -n hw.acpi.battery.time)
|
||||
if [[ $remaining_time -ge 0 ]] ; then
|
||||
# calculation from https://www.unix.com/shell-programming-and-scripting/23695-convert-minutes-hours-minutes-seconds.html
|
||||
((hour=$remaining_time/60))
|
||||
((minute=$remaining_time-$hour*60))
|
||||
echo $hour:$minute
|
||||
fi
|
||||
}
|
||||
|
||||
function battery_pct_prompt() {
|
||||
b=$(battery_pct_remaining)
|
||||
if [ ! $(battery_is_charging) ] ; then
|
||||
if [ $b -gt 50 ] ; then
|
||||
color='green'
|
||||
elif [ $b -gt 20 ] ; then
|
||||
color='yellow'
|
||||
else
|
||||
color='red'
|
||||
fi
|
||||
echo "%{$fg[$color]%}$(battery_pct_remaining)%%%{$reset_color%}"
|
||||
else
|
||||
echo "∞"
|
||||
fi
|
||||
}
|
||||
|
||||
elif [[ "$OSTYPE" = linux* ]] ; then
|
||||
|
||||
function battery_is_charging() {
|
||||
|
@ -17,3 +17,5 @@ plugins=(... brew)
|
||||
| bubo | `brew update && brew outdated` | Fetch the newest version of Homebrew and all formulae, then list outdated formulae. |
|
||||
| bubc | `brew upgrade && brew cleanup` | Upgrade outdated, unpinned brews (with existing install options), then removes stale lock files and outdated downloads for formulae and casks, and removes old versions of installed formulae. |
|
||||
| bubu | `bubo && bubc` | Updates Homebrew, lists outdated formulae, upgrades oudated and unpinned formulae, and removes stale and outdated downloads and versions. |
|
||||
| bcubo | `brew update && brew cask outdated` | Fetch the newest version of Homebrew and all formulae, then list outdated casks. |
|
||||
| bcubc | `brew cask reinstall $(brew cask outdated) && brew cleanup` | Updates outdated casks, then runs cleanup. |
|
@ -4,6 +4,8 @@ alias brewsp='brew list --pinned'
|
||||
alias bubo='brew update && brew outdated'
|
||||
alias bubc='brew upgrade && brew cleanup'
|
||||
alias bubu='bubo && bubc'
|
||||
alias bcubo='brew update && brew cask outdated'
|
||||
alias bcubc='brew cask reinstall $(brew cask outdated) && brew cleanup'
|
||||
|
||||
if command mkdir "$ZSH_CACHE_DIR/.brew-completion-message" 2>/dev/null; then
|
||||
print -P '%F{yellow}'Oh My Zsh brew plugin:
|
||||
|
@ -15,7 +15,7 @@
|
||||
- calls `bundle exec <gem executable>` otherwise
|
||||
|
||||
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
|
||||
|
||||
|
@ -27,6 +27,7 @@ bundled_commands=(
|
||||
rainbows
|
||||
rake
|
||||
rspec
|
||||
rubocop
|
||||
shotgun
|
||||
sidekiq
|
||||
spec
|
||||
@ -81,7 +82,7 @@ _bundler-installed() {
|
||||
_within-bundled-project() {
|
||||
local check_dir="$PWD"
|
||||
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)"
|
||||
done
|
||||
false
|
||||
@ -94,7 +95,7 @@ _binstubbed() {
|
||||
_run-with-bundler() {
|
||||
if _bundler-installed && _within-bundled-project; then
|
||||
if _binstubbed $1; then
|
||||
./bin/$@
|
||||
./bin/${^^@}
|
||||
else
|
||||
bundle exec $@
|
||||
fi
|
||||
|
@ -1,9 +0,0 @@
|
||||
# Bwana
|
||||
|
||||
This plugin provides a function to open `man` pages directly with [Bwana](https://www.bruji.com/bwana/).
|
||||
|
||||
To use it add bwana to the plugins array in your zshrc file.
|
||||
|
||||
```bash
|
||||
plugins=(... bwana)
|
||||
```
|
@ -1,13 +0,0 @@
|
||||
#
|
||||
# Requires https://www.bruji.com/bwana/
|
||||
#
|
||||
if [[ -e /Applications/Bwana.app ]] ||
|
||||
( system_profiler -detailLevel mini SPApplicationsDataType | grep -q Bwana )
|
||||
then
|
||||
function man() {
|
||||
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
|
@ -1,6 +1,6 @@
|
||||
# cargo
|
||||
|
||||
This plugin adds completion for the Rust build tool [`cargo`](https://github.com/rust-lang/cargo).
|
||||
This plugin adds completion for the Rust build tool [`Cargo`](https://github.com/rust-lang/cargo).
|
||||
|
||||
To use it, add `cargo` to the plugins array in your zshrc file:
|
||||
|
||||
@ -8,4 +8,4 @@ To use it, add `cargo` to the plugins array in your zshrc file:
|
||||
plugins=(... cargo)
|
||||
```
|
||||
|
||||
Updated on October 4th, 2016.
|
||||
Updated on March 3rd, 2019, from [Cargo 0.34.0](https://github.com/rust-lang/cargo/releases/tag/0.34.0).
|
||||
|
@ -1,445 +1,368 @@
|
||||
#compdef cargo
|
||||
|
||||
typeset -A opt_args
|
||||
autoload -U regexp-replace
|
||||
|
||||
_cargo() {
|
||||
local curcontext="$curcontext" ret=1
|
||||
local -a command_scope_spec common parallel features msgfmt triple target registry
|
||||
local -a state line state_descr # These are set by _arguments
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments \
|
||||
'(- 1 *)'{-h,--help}'[show help message]' \
|
||||
common=(
|
||||
'(-q --quiet)*'{-v,--verbose}'[use verbose output]'
|
||||
'(-q --quiet -v --verbose)'{-q,--quiet}'[no output printed to stdout]'
|
||||
'-Z+[pass unstable (nightly-only) flags to cargo]: :_cargo_unstable_flags'
|
||||
'--frozen[require that Cargo.lock and cache are up-to-date]'
|
||||
'--locked[require that Cargo.lock is up-to-date]'
|
||||
'--color=[specify colorization option]:coloring:(auto always never)'
|
||||
'(- 1 *)'{-h,--help}'[show help message]'
|
||||
)
|
||||
|
||||
# leading items in parentheses are an exclusion list for the arguments following that arg
|
||||
# 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 *)--explain=[provide a detailed explanation of an error message]:error code' \
|
||||
'(- 1 *)'{-V,--version}'[show version information]' \
|
||||
'(- 1 *)'--list'[list installed commands]' \
|
||||
'(- 1 *)'--explain'[Run `rustc --explain CODE`]' \
|
||||
'(- 1 *)'{-v,--verbose}'[use verbose output]' \
|
||||
'(- 1 *)'--color'[colorization option]' \
|
||||
'(- 1 *)'--frozen'[Require Cargo.lock and cache are up to date]' \
|
||||
'(- 1 *)'--locked'[Require Cargo.lock is up to date]' \
|
||||
'(+beta +nightly)+stable[use the stable toolchain]' \
|
||||
'(+stable +nightly)+beta[use the beta toolchain]' \
|
||||
'(+stable +beta)+nightly[use the nightly toolchain]' \
|
||||
'1: :_cargo_cmds' \
|
||||
'*:: :->args'
|
||||
|
||||
case $state in
|
||||
# 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.
|
||||
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)
|
||||
case $words[1] in
|
||||
curcontext="${curcontext%:*}-${words[1]}:"
|
||||
case ${words[1]} in
|
||||
bench)
|
||||
_arguments \
|
||||
'--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]' \
|
||||
_arguments -s -A "^--" $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
"${command_scope_spec[@]}" \
|
||||
'--manifest-path=[path to manifest]: :_files -/' \
|
||||
'--no-default-features[do not build the default features]' \
|
||||
'--no-run[compile but do not run]' \
|
||||
'(-p,--package)'{-p=,--package=}'[package to run benchmarks for]:packages:_get_package_names' \
|
||||
'--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)' \
|
||||
'--all-targets[benchmark all targets]' \
|
||||
"--no-run[compile but don't run]" \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to run benchmarks for]:package:_cargo_package_names' \
|
||||
'--exclude=[exclude packages from the benchmark]:spec' \
|
||||
'--no-fail-fast[run all benchmarks regardless of failure]' \
|
||||
'1: :_guard "^-*" "bench name"' \
|
||||
'*:args:_default'
|
||||
;;
|
||||
|
||||
build)
|
||||
_arguments \
|
||||
'--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]' \
|
||||
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
'--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \
|
||||
"${command_scope_spec[@]}" \
|
||||
'--manifest-path=[path to manifest]: :_files -/' \
|
||||
'--no-default-features[do not build the default features]' \
|
||||
'(-p,--package)'{-p=,--package=}'[package to build]:packages:_get_package_names' \
|
||||
'--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)' \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to build]:package:_cargo_package_names' \
|
||||
'--release[build in release mode]' \
|
||||
'--build-plan[output the build plan in JSON]' \
|
||||
;;
|
||||
|
||||
check)
|
||||
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
'--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \
|
||||
"${command_scope_spec[@]}" \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to check]:package:_cargo_package_names' \
|
||||
'--release[check in release mode]' \
|
||||
;;
|
||||
|
||||
clean)
|
||||
_arguments \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'--manifest-path=[path to manifest]: :_files -/' \
|
||||
'(-p,--package)'{-p=,--package=}'[package to clean]:packages:_get_package_names' \
|
||||
'(-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)' \
|
||||
_arguments -s -S $common $triple $target $manifest \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to clean]:package:_cargo_package_names' \
|
||||
'--release[clean release artifacts]' \
|
||||
'--doc[clean just the documentation directory]'
|
||||
;;
|
||||
|
||||
doc)
|
||||
_arguments \
|
||||
'--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 -/' \
|
||||
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
'--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]' \
|
||||
'(-p, --package)'{-p,--package}'=[package to document]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to document]:package:_cargo_package_names' \
|
||||
'--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)
|
||||
_arguments \
|
||||
'(-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)' \
|
||||
_arguments -s -S $common $triple $manifest
|
||||
;;
|
||||
|
||||
fix)
|
||||
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
"${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)
|
||||
_arguments \
|
||||
'(-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)' \
|
||||
_arguments -s -S $common $manifest
|
||||
;;
|
||||
|
||||
git-checkout)
|
||||
_arguments \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'q(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'--reference=[REF]' \
|
||||
'--url=[URL]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
_arguments -s -S $common \
|
||||
'--reference=:reference' \
|
||||
'--url=:url:_urls'
|
||||
;;
|
||||
|
||||
help)
|
||||
_arguments \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'*: :_cargo_cmds' \
|
||||
_cargo_cmds
|
||||
;;
|
||||
|
||||
init)
|
||||
_arguments \
|
||||
'--bin[use binary template]' \
|
||||
'--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]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
_arguments -s -S $common $registry \
|
||||
'--lib[use library template]' \
|
||||
'--edition=[specify edition to set for the crate generated]:edition:(2015 2018)' \
|
||||
'--vcs=[initialize a new repo with a given VCS]:vcs:(git hg pijul fossil none)' \
|
||||
'--name=[set the resulting package name]:name' \
|
||||
'1:path:_directories'
|
||||
;;
|
||||
|
||||
install)
|
||||
_arguments \
|
||||
'--bin=[only install the specified binary]' \
|
||||
'--branch=[branch to use when installing from git]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
_arguments -s -S $common $parallel $features $triple $registry \
|
||||
'(-f --force)'{-f,--force}'[force overwriting of existing crates or binaries]' \
|
||||
'--bin=[only install the specified binary]:binary' \
|
||||
'--branch=[branch to use when installing from git]:branch' \
|
||||
'--debug[build in debug mode instead of release mode]' \
|
||||
'--example[install the specified example instead of binaries]' \
|
||||
'--features=[space separated feature list]' \
|
||||
'--all-features[enable all available features]' \
|
||||
'--git=[URL from which to install the crate]' \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
|
||||
'--no-default-features[do not build the default features]' \
|
||||
'--path=[local filesystem path to crate to install]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'--rev=[specific commit to use when installing from git]' \
|
||||
'--root=[directory to install packages into]' \
|
||||
'--tag=[tag to use when installing from git]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--vers=[version to install from crates.io]' \
|
||||
'--example=[install the specified example instead of binaries]:example' \
|
||||
'--git=[specify URL from which to install the crate]:url:_urls' \
|
||||
'--path=[local filesystem path to crate to install]: :_directories' \
|
||||
'--rev=[specific commit to use when installing from git]:commit' \
|
||||
'--root=[directory to install packages into]: :_directories' \
|
||||
'--tag=[tag to use when installing from git]:tag' \
|
||||
'--vers=[version to install from crates.io]:version' \
|
||||
'--list[list all installed packages and their versions]' \
|
||||
'*: :_guard "^-*" "crate"'
|
||||
;;
|
||||
|
||||
locate-project)
|
||||
_arguments \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'--manifest-path=[path to manifest]: :_files -/' \
|
||||
_arguments -s -S $common $manifest
|
||||
;;
|
||||
|
||||
login)
|
||||
_arguments \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'--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)' \
|
||||
_arguments -s -S $common $registry \
|
||||
'*: :_guard "^-*" "token"'
|
||||
;;
|
||||
|
||||
metadata)
|
||||
_arguments \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
_arguments -s -S $common $features $manifest \
|
||||
"--no-deps[output information only about the root package and don't fetch dependencies]" \
|
||||
'--no-default-features[do not include the default feature]' \
|
||||
'--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)' \
|
||||
'--format-version=[specify format version]:version [1]:(1)'
|
||||
;;
|
||||
|
||||
new)
|
||||
_arguments \
|
||||
'--bin[use binary template]' \
|
||||
_arguments -s -S $common $registry \
|
||||
'--lib[use library template]' \
|
||||
'--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]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
'--name=[set the resulting package name]'
|
||||
;;
|
||||
|
||||
owner)
|
||||
_arguments \
|
||||
'(-a, --add)'{-a,--add}'[add owner LOGIN]' \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'--index[registry index]' \
|
||||
'(-l, --list)'{-l,--list}'[list owners of a crate]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'(-r, --remove)'{-r,--remove}'[remove owner LOGIN]' \
|
||||
'--token[API token to use when authenticating]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
_arguments -s -S $common $registry \
|
||||
'(-a --add)'{-a,--add}'[specify name of a user or team to invite as an owner]:name' \
|
||||
'--index=[specify registry index]:index' \
|
||||
'(-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' \
|
||||
'--token=[specify API token to use when authenticating]:token' \
|
||||
'*: :_guard "^-*" "crate"'
|
||||
;;
|
||||
|
||||
package)
|
||||
_arguments \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'(-l, --list)'{-l,--list}'[print files included in a package without making one]' \
|
||||
'--manifest-path=[path to manifest]: :_files -/' \
|
||||
_arguments -s -S $common $parallel $features $triple $target $manifest \
|
||||
'(-l --list)'{-l,--list}'[print files included in a package without making one]' \
|
||||
'--no-metadata[ignore warnings about a lack of human-usable metadata]' \
|
||||
'--no-verify[do not build to verify contents]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
'--allow-dirty[allow dirty working directories to be packaged]' \
|
||||
"--no-verify[don't build to verify contents]"
|
||||
;;
|
||||
|
||||
pkgid)
|
||||
_arguments \
|
||||
'(-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)' \
|
||||
_arguments -s -S $common $manifest \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to get ID specifier for]:package:_cargo_package_names' \
|
||||
'*: :_guard "^-*" "spec"'
|
||||
;;
|
||||
|
||||
publish)
|
||||
_arguments \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'--host=[Host to set the token for]' \
|
||||
'--manifest-path=[path to manifest]: :_files -/' \
|
||||
'--no-verify[Do not verify tarball until before publish]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'--token[token to use when uploading]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
_arguments -s -S $common $parallel $features $triple $target $manifest $registry \
|
||||
'--index=[specify registry index]:index' \
|
||||
'--allow-dirty[allow dirty working directories to be packaged]' \
|
||||
"--no-verify[don't verify the contents by building them]" \
|
||||
'--token=[specify token to use when uploading]:token' \
|
||||
'--dry-run[perform all checks without uploading]'
|
||||
;;
|
||||
|
||||
read-manifest)
|
||||
_arguments \
|
||||
'(-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)' \
|
||||
_arguments -s -S $common $manifest
|
||||
;;
|
||||
|
||||
run)
|
||||
_arguments \
|
||||
'--example=[name of the bin target]' \
|
||||
'--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 -/' \
|
||||
'--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' \
|
||||
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
'--example=[name of the bin target]:name' \
|
||||
'--bin=[name of the bin target]:name' \
|
||||
'(-p --package)'{-p+,--package=}'[specify package with the target to run]:package:_cargo_package_names' \
|
||||
'--release[build in release mode]' \
|
||||
'*: :_default'
|
||||
;;
|
||||
|
||||
rustc)
|
||||
_arguments \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
'--features=[features to compile for the package]' \
|
||||
'--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]' \
|
||||
'--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]' \
|
||||
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to build]:package:_cargo_package_names' \
|
||||
'--profile=[specify profile to build the selected target for]:profile' \
|
||||
'--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[@]}" \
|
||||
'*: : _dispatch rustc rustc -default-'
|
||||
;;
|
||||
|
||||
rustdoc)
|
||||
_arguments \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
'--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]' \
|
||||
'--no-default-features[do not build the `default` feature]' \
|
||||
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
'--document-private-items[include non-public items in the documentation]' \
|
||||
'--open[open the docs in a browser after the operation]' \
|
||||
'(-p, --package)'{-p,--package}'=[package to document]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to document]:package:_cargo_package_names' \
|
||||
'--release[build artifacts in release mode, with optimizations]' \
|
||||
'--target=[build for the target triple]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
"${command_scope_spec[@]}" \
|
||||
'*: : _dispatch rustdoc rustdoc -default-'
|
||||
;;
|
||||
|
||||
search)
|
||||
_arguments \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'--host=[host of a registry to search in]' \
|
||||
'--limit=[limit the number of results]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
_arguments -s -S $common $registry \
|
||||
'--index=[specify registry index]:index' \
|
||||
'--limit=[limit the number of results]:results [10]' \
|
||||
'*: :_guard "^-*" "query"'
|
||||
;;
|
||||
|
||||
test)
|
||||
_arguments \
|
||||
'--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 -/' \
|
||||
'--test=[test name]: :_test_names' \
|
||||
'--no-default-features[do not build the default features]' \
|
||||
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||
'--test=[test name]: :_cargo_test_names' \
|
||||
'--no-fail-fast[run all tests regardless of failure]' \
|
||||
'--no-run[compile but do not run]' \
|
||||
'(-p,--package)'{-p=,--package=}'[package to run tests for]:packages:_get_package_names' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'(-p --package)'{-p+,--package=}'[package to run tests for]:package:_cargo_package_names' \
|
||||
'--all[test all packages in the workspace]' \
|
||||
'--release[build artifacts in release mode, with optimizations]' \
|
||||
'--target=[target triple]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
'1: :_test_names' \
|
||||
'1: :_cargo_test_names' \
|
||||
'(--doc --bin --example --test --bench)--lib[only test library]' \
|
||||
'(--lib --bin --example --test --bench)--doc[only test documentation]' \
|
||||
'(--lib --doc --example --test --bench)--bin=[binary name]' \
|
||||
'(--lib --doc --bin --test --bench)--example=[example name]' \
|
||||
'(--lib --doc --bin --example --bench)--test=[test name]' \
|
||||
'(--lib --doc --bin --example --test)--bench=[benchmark name]' \
|
||||
'*: :_default'
|
||||
;;
|
||||
|
||||
uninstall)
|
||||
_arguments \
|
||||
'--bin=[only uninstall the binary NAME]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[less output printed to stdout]' \
|
||||
'--root=[directory to uninstall packages from]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
_arguments -s -S $common \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to uninstall]:package:_cargo_package_names' \
|
||||
'--bin=[only uninstall the specified binary]:name' \
|
||||
'--root=[directory to uninstall packages from]: :_files -/' \
|
||||
'*:crate:_cargo_installed_crates -F line'
|
||||
;;
|
||||
|
||||
update)
|
||||
_arguments \
|
||||
_arguments -s -S $common $manifest \
|
||||
'--aggressive=[force dependency update]' \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'--manifest-path=[path to manifest]: :_files -/' \
|
||||
'(-p,--package)'{-p=,--package=}'[package to update]:packages:__get_package_names' \
|
||||
'--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)' \
|
||||
"--dry-run[don't actually write the lockfile]" \
|
||||
'(-p --package)'{-p+,--package=}'[specify package to update]:package:_cargo_package_names' \
|
||||
'--precise=[update single dependency to precise release]:release'
|
||||
;;
|
||||
|
||||
verify-project)
|
||||
_arguments \
|
||||
'(-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)' \
|
||||
_arguments -s -S $common $manifest
|
||||
;;
|
||||
|
||||
version)
|
||||
_arguments \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
_arguments -s -S $common
|
||||
;;
|
||||
|
||||
yank)
|
||||
_arguments \
|
||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
||||
'--index[registry index]' \
|
||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
||||
'--token[API token to use when authenticating]' \
|
||||
_arguments -s -S $common $registry \
|
||||
'--vers=[specify yank version]:version' \
|
||||
'--undo[undo a yank, putting a version back into the index]' \
|
||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
||||
'--color=:colorization option:(auto always never)' \
|
||||
'--vers[yank version]' \
|
||||
'--index=[specify registry index to yank from]:registry index' \
|
||||
'--token=[specify API token to use when authenticating]:token' \
|
||||
'*: :_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
|
||||
}
|
||||
|
||||
_cargo_cmds(){
|
||||
local -a commands;commands=(
|
||||
'bench:execute all benchmarks of a local package'
|
||||
'build:compile the current project'
|
||||
'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 project in current directory'
|
||||
'install:install a Rust binary'
|
||||
'locate-project:print "Cargo.toml" location'
|
||||
'login:login to remote server'
|
||||
'metadata:the metadata for a project in json'
|
||||
'new:create a new project'
|
||||
'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 'command' commands
|
||||
_cargo_unstable_flags() {
|
||||
local flags
|
||||
flags=( help ${${${(M)${(f)"$(_call_program flags cargo -Z help)"}:#*--*}/ #-- #/:}##*-Z } )
|
||||
_describe -t flags 'unstable flag' flags
|
||||
}
|
||||
|
||||
_cargo_installed_crates() {
|
||||
local expl
|
||||
_description crates expl 'crate'
|
||||
compadd "$@" "$expl[@]" - ${${${(f)"$(cargo install --list)"}:# *}%% *}
|
||||
}
|
||||
|
||||
_cargo_cmds() {
|
||||
local -a 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
|
||||
#gets package names from the manifest file
|
||||
_get_package_names()
|
||||
{
|
||||
}
|
||||
|
||||
#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
|
||||
_cargo_package_names() {
|
||||
_message -e packages package
|
||||
}
|
||||
|
||||
# Extracts the values of "name" from the array given in $1 and shows them as
|
||||
# command line options for completion
|
||||
_get_names_from_array()
|
||||
{
|
||||
local -a filelist;
|
||||
local manifest=$(_locate_manifest)
|
||||
_cargo_names_from_array() {
|
||||
# strip json from the path
|
||||
local manifest=${${${"$(cargo locate-project)"}%\"\}}##*\"}
|
||||
if [[ -z $manifest ]]; then
|
||||
return 0
|
||||
fi
|
||||
@ -449,52 +372,36 @@ _get_names_from_array()
|
||||
local in_block=false
|
||||
local block_name=$1
|
||||
names=()
|
||||
while read line
|
||||
do
|
||||
while read -r line; do
|
||||
if [[ $last_line == "[[$block_name]]" ]]; then
|
||||
in_block=true
|
||||
else
|
||||
if [[ $last_line =~ '.*\[\[.*' ]]; then
|
||||
if [[ $last_line =~ '\s*\[\[.*' ]]; then
|
||||
in_block=false
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $in_block == true ]]; then
|
||||
if [[ $line =~ '.*name.*=' ]]; then
|
||||
regexp-replace line '^.*name *= *|"' ""
|
||||
names+=$line
|
||||
if [[ $line =~ '\s*name\s*=' ]]; then
|
||||
regexp-replace line '^\s*name\s*=\s*|"' ''
|
||||
names+=( "$line" )
|
||||
fi
|
||||
fi
|
||||
|
||||
last_line=$line
|
||||
done < $manifest
|
||||
_describe $block_name names
|
||||
done < "$manifest"
|
||||
_describe "$block_name" names
|
||||
|
||||
}
|
||||
|
||||
#Gets the test names from the manifest file
|
||||
_test_names()
|
||||
{
|
||||
_get_names_from_array "test"
|
||||
_cargo_test_names() {
|
||||
_cargo_names_from_array "test"
|
||||
}
|
||||
|
||||
#Gets the bench names from the manifest file
|
||||
_benchmark_names()
|
||||
{
|
||||
_get_names_from_array "bench"
|
||||
_cargo_benchmark_names() {
|
||||
_cargo_names_from_array "bench"
|
||||
}
|
||||
|
||||
# These flags are mutally 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
|
||||
|
@ -4,7 +4,7 @@
|
||||
# #
|
||||
# Ouput the content of an image to the stdout using the 256 colors of the #
|
||||
# terminal. #
|
||||
# Github: https://github.com/posva/catimg #
|
||||
# GitHub: https://github.com/posva/catimg #
|
||||
################################################################################
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
# #
|
||||
# Ouput the content of an image to the stdout using the 256 colors of the #
|
||||
# terminal. #
|
||||
# Github: https://github.com/posva/catimg #
|
||||
# GitHub: https://github.com/posva/catimg #
|
||||
################################################################################
|
||||
|
||||
function help() {
|
||||
|
@ -1,2 +1,6 @@
|
||||
#!/bin/zsh
|
||||
alias cloudapp=$ZSH/plugins/cloudapp/cloudapp.rb
|
||||
alias cloudapp="${0:a:h}/cloudapp.rb"
|
||||
|
||||
# Ensure only the owner can access the credentials file
|
||||
if [[ -f ~/.cloudapp ]]; then
|
||||
chmod 600 ~/.cloudapp
|
||||
fi
|
||||
|
@ -16,7 +16,7 @@ EOF
|
||||
fi
|
||||
fi
|
||||
|
||||
function man() {
|
||||
function colored() {
|
||||
env \
|
||||
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
|
||||
LESS_TERMCAP_md=$(printf "\e[1;31m") \
|
||||
@ -28,5 +28,9 @@ function man() {
|
||||
PAGER="${commands[less]:-$PAGER}" \
|
||||
_NROFF_U=1 \
|
||||
PATH="$HOME/bin:$PATH" \
|
||||
man "$@"
|
||||
"$@"
|
||||
}
|
||||
|
||||
function man() {
|
||||
colored man "$@"
|
||||
}
|
||||
|
@ -2,16 +2,33 @@
|
||||
|
||||
With this plugin you can syntax-highlight file contents of over 300 supported languages and other text formats.
|
||||
|
||||
Colorize will highlight the content based on the filename extension. If it can't find a syntax-highlighting
|
||||
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.
|
||||
|
||||
To use it, add colorize to the plugins array of your zshrc file:
|
||||
```
|
||||
plugins=(... colorize)
|
||||
```
|
||||
|
||||
## 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 arguments are passed it will colorize the standard input or stdin.
|
||||
* `ccat <file> [files]`: colorize the contents of the file (or files, if more than one are provided).
|
||||
If no arguments are passed it will colorize the standard input or stdin.
|
||||
|
||||
Colorize will highlight the content based on the filename extension. If it can't find a syntax-highlighting 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.
|
||||
* `cless <file> [files]`: colorize the contents of the file (or files, if more than one are provided) and
|
||||
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.
|
||||
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
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
# easier alias to use the plugin
|
||||
alias ccat='colorize_via_pygmentize'
|
||||
alias cless='colorize_via_pygmentize_less'
|
||||
|
||||
colorize_via_pygmentize() {
|
||||
if ! (( $+commands[pygmentize] )); then
|
||||
@ -7,22 +8,50 @@ colorize_via_pygmentize() {
|
||||
return 1
|
||||
fi
|
||||
|
||||
# If the environment varianle ZSH_COLORIZE_STYLE
|
||||
# is set, use that theme instead. Otherwise,
|
||||
# use the default.
|
||||
if [ -z $ZSH_COLORIZE_STYLE ]; then
|
||||
ZSH_COLORIZE_STYLE="default"
|
||||
fi
|
||||
|
||||
# pygmentize stdin if no arguments passed
|
||||
if [ $# -eq 0 ]; then
|
||||
pygmentize -g
|
||||
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g
|
||||
return $?
|
||||
fi
|
||||
|
||||
# guess lexer from file extension, or
|
||||
# guess it from file contents if unsuccessful
|
||||
|
||||
local FNAME lexer
|
||||
for FNAME in $@
|
||||
for FNAME in "$@"
|
||||
do
|
||||
lexer=$(pygmentize -N "$FNAME")
|
||||
if [[ $lexer != text ]]; then
|
||||
pygmentize -l "$lexer" "$FNAME"
|
||||
pygmentize -O style="$ZSH_COLORIZE_STYLE" -l "$lexer" "$FNAME"
|
||||
else
|
||||
pygmentize -g "$FNAME"
|
||||
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g "$FNAME"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
colorize_via_pygmentize_less() (
|
||||
# this function is a subshell so tmp_files can be shared to cleanup function
|
||||
declare -a tmp_files
|
||||
|
||||
cleanup () {
|
||||
[[ ${#tmp_files} -gt 0 ]] && rm -f "${tmp_files[@]}"
|
||||
exit
|
||||
}
|
||||
trap 'cleanup' EXIT HUP TERM INT
|
||||
|
||||
while (( $# != 0 )); do #TODO: filter out less opts
|
||||
tmp_file="$(mktemp -t "tmp.colorize.XXXX.$(sed 's/\//./g' <<< "$1")")"
|
||||
tmp_files+=("$tmp_file")
|
||||
colorize_via_pygmentize "$1" > "$tmp_file"
|
||||
shift 1
|
||||
done
|
||||
|
||||
less -f "${tmp_files[@]}"
|
||||
)
|
||||
|
@ -27,5 +27,6 @@ It works out of the box with the command-not-found packages for:
|
||||
- [Arch Linux](https://wiki.archlinux.org/index.php/Pkgfile#Command_not_found)
|
||||
- [macOS (Homebrew)](https://github.com/Homebrew/homebrew-command-not-found)
|
||||
- [Fedora](https://fedoraproject.org/wiki/Features/PackageKitCommandNotFound)
|
||||
- [NixOS](https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/command-not-found)
|
||||
|
||||
You can add support for other platforms by submitting a Pull Request.
|
||||
|
@ -31,3 +31,10 @@ if type brew &> /dev/null; then
|
||||
eval "$(brew command-not-found-init)";
|
||||
fi
|
||||
fi
|
||||
|
||||
# NixOS command-not-found support
|
||||
if [ -x /run/current-system/sw/bin/command-not-found ]; then
|
||||
command_not_found_handler () {
|
||||
/run/current-system/sw/bin/command-not-found $@
|
||||
}
|
||||
fi
|
||||
|
@ -35,36 +35,30 @@ _dash() {
|
||||
if [[ "$locator" == "platform" ]]; then
|
||||
# Since these are the only special cases right now, let's not do the
|
||||
# expensive processing unless we have to
|
||||
if [[ "$keyword" == "python" || "$keyword" == "java" || \
|
||||
"$keyword" == "qt" || "$keyword" == "cocs2d" ]]; then
|
||||
if [[ "$keyword" = (python|java|qt|cocos2d) ]]; then
|
||||
docsetName=`echo $doc | grep -Eo "docsetName = .*?;" | sed -e "s/docsetName = \(.*\);/\1/" -e "s/[\":]//g"`
|
||||
if [[ "$keyword" == "python" ]]; then
|
||||
if [[ "$docsetName" == "Python 2" ]]; then
|
||||
keyword="python2"
|
||||
elif [[ "$docsetName" == "Python 3" ]]; then
|
||||
keyword="python3"
|
||||
fi
|
||||
elif [[ "$keyword" == "java" ]]; then
|
||||
if [[ "$docsetName" == "Java SE7" ]]; then
|
||||
keyword="java7"
|
||||
elif [[ "$docsetName" == "Java SE6" ]]; then
|
||||
keyword="java6"
|
||||
elif [[ "$docsetName" == "Java SE8" ]]; then
|
||||
keyword="java8"
|
||||
fi
|
||||
elif [[ "$keyword" == "qt" ]]; then
|
||||
if [[ "$docsetName" == "Qt 5" ]]; then
|
||||
keyword="qt5"
|
||||
elif [[ "$docsetName" == "Qt 4" ]]; then
|
||||
keyword="qt4"
|
||||
elif [[ "$docsetName" == "Qt" ]]; then
|
||||
keyword="qt4"
|
||||
fi
|
||||
elif [[ "$keyword" == "cocos2d" ]]; then
|
||||
if [[ "$docsetName" == "Cocos3D" ]]; then
|
||||
keyword="cocos3d"
|
||||
fi
|
||||
fi
|
||||
case "$keyword" in
|
||||
python)
|
||||
case "$docsetName" in
|
||||
"Python 2") keyword="python2" ;;
|
||||
"Python 3") keyword="python3" ;;
|
||||
esac ;;
|
||||
java)
|
||||
case "$docsetName" in
|
||||
"Java SE7") keyword="java7" ;;
|
||||
"Java SE6") keyword="java6" ;;
|
||||
"Java SE8") keyword="java8" ;;
|
||||
esac ;;
|
||||
qt)
|
||||
case "$docsetName" in
|
||||
"Qt 5") keyword="qt5" ;;
|
||||
"Qt 4"|Qt) keyword="qt4" ;;
|
||||
esac ;;
|
||||
cocos2d)
|
||||
case "$docsetName" in
|
||||
Cocos3D) keyword="cocos3d" ;;
|
||||
esac ;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -1,75 +1,85 @@
|
||||
# debian
|
||||
|
||||
This plugin provides debian related zsh aliases.
|
||||
This plugin provides Debian-related aliases and functions for zsh.
|
||||
|
||||
To use it add `debian` to the plugins array in your zshrc file.
|
||||
|
||||
```zsh
|
||||
plugins=(... debian)
|
||||
```
|
||||
|
||||
## Settings
|
||||
|
||||
- `$apt_pref`: use apt or aptitude if installed, fallback is apt-get.
|
||||
- `$apt_upgr`: use upgrade or safe-upgrade (for aptitude).
|
||||
|
||||
Set `$apt_pref` and `$apt_upgr` to whatever command you want (before sourcing Oh My Zsh) to override this behavior.
|
||||
|
||||
## Common Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
| -------- | ------------------------------------------------------------------------------|--------------------------------------------------------------------------- |
|
||||
| `age` | apt-get | Command line tool for handling packages |
|
||||
| `api` | aptitude | Same functionality as `apt-get`, provides extra options while installation |
|
||||
| `acs` | apt-cache search | Command line tool for searching apt software package cache |
|
||||
| `aps` | aptitude search | Searches installed packages using aptitude |
|
||||
| `as` | aptitude -F \"* %p -> %d \n(%v/%V)\" \ -no-gui --disable-columns search | - |
|
||||
| `afs` | apt-file search --regexp | Search file in packages |
|
||||
| `asrc` | apt-get source | Fetch source packages through `apt-get` |
|
||||
| `app` | apt-cache policy | Displays priority of package sources |
|
||||
| ------ | ---------------------------------------------------------------------- | ---------------------------------------------------------- |
|
||||
| `age` | `apt-get` | Command line tool for handling packages |
|
||||
| `api` | `aptitude` | Same functionality as `apt-get`, provides extra options |
|
||||
| `acs` | `apt-cache search` | Command line tool for searching apt software package cache |
|
||||
| `aps` | `aptitude search` | Searches installed packages using aptitude |
|
||||
| `as` | `aptitude -F '* %p -> %d \n(%v/%V)' --no-gui --disable-columns search` | Print searched packages using a custom format |
|
||||
| `afs` | `apt-file search --regexp` | Search file in packages |
|
||||
| `asrc` | `apt-get source` | Fetch source packages through `apt-get` |
|
||||
| `app` | `apt-cache policy` | Displays priority of package sources |
|
||||
|
||||
## Superuser Operations Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
| -------- | -------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------- |
|
||||
| `aac` | sudo $apt_pref autoclean | Clears out the local repository of retrieved package files |
|
||||
| `abd` | sudo $apt_pref build-dep | Installs all dependencies for building packages |
|
||||
| `ac` | sudo $apt_pref clean | Clears out the local repository of retrieved package files except lock files |
|
||||
| `ad` | sudo $apt_pref update | Updates the package lists for upgrades for packages |
|
||||
| `adg` | sudo $apt_pref update && sudo $apt_pref $apt_upgr | Update and upgrade packages |
|
||||
| `adu` | sudo $apt_pref update && sudo $apt_pref dist-upgrade | Smart upgrade that handles dependencies |
|
||||
| `afu` | sudo apt-file update | Update the files in packages |
|
||||
| `au` | sudo $apt_pref $apt_upgr | - |
|
||||
| `ai` | sudo $apt_pref install | Command-line tool to install package |
|
||||
| `ail` | sed -e 's/ */ /g' -e 's/ *//' | cut -s -d ' ' -f 1 | "' xargs sudo $apt_pref install | Install all packages given on the command line while using only the first word of each line |
|
||||
| `ap` | sudo $apt_pref purge | Removes packages along with configuration files |
|
||||
| `ar` | sudo $apt_pref remove | Removes packages, keeps the configuration files |
|
||||
| `ads` | sudo apt-get dselect-upgrade | Installs packages from list and removes all not in the list |
|
||||
| `dia` | sudo dpkg -i ./*.deb | Install all .deb files in the current directory |
|
||||
| `di` | sudo dpkg -i | Install all .deb files in the current directory |
|
||||
| `kclean` | sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) ?not(~n`uname -r`)) | Remove ALL kernel images and headers EXCEPT the one in use |
|
||||
|
||||
- `$apt_pref` - Use apt or aptitude if installed, fallback is apt-get.
|
||||
- `$apt_upgr` - Use upgrade.
|
||||
| -------- | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
|
||||
| `aac` | `sudo $apt_pref autoclean` | Clears out the local repository of retrieved package files |
|
||||
| `abd` | `sudo $apt_pref build-dep` | Installs all dependencies for building packages |
|
||||
| `ac` | `sudo $apt_pref clean` | Clears out the local repository of retrieved package files except lock files |
|
||||
| `ad` | `sudo $apt_pref update` | Updates the package lists for upgrades for packages |
|
||||
| `adg` | `sudo $apt_pref update && sudo $apt_pref $apt_upgr` | Update and upgrade packages |
|
||||
| `adu` | `sudo $apt_pref update && sudo $apt_pref dist-upgrade` | Smart upgrade that handles dependencies |
|
||||
| `afu` | `sudo apt-file update` | Update the files in packages |
|
||||
| `au` | `sudo $apt_pref $apt_upgr` | Install package upgrades |
|
||||
| `ai` | `sudo $apt_pref install` | Command-line tool to install package |
|
||||
| `ail` | `sed -e 's/ */ /g' -e 's/ *//' \| cut -s -d ' ' -f 1 \| xargs sudo $apt_pref install` | Install all packages given on the command line while using only the first word of each line |
|
||||
| `ap` | `sudo $apt_pref purge` | Removes packages along with configuration files |
|
||||
| `ar` | `sudo $apt_pref remove` | Removes packages, keeps the configuration files |
|
||||
| `ads` | `sudo apt-get dselect-upgrade` | Installs packages from list and removes all not in the list |
|
||||
| `dia` | `sudo dpkg -i ./*.deb` | Install all .deb files in the current directory |
|
||||
| `di` | `sudo dpkg -i` | Install all .deb files in the current directory |
|
||||
| `kclean` | `sudo aptitude remove -P ?and(~i~nlinux-(ima\|hea) ?not(~n$(uname -r)))` | Remove ALL kernel images and headers EXCEPT the one in use |
|
||||
|
||||
## Aliases - Commands using `su`
|
||||
|
||||
| Alias | Command |
|
||||
| -------- | ------------------------------------------------------------------------------|
|
||||
| `aac` | su -ls \'$apt_pref autoclean\' root |
|
||||
| `ac` | su -ls \'$apt_pref clean\' root |
|
||||
| `ad` | su -lc \'$apt_pref update\' root |
|
||||
| `adg` | su -lc \'$apt_pref update && aptitude $apt_upgr\' root |
|
||||
| `adu` | su -lc \'$apt_pref update && aptitude dist-upgrade\' root |
|
||||
| `afu` | su -lc "apt-file update |
|
||||
| `ag` | su -lc \'$apt_pref $apt_upgr\' root |
|
||||
| `dia` | su -lc "dpkg -i ./*.deb" root |
|
||||
| ----- | --------------------------------------------------------- |
|
||||
| `aac` | `su -ls "$apt_pref autoclean" root` |
|
||||
| `ac` | `su -ls "$apt_pref clean" root` |
|
||||
| `ad` | `su -lc "$apt_pref update" root` |
|
||||
| `adg` | `su -lc "$apt_pref update && aptitude $apt_upgr" root` |
|
||||
| `adu` | `su -lc "$apt_pref update && aptitude dist-upgrade" root` |
|
||||
| `afu` | `su -lc "apt-file update"` |
|
||||
| `au` | `su -lc "$apt_pref $apt_upgr" root` |
|
||||
| `dia` | `su -lc "dpkg -i ./*.deb" root` |
|
||||
|
||||
## Miscellaneous Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
| -------- | -------------------------------------------------|---------------------------------------- |
|
||||
| `allpkgs`| aptitude search -F "%p" --disable-columns ~i | Display all installed packages |
|
||||
| `mydeb` | time dpkg-buildpackage -rfakeroot -us -uc | Create a basic .deb package |
|
||||
| --------- | ---------------------------------------------- | ------------------------------ |
|
||||
| `allpkgs` | `aptitude search -F "%p" --disable-columns ~i` | Display all installed packages |
|
||||
| `mydeb` | `time dpkg-buildpackage -rfakeroot -us -uc` | Create a basic .deb package |
|
||||
|
||||
## Functions
|
||||
|
||||
| Fucntion | Description |
|
||||
|-----------------------|-------------------------------------------------------------------------------|
|
||||
| Function | Description |
|
||||
| ------------------- | --------------------------------------------------------------- |
|
||||
| `apt-copy` | Create a simple script that can be used to 'duplicate' a system |
|
||||
| `apt-history` | Displays apt history for a command |
|
||||
| `kerndeb` | Builds kernel packages |
|
||||
| `apt-list-packages` | List packages by size |
|
||||
|
||||
## Authors
|
||||
|
||||
- [@AlexBio](https://github.com/AlexBio)
|
||||
- [@dbb](https://github.com/dbb)
|
||||
- [@Mappleconfusers](https://github.com/Mappleconfusers)
|
||||
|
@ -1,25 +1,21 @@
|
||||
# Authors:
|
||||
# https://github.com/AlexBio
|
||||
# https://github.com/dbb
|
||||
# https://github.com/Mappleconfusers
|
||||
#
|
||||
# Debian-related zsh aliases and functions for zsh
|
||||
|
||||
# Use apt or aptitude if installed, fallback is apt-get
|
||||
# You can just set apt_pref='apt-get' to override it.
|
||||
if [[ -e $( which -p apt 2>&1 ) ]]; then
|
||||
|
||||
if [[ -z $apt_pref || -z $apt_upgr ]]; then
|
||||
if [[ -e $commands[apt] ]]; then
|
||||
apt_pref='apt'
|
||||
apt_upgr='upgrade'
|
||||
elif [[ -e $( which -p aptitude 2>&1 ) ]]; then
|
||||
elif [[ -e $commands[aptitude] ]]; then
|
||||
apt_pref='aptitude'
|
||||
apt_upgr='safe-upgrade'
|
||||
else
|
||||
else
|
||||
apt_pref='apt-get'
|
||||
apt_upgr='upgrade'
|
||||
fi
|
||||
fi
|
||||
|
||||
# Use sudo by default if it's installed
|
||||
if [[ -e $( which -p sudo 2>&1 ) ]]; then
|
||||
if [[ -e $commands[sudo] ]]; then
|
||||
use_sudo=1
|
||||
fi
|
||||
|
||||
@ -32,8 +28,7 @@ alias api='aptitude'
|
||||
# Some self-explanatory aliases
|
||||
alias acs="apt-cache search"
|
||||
alias aps='aptitude search'
|
||||
alias as="aptitude -F \"* %p -> %d \n(%v/%V)\" \
|
||||
--no-gui --disable-columns search" # search package
|
||||
alias as="aptitude -F '* %p -> %d \n(%v/%V)' --no-gui --disable-columns search"
|
||||
|
||||
# apt-file
|
||||
alias afs='apt-file search --regexp'
|
||||
@ -46,60 +41,59 @@ alias app='apt-cache policy'
|
||||
# superuser operations ######################################################
|
||||
if [[ $use_sudo -eq 1 ]]; then
|
||||
# commands using sudo #######
|
||||
alias aac='sudo $apt_pref autoclean'
|
||||
alias abd='sudo $apt_pref build-dep'
|
||||
alias ac='sudo $apt_pref clean'
|
||||
alias ad='sudo $apt_pref update'
|
||||
alias adg='sudo $apt_pref update && sudo $apt_pref $apt_upgr'
|
||||
alias adu='sudo $apt_pref update && sudo $apt_pref dist-upgrade'
|
||||
alias afu='sudo apt-file update'
|
||||
alias au='sudo $apt_pref $apt_upgr'
|
||||
alias ai='sudo $apt_pref install'
|
||||
alias aac="sudo $apt_pref autoclean"
|
||||
alias abd="sudo $apt_pref build-dep"
|
||||
alias ac="sudo $apt_pref clean"
|
||||
alias ad="sudo $apt_pref update"
|
||||
alias adg="sudo $apt_pref update && sudo $apt_pref $apt_upgr"
|
||||
alias adu="sudo $apt_pref update && sudo $apt_pref dist-upgrade"
|
||||
alias afu="sudo apt-file update"
|
||||
alias au="sudo $apt_pref $apt_upgr"
|
||||
alias ai="sudo $apt_pref install"
|
||||
# Install all packages given on the command line while using only the first word of each line:
|
||||
# acs ... | ail
|
||||
alias ail="sed -e 's/ */ /g' -e 's/ *//' | cut -s -d ' ' -f 1 | "' xargs sudo $apt_pref install'
|
||||
alias ap='sudo $apt_pref purge'
|
||||
alias ar='sudo $apt_pref remove'
|
||||
alias ail="sed -e 's/ */ /g' -e 's/ *//' | cut -s -d ' ' -f 1 | xargs sudo $apt_pref install"
|
||||
alias ap="sudo $apt_pref purge"
|
||||
alias ar="sudo $apt_pref remove"
|
||||
|
||||
# apt-get only
|
||||
alias ads='sudo apt-get dselect-upgrade'
|
||||
alias ads="sudo apt-get dselect-upgrade"
|
||||
|
||||
# Install all .deb files in the current directory.
|
||||
# Warning: you will need to put the glob in single quotes if you use:
|
||||
# glob_subst
|
||||
alias dia='sudo dpkg -i ./*.deb'
|
||||
alias di='sudo dpkg -i'
|
||||
alias dia="sudo dpkg -i ./*.deb"
|
||||
alias di="sudo dpkg -i"
|
||||
|
||||
# Remove ALL kernel images and headers EXCEPT the one in use
|
||||
alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) \
|
||||
?not(~n`uname -r`))'
|
||||
alias kclean='sudo aptitude remove -P ?and(~i~nlinux-(ima|hea) ?not(~n$(uname -r)))'
|
||||
|
||||
|
||||
# commands using su #########
|
||||
else
|
||||
alias aac='su -ls \'$apt_pref autoclean\' root'
|
||||
abd() {
|
||||
alias aac="su -ls '$apt_pref autoclean' root"
|
||||
function abd() {
|
||||
cmd="su -lc '$apt_pref build-dep $@' root"
|
||||
print "$cmd"
|
||||
eval "$cmd"
|
||||
}
|
||||
alias ac='su -ls \'$apt_pref clean\' root'
|
||||
alias ad='su -lc \'$apt_pref update\' root'
|
||||
alias adg='su -lc \'$apt_pref update && aptitude $apt_upgr\' root'
|
||||
alias adu='su -lc \'$apt_pref update && aptitude dist-upgrade\' root'
|
||||
alias afu='su -lc "apt-file update"'
|
||||
alias ag='su -lc \'$apt_pref $apt_upgr\' root'
|
||||
ai() {
|
||||
alias ac="su -ls '$apt_pref clean' root"
|
||||
alias ad="su -lc '$apt_pref update' root"
|
||||
alias adg="su -lc '$apt_pref update && aptitude $apt_upgr' root"
|
||||
alias adu="su -lc '$apt_pref update && aptitude dist-upgrade' root"
|
||||
alias afu="su -lc '$apt-file update'"
|
||||
alias au="su -lc '$apt_pref $apt_upgr' root"
|
||||
function ai() {
|
||||
cmd="su -lc 'aptitude -P install $@' root"
|
||||
print "$cmd"
|
||||
eval "$cmd"
|
||||
}
|
||||
ap() {
|
||||
function ap() {
|
||||
cmd="su -lc '$apt_pref -P purge $@' root"
|
||||
print "$cmd"
|
||||
eval "$cmd"
|
||||
}
|
||||
ar() {
|
||||
function ar() {
|
||||
cmd="su -lc '$apt_pref -P remove $@' root"
|
||||
print "$cmd"
|
||||
eval "$cmd"
|
||||
@ -111,8 +105,7 @@ else
|
||||
alias di='su -lc "dpkg -i" root'
|
||||
|
||||
# Remove ALL kernel images and headers EXCEPT the one in use
|
||||
alias kclean='su -lc '\''aptitude remove -P ?and(~i~nlinux-(ima|hea) \
|
||||
?not(~n`uname -r`))'\'' root'
|
||||
alias kclean='su -lc "aptitude remove -P ?and(~i~nlinux-(ima|hea) ?not(~n$(uname -r)))" root'
|
||||
fi
|
||||
|
||||
# Completion ################################################################
|
||||
@ -121,7 +114,7 @@ fi
|
||||
# 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
|
||||
#
|
||||
apt_pref_compdef() {
|
||||
function apt_pref_compdef() {
|
||||
local f fb
|
||||
f="_apt_pref_${2}"
|
||||
|
||||
@ -141,7 +134,7 @@ apt_pref_compdef abd "build-dep"
|
||||
apt_pref_compdef ac "clean"
|
||||
apt_pref_compdef ad "update"
|
||||
apt_pref_compdef afu "update"
|
||||
apt_pref_compdef ag "$apt_upgr"
|
||||
apt_pref_compdef au "$apt_upgr"
|
||||
apt_pref_compdef ai "install"
|
||||
apt_pref_compdef ail "install"
|
||||
apt_pref_compdef ap "purge"
|
||||
@ -158,7 +151,7 @@ alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc'
|
||||
|
||||
# Functions #################################################################
|
||||
# create a simple script that can be used to 'duplicate' a system
|
||||
apt-copy() {
|
||||
function apt-copy() {
|
||||
print '#!/bin/sh'"\n" > apt-copy.sh
|
||||
|
||||
cmd='$apt_pref install'
|
||||
@ -180,7 +173,7 @@ apt-copy() {
|
||||
# apt-history rollback
|
||||
# apt-history list
|
||||
# Based On: https://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html
|
||||
apt-history () {
|
||||
function apt-history() {
|
||||
case "$1" in
|
||||
install)
|
||||
zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*)
|
||||
@ -209,11 +202,11 @@ apt-history () {
|
||||
}
|
||||
|
||||
# Kernel-package building shortcut
|
||||
kerndeb () {
|
||||
function kerndeb() {
|
||||
# temporarily unset MAKEFLAGS ( '-j3' will fail )
|
||||
MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' )
|
||||
print '$MAKEFLAGS set to '"'$MAKEFLAGS'"
|
||||
appendage='-custom' # this shows up in $ (uname -r )
|
||||
appendage='-custom' # this shows up in $(uname -r )
|
||||
revision=$(date +"%Y%m%d") # this shows up in the .deb file name
|
||||
|
||||
make-kpkg clean
|
||||
@ -223,10 +216,9 @@ kerndeb () {
|
||||
}
|
||||
|
||||
# List packages by size
|
||||
function apt-list-packages {
|
||||
function apt-list-packages() {
|
||||
dpkg-query -W --showformat='${Installed-Size} ${Package} ${Status}\n' | \
|
||||
grep -v deinstall | \
|
||||
sort -n | \
|
||||
awk '{print $1" "$2}'
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ _managepy-makemessages(){
|
||||
"--no-default-ignore[Don't ignore the common glob-style patterns 'CVS', '.*', '*~' and '*.pyc'.]" \
|
||||
"--no-wrap[Don't break long message lines into several lines.]" \
|
||||
"--no-location[Don't write '#: filename:line' lines.]" \
|
||||
'--no-obsolete[emove obsolete message strings.]' \
|
||||
'--no-obsolete[Remove obsolete message strings.]' \
|
||||
'--keep-pot[Keep .pot file after making messages.]' \
|
||||
$nul_args && ret=0
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ __docker-compose_all_services_in_compose_file() {
|
||||
local already_selected
|
||||
local -a services
|
||||
already_selected=$(echo $words | tr " " "|")
|
||||
__docker-compose_q config --services \
|
||||
__docker-compose_q ps --services "$@" \
|
||||
| grep -Ev "^(${already_selected})$"
|
||||
}
|
||||
|
||||
@ -31,125 +31,42 @@ __docker-compose_all_services_in_compose_file() {
|
||||
__docker-compose_services_all() {
|
||||
[[ $PREFIX = -* ]] && return 1
|
||||
integer ret=1
|
||||
services=$(__docker-compose_all_services_in_compose_file)
|
||||
services=$(__docker-compose_all_services_in_compose_file "$@")
|
||||
_alternative "args:services:($services)" && ret=0
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
# All services that have an entry with the given key in their docker-compose.yml section
|
||||
__docker-compose_services_with_key() {
|
||||
local already_selected
|
||||
local -a buildable
|
||||
already_selected=$(echo $words | tr " " "|")
|
||||
# flatten sections to one line, then filter lines containing the key and return section name.
|
||||
__docker-compose_q config \
|
||||
| sed -n -e '/^services:/,/^[^ ]/p' \
|
||||
| sed -n 's/^ //p' \
|
||||
| awk '/^[a-zA-Z0-9]/{printf "\n"};{printf $0;next;}' \
|
||||
| grep " \+$1:" \
|
||||
| cut -d: -f1 \
|
||||
| grep -Ev "^(${already_selected})$"
|
||||
}
|
||||
|
||||
# All services that are defined by a Dockerfile reference
|
||||
__docker-compose_services_from_build() {
|
||||
[[ $PREFIX = -* ]] && return 1
|
||||
integer ret=1
|
||||
buildable=$(__docker-compose_services_with_key build)
|
||||
_alternative "args:buildable services:($buildable)" && ret=0
|
||||
|
||||
return ret
|
||||
__docker-compose_services_all --filter source=build
|
||||
}
|
||||
|
||||
# All services that are defined by an image
|
||||
__docker-compose_services_from_image() {
|
||||
[[ $PREFIX = -* ]] && return 1
|
||||
integer ret=1
|
||||
pullable=$(__docker-compose_services_with_key image)
|
||||
_alternative "args:pullable services:($pullable)" && ret=0
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
__docker-compose_get_services() {
|
||||
[[ $PREFIX = -* ]] && return 1
|
||||
integer ret=1
|
||||
local kind
|
||||
declare -a running paused stopped lines args services
|
||||
|
||||
docker_status=$(docker ps > /dev/null 2>&1)
|
||||
if [ $? -ne 0 ]; then
|
||||
_message "Error! Docker is not running."
|
||||
return 1
|
||||
fi
|
||||
|
||||
kind=$1
|
||||
shift
|
||||
[[ $kind =~ (stopped|all) ]] && args=($args -a)
|
||||
|
||||
lines=(${(f)"$(_call_program commands docker $docker_options ps $args)"})
|
||||
services=(${(f)"$(_call_program commands docker-compose 2>/dev/null $compose_options ps -q)"})
|
||||
|
||||
# Parse header line to find columns
|
||||
local i=1 j=1 k header=${lines[1]}
|
||||
declare -A begin end
|
||||
while (( j < ${#header} - 1 )); do
|
||||
i=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 1 ))
|
||||
j=$(( i + ${${header[$i,-1]}[(i) ]} - 1 ))
|
||||
k=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 2 ))
|
||||
begin[${header[$i,$((j-1))]}]=$i
|
||||
end[${header[$i,$((j-1))]}]=$k
|
||||
done
|
||||
lines=(${lines[2,-1]})
|
||||
|
||||
# Container ID
|
||||
local line s name
|
||||
local -a names
|
||||
for line in $lines; do
|
||||
if [[ ${services[@]} == *"${line[${begin[CONTAINER ID]},${end[CONTAINER ID]}]%% ##}"* ]]; then
|
||||
names=(${(ps:,:)${${line[${begin[NAMES]},-1]}%% *}})
|
||||
for name in $names; do
|
||||
s="${${name%_*}#*_}:${(l:15:: :::)${${line[${begin[CREATED]},${end[CREATED]}]/ ago/}%% ##}}"
|
||||
s="$s, ${line[${begin[CONTAINER ID]},${end[CONTAINER ID]}]%% ##}"
|
||||
s="$s, ${${${line[${begin[IMAGE]},${end[IMAGE]}]}/:/\\:}%% ##}"
|
||||
if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = Exit* ]]; then
|
||||
stopped=($stopped $s)
|
||||
else
|
||||
if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = *\(Paused\)* ]]; then
|
||||
paused=($paused $s)
|
||||
fi
|
||||
running=($running $s)
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
[[ $kind =~ (running|all) ]] && _describe -t services-running "running services" running "$@" && ret=0
|
||||
[[ $kind =~ (paused|all) ]] && _describe -t services-paused "paused services" paused "$@" && ret=0
|
||||
[[ $kind =~ (stopped|all) ]] && _describe -t services-stopped "stopped services" stopped "$@" && ret=0
|
||||
|
||||
return ret
|
||||
__docker-compose_services_all --filter source=image
|
||||
}
|
||||
|
||||
__docker-compose_pausedservices() {
|
||||
[[ $PREFIX = -* ]] && return 1
|
||||
__docker-compose_get_services paused "$@"
|
||||
__docker-compose_services_all --filter status=paused
|
||||
}
|
||||
|
||||
__docker-compose_stoppedservices() {
|
||||
[[ $PREFIX = -* ]] && return 1
|
||||
__docker-compose_get_services stopped "$@"
|
||||
__docker-compose_services_all --filter status=stopped
|
||||
}
|
||||
|
||||
__docker-compose_runningservices() {
|
||||
[[ $PREFIX = -* ]] && return 1
|
||||
__docker-compose_get_services running "$@"
|
||||
__docker-compose_services_all --filter status=running
|
||||
}
|
||||
|
||||
__docker-compose_services() {
|
||||
[[ $PREFIX = -* ]] && return 1
|
||||
__docker-compose_get_services all "$@"
|
||||
__docker-compose_services_all
|
||||
}
|
||||
|
||||
__docker-compose_caching_policy() {
|
||||
@ -196,9 +113,12 @@ __docker-compose_subcommand() {
|
||||
$opts_help \
|
||||
"*--build-arg=[Set build-time variables for one service.]:<varname>=<value>: " \
|
||||
'--force-rm[Always remove intermediate containers.]' \
|
||||
'--memory[Memory limit for the build container.]' \
|
||||
'(--quiet -q)'{--quiet,-q}'[Curb build output]' \
|
||||
'(--memory -m)'{--memory,-m}'[Memory limit for the build container.]' \
|
||||
'--no-cache[Do not use cache when building the image.]' \
|
||||
'--pull[Always attempt to pull a newer version of the image.]' \
|
||||
'--compress[Compress the build context using gzip.]' \
|
||||
'--parallel[Build images in parallel.]' \
|
||||
'*:services:__docker-compose_services_from_build' && ret=0
|
||||
;;
|
||||
(bundle)
|
||||
@ -213,7 +133,8 @@ __docker-compose_subcommand() {
|
||||
'(--quiet -q)'{--quiet,-q}"[Only validate the configuration, don't print anything.]" \
|
||||
'--resolve-image-digests[Pin image tags to digests.]' \
|
||||
'--services[Print the service names, one per line.]' \
|
||||
'--volumes[Print the volume names, one per line.]' && ret=0
|
||||
'--volumes[Print the volume names, one per line.]' \
|
||||
'--hash[Print the service config hash, one per line. Set "service1,service2" for a list of specified services.]' \ && ret=0
|
||||
;;
|
||||
(create)
|
||||
_arguments \
|
||||
@ -222,11 +143,12 @@ __docker-compose_subcommand() {
|
||||
$opts_no_recreate \
|
||||
$opts_no_build \
|
||||
"(--no-build)--build[Build images before creating containers.]" \
|
||||
'*:services:__docker-compose_services_all' && ret=0
|
||||
'*:services:__docker-compose_services' && ret=0
|
||||
;;
|
||||
(down)
|
||||
_arguments \
|
||||
$opts_help \
|
||||
$opts_timeout \
|
||||
"--rmi[Remove images. Type must be one of: 'all': Remove all images used by any service. 'local': Remove only images that don't have a custom tag set by the \`image\` field.]:type:(all local)" \
|
||||
'(-v --volumes)'{-v,--volumes}"[Remove named volumes declared in the \`volumes\` section of the Compose file and anonymous volumes attached to containers.]" \
|
||||
$opts_remove_orphans && ret=0
|
||||
@ -235,7 +157,7 @@ __docker-compose_subcommand() {
|
||||
_arguments \
|
||||
$opts_help \
|
||||
'--json[Output events as a stream of json objects]' \
|
||||
'*:services:__docker-compose_services_all' && ret=0
|
||||
'*:services:__docker-compose_services' && ret=0
|
||||
;;
|
||||
(exec)
|
||||
_arguments \
|
||||
@ -245,6 +167,8 @@ __docker-compose_subcommand() {
|
||||
'(-u --user)'{-u,--user=}'[Run the command as this user.]:username:_users' \
|
||||
'-T[Disable pseudo-tty allocation. By default `docker-compose exec` allocates a TTY.]' \
|
||||
'--index=[Index of the container if there are multiple instances of a service \[default: 1\]]:index: ' \
|
||||
'*'{-e,--env}'[KEY=VAL Set an environment variable (can be used multiple times)]:environment variable KEY=VAL: ' \
|
||||
'(-w --workdir)'{-w,--workdir=}'[Working directory inside the container]:workdir: ' \
|
||||
'(-):running services:__docker-compose_runningservices' \
|
||||
'(-):command: _command_names -e' \
|
||||
'*::arguments: _normal' && ret=0
|
||||
@ -256,7 +180,7 @@ __docker-compose_subcommand() {
|
||||
_arguments \
|
||||
$opts_help \
|
||||
'-q[Only display IDs]' \
|
||||
'*:services:__docker-compose_services_all' && ret=0
|
||||
'*:services:__docker-compose_services' && ret=0
|
||||
;;
|
||||
(kill)
|
||||
_arguments \
|
||||
@ -271,7 +195,7 @@ __docker-compose_subcommand() {
|
||||
$opts_no_color \
|
||||
'--tail=[Number of lines to show from the end of the logs for each container.]:number of lines: ' \
|
||||
'(-t --timestamps)'{-t,--timestamps}'[Show timestamps]' \
|
||||
'*:services:__docker-compose_services_all' && ret=0
|
||||
'*:services:__docker-compose_services' && ret=0
|
||||
;;
|
||||
(pause)
|
||||
_arguments \
|
||||
@ -290,12 +214,16 @@ __docker-compose_subcommand() {
|
||||
_arguments \
|
||||
$opts_help \
|
||||
'-q[Only display IDs]' \
|
||||
'*:services:__docker-compose_services_all' && ret=0
|
||||
'--filter KEY=VAL[Filter services by a property]:<filtername>=<value>:' \
|
||||
'*:services:__docker-compose_services' && ret=0
|
||||
;;
|
||||
(pull)
|
||||
_arguments \
|
||||
$opts_help \
|
||||
'--ignore-pull-failures[Pull what it can and ignores images with pull failures.]' \
|
||||
'--no-parallel[Disable parallel pulling]' \
|
||||
'(-q --quiet)'{-q,--quiet}'[Pull without printing progress information]' \
|
||||
'--include-deps[Also pull services declared as dependencies]' \
|
||||
'*:services:__docker-compose_services_from_image' && ret=0
|
||||
;;
|
||||
(push)
|
||||
@ -317,6 +245,7 @@ __docker-compose_subcommand() {
|
||||
$opts_no_deps \
|
||||
'-d[Detached mode: Run container in the background, print new container name.]' \
|
||||
'*-e[KEY=VAL Set an environment variable (can be used multiple times)]:environment variable KEY=VAL: ' \
|
||||
'*'{-l,--label}'[KEY=VAL Add or override a label (can be used multiple times)]:label KEY=VAL: ' \
|
||||
'--entrypoint[Overwrite the entrypoint of the image.]:entry point: ' \
|
||||
'--name=[Assign a name to the container]:name: ' \
|
||||
'(-p --publish)'{-p,--publish=}"[Publish a container's port(s) to the host]" \
|
||||
@ -326,6 +255,7 @@ __docker-compose_subcommand() {
|
||||
'(-u --user)'{-u,--user=}'[Run as specified username or uid]:username or uid:_users' \
|
||||
'(-v --volume)*'{-v,--volume=}'[Bind mount a volume]:volume: ' \
|
||||
'(-w --workdir)'{-w,--workdir=}'[Working directory inside the container]:workdir: ' \
|
||||
"--use-aliases[Use the services network aliases in the network(s) the container connects to]" \
|
||||
'(-):services:__docker-compose_services' \
|
||||
'(-):command: _command_names -e' \
|
||||
'*::arguments: _normal' && ret=0
|
||||
@ -369,8 +299,10 @@ __docker-compose_subcommand() {
|
||||
"(--no-build)--build[Build images before starting containers.]" \
|
||||
"(-d)--abort-on-container-exit[Stops all containers if any container was stopped. Incompatible with -d.]" \
|
||||
'(-t --timeout)'{-t,--timeout}"[Use this timeout in seconds for container shutdown when attached or when containers are already running. (default: 10)]:seconds: " \
|
||||
'--scale[SERVICE=NUM Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present.]:service scale SERVICE=NUM: ' \
|
||||
'--exit-code-from=[Return the exit code of the selected service container. Implies --abort-on-container-exit]:service:__docker-compose_services' \
|
||||
$opts_remove_orphans \
|
||||
'*:services:__docker-compose_services_all' && ret=0
|
||||
'*:services:__docker-compose_services' && ret=0
|
||||
;;
|
||||
(version)
|
||||
_arguments \
|
||||
@ -409,8 +341,11 @@ _docker-compose() {
|
||||
'(- :)'{-h,--help}'[Get help]' \
|
||||
'*'{-f,--file}"[${file_description}]:file:_files -g '*.yml'" \
|
||||
'(-p --project-name)'{-p,--project-name}'[Specify an alternate project name (default: directory name)]:project name:' \
|
||||
'--verbose[Show more output]' \
|
||||
"--compatibility[If set, Compose will attempt to convert keys in v3 files to their non-Swarm equivalent]" \
|
||||
'(- :)'{-v,--version}'[Print version and exit]' \
|
||||
'--verbose[Show more output]' \
|
||||
'--log-level=[Set log level]:level:(DEBUG INFO WARNING ERROR CRITICAL)' \
|
||||
'--no-ansi[Do not print ANSI control characters]' \
|
||||
'(-H --host)'{-H,--host}'[Daemon socket to connect to]:host:' \
|
||||
'--tls[Use TLS; implied by --tlsverify]' \
|
||||
'--tlscacert=[Trust certs signed only by this CA]:ca path:' \
|
||||
@ -421,7 +356,7 @@ _docker-compose() {
|
||||
'(-): :->command' \
|
||||
'(-)*:: :->option-or-argument' && ret=0
|
||||
|
||||
local -a relevant_compose_flags relevant_docker_flags compose_options docker_options
|
||||
local -a relevant_compose_flags relevant_compose_repeatable_flags relevant_docker_flags compose_options docker_options
|
||||
|
||||
relevant_compose_flags=(
|
||||
"--file" "-f"
|
||||
@ -435,6 +370,10 @@ _docker-compose() {
|
||||
"--skip-hostname-check"
|
||||
)
|
||||
|
||||
relevant_compose_repeatable_flags=(
|
||||
"--file" "-f"
|
||||
)
|
||||
|
||||
relevant_docker_flags=(
|
||||
"--host" "-H"
|
||||
"--tls"
|
||||
@ -452,11 +391,20 @@ _docker-compose() {
|
||||
fi
|
||||
fi
|
||||
if [[ -n "${relevant_compose_flags[(r)$k]}" ]]; then
|
||||
if [[ -n "${relevant_compose_repeatable_flags[(r)$k]}" ]]; then
|
||||
values=("${(@s/:/)opt_args[$k]}")
|
||||
for value in $values
|
||||
do
|
||||
compose_options+=$k
|
||||
compose_options+=$value
|
||||
done
|
||||
else
|
||||
compose_options+=$k
|
||||
if [[ -n "$opt_args[$k]" ]]; then
|
||||
compose_options+=$opt_args[$k]
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
case $state in
|
||||
|
@ -1,5 +1,11 @@
|
||||
## Docker autocomplete plugin
|
||||
# Docker plugin
|
||||
|
||||
A copy of the completion script from the
|
||||
[docker/cli](https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker)
|
||||
git repo.
|
||||
This plugin adds auto-completion for [docker](https://www.docker.com/).
|
||||
|
||||
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,17 @@ PORT=3001
|
||||
```
|
||||
You can even mix both formats, although it's probably a bad idea.
|
||||
|
||||
### ZSH_DOTENV_FILE
|
||||
|
||||
You can also modify the name of the file to be loaded with the variable `ZSH_DOTENV_FILE`.
|
||||
If the variable isn't set, the plugin will default to use `.env`.
|
||||
For example, this will make the plugin look for files named `.dotenv` and load them:
|
||||
|
||||
```
|
||||
# in ~/.zshrc, before Oh My Zsh is sourced:
|
||||
ZSH_DOTENV_FILE=.dotenv
|
||||
```
|
||||
|
||||
## Version Control
|
||||
|
||||
**It's strongly recommended to add `.env` file to `.gitignore`**, because usually it contains sensitive information such as your credentials, secret keys, passwords etc. You don't want to commit this file, it's supposed to be local only.
|
||||
|
@ -1,13 +1,13 @@
|
||||
source_env() {
|
||||
if [[ -f .env ]]; then
|
||||
if [[ -f $ZSH_DOTENV_FILE ]]; then
|
||||
# test .env syntax
|
||||
zsh -fn .env || echo 'dotenv: error when sourcing `.env` file' >&2
|
||||
zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2
|
||||
|
||||
if [[ -o a ]]; then
|
||||
source .env
|
||||
source $ZSH_DOTENV_FILE
|
||||
else
|
||||
set -a
|
||||
source .env
|
||||
source $ZSH_DOTENV_FILE
|
||||
set +a
|
||||
fi
|
||||
fi
|
||||
@ -16,4 +16,8 @@ source_env() {
|
||||
autoload -U add-zsh-hook
|
||||
add-zsh-hook chpwd source_env
|
||||
|
||||
if [[ -z $ZSH_DOTENV_FILE ]]; then
|
||||
ZSH_DOTENV_FILE=.env
|
||||
fi
|
||||
|
||||
source_env
|
||||
|
@ -25,8 +25,14 @@ emotty_default_set=emoji
|
||||
function emotty() {
|
||||
# Use emotty set defined by user, fallback to default
|
||||
local emotty=${_emotty_sets[${emotty_set:-$emotty_default_set}]}
|
||||
# Parse $TTY number, normalizing it to an emotty set index
|
||||
(( tty = (${TTY##/dev/tty} % ${#${=emotty}}) + 1 ))
|
||||
|
||||
# Parse tty number via prompt expansion. %l equals:
|
||||
# - N if tty = /dev/ttyN
|
||||
# - pts/N if tty = /dev/pts/N
|
||||
local tty = ${${(%):-%l}##pts/}
|
||||
# Normalize it to an emotty set index
|
||||
(( tty = (tty % ${#${=emotty}}) + 1 ))
|
||||
|
||||
local character_name=${${=emotty}[tty]}
|
||||
echo "${emoji[${character_name}]}${emoji2[emoji_style]}"
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ plugins=(... extract)
|
||||
| `7z` | 7zip file |
|
||||
| `Z` | Z archive (LZW) |
|
||||
| `apk` | Android app file |
|
||||
| `aar` | Android library file |
|
||||
| `bz2` | Bzip2 file |
|
||||
| `deb` | Debian package |
|
||||
| `gz` | Gzip file |
|
||||
|
@ -3,5 +3,5 @@
|
||||
|
||||
_arguments \
|
||||
'(-r --remove)'{-r,--remove}'[Remove archive.]' \
|
||||
"*::archive file:_files -g '(#i)*.(7z|Z|apk|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|lzma|rar|sublime-package|tar|tar.bz2|tar.gz|tar.xz|tar.zma|tbz|tbz2|tgz|tlz|txz|war|whl|xpi|xz|zip)(-.)'" \
|
||||
&& return 0
|
||||
|
@ -46,7 +46,7 @@ extract() {
|
||||
(*.xz) unxz "$1" ;;
|
||||
(*.lzma) unlzma "$1" ;;
|
||||
(*.z) uncompress "$1" ;;
|
||||
(*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk|*.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" ;;
|
||||
(*.7z) 7za x "$1" ;;
|
||||
(*.deb)
|
||||
|
@ -4,10 +4,19 @@
|
||||
local curcontext=$curcontext state line
|
||||
declare -A opt_args
|
||||
|
||||
declare target_list
|
||||
target_list=(`fab --shortlist 2>/dev/null`)
|
||||
declare -a target_list
|
||||
target_list=("${(@f)$(fab -l 2>/dev/null | awk '{
|
||||
if (NF == 0 || NR == 1) return
|
||||
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
|
||||
}
|
||||
|
||||
@ -28,7 +37,7 @@ _arguments -w -S -C \
|
||||
'(-)--shortlist[print non-verbose list of possible commands and exit]: :->noargs' \
|
||||
'(--reject-unknown-hosts)--reject-unknown-hosts[reject unknown hosts]' \
|
||||
'(--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]' \
|
||||
'(-r --reject-unknown-hosts)'{-r,--reject-unknown-hosts}'[reject unknown hosts]' \
|
||||
'(-u+ --user=-)'{-u+,--user=-}'[username to use when connecting to remote hosts]: :' \
|
||||
@ -53,7 +62,7 @@ if [[ CURRENT -ge 1 ]]; then
|
||||
levels)
|
||||
_describe -t commands "output levels" output_levels;;
|
||||
*)
|
||||
_targets;;
|
||||
_fab_targets;;
|
||||
esac
|
||||
|
||||
return
|
||||
|
@ -1,10 +1,10 @@
|
||||
# Use Ctrl-Z to switch back to Vim
|
||||
|
||||
I frequently need to execute random command in my shell. To achieve it I pause
|
||||
I frequently need to execute random commands in my shell. To achieve it I pause
|
||||
Vim by pressing Ctrl-z, type command and press fg<Enter> to switch back to Vim.
|
||||
The fg part really hurt sme. I just wanted to hit Ctrl-z once again to get back
|
||||
The fg part really hurts me. I just wanted to hit Ctrl-z once again to get back
|
||||
to Vim. I could not find a solution, so I developed one on my own that
|
||||
works wonderfully with ZSH
|
||||
works wonderfully with ZSH.
|
||||
|
||||
Source: http://sheerun.net/2014/03/21/how-to-boost-your-vim-productivity/
|
||||
|
||||
|
@ -6,7 +6,7 @@ if [ $commands[fasd] ]; then # check if fasd is installed
|
||||
source "$fasd_cache"
|
||||
unset fasd_cache
|
||||
|
||||
alias v="f -e \"$EDITOR\""
|
||||
alias v='f -e "$EDITOR"'
|
||||
alias o='a -e xdg-open'
|
||||
alias j='zz'
|
||||
fi
|
||||
|
@ -1,9 +1,8 @@
|
||||
## Introduction ##
|
||||
## Introduction
|
||||
|
||||
> Searches for your frontend web development made easier
|
||||
|
||||
|
||||
## Installation ##
|
||||
## Installation
|
||||
|
||||
Open your `~/.zshrc` file and enable the `frontend-search` plugin:
|
||||
|
||||
@ -13,53 +12,63 @@ plugins=( ... frontend-search)
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Usage ##
|
||||
## Usage
|
||||
|
||||
You can use the frontend-search plugin in these two forms:
|
||||
|
||||
* `frontend <context> <term> [more terms if you want]`
|
||||
* `<context> <term> [more terms if you want]`
|
||||
- `frontend <context> <term> [more terms if you want]`
|
||||
- `<context> <term> [more terms if you want]`
|
||||
|
||||
For example, these two are equivalent:
|
||||
|
||||
```zsh
|
||||
$ frontend angularjs dependency injection
|
||||
$ angularjs dependency injection
|
||||
$ angular dependency injection
|
||||
# Will turn into ...
|
||||
$ frontend angular dependency injection
|
||||
```
|
||||
|
||||
Available search contexts are:
|
||||
|
||||
| context | URL |
|
||||
|---------------|--------------------------------------------------------------------------|
|
||||
| ------------- | --------------------------------------------------------------------------- |
|
||||
| angular | `https://angular.io/?search=` |
|
||||
| angularjs | `https://google.com/search?as_sitesearch=angularjs.org&as_q=` |
|
||||
| aurajs | `http://aurajs.com/api/#stq=` |
|
||||
| bem | `https://google.com/search?as_sitesearch=bem.info&as_q=` |
|
||||
| bootsnipp | `https://bootsnipp.com/search?q=` |
|
||||
| bundlephobia | `https://bundlephobia.com/result?p=` |
|
||||
| caniuse | `https://caniuse.com/#search=` |
|
||||
| codepen | `https://codepen.io/search?q=` |
|
||||
| compassdoc | `http://compass-style.org/search?q=` |
|
||||
| cssflow | `http://www.cssflow.com/search?q=` |
|
||||
| dartlang | `https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:` |
|
||||
| emberjs | `https://emberjs.com/api/#stp=1&stq=` |
|
||||
| emberjs | `https://www.google.com/search?as_sitesearch=emberjs.com/&as_q=` |
|
||||
| flowtype | `https://google.com/search?as_sitesearch=flow.org/en/docs/&as_q=` |
|
||||
| fontello | `http://fontello.com/#search=` |
|
||||
| html5please | `http://html5please.com/#` |
|
||||
| github | `https://github.com/search?q=` |
|
||||
| html5please | `https://html5please.com/#` |
|
||||
| jestjs | `https://www.google.com/search?as_sitesearch=jestjs.io&as_q=` |
|
||||
| jquery | `https://api.jquery.com/?s=` |
|
||||
| lodash | `https://devdocs.io/lodash/index#` |
|
||||
| mdn | `https://developer.mozilla.org/search?q=` |
|
||||
| nodejs | `https://www.google.com/search?as_sitesearch=nodejs.org/en/docs/&as_q=` |
|
||||
| npmjs | `https://www.npmjs.com/search?q=` |
|
||||
| qunit | `https://api.qunitjs.com/?s=` |
|
||||
| reactjs | `https://google.com/search?as_sitesearch=facebook.github.io/react&as_q=` |
|
||||
| smacss | `https://google.com/search?as_sitesearch=smacss.com&as_q=` |
|
||||
| stackoverflow | `https://stackoverflow.com/search?q=` |
|
||||
| typescript | `https://google.com/search?as_sitesearch=www.typescriptlang.org/docs&as_q=` |
|
||||
| unheap | `http://www.unheap.com/?s=` |
|
||||
| vuejs | `https://www.google.com/search?as_sitesearch=vuejs.org&as_q=` |
|
||||
|
||||
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
|
||||
|
||||
**Wilson Mendes (willmendesneto)**
|
||||
+ <https://plus.google.com/+WilsonMendes>
|
||||
+ <https://twitter.com/willmendesneto>
|
||||
+ <https://github.com/willmendesneto>
|
||||
|
||||
- <https://twitter.com/willmendesneto>
|
||||
- <https://github.com/willmendesneto>
|
||||
|
@ -17,27 +17,34 @@ function _frontend() {
|
||||
frontend_points=( "${(f)mapfile[$CONFIG]//$HOME/~}" )
|
||||
|
||||
commands=(
|
||||
'jquery: Search in jQuery website'
|
||||
'mdn: Search in MDN website'
|
||||
'compassdoc: Search in COMPASS website'
|
||||
'html5please: Search in HTML5 Please website'
|
||||
'caniuse: Search in Can I Use website'
|
||||
'aurajs: Search in AuraJs website'
|
||||
'dartlang: Search in Dart website'
|
||||
'lodash: Search in Lo-Dash website'
|
||||
'qunit: Search in Qunit website'
|
||||
'fontello: Search in fontello website'
|
||||
'bootsnipp: Search in bootsnipp website'
|
||||
'cssflow: Search in cssflow website'
|
||||
'codepen: Search in codepen website'
|
||||
'unheap: Search in unheap website'
|
||||
'angular: Search in Angular.io website'
|
||||
'angularjs: Search in docs.angularjs.org website'
|
||||
'bem: Search in BEM website'
|
||||
'smacss: Search in SMACSS website'
|
||||
'angularjs: Search in Angular website'
|
||||
'reactjs: Search in React website'
|
||||
'bootsnipp: Search in bootsnipp website'
|
||||
'bundlephobia: Search in Bundlephobia website'
|
||||
'caniuse: Search in Can I Use website'
|
||||
'codepen: Search in codepen website'
|
||||
'compassdoc: Search in COMPASS website'
|
||||
'cssflow: Search in cssflow website'
|
||||
'dartlang: Search in Dart website'
|
||||
'emberjs: Search in Ember website'
|
||||
'stackoverflow: Search in StackOverflow website'
|
||||
'flowtype: Search in Flowtype website'
|
||||
'fontello: Search in fontello website'
|
||||
'github: Search in GitHub website'
|
||||
'html5please: Search in HTML5 Please website'
|
||||
'jestjs: Search in Jest website'
|
||||
'jquery: Search in jQuery website'
|
||||
'lodash: Search in Lo-Dash website'
|
||||
'mdn: Search in MDN website'
|
||||
'nodejs: Search in NodeJS website'
|
||||
'npmjs: Search in NPMJS website'
|
||||
'qunit: Search in Qunit website'
|
||||
'reactjs: Search in React website'
|
||||
'smacss: Search in SMACSS website'
|
||||
'stackoverflow: Search in StackOverflow website'
|
||||
'typescript: Search in TypeScript website'
|
||||
'unheap: Search in unheap website'
|
||||
'vuejs: Search in VueJS website'
|
||||
)
|
||||
|
||||
_arguments -C \
|
||||
@ -66,9 +73,6 @@ function _frontend() {
|
||||
caniuse)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
aurajs)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
dartlang)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
@ -81,6 +85,9 @@ function _frontend() {
|
||||
fontello)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
github)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
bootsnipp)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
@ -114,6 +121,24 @@ function _frontend() {
|
||||
npmjs)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
bundlephobia)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
flowtype)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
typescript)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
vuejs)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
nodejs)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
jestjs)
|
||||
_describe -t points "Warp points" frontend_points && ret=0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
|
@ -1,24 +1,42 @@
|
||||
alias angular='frontend angular'
|
||||
alias angularjs='frontend angularjs'
|
||||
alias aurajs='frontend aurajs'
|
||||
alias bem='frontend bem'
|
||||
alias bootsnipp='frontend bootsnipp'
|
||||
alias bundlephobia='frontend bundlephobia'
|
||||
alias caniuse='frontend caniuse'
|
||||
alias codepen='frontend codepen'
|
||||
alias compassdoc='frontend compassdoc'
|
||||
alias cssflow='frontend cssflow'
|
||||
alias dartlang='frontend dartlang'
|
||||
alias emberjs='frontend emberjs'
|
||||
alias flowtype='frontend flowtype'
|
||||
alias fontello='frontend fontello'
|
||||
alias github='frontend github'
|
||||
alias html5please='frontend html5please'
|
||||
alias jestjs='frontend jestjs'
|
||||
alias jquery='frontend jquery'
|
||||
alias lodash='frontend lodash'
|
||||
alias mdn='frontend mdn'
|
||||
alias nodejs='frontend nodejs'
|
||||
alias npmjs='frontend npmjs'
|
||||
alias qunit='frontend qunit'
|
||||
alias reactjs='frontend reactjs'
|
||||
alias smacss='frontend smacss'
|
||||
alias stackoverflow='frontend stackoverflow'
|
||||
alias typescript='frontend typescript'
|
||||
alias unheap='frontend unheap'
|
||||
alias vuejs='frontend vuejs'
|
||||
|
||||
function _frontend_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() {
|
||||
emulate -L zsh
|
||||
@ -26,27 +44,34 @@ function frontend() {
|
||||
# define search context URLS
|
||||
typeset -A urls
|
||||
urls=(
|
||||
angularjs 'https://google.com/search?as_sitesearch=angularjs.org&as_q='
|
||||
aurajs 'http://aurajs.com/api/#stq='
|
||||
bem 'https://google.com/search?as_sitesearch=bem.info&as_q='
|
||||
angular 'https://angular.io/?search='
|
||||
angularjs $(_frontend_fallback 'angularjs.org')
|
||||
bem $(_frontend_fallback 'bem.info')
|
||||
bootsnipp 'https://bootsnipp.com/search?q='
|
||||
bundlephobia 'https://bundlephobia.com/result?p='
|
||||
caniuse 'https://caniuse.com/#search='
|
||||
codepen 'https://codepen.io/search?q='
|
||||
compassdoc 'http://compass-style.org/search?q='
|
||||
cssflow 'http://www.cssflow.com/search?q='
|
||||
dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:'
|
||||
emberjs 'https://emberjs.com/api/#stp=1&stq='
|
||||
emberjs $(_frontend_fallback 'emberjs.com/')
|
||||
flowtype $(_frontend_fallback 'flow.org/en/docs/')
|
||||
fontello 'http://fontello.com/#search='
|
||||
html5please 'http://html5please.com/#'
|
||||
github 'https://github.com/search?q='
|
||||
html5please 'https://html5please.com/#'
|
||||
jestjs $(_frontend_fallback 'jestjs.io')
|
||||
jquery 'https://api.jquery.com/?s='
|
||||
lodash 'https://devdocs.io/lodash/index#'
|
||||
mdn 'https://developer.mozilla.org/search?q='
|
||||
nodejs $(_frontend_fallback 'nodejs.org/en/docs/')
|
||||
npmjs 'https://www.npmjs.com/search?q='
|
||||
qunit 'https://api.qunitjs.com/?s='
|
||||
reactjs 'https://google.com/search?as_sitesearch=facebook.github.io/react&as_q='
|
||||
smacss 'https://google.com/search?as_sitesearch=smacss.com&as_q='
|
||||
reactjs $(_frontend_fallback 'reactjs.org/')
|
||||
smacss $(_frontend_fallback 'smacss.com')
|
||||
stackoverflow 'https://stackoverflow.com/search?q='
|
||||
typescript $(_frontend_fallback 'www.typescriptlang.org/docs')
|
||||
unheap 'http://www.unheap.com/?s='
|
||||
vuejs $(_frontend_fallback 'vuejs.org')
|
||||
)
|
||||
|
||||
# show help for command list
|
||||
@ -57,9 +82,9 @@ function frontend() {
|
||||
print -P "%Uterm%u and what follows is what will be searched for in the %Ucontext%u website,"
|
||||
print -P "and %Ucontext%u is one of the following:"
|
||||
print -P ""
|
||||
print -P " angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow,"
|
||||
print -P " dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs,"
|
||||
print -P " qunit, reactjs, smacss, stackoverflow, unheap"
|
||||
print -P " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow,"
|
||||
print -P " dartlang, emberjs, fontello, flowtype, github, html5please, jestjs, jquery, lodash,"
|
||||
print -P " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia"
|
||||
print -P ""
|
||||
print -P "For example: frontend npmjs mocha (or just: npmjs mocha)."
|
||||
print -P ""
|
||||
@ -73,17 +98,17 @@ function frontend() {
|
||||
echo ""
|
||||
echo "Valid contexts are:"
|
||||
echo ""
|
||||
echo " angularjs, aurajs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow, "
|
||||
echo " dartlang, emberjs, fontello, html5please, jquery, lodash, mdn, npmjs, "
|
||||
echo " qunit, reactjs, smacss, stackoverflow, unheap"
|
||||
echo " angular, angularjs, bem, bootsnipp, caniuse, codepen, compassdoc, cssflow,"
|
||||
echo " dartlang, emberjs, fontello, github, html5please, jest, jquery, lodash,"
|
||||
echo " mdn, npmjs, nodejs, qunit, reactjs, smacss, stackoverflow, unheap, vuejs, bundlephobia"
|
||||
echo ""
|
||||
return 1
|
||||
fi
|
||||
|
||||
# build search url:
|
||||
# join arguments passed with '+', then append to search context URL
|
||||
# join arguments passed with '%20', then append to search context URL
|
||||
# TODO substitute for proper urlencode method
|
||||
url="${urls[$1]}${(j:+:)@[2,-1]}"
|
||||
url="${urls[$1]}${(j:%20:)@[2,-1]}"
|
||||
|
||||
echo "Opening $url ..."
|
||||
|
||||
|
@ -1,6 +1,13 @@
|
||||
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=(
|
||||
"${HOME}/.fzf"
|
||||
"/usr/local/opt/fzf"
|
||||
@ -20,10 +27,9 @@ if [[ -z "${fzf_base}" ]]; then
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -n "${fzf_base}" ]]; then
|
||||
fi
|
||||
|
||||
if [[ -d "${fzf_base}" ]]; then
|
||||
# Fix fzf shell directory for Archlinux package
|
||||
if [[ ! -d "${fzf_base}/shell" ]] && [[ -f /etc/arch-release ]]; then
|
||||
fzf_shell="${fzf_base}"
|
||||
@ -31,27 +37,59 @@ if [[ -n "${fzf_base}" ]]; then
|
||||
fzf_shell="${fzf_base}/shell"
|
||||
fi
|
||||
|
||||
# Setup fzf
|
||||
# ---------
|
||||
# Setup fzf binary path
|
||||
if ! (( ${+commands[fzf]} )) && [[ ! "$PATH" == *$fzf_base/bin* ]]; then
|
||||
export PATH="$PATH:$fzf_base/bin"
|
||||
fi
|
||||
|
||||
# Auto-completion
|
||||
# ---------------
|
||||
if [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then
|
||||
[[ $- == *i* ]] && source "${fzf_shell}/completion.zsh" 2> /dev/null
|
||||
fi
|
||||
|
||||
# Key bindings
|
||||
# ------------
|
||||
if [[ ! "$DISABLE_FZF_KEY_BINDINGS" == "true" ]]; then
|
||||
source "${fzf_shell}/key-bindings.zsh"
|
||||
fi
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
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
|
||||
|
||||
local completions="/usr/share/zsh/vendor-completions/_fzf"
|
||||
local key_bindings="/usr/share/doc/fzf/examples/key-bindings.zsh"
|
||||
|
||||
# Auto-completion
|
||||
if [[ $- == *i* ]] && [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then
|
||||
source $completions 2> /dev/null
|
||||
fi
|
||||
|
||||
# Key bindings
|
||||
if [[ ! "$DISABLE_FZF_KEY_BINDINGS" == "true" ]]; then
|
||||
source $key_bindings
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function indicate_error() {
|
||||
print "[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.\n"\
|
||||
"Please add \`export FZF_BASE=/path/to/fzf/install/dir\` to your .zshrc" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
unset fzf_base fzf_shell dir fzfdirs
|
||||
# Check for debian package first, because it easy to short cut
|
||||
# Indicate to user that fzf installation not found if nothing worked
|
||||
setup_using_debian_package || setup_using_base_dir || indicate_error
|
||||
|
||||
unset -f setup_using_debian_package setup_using_base_dir indicate_error
|
||||
|
@ -5,7 +5,7 @@ function git-fetch-all {
|
||||
dir=`git rev-parse --git-dir` &&
|
||||
[[ ! -f $dir/NO_AUTO_FETCH ]] &&
|
||||
(( `date +%s` - `date -r $dir/FETCH_LOG +%s 2>/dev/null || echo 0` > $GIT_AUTO_FETCH_INTERVAL )) &&
|
||||
git fetch --all &>! $dir/FETCH_LOG &)
|
||||
git fetch --all 2>/dev/null &>! $dir/FETCH_LOG &)
|
||||
}
|
||||
|
||||
function git-auto-fetch {
|
||||
@ -18,10 +18,18 @@ function git-auto-fetch {
|
||||
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
|
||||
override-git-auto-fetch-zle-line-init
|
||||
}
|
||||
}
|
||||
else
|
||||
function zle-line-init () {
|
||||
git-fetch-all
|
||||
}
|
||||
fi
|
||||
|
||||
zle -N zle-line-init
|
||||
|
@ -454,9 +454,9 @@ zstyle ':completion:*:*:git:*' user-commands $existing_user_commands \
|
||||
extras:'awesome git utilities' \
|
||||
feature:'create/merge feature branch' \
|
||||
force-clone:'overwrite local repositories with clone' \
|
||||
fork:'fork a repo on github' \
|
||||
fork:'fork a repo on GitHub' \
|
||||
fresh-branch:'create fresh branches' \
|
||||
gh-pages:'create the github pages branch' \
|
||||
gh-pages:'create the GitHub pages branch' \
|
||||
graft:'merge and destroy a given branch' \
|
||||
guilt:'calculate change between two revisions' \
|
||||
ignore-io:'get sample gitignore file' \
|
||||
|
@ -75,8 +75,8 @@ __git-hf-release ()
|
||||
'finish:Finish a release branch.'
|
||||
'list:List all your release branches. (Alias to `git hf release`)'
|
||||
'cancel:Cancel release'
|
||||
'push:Push release to github'
|
||||
'pull:Pull release from github'
|
||||
'push:Push release to GitHub'
|
||||
'pull:Pull release from GitHub'
|
||||
'track:Track release'
|
||||
)
|
||||
_describe -t commands 'git hf release' subcommands
|
||||
@ -133,8 +133,8 @@ __git-hf-hotfix ()
|
||||
'list:List all your hotfix branches. (Alias to `git hf hotfix`)'
|
||||
'publish:Publish the hotfix branch.'
|
||||
'track:Track the hotfix branch.'
|
||||
'pull:Pull the hotfix from github.'
|
||||
'push:Push the hotfix to github.'
|
||||
'pull:Pull the hotfix from GitHub.'
|
||||
'push:Push the hotfix to GitHub.'
|
||||
'cancel:Cancel the hotfix.'
|
||||
)
|
||||
_describe -t commands 'git hf hotfix' subcommands
|
||||
@ -195,8 +195,8 @@ __git-hf-feature ()
|
||||
'diff:Diff'
|
||||
'rebase:Rebase feature branch against develop'
|
||||
'checkout:Checkout feature'
|
||||
'pull:Pull feature branch from github'
|
||||
'push:Push feature branch to github'
|
||||
'pull:Pull feature branch from GitHub'
|
||||
'push:Push feature branch to GitHub'
|
||||
'cancel:Cancel feature'
|
||||
)
|
||||
_describe -t commands 'git hf feature' subcommands
|
||||
|
@ -1,6 +1,3 @@
|
||||
# ZSH Git Prompt Plugin from:
|
||||
# https://github.com/olivierverdier/zsh-git-prompt
|
||||
|
||||
__GIT_PROMPT_DIR="${0:A:h}"
|
||||
|
||||
## Hook function definitions
|
||||
|
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
import shlex
|
||||
@ -30,7 +31,7 @@ def get_tagname_or_hash():
|
||||
|
||||
# `git status --porcelain --branch` can collect all information
|
||||
# branch, remote_branch, untracked, staged, changed, conflicts, ahead, behind
|
||||
po = Popen(['git', 'status', '--porcelain', '--branch'], stdout=PIPE, stderr=PIPE)
|
||||
po = Popen(['git', 'status', '--porcelain', '--branch'], env=dict(os.environ, LANG="C"), stdout=PIPE, stderr=PIPE)
|
||||
stdout, sterr = po.communicate()
|
||||
if po.returncode != 0:
|
||||
sys.exit(0) # Not a git repository
|
||||
|
@ -1,10 +1,216 @@
|
||||
## git
|
||||
# git plugin
|
||||
|
||||
**Maintainer:** [@ncanceill](https://github.com/ncanceill)
|
||||
The git plugin provides many [aliases](#aliases) and a few useful [functions](#functions).
|
||||
|
||||
This plugin adds many useful aliases and functions.
|
||||
To use it, add `git` to the plugins array in your zshrc file:
|
||||
|
||||
### Usage
|
||||
```zsh
|
||||
plugins=(... git)
|
||||
```
|
||||
|
||||
See the [wiki](https://github.com/robbyrussell/oh-my-zsh/wiki/Plugin:git) for a list of aliases and functions provided by the plugin.
|
||||
## Aliases
|
||||
|
||||
| Alias | Command |
|
||||
|:---------------------|:------------------------------------------------------------------------------------------------------------------------------|
|
||||
| g | git |
|
||||
| ga | git add |
|
||||
| gaa | git add --all |
|
||||
| gapa | git add --patch |
|
||||
| gau | git add --update |
|
||||
| gav | git add --verbose |
|
||||
| gap | git apply |
|
||||
| gb | git branch |
|
||||
| gba | git branch -a |
|
||||
| gbd | git branch -d |
|
||||
| gbda | git branch --no-color --merged \| command grep -vE "^(\+|\*\|\s*(master\|develop\|dev)\s*$)" \| command xargs -n 1 git branch -d |
|
||||
| gbD | git branch -D |
|
||||
| gbl | git blame -b -w |
|
||||
| gbnm | git branch --no-merged |
|
||||
| gbr | git branch --remote |
|
||||
| gbs | git bisect |
|
||||
| gbsb | git bisect bad |
|
||||
| gbsg | git bisect good |
|
||||
| gbsr | git bisect reset |
|
||||
| gbss | git bisect start |
|
||||
| gc | git commit -v |
|
||||
| gc! | git commit -v --amend |
|
||||
| gcn! | git commit -v --no-edit --amend |
|
||||
| gca | git commit -v -a |
|
||||
| gca! | git commit -v -a --amend |
|
||||
| gcan! | git commit -v -a --no-edit --amend |
|
||||
| gcans! | git commit -v -a -s --no-edit --amend |
|
||||
| gcam | git commit -a -m |
|
||||
| gcsm | git commit -s -m |
|
||||
| gcb | git checkout -b |
|
||||
| gcf | git config --list |
|
||||
| gcl | git clone --recurse-submodules |
|
||||
| gclean | git clean -id |
|
||||
| gpristine | git reset --hard && git clean -dfx |
|
||||
| gcm | git checkout master |
|
||||
| gcd | git checkout develop |
|
||||
| gcmsg | git commit -m |
|
||||
| gco | git checkout |
|
||||
| gcount | git shortlog -sn |
|
||||
| gcp | git cherry-pick |
|
||||
| gcpa | git cherry-pick --abort |
|
||||
| gcpc | git cherry-pick --continue |
|
||||
| gcs | git commit -S |
|
||||
| gd | git diff |
|
||||
| gdca | git diff --cached |
|
||||
| gdcw | git diff --cached --word-diff |
|
||||
| gdct | git describe --tags $(git rev-list --tags --max-count=1) |
|
||||
| gds | git diff --staged |
|
||||
| gdt | git diff-tree --no-commit-id --name-only -r |
|
||||
| gdv | git diff -w $@ \| view - |
|
||||
| gdw | git diff --word-diff |
|
||||
| gf | git fetch |
|
||||
| gfa | git fetch --all --prune |
|
||||
| gfg | git ls-files \| grep |
|
||||
| gfo | git fetch origin |
|
||||
| gg | git gui citool |
|
||||
| gga | git gui citool --amend |
|
||||
| ggf | git push --force origin $(current_branch) |
|
||||
| ggfl | git push --force-with-lease origin $(current_branch) |
|
||||
| ggl | git pull origin $(current_branch) |
|
||||
| ggp | git push origin $(current_branch) |
|
||||
| ggpnp | ggl && ggp |
|
||||
| ggpull | git pull origin "$(git_current_branch)" |
|
||||
| ggpur | ggu |
|
||||
| ggpush | git push origin "$(git_current_branch)" |
|
||||
| ggsup | git branch --set-upstream-to=origin/$(git_current_branch) |
|
||||
| ggu | git pull --rebase origin $(current_branch) |
|
||||
| gpsup | git push --set-upstream origin $(git_current_branch) |
|
||||
| ghh | git help |
|
||||
| gignore | git update-index --assume-unchanged |
|
||||
| gignored | git ls-files -v \| grep "^[[:lower:]]" |
|
||||
| git-svn-dcommit-push | git svn dcommit && git push github master:svntrunk |
|
||||
| gk | gitk --all --branches |
|
||||
| gke | gitk --all $(git log -g --pretty=%h) |
|
||||
| gl | git pull |
|
||||
| glg | git log --stat |
|
||||
| glgp | git log --stat -p |
|
||||
| glgg | git log --graph |
|
||||
| glgga | git log --graph --decorate --all |
|
||||
| glgm | git log --graph --max-count=10 |
|
||||
| glo | git log --oneline --decorate |
|
||||
| glol | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' |
|
||||
| glols | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --stat |
|
||||
| glod | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' |
|
||||
| glods | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short |
|
||||
| glola | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all |
|
||||
| glog | git log --oneline --decorate --graph |
|
||||
| gloga | git log --oneline --decorate --graph --all |
|
||||
| glp | `_git_log_prettily` |
|
||||
| gm | git merge |
|
||||
| gmom | git merge origin/master |
|
||||
| gmt | git mergetool --no-prompt |
|
||||
| gmtvim | git mergetool --no-prompt --tool=vimdiff |
|
||||
| gmum | git merge upstream/master |
|
||||
| gma | git merge --abort |
|
||||
| gp | git push |
|
||||
| gpd | git push --dry-run |
|
||||
| gpf | git push --force-with-lease |
|
||||
| gpf! | git push --force |
|
||||
| gpoat | git push origin --all && git push origin --tags |
|
||||
| gpu | git push upstream |
|
||||
| gpv | git push -v |
|
||||
| gr | git remote |
|
||||
| gra | git remote add |
|
||||
| grb | git rebase |
|
||||
| grba | git rebase --abort |
|
||||
| grbc | git rebase --continue |
|
||||
| grbd | git rebase develop |
|
||||
| grbi | git rebase -i |
|
||||
| grbm | git rebase master |
|
||||
| grbs | git rebase --skip |
|
||||
| grev | git revert |
|
||||
| grh | git reset |
|
||||
| grhh | git reset --hard |
|
||||
| groh | git reset origin/$(git_current_branch) --hard |
|
||||
| grm | git rm |
|
||||
| grmc | git rm --cached |
|
||||
| grmv | git remote rename |
|
||||
| grrm | git remote remove |
|
||||
| grs | git restore |
|
||||
| grset | git remote set-url |
|
||||
| grss | git restore --source |
|
||||
| grt | cd "$(git rev-parse --show-toplevel \|\| echo .)" |
|
||||
| gru | git reset -- |
|
||||
| grup | git remote update |
|
||||
| grv | git remote -v |
|
||||
| gsb | git status -sb |
|
||||
| gsd | git svn dcommit |
|
||||
| gsh | git show |
|
||||
| gsi | git submodule init |
|
||||
| gsps | git show --pretty=short --show-signature |
|
||||
| gsr | git svn rebase |
|
||||
| gss | git status -s |
|
||||
| gst | git status |
|
||||
| gsta | git stash push |
|
||||
| gsta | git stash save |
|
||||
| gstaa | git stash apply |
|
||||
| gstc | git stash clear |
|
||||
| gstd | git stash drop |
|
||||
| gstl | git stash list |
|
||||
| gstp | git stash pop |
|
||||
| gsts | git stash show --text |
|
||||
| gstall | git stash --all |
|
||||
| gsu | git submodule update |
|
||||
| gsw | git switch |
|
||||
| gswc | git switch -c |
|
||||
| gts | git tag -s |
|
||||
| gtv | git tag \| sort -V |
|
||||
| gtl | gtl(){ git tag --sort=-v:refname -n -l ${1}* }; noglob gtl |
|
||||
| gunignore | git update-index --no-assume-unchanged |
|
||||
| gunwip | git log -n 1 \| grep -q -c "\-\-wip\-\-" && git reset HEAD~1 |
|
||||
| gup | git pull --rebase |
|
||||
| gupv | git pull --rebase -v |
|
||||
| gupa | git pull --rebase --autostash |
|
||||
| gupav | git pull --rebase --autostash -v |
|
||||
| glum | git pull upstream master |
|
||||
| gwch | git whatchanged -p --abbrev-commit --pretty=medium |
|
||||
| gwip | git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]" |
|
||||
|
||||
### Deprecated
|
||||
|
||||
These are aliases that have been removed, renamed, or otherwise modified in a way that may, or may not, receive further support.
|
||||
|
||||
| Alias | Command | Modification |
|
||||
| :----- | :----------------------------------------------------------------------------------| --------------------------------------------------------------------------------------------------- |
|
||||
| gap | git add --patch | new alias `gapa` |
|
||||
| gcl | git config --list | new alias `gcf` |
|
||||
| gdc | git diff --cached | new alias `gdca` |
|
||||
| gdt | git difftool | no replacement |
|
||||
| ggpull | git pull origin $(current_branch) | new alias `ggl` (`ggpull` still exists for now though) |
|
||||
| ggpur | git pull --rebase origin $(current_branch) | new alias `ggu` (`ggpur` still exists for now though) |
|
||||
| ggpush | git push origin $(current_branch) | new alias `ggp` (`ggpush` still exists for now though) |
|
||||
| gk | gitk --all --branches | now aliased to `gitk --all --branches` |
|
||||
| glg | git log --stat --max-count = 10 | now aliased to `git log --stat --color` |
|
||||
| glgg | git log --graph --max-count = 10 | now aliased to `git log --graph --color` |
|
||||
| gwc | git whatchanged -p --abbrev-commit --pretty = medium | new alias `gwch` |
|
||||
|
||||
## Functions
|
||||
|
||||
### Current
|
||||
|
||||
| Command | Description |
|
||||
|:-----------------------|:----------------------------------------|
|
||||
| current_branch | Return the name of the current branch |
|
||||
| git_current_user_name | Returns the `user.name` config value |
|
||||
| git_current_user_email | Returns the `user.email` config value |
|
||||
|
||||
### Work in Progress (WIP)
|
||||
|
||||
These features allow to pause a branch development and switch to another one (_"Work in Progress"_, or wip). When you want to go back to work, just unwip it.
|
||||
|
||||
| Command | Description |
|
||||
|:-----------------|:------------------------------------------------|
|
||||
| work_in_progress | Echoes a warning if the current branch is a wip |
|
||||
| gwip | Commit wip branch |
|
||||
| gunwip | Uncommit wip branch |
|
||||
|
||||
### Deprecated
|
||||
|
||||
| Command | Description | Reason |
|
||||
|:-----------------------|:----------------------------------------|:----------------------------------------------------------------|
|
||||
| current_repository | Return the names of the current remotes | Didn't work properly. Use `git remote -v` instead (`grv` alias) |
|
||||
|
@ -1,7 +1,3 @@
|
||||
# Query/use custom command for `git`.
|
||||
zstyle -s ":vcs_info:git:*:-all-" "command" _omz_git_git_cmd
|
||||
: ${_omz_git_git_cmd:=git}
|
||||
|
||||
#
|
||||
# Functions
|
||||
#
|
||||
@ -13,19 +9,15 @@ zstyle -s ":vcs_info:git:*:-all-" "command" _omz_git_git_cmd
|
||||
function current_branch() {
|
||||
git_current_branch
|
||||
}
|
||||
# The list of remotes
|
||||
function current_repository() {
|
||||
if ! $_omz_git_git_cmd rev-parse --is-inside-work-tree &> /dev/null; then
|
||||
return
|
||||
fi
|
||||
echo $($_omz_git_git_cmd remote -v | cut -d':' -f 2)
|
||||
}
|
||||
|
||||
# Pretty log messages
|
||||
function _git_log_prettily(){
|
||||
if ! [ -z $1 ]; then
|
||||
git log --pretty=$1
|
||||
fi
|
||||
}
|
||||
compdef _git _git_log_prettily=git-log
|
||||
|
||||
# Warn if the current branch is a WIP
|
||||
function work_in_progress() {
|
||||
if $(git log -n 1 2>/dev/null | grep -q -c "\-\-wip\-\-"); then
|
||||
@ -50,7 +42,7 @@ alias gap='git apply'
|
||||
alias gb='git branch'
|
||||
alias gba='git branch -a'
|
||||
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 gbl='git blame -b -w'
|
||||
alias gbnm='git branch --no-merged'
|
||||
@ -73,14 +65,13 @@ alias gcsm='git commit -s -m'
|
||||
alias gcb='git checkout -b'
|
||||
alias gcf='git config --list'
|
||||
alias gcl='git clone --recurse-submodules'
|
||||
alias gclean='git clean -fd'
|
||||
alias gclean='git clean -id'
|
||||
alias gpristine='git reset --hard && git clean -dfx'
|
||||
alias gcm='git checkout master'
|
||||
alias gcd='git checkout develop'
|
||||
alias gcmsg='git commit -m'
|
||||
alias gco='git checkout'
|
||||
alias gcount='git shortlog -sn'
|
||||
compdef _git gcount
|
||||
alias gcp='git cherry-pick'
|
||||
alias gcpa='git cherry-pick --abort'
|
||||
alias gcpc='git cherry-pick --continue'
|
||||
@ -89,35 +80,35 @@ alias gcs='git commit -S'
|
||||
alias gd='git diff'
|
||||
alias gdca='git diff --cached'
|
||||
alias gdcw='git diff --cached --word-diff'
|
||||
alias gdct='git describe --tags `git rev-list --tags --max-count=1`'
|
||||
alias gdct='git describe --tags $(git rev-list --tags --max-count=1)'
|
||||
alias gds='git diff --staged'
|
||||
alias gdt='git diff-tree --no-commit-id --name-only -r'
|
||||
alias gdw='git diff --word-diff'
|
||||
|
||||
gdv() { git diff -w "$@" | view - }
|
||||
function gdv() { git diff -w "$@" | view - }
|
||||
compdef _git gdv=git-diff
|
||||
|
||||
alias gf='git fetch'
|
||||
alias gfa='git fetch --all --prune'
|
||||
alias gfo='git fetch origin'
|
||||
|
||||
function gfg() { git ls-files | grep $@ }
|
||||
compdef _grep gfg
|
||||
alias gfg='git ls-files | grep'
|
||||
|
||||
alias gg='git gui citool'
|
||||
alias gga='git gui citool --amend'
|
||||
|
||||
ggf() {
|
||||
function ggf() {
|
||||
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
|
||||
git push --force origin "${b:=$1}"
|
||||
}
|
||||
ggfl() {
|
||||
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
|
||||
git push --force-with-lease origin "${b:=$1}"
|
||||
}
|
||||
compdef _git ggf=git-checkout
|
||||
function ggfl() {
|
||||
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
|
||||
git push --force-with-lease origin "${b:=$1}"
|
||||
}
|
||||
compdef _git ggfl=git-checkout
|
||||
|
||||
ggl() {
|
||||
function ggl() {
|
||||
if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
|
||||
git pull origin "${*}"
|
||||
else
|
||||
@ -127,7 +118,7 @@ ggl() {
|
||||
}
|
||||
compdef _git ggl=git-checkout
|
||||
|
||||
ggp() {
|
||||
function ggp() {
|
||||
if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
|
||||
git push origin "${*}"
|
||||
else
|
||||
@ -137,7 +128,7 @@ ggp() {
|
||||
}
|
||||
compdef _git ggp=git-checkout
|
||||
|
||||
ggpnp() {
|
||||
function ggpnp() {
|
||||
if [[ "$#" == 0 ]]; then
|
||||
ggl && ggp
|
||||
else
|
||||
@ -146,20 +137,15 @@ ggpnp() {
|
||||
}
|
||||
compdef _git ggpnp=git-checkout
|
||||
|
||||
ggu() {
|
||||
function ggu() {
|
||||
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
|
||||
git pull --rebase origin "${b:=$1}"
|
||||
}
|
||||
compdef _git ggu=git-checkout
|
||||
|
||||
alias ggpur='ggu'
|
||||
compdef _git ggpur=git-checkout
|
||||
|
||||
alias ggpull='git pull origin $(git_current_branch)'
|
||||
compdef _git ggpull=git-checkout
|
||||
|
||||
alias ggpush='git push origin $(git_current_branch)'
|
||||
compdef _git ggpush=git-checkout
|
||||
alias ggpull='git pull origin "$(git_current_branch)"'
|
||||
alias ggpush='git push origin "$(git_current_branch)"'
|
||||
|
||||
alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)'
|
||||
alias gpsup='git push --set-upstream origin $(git_current_branch)'
|
||||
@ -169,12 +155,9 @@ alias ghh='git help'
|
||||
alias gignore='git update-index --assume-unchanged'
|
||||
alias gignored='git ls-files -v | grep "^[[:lower:]]"'
|
||||
alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
|
||||
compdef _git git-svn-dcommit-push=git
|
||||
|
||||
alias gk='\gitk --all --branches'
|
||||
compdef _git gk='gitk'
|
||||
alias gke='\gitk --all $(git log -g --pretty=%h)'
|
||||
compdef _git gke='gitk'
|
||||
|
||||
alias gl='git pull'
|
||||
alias glg='git log --stat'
|
||||
@ -191,7 +174,6 @@ alias glola="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgr
|
||||
alias glog='git log --oneline --decorate --graph'
|
||||
alias gloga='git log --oneline --decorate --graph --all'
|
||||
alias glp="_git_log_prettily"
|
||||
compdef _git glp=git-log
|
||||
|
||||
alias gm='git merge'
|
||||
alias gmom='git merge origin/master'
|
||||
@ -205,7 +187,6 @@ alias gpd='git push --dry-run'
|
||||
alias gpf='git push --force-with-lease'
|
||||
alias gpf!='git push --force'
|
||||
alias gpoat='git push origin --all && git push origin --tags'
|
||||
compdef _git gpoat=git-push
|
||||
alias gpu='git push upstream'
|
||||
alias gpv='git push -v'
|
||||
|
||||
@ -218,14 +199,18 @@ alias grbd='git rebase develop'
|
||||
alias grbi='git rebase -i'
|
||||
alias grbm='git rebase master'
|
||||
alias grbs='git rebase --skip'
|
||||
alias grev='git revert'
|
||||
alias grh='git reset'
|
||||
alias grhh='git reset --hard'
|
||||
alias groh='git reset origin/$(git_current_branch) --hard'
|
||||
alias grm='git rm'
|
||||
alias grmc='git rm --cached'
|
||||
alias grmv='git remote rename'
|
||||
alias grrm='git remote remove'
|
||||
alias grs='git restore'
|
||||
alias grset='git remote set-url'
|
||||
alias grt='cd $(git rev-parse --show-toplevel || echo ".")'
|
||||
alias grss='git restore --source'
|
||||
alias grt='cd "$(git rev-parse --show-toplevel || echo .)"'
|
||||
alias gru='git reset --'
|
||||
alias grup='git remote update'
|
||||
alias grv='git remote -v'
|
||||
@ -238,7 +223,13 @@ alias gsps='git show --pretty=short --show-signature'
|
||||
alias gsr='git svn rebase'
|
||||
alias gss='git status -s'
|
||||
alias gst='git status'
|
||||
alias gsta='git stash save'
|
||||
|
||||
# use the default stash push on git 2.13 and newer
|
||||
autoload -Uz is-at-least
|
||||
is-at-least 2.13 "$(git --version 2>/dev/null | awk '{print $3}')" \
|
||||
&& alias gsta='git stash push' \
|
||||
|| alias gsta='git stash save'
|
||||
|
||||
alias gstaa='git stash apply'
|
||||
alias gstc='git stash clear'
|
||||
alias gstd='git stash drop'
|
||||
@ -247,9 +238,12 @@ alias gstp='git stash pop'
|
||||
alias gsts='git stash show --text'
|
||||
alias gstall='git stash --all'
|
||||
alias gsu='git submodule update'
|
||||
alias gsw='git switch'
|
||||
alias gswc='git switch -c'
|
||||
|
||||
alias gts='git tag -s'
|
||||
alias gtv='git tag | sort -V'
|
||||
alias gtl='gtl(){ git tag --sort=-v:refname -n -l "${1}*" }; noglob gtl'
|
||||
|
||||
alias gunignore='git update-index --no-assume-unchanged'
|
||||
alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1'
|
||||
@ -260,4 +254,4 @@ alias gupav='git pull --rebase --autostash -v'
|
||||
alias glum='git pull upstream master'
|
||||
|
||||
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 -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]"'
|
||||
|
@ -10,129 +10,6 @@ plugins=(... gitfast)
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command |
|
||||
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| g | `git` |
|
||||
| ga | `git add` |
|
||||
| gaa | `git add --all` |
|
||||
| gapa | `git add --patch` |
|
||||
| gau | `git add --update` |
|
||||
| gb | `git branch` |
|
||||
| gba | `git branch -a` |
|
||||
| gbd | `git branch -d` |
|
||||
| gbda | `git branch --no-color --merged | command grep -vE "^(\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d` |
|
||||
| gbl | `git blame -b -w` |
|
||||
| gbnm | `git branch --no-merged` |
|
||||
| gbr | `git branch --remote` |
|
||||
| gbs | `git bisect` |
|
||||
| gbsb | `git bisect bad` |
|
||||
| gbsg | `git bisect good` |
|
||||
| gbsr | `git bisect reset` |
|
||||
| gbss | `git bisect start` |
|
||||
| gc | `git commit -v` |
|
||||
| gc! | `git commit -v --amend` |
|
||||
| gca | `git commit -v -a` |
|
||||
| gca! | `git commit -v -a --amend` |
|
||||
| gcam | `git commit -a -m` |
|
||||
| gcan! | `git commit -v -a --no-edit --amend` |
|
||||
| gcans! | `git commit -v -a -s --no-edit --amend` |
|
||||
| gcb | `git checkout -b` |
|
||||
| gcd | `git checkout develop` |
|
||||
| gcf | `git config --list` |
|
||||
| gcl | `git clone --recursive` |
|
||||
| gclean | `git clean -fd` |
|
||||
| gcm | `git checkout master` |
|
||||
| gcmsg | `git commit -m` |
|
||||
| gcn! | `git commit -v --no-edit --amend` |
|
||||
| gco | `git checkout` |
|
||||
| gcount | `git shortlog -sn` |
|
||||
| gcp | `git cherry-pick` |
|
||||
| gcpa | `git cherry-pick --abort` |
|
||||
| gcpc | `git cherry-pick --continue` |
|
||||
| gcs | `git commit -S` |
|
||||
| gcsm | `git commit -s -m` |
|
||||
| gd | `git diff` |
|
||||
| gdca | `git diff --cached` |
|
||||
| gdct | `` git describe --tags `git rev-list --tags --max-count=1` `` |
|
||||
| gdt | `git diff-tree --no-commit-id --name-only -r` |
|
||||
| gdw | `git diff --word-diff` |
|
||||
| gf | `git fetch` |
|
||||
| gfa | `git fetch --all --prune` |
|
||||
| gfo | `git fetch origin` |
|
||||
| gg | `git gui citool` |
|
||||
| gga | `git gui citool --amend` |
|
||||
| ggpull | `git pull origin $(git_current_branch)` |
|
||||
| ggpur | `ggu` |
|
||||
| ggpush | `git push origin $(git_current_branch)` |
|
||||
| ggsup | `git branch --set-upstream-to=origin/$(git_current_branch)` |
|
||||
| ghh | `git help` |
|
||||
| gignore | `git update-index --assume-unchanged` |
|
||||
| gignored | `git ls-files -v | grep "^[[:lower:]]"` |
|
||||
| git-svn-dcommit-push | `git svn dcommit && git push github master:svntrunk` |
|
||||
| gk | `\gitk --all --branches` |
|
||||
| gke | `\gitk --all $(git log -g --pretty=%h)` |
|
||||
| gl | `git pull` |
|
||||
| glg | `git log --stat` |
|
||||
| glgg | `git log --graph` |
|
||||
| glgga | `git log --graph --decorate --all` |
|
||||
| glgm | `git log --graph --max-count=10` |
|
||||
| glgp | `git log --stat -p` |
|
||||
| glo | `git log --oneline --decorate` |
|
||||
| glog | `git log --oneline --decorate --graph` |
|
||||
| gloga | `git log --oneline --decorate --graph --all` |
|
||||
| glol | `git log --graph --pretty='\''%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'\'' --abbrev-commit` |
|
||||
| glola | `git log --graph --pretty='\''%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'\'' --abbrev-commit --all` |
|
||||
| glp | `_git_log_prettily` |
|
||||
| glum | `git pull upstream master` |
|
||||
| gm | `git merge` |
|
||||
| gmom | `git merge origin/master` |
|
||||
| gmt | `git mergetool --no-prompt` |
|
||||
| gmtvim | `git mergetool --no-prompt --tool=vimdiff` |
|
||||
| gmum | `git merge upstream/master` |
|
||||
| gp | `git push` |
|
||||
| gpd | `git push --dry-run` |
|
||||
| gpoat | `git push origin --all && git push origin --tags` |
|
||||
| gpristine | `git reset --hard && git clean -dfx` |
|
||||
| gpsup | `git push --set-upstream origin $(git_current_branch)` |
|
||||
| gpu | `git push upstream` |
|
||||
| gpv | `git push -v` |
|
||||
| gr | `git remote` |
|
||||
| gra | `git remote add` |
|
||||
| grb | `git rebase` |
|
||||
| grba | `git rebase --abort` |
|
||||
| grbc | `git rebase --continue` |
|
||||
| grbi | `git rebase -i` |
|
||||
| grbm | `git rebase master` |
|
||||
| grbs | `git rebase --skip` |
|
||||
| grh | `git reset HEAD` |
|
||||
| grhh | `git reset HEAD --hard` |
|
||||
| grmv | `git remote rename` |
|
||||
| grrm | `git remote remove` |
|
||||
| grset | `git remote set-url` |
|
||||
| grt | `cd $(git rev-parse --show-toplevel || echo ".")` |
|
||||
| gru | `git reset --` |
|
||||
| grup | `git remote update` |
|
||||
| grv | `git remote -v` |
|
||||
| gsb | `git status -sb` |
|
||||
| gsd | `git svn dcommit` |
|
||||
| gsi | `git submodule init` |
|
||||
| gsps | `git show --pretty=short --show-signature` |
|
||||
| gsr | `git svn rebase` |
|
||||
| gss | `git status -s` |
|
||||
| gst | `git status` |
|
||||
| gsta | `git stash save` |
|
||||
| gstaa | `git stash apply` |
|
||||
| gstc | `git stash clear` |
|
||||
| gstd | `git stash drop` |
|
||||
| gstl | `git stash list` |
|
||||
| gstp | `git stash pop` |
|
||||
| gsts | `git stash show --text` |
|
||||
| gsu | `git submodule update` |
|
||||
| gts | `git tag -s` |
|
||||
| gtv | `git tag | sort -V` |
|
||||
| gunignore | `git update-index --no-assume-unchanged` |
|
||||
| gunwip | `git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1` |
|
||||
| gup | `git pull --rebase` |
|
||||
| gupv | `git pull --rebase -v` |
|
||||
| gwch | `git whatchanged -p --abbrev-commit --pretty=medium` |
|
||||
| gwip | `git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify -m "--wip-- [skip ci]"` |
|
||||
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)
|
||||
as well.
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user