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

Merge branch 'master' into clipboard

parents d81cd753 368198b7
--- ---
name: Bug report name: Bug report
about: Create a report to help us improve about: Create a report to help us improve Oh My Zsh
labels: 'Type: bug' labels: 'Type: support'
--- ---
...@@ -11,29 +11,26 @@ an issue where no sections have been filled will be deleted without comment. ...@@ -11,29 +11,26 @@ an issue where no sections have been filled will be deleted without comment.
--> -->
**Describe the bug** **Describe the bug**
<!-- A clear and concise description of what the bug is. --> A clear description of what the bug is.
**To Reproduce** **To Reproduce**
<!-- Steps to reproduce the behavior, for example:
Steps to reproduce the behavior: 1. Enable this plugin '...'
1. Enable plugin '...' 2. Run command '...' or try the autocomplete command '...'
2. Run command '...', _or_ try to complete command '...', _etc._
3. See error 3. See error
-->
**Expected behavior** **Expected behavior**
<!-- A clear and concise description of what you expected to happen. --> A brief description of what should happen.
**Screenshots or recordings** **Screenshots and/or Recordings**
<!-- If applicable, add screenshots to help explain your problem.
If applicable, add screenshots or record an asciinema session (https://asciinema.org/) You can also record an asciinema session: https://asciinema.org/
to help explain your problem.
-->
**System:** **Desktop (please complete the following information):**
- OS: [e.g. macOS] - OS / Distro: [e.g. Arch Linux, macOS]
- Zsh version [e.g. 5.6] - Latest ohmyzsh Update?: [e.g. Yes/No]
- ZSH Version: [e.g. 5.6]
- Terminal emulator [e.g. iTerm2] - Terminal emulator [e.g. iTerm2]
**Additional context** **Additional context**
<!-- Add any other context about the problem here. --> Add any other context about the problem here. This can be themes, plugins, custom configs.
...@@ -11,16 +11,16 @@ an issue where no sections have been filled will be deleted without comment. ...@@ -11,16 +11,16 @@ an issue where no sections have been filled will be deleted without comment.
--> -->
**Is your feature request related to a particular plugin or theme? If so, specify it.** **Is your feature request related to a particular plugin or theme? If so, specify it.**
<!-- The name of the plugin or theme you'd like us to improve. --> The name of the plugin or theme that you would like us to improve. [...]
**Is your feature request related to a problem? Please describe.** **Is your feature request related to a problem? Please describe.**
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] --> A description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like** **Describe the solution you'd like**
<!-- A clear and concise description of what you want to happen. --> A description of what you want to happen.
**Describe alternatives you've considered** **Describe alternatives you've considered**
<!-- A clear and concise description of any alternative solutions or features you've considered. --> A description of any alternative solutions or features you've considered. This can also include other plugins or aliases.
**Additional context** **Additional context**
<!-- Add any other context or screenshots about the feature request here. --> Add any other context or screenshots about the feature request here. Also if you have any PRs related to this issue that are already open that you would like us to look at.
...@@ -5,8 +5,6 @@ labels: 'Type: support' ...@@ -5,8 +5,6 @@ labels: 'Type: support'
--- ---
<!--
1. Look for similar issues already posted (including closed ones) 1. Look for similar issues already posted (including closed ones)
2. Include as much relevant information as possible 2. Include as much relevant information as possible
3. Try to make sure the issue is due to Oh My Zsh 3. Try to make sure the issue is due to Oh My Zsh
-->
## Standards checklist:
- [ ] The PR title is descriptive.
- [ ] The PR doesn't replicate another PR which is already open.
- [ ] I have read the contribution guide and followed all the instructions.
- [ ] The code follows the code style guide detailed in the wiki.
- [ ] The code is mine or it's from somewhere with an MIT-compatible license.
- [ ] The code is efficient, to the best of my ability, and does not waste computer resources.
- [ ] The code is stable and I have tested it myself, to the best of my abilities.
## Changes:
- [...]
## Other comments:
...
workflow "Triage Pull Request" {
on = "pull_request"
resolves = ["Triage"]
}
# Only act if there are code changes: if the pull_request
# event's action is either 'opened' (new PR) or 'synchronize' (new commits)
action "Filter actions" {
uses = "actions/bin/filter@0ac6d44"
args = "action 'opened|synchronize'"
}
action "Triage" {
needs = ["Filter actions"]
uses = "ohmyzsh/github-actions/pull-request-triage@master"
secrets = ["GITHUB_TOKEN"]
}
name: CI
on:
pull_request:
types:
- opened
- synchronize
branches:
- master
push:
branches:
- master
jobs:
tests:
name: Run tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- name: Set up git repository
uses: actions/checkout@v2
- name: Install zsh
if: runner.os == 'Linux'
run: sudo apt-get update; sudo apt-get install zsh
- name: Test installer
run: sh ./tools/install.sh
- name: Check syntax
run: |
for file in ./oh-my-zsh.sh \
./lib/*.zsh \
./plugins/*/*.plugin.zsh \
./plugins/*/_* \
./themes/*.zsh-theme; do
zsh -n "$file" || return 1
done
...@@ -4,3 +4,5 @@ custom/ ...@@ -4,3 +4,5 @@ custom/
# temp files directories # temp files directories
cache/ cache/
log/ log/
*.swp
.DS_Store
...@@ -31,7 +31,7 @@ your problem. ...@@ -31,7 +31,7 @@ your problem.
If you find one, comment on it so we can know there are more people experiencing it. If you find one, comment on it so we can know there are more people experiencing it.
If not, look at the [Troubleshooting](https://github.com/robbyrussell/oh-my-zsh/wiki/Troubleshooting) If not, look at the [Troubleshooting](https://github.com/ohmyzsh/ohmyzsh/wiki/Troubleshooting)
page for instructions on how to gather data to better debug your problem. page for instructions on how to gather data to better debug your problem.
Then, you can go ahead and create an issue with as much detail as you can provide. Then, you can go ahead and create an issue with as much detail as you can provide.
...@@ -62,7 +62,7 @@ maintainers) by mentioning their GitHub handle (starting with `@`) in your messa ...@@ -62,7 +62,7 @@ maintainers) by mentioning their GitHub handle (starting with `@`) in your messa
You should be familiar with the basics of You should be familiar with the basics of
[contributing on GitHub](https://help.github.com/articles/using-pull-requests) and have a fork [contributing on GitHub](https://help.github.com/articles/using-pull-requests) and have a fork
[properly set up](https://github.com/robbyrussell/oh-my-zsh/wiki/Contribution-Technical-Practices). [properly set up](https://github.com/ohmyzsh/ohmyzsh/wiki/Contribution-Technical-Practices).
You MUST always create PRs with _a dedicated branch_ based on the latest upstream tree. You MUST always create PRs with _a dedicated branch_ based on the latest upstream tree.
...@@ -85,7 +85,7 @@ maintainers) by mentioning their GitHub handle (starting with `@`) in your messa ...@@ -85,7 +85,7 @@ maintainers) by mentioning their GitHub handle (starting with `@`) in your messa
### You have an addition ### You have an addition
Please [do not](https://github.com/robbyrussell/oh-my-zsh/wiki/Themes#dont-send-us-your-theme-for-now) Please [do not](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#dont-send-us-your-theme-for-now)
send themes for now. send themes for now.
Please be so kind as to [search](#use-the-search-luke) for any pending, merged or rejected Pull Requests Please be so kind as to [search](#use-the-search-luke) for any pending, merged or rejected Pull Requests
...@@ -109,7 +109,7 @@ to help you check whether a similar contribution to yours already exists. Please ...@@ -109,7 +109,7 @@ to help you check whether a similar contribution to yours already exists. Please
before making any contribution, it avoids duplicates and eases maintenance. Trust me, before making any contribution, it avoids duplicates and eases maintenance. Trust me,
that works 90% of the time. that works 90% of the time.
You can also take a look at the [FAQ](https://github.com/robbyrussell/oh-my-zsh/wiki/FAQ) You can also take a look at the [FAQ](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ)
to be sure your contribution has not already come up. to be sure your contribution has not already come up.
If all fails, your thing has probably not been reported yet, so you can go ahead If all fails, your thing has probably not been reported yet, so you can go ahead
...@@ -121,5 +121,5 @@ and [create an issue](#reporting-issues) or [submit a PR](#submitting-pull-reque ...@@ -121,5 +121,5 @@ and [create an issue](#reporting-issues) or [submit a PR](#submitting-pull-reque
Very nice!! :) Very nice!! :)
Please have a look at the [Volunteer](https://github.com/robbyrussell/oh-my-zsh/wiki/Volunteers) Please have a look at the [Volunteer](https://github.com/ohmyzsh/ohmyzsh/wiki/Volunteers)
page for instructions on where to start and more. page for instructions on where to start and more.
The MIT License (MIT) MIT License
Copyright (c) 2009-2019 Robby Russell and contributors Copyright (c) 2009-2020 Robby Russell and contributors (https://github.com/ohmyzsh/ohmyzsh/contributors)
See the full list at https://github.com/robbyrussell/oh-my-zsh/contributors
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
......
...@@ -12,16 +12,18 @@ Once installed, your terminal shell will become the talk of the town _or your mo ...@@ -12,16 +12,18 @@ Once installed, your terminal shell will become the talk of the town _or your mo
Finally, you'll begin to get the sort of attention that you have always felt you deserved. ...or maybe you'll use the time that you're saving to start flossing more often. 😬 Finally, you'll begin to get the sort of attention that you have always felt you deserved. ...or maybe you'll use the time that you're saving to start flossing more often. 😬
To learn more, visit [ohmyz.sh](https://ohmyz.sh) and follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter, and/or join us on Discord.
[![CI](https://github.com/ohmyzsh/ohmyzsh/workflows/CI/badge.svg)](https://github.com/ohmyzsh/ohmyzsh/actions?query=workflow%3ACI)
[![Follow @ohmyzsh](https://img.shields.io/twitter/follow/ohmyzsh?label=Follow+@ohmyzsh&style=flat)](https://twitter.com/intent/follow?screen_name=ohmyzsh)
[![Discord server](https://img.shields.io/discord/642496866407284746)](https://discord.gg/bpXWhnN)
## Getting Started ## Getting Started
### Prerequisites ### Prerequisites
__Disclaimer:__ _Oh My Zsh works best on macOS and Linux._ * A Unix-like operating system: macOS, Linux, BSD. On Windows: WSL is preferred, but cygwin or msys also mostly work.
* [Zsh](https://www.zsh.org) should be installed (v4.3.9 or more recent). If not pre-installed (run `zsh --version` to confirm), check the following instructions here: [Installing ZSH](https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH)
* Unix-like operating system (macOS or Linux)
* [Zsh](https://www.zsh.org) should be installed (v4.3.9 or more recent). If not pre-installed (`zsh --version` to confirm), check the following instruction here: [Installing ZSH](https://github.com/robbyrussell/oh-my-zsh/wiki/Installing-ZSH)
* `curl` or `wget` should be installed * `curl` or `wget` should be installed
* `git` should be installed * `git` should be installed
...@@ -32,13 +34,13 @@ Oh My Zsh is installed by running one of the following commands in your terminal ...@@ -32,13 +34,13 @@ Oh My Zsh is installed by running one of the following commands in your terminal
#### via curl #### via curl
```shell ```shell
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
``` ```
#### via wget #### via wget
```shell ```shell
sh -c "$(wget -O- https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
``` ```
#### Manual inspection #### Manual inspection
...@@ -48,7 +50,7 @@ that by downloading the install script first, looking through it so everything l ...@@ -48,7 +50,7 @@ that by downloading the install script first, looking through it so everything l
then running it: then running it:
```shell ```shell
curl -Lo install.sh https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh curl -Lo install.sh https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
sh install.sh sh install.sh
``` ```
...@@ -56,7 +58,7 @@ sh install.sh ...@@ -56,7 +58,7 @@ sh install.sh
### Plugins ### Plugins
Oh My Zsh comes with a shitload of plugins to take advantage of. You can take a look in the [plugins](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins) directory and/or the [wiki](https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins) to see what's currently available. Oh My Zsh comes with a shitload of plugins to take advantage of. You can take a look in the [plugins](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins) directory and/or the [wiki](https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins) to see what's currently available.
#### Enabling Plugins #### Enabling Plugins
...@@ -88,7 +90,7 @@ Most plugins (should! we're working on this) include a __README__, which documen ...@@ -88,7 +90,7 @@ Most plugins (should! we're working on this) include a __README__, which documen
### Themes ### Themes
We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme happy. We have over one hundred themes now bundled. Most of them have [screenshots](https://github.com/robbyrussell/oh-my-zsh/wiki/Themes) on the wiki. Check them out! We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme happy. We have over one hundred themes now bundled. Most of them have [screenshots](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes) on the wiki. Check them out!
#### Selecting a Theme #### Selecting a Theme
...@@ -104,7 +106,7 @@ To use a different theme, simply change the value to match the name of your desi ...@@ -104,7 +106,7 @@ To use a different theme, simply change the value to match the name of your desi
```shell ```shell
ZSH_THEME="agnoster" # (this is one of the fancy ones) ZSH_THEME="agnoster" # (this is one of the fancy ones)
# see https://github.com/robbyrussell/oh-my-zsh/wiki/Themes#agnoster # see https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#agnoster
``` ```
_Note: many themes require installing the [Powerline Fonts](https://github.com/powerline/fonts) in order to render properly._ _Note: many themes require installing the [Powerline Fonts](https://github.com/powerline/fonts) in order to render properly._
...@@ -113,7 +115,7 @@ Open up a new terminal window and your prompt should look something like this: ...@@ -113,7 +115,7 @@ Open up a new terminal window and your prompt should look something like this:
![Agnoster theme](https://cloud.githubusercontent.com/assets/2618447/6316862/70f58fb6-ba03-11e4-82c9-c083bf9a6574.png) ![Agnoster theme](https://cloud.githubusercontent.com/assets/2618447/6316862/70f58fb6-ba03-11e4-82c9-c083bf9a6574.png)
In case you did not find a suitable theme for your needs, please have a look at the wiki for [more of them](https://github.com/robbyrussell/oh-my-zsh/wiki/External-themes). In case you did not find a suitable theme for your needs, please have a look at the wiki for [more of them](https://github.com/ohmyzsh/ohmyzsh/wiki/External-themes).
If you're feeling feisty, you can let the computer select one randomly for you each time you open a new terminal window. If you're feeling feisty, you can let the computer select one randomly for you each time you open a new terminal window.
...@@ -131,6 +133,10 @@ ZSH_THEME_RANDOM_CANDIDATES=( ...@@ -131,6 +133,10 @@ ZSH_THEME_RANDOM_CANDIDATES=(
) )
``` ```
### FAQ
If you have some more questions or issues, you might find a solution in our [FAQ](https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ).
## Advanced Topics ## Advanced Topics
If you're the type that likes to get their hands dirty, these sections might resonate. If you're the type that likes to get their hands dirty, these sections might resonate.
...@@ -159,14 +165,14 @@ flag `--unattended` to the `install.sh` script. This will have the effect of not ...@@ -159,14 +165,14 @@ flag `--unattended` to the `install.sh` script. This will have the effect of not
the default shell, and also won't run `zsh` when the installation has finished. the default shell, and also won't run `zsh` when the installation has finished.
```shell ```shell
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" "" --unattended sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
``` ```
#### Installing from a forked repository #### Installing from a forked repository
The install script also accepts these variables to allow installation of a different repository: The install script also accepts these variables to allow installation of a different repository:
- `REPO` (default: `robbyrussell/oh-my-zsh`): this takes the form of `owner/repository`. If you set - `REPO` (default: `ohmyzsh/ohmyzsh`): this takes the form of `owner/repository`. If you set
this variable, the installer will look for a repository at `https://github.com/{owner}/{repository}`. this variable, the installer will look for a repository at `https://github.com/{owner}/{repository}`.
- `REMOTE` (default: `https://github.com/${REPO}.git`): this is the full URL of the git repository - `REMOTE` (default: `https://github.com/${REPO}.git`): this is the full URL of the git repository
...@@ -190,7 +196,7 @@ REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh ...@@ -190,7 +196,7 @@ REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh
##### 1. Clone the repository: ##### 1. Clone the repository:
```shell ```shell
git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
``` ```
##### 2. *Optionally*, backup your existing `~/.zshrc` file: ##### 2. *Optionally*, backup your existing `~/.zshrc` file:
...@@ -272,13 +278,13 @@ Before you participate in our delightful community, please read the [code of con ...@@ -272,13 +278,13 @@ Before you participate in our delightful community, please read the [code of con
I'm far from being a [Zsh](https://www.zsh.org/) expert and suspect there are many ways to improve – if you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests! I'm far from being a [Zsh](https://www.zsh.org/) expert and suspect there are many ways to improve – if you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests!
We also need people to test out pull-requests. So take a look through [the open issues](https://github.com/robbyrussell/oh-my-zsh/issues) and help where you can. We also need people to test out pull-requests. So take a look through [the open issues](https://github.com/ohmyzsh/ohmyzsh/issues) and help where you can.
See [Contributing](CONTRIBUTING.md) for more details. See [Contributing](CONTRIBUTING.md) for more details.
### Do NOT send us themes ### Do NOT send us themes
We have (more than) enough themes for the time being. Please add your theme to the [external themes](https://github.com/robbyrussell/oh-my-zsh/wiki/External-themes) wiki page. We have (more than) enough themes for the time being. Please add your theme to the [external themes](https://github.com/ohmyzsh/ohmyzsh/wiki/External-themes) wiki page.
## Contributors ## Contributors
......
...@@ -54,7 +54,7 @@ function detect-clipboard() { ...@@ -54,7 +54,7 @@ function detect-clipboard() {
if [[ "${OSTYPE}" == darwin* ]] && (( ${+commands[pbcopy]} )) && (( ${+commands[pbpaste]} )); then if [[ "${OSTYPE}" == darwin* ]] && (( ${+commands[pbcopy]} )) && (( ${+commands[pbpaste]} )); then
function clipcopy() { pbcopy < "${1:-/dev/stdin}"; } function clipcopy() { pbcopy < "${1:-/dev/stdin}"; }
function clippaste() { pbpaste; } function clippaste() { pbpaste; }
elif [[ "${OSTYPE}" == cygwin* ]]; then elif [[ "${OSTYPE}" == (cygwin|msys)* ]]; then
function clipcopy() { cat "${1:-/dev/stdin}" > /dev/clipboard; } function clipcopy() { cat "${1:-/dev/stdin}" > /dev/clipboard; }
function clippaste() { cat /dev/clipboard; } function clippaste() { cat /dev/clipboard; }
elif [ -n "${WAYLAND_DISPLAY:-}" ] && (( ${+commands[wl-copy]} )) && (( ${+commands[wl-paste]} )); then elif [ -n "${WAYLAND_DISPLAY:-}" ] && (( ${+commands[wl-copy]} )) && (( ${+commands[wl-paste]} )); then
......
...@@ -71,3 +71,6 @@ if [[ $COMPLETION_WAITING_DOTS = true ]]; then ...@@ -71,3 +71,6 @@ if [[ $COMPLETION_WAITING_DOTS = true ]]; then
zle -N expand-or-complete-with-dots zle -N expand-or-complete-with-dots
bindkey "^I" expand-or-complete-with-dots bindkey "^I" expand-or-complete-with-dots
fi fi
# automatically load bash completion functions
autoload -Uz bashcompinit && bashcompinit
...@@ -3,11 +3,12 @@ function zsh_stats() { ...@@ -3,11 +3,12 @@ function zsh_stats() {
} }
function uninstall_oh_my_zsh() { function uninstall_oh_my_zsh() {
env ZSH=$ZSH sh $ZSH/tools/uninstall.sh env ZSH="$ZSH" sh "$ZSH/tools/uninstall.sh"
} }
function upgrade_oh_my_zsh() { function upgrade_oh_my_zsh() {
env ZSH=$ZSH sh $ZSH/tools/upgrade.sh env ZSH="$ZSH" sh "$ZSH/tools/upgrade.sh"
rm -rf "$ZSH/log/update.lock"
} }
function take() { function take() {
...@@ -21,7 +22,7 @@ function open_command() { ...@@ -21,7 +22,7 @@ function open_command() {
case "$OSTYPE" in case "$OSTYPE" in
darwin*) open_cmd='open' ;; darwin*) open_cmd='open' ;;
cygwin*) open_cmd='cygstart' ;; cygwin*) open_cmd='cygstart' ;;
linux*) ! [[ $(uname -a) =~ "Microsoft" ]] && open_cmd='xdg-open' || { linux*) [[ "$(uname -r)" != *icrosoft* ]] && open_cmd='nohup xdg-open' || {
open_cmd='cmd.exe /c start ""' open_cmd='cmd.exe /c start ""'
[[ -e "$1" ]] && { 1="$(wslpath -w "${1:a}")" || return 1 } [[ -e "$1" ]] && { 1="$(wslpath -w "${1:a}")" || return 1 }
} ;; } ;;
...@@ -31,12 +32,7 @@ function open_command() { ...@@ -31,12 +32,7 @@ function open_command() {
;; ;;
esac esac
# don't use nohup on OSX ${=open_cmd} "$@" &>/dev/null
if [[ "$OSTYPE" == darwin* ]]; then
${=open_cmd} "$@" &>/dev/null
else
nohup ${=open_cmd} "$@" &>/dev/null
fi
} }
# #
......
...@@ -12,11 +12,21 @@ function git_prompt_info() { ...@@ -12,11 +12,21 @@ function git_prompt_info() {
function parse_git_dirty() { function parse_git_dirty() {
local STATUS local STATUS
local -a FLAGS local -a FLAGS
FLAGS=('--porcelain' '--ignore-submodules=dirty') FLAGS=('--porcelain')
if [[ "$(command git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then if [[ "$(command git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then
if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then
FLAGS+='--untracked-files=no' FLAGS+='--untracked-files=no'
fi fi
case "$GIT_STATUS_IGNORE_SUBMODULES" in
git)
# let git decide (this respects per-repo config in .gitmodules)
;;
*)
# if unset: ignore dirty submodules
# other values are passed to --ignore-submodules
FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}"
;;
esac
STATUS=$(command git status ${FLAGS} 2> /dev/null | tail -n1) STATUS=$(command git status ${FLAGS} 2> /dev/null | tail -n1)
fi fi
if [[ -n $STATUS ]]; then if [[ -n $STATUS ]]; then
...@@ -189,3 +199,12 @@ function git_current_user_name() { ...@@ -189,3 +199,12 @@ function git_current_user_name() {
function git_current_user_email() { function git_current_user_email() {
command git config user.email 2>/dev/null command git config user.email 2>/dev/null
} }
# Output the name of the root directory of the git repository
# Usage example: $(git_repo_name)
function git_repo_name() {
local repo_path
if repo_path="$(git rev-parse --show-toplevel 2>/dev/null)" && [[ -n "$repo_path" ]]; then
echo ${repo_path:t}
fi
}
...@@ -22,7 +22,7 @@ env_default 'PAGER' 'less' ...@@ -22,7 +22,7 @@ env_default 'PAGER' 'less'
env_default 'LESS' '-R' env_default 'LESS' '-R'
## super user alias ## super user alias
alias _='sudo' alias _='sudo '
## more intelligent acking for ubuntu users ## more intelligent acking for ubuntu users
if which ack-grep &> /dev/null; then if which ack-grep &> /dev/null; then
...@@ -31,10 +31,5 @@ else ...@@ -31,10 +31,5 @@ else
alias afind='ack -il' alias afind='ack -il'
fi fi
# only define LC_CTYPE if undefined
if [[ -z "$LC_CTYPE" && -z "$LC_ALL" ]]; then
export LC_CTYPE=${LANG%%:*} # pick the first entry from LANG
fi
# recognize comments # recognize comments
setopt interactivecomments setopt interactivecomments
...@@ -75,8 +75,9 @@ function omz_termsupport_preexec { ...@@ -75,8 +75,9 @@ function omz_termsupport_preexec {
title '$CMD' '%100>...>$LINE%<<' title '$CMD' '%100>...>$LINE%<<'
} }
precmd_functions+=(omz_termsupport_precmd) autoload -U add-zsh-hook
preexec_functions+=(omz_termsupport_preexec) add-zsh-hook precmd omz_termsupport_precmd
add-zsh-hook preexec omz_termsupport_preexec
# Keep Apple Terminal.app's current working directory updated # Keep Apple Terminal.app's current working directory updated
...@@ -99,7 +100,7 @@ if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then ...@@ -99,7 +100,7 @@ if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
} }
# Use a precmd hook instead of a chpwd hook to avoid contaminating output # Use a precmd hook instead of a chpwd hook to avoid contaminating output
precmd_functions+=(update_terminalapp_cwd) add-zsh-hook precmd update_terminalapp_cwd
# Run once to get initial cwd set # Run once to get initial cwd set
update_terminalapp_cwd update_terminalapp_cwd
fi fi
...@@ -32,8 +32,8 @@ fi ...@@ -32,8 +32,8 @@ fi
is_plugin() { is_plugin() {
local base_dir=$1 local base_dir=$1
local name=$2 local name=$2
test -f $base_dir/plugins/$name/$name.plugin.zsh \ builtin test -f $base_dir/plugins/$name/$name.plugin.zsh \
|| test -f $base_dir/plugins/$name/_$name || builtin test -f $base_dir/plugins/$name/_$name
} }
# Add all defined plugins to fpath. This must be done # Add all defined plugins to fpath. This must be done
...@@ -97,25 +97,12 @@ done ...@@ -97,25 +97,12 @@ done
unset config_file unset config_file
# Load the theme # Load the theme
if [[ "$ZSH_THEME" == "random" ]]; then if [ ! "$ZSH_THEME" = "" ]; then
if [[ "${(t)ZSH_THEME_RANDOM_CANDIDATES}" = "array" ]] && [[ "${#ZSH_THEME_RANDOM_CANDIDATES[@]}" -gt 0 ]]; then if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then
themes=($ZSH/themes/${^ZSH_THEME_RANDOM_CANDIDATES}.zsh-theme) source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then
source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
else else
themes=($ZSH/themes/*zsh-theme) source "$ZSH/themes/$ZSH_THEME.zsh-theme"
fi
N=${#themes[@]}
((N=(RANDOM%N)+1))
RANDOM_THEME=${themes[$N]}
source "$RANDOM_THEME"
echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..."
else
if [ ! "$ZSH_THEME" = "" ]; then
if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then
source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then
source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
else
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
fi
fi fi
fi fi
# alias-finder plugin
This plugin searches the defined aliases and outputs any that match the command inputted. This makes learning new aliases easier.
To use it, add `alias-finder` to the `plugins` array of your zshrc file:
```
plugins=(... alias-finder)
```
## Usage
To see if there is an alias defined for the command, pass it as an argument to `alias-finder`. This can also run automatically before each command you input - add `ZSH_ALIAS_FINDER_AUTOMATIC=true` to your zshrc if you want this.
## Options
- Use `--longer` or `-l` to allow the aliases to be longer than the input (match aliases if they contain the input).
- Use `--exact` or `-e` to avoid matching aliases that are shorter than the input.
## Examples
```
$ alias-finder "git pull"
gl='git pull'
g=git
```
```
$ alias-finder "web_search google oh my zsh"
google='web_search google'
```
```
$ alias-finder "git commit -v"
gc="git commit -v"
g=git
```
```
$ alias-finder -e "git commit -v"
gc='git commit -v'
```
```
$ alias-finder -l "git commit -v"
gc='git commit -v'
'gc!'='git commit -v --amend'
gca='git commit -v -a'
'gca!'='git commit -v -a --amend'
'gcan!'='git commit -v -a --no-edit --amend'
'gcans!'='git commit -v -a -s --no-edit --amend'
'gcn!'='git commit -v --no-edit --amend'
```
alias-finder() {
local cmd="" exact="" longer="" wordStart="" wordEnd="" multiWordEnd=""
for i in $@; do
case $i in
-e|--exact) exact=true;;
-l|--longer) longer=true;;
*)
if [[ -z $cmd ]]; then
cmd=$i
else
cmd="$cmd $i"
fi
;;
esac
done
cmd=$(sed 's/[].\|$(){}?+*^[]/\\&/g' <<< $cmd) # adds escaping for grep
if (( $(wc -l <<< $cmd) == 1 )); then
while [[ $cmd != "" ]]; do
if [[ $longer = true ]]; then
wordStart="'{0,1}"
else
wordEnd="$"
multiWordEnd="'$"
fi
if [[ $cmd == *" "* ]]; then
local finder="'$cmd$multiWordEnd"
else
local finder=$wordStart$cmd$wordEnd
fi
alias | grep -E "=$finder"
if [[ $exact = true || $longer = true ]]; then
break
else
cmd=$(sed -E 's/ {0,1}[^ ]*$//' <<< $cmd) # removes last word
fi
done
fi
}
preexec_alias-finder() {
if [[ $ZSH_ALIAS_FINDER_AUTOMATIC = true ]]; then
alias-finder $1
fi
}
autoload -U add-zsh-hook
add-zsh-hook preexec preexec_alias-finder
## arcanist ## arcanist
**Maintainer:** [@emzar](https://github.com/emzar) This plugin adds many useful aliases for [arcanist](https://github.com/phacility/arcanist).
This plugin adds many useful aliases. To use it, add `arcanist` to the plugins array of your zshrc file:
```zsh
plugins=(... arcanist)
```
## Aliases
| Alias | Command |
|---------|------------------------------------|
| ara | `arc amend` |
| arb | `arc branch` |
| arco | `arc cover` |
| arci | `arc commit` |
| ard | `arc diff` |
| ardc | `arc diff --create` |
| ardnu | `arc diff --nounit` |
| ardnupc | `arc diff --nounit --plan-changes` |
| ardpc | `arc diff --plan-changes` |
| are | `arc export` |
| arh | `arc help` |
| arl | `arc land` |
| arli | `arc lint` |
| arls | `arc list` |
| arpa | `arc patch` |
...@@ -9,6 +9,7 @@ alias arco='arc cover' ...@@ -9,6 +9,7 @@ alias arco='arc cover'
alias arci='arc commit' alias arci='arc commit'
alias ard='arc diff' alias ard='arc diff'
alias ardc='arc diff --create'
alias ardnu='arc diff --nounit' alias ardnu='arc diff --nounit'
alias ardnupc='arc diff --nounit --plan-changes' alias ardnupc='arc diff --nounit --plan-changes'
alias ardpc='arc diff --plan-changes' alias ardpc='arc diff --plan-changes'
......
# Autoenv plugin
This plugin loads the [Autoenv](https://github.com/inishchith/autoenv).
To use it, add `autoenv` to the plugins array in your zshrc file:
```zsh
plugins=(... autoenv)
```
## Requirements
In order to make this work, you will need to have the autoenv installed.
More info on the usage and install: https://github.com/inishchith/autoenv
(( $+commands[autojump] )) || {
echo '[oh-my-zsh] Please install autojump first (https://github.com/wting/autojump)'
return
}
declare -a autojump_paths declare -a autojump_paths
autojump_paths=( autojump_paths=(
$HOME/.autojump/etc/profile.d/autojump.zsh # manual installation $HOME/.autojump/etc/profile.d/autojump.zsh # manual installation
......
...@@ -10,7 +10,8 @@ function asp() { ...@@ -10,7 +10,8 @@ function asp() {
return return
fi fi
local available_profiles=($(aws_profiles)) local -a available_profiles
available_profiles=($(aws_profiles))
if [[ -z "${available_profiles[(r)$1]}" ]]; then if [[ -z "${available_profiles[(r)$1]}" ]]; then
echo "${fg[red]}Profile '$1' not found in '${AWS_CONFIG_FILE:-$HOME/.aws/config}'" >&2 echo "${fg[red]}Profile '$1' not found in '${AWS_CONFIG_FILE:-$HOME/.aws/config}'" >&2
echo "Available profiles: ${(j:, :)available_profiles:-no profiles found}${reset_color}" >&2 echo "Available profiles: ${(j:, :)available_profiles:-no profiles found}${reset_color}" >&2
......
...@@ -7,23 +7,25 @@ ...@@ -7,23 +7,25 @@
# Email: neuralsandwich@gmail.com # # Email: neuralsandwich@gmail.com #
# Modified to add support for Apple Mac # # Modified to add support for Apple Mac #
########################################### ###########################################
# Author: J (927589452) #
# Modified to add support for FreeBSD #
###########################################
if [[ "$OSTYPE" = darwin* ]] ; then if [[ "$OSTYPE" = darwin* ]]; then
function battery_pct() { function battery_is_charging() {
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")" ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ Yes'
typeset -F maxcapacity=$(echo $smart_battery_status | grep '^.*"MaxCapacity"\ =\ ' | sed -e 's/^.*"MaxCapacity"\ =\ //')
typeset -F currentcapacity=$(echo $smart_battery_status | grep '^.*"CurrentCapacity"\ =\ ' | sed -e 's/^.*CurrentCapacity"\ =\ //')
integer i=$(((currentcapacity/maxcapacity) * 100))
echo $i
} }
function plugged_in() { function battery_pct() {
[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ Yes') -eq 1 ] local battery_status="$(ioreg -rc AppleSmartBattery)"
local -i capacity=$(sed -n -e '/MaxCapacity/s/^.*"MaxCapacity"\ =\ //p' <<< $battery_status)
local -i current=$(sed -n -e '/CurrentCapacity/s/^.*"CurrentCapacity"\ =\ //p' <<< $battery_status)
echo $(( current * 100 / capacity ))
} }
function battery_pct_remaining() { function battery_pct_remaining() {
if plugged_in ; then if battery_is_charging; then
echo "External Power" echo "External Power"
else else
battery_pct battery_pct
...@@ -32,9 +34,9 @@ if [[ "$OSTYPE" = darwin* ]] ; then ...@@ -32,9 +34,9 @@ if [[ "$OSTYPE" = darwin* ]] ; then
function battery_time_remaining() { function battery_time_remaining() {
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")" local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
if [[ $(echo $smart_battery_status | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then if [[ $(echo $smart_battery_status | command grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]]; then
timeremaining=$(echo $smart_battery_status | grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //') timeremaining=$(echo $smart_battery_status | command grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //')
if [ $timeremaining -gt 720 ] ; then if [ $timeremaining -gt 720 ]; then
echo "::" echo "::"
else else
echo "~$((timeremaining / 60)):$((timeremaining % 60))" echo "~$((timeremaining / 60)):$((timeremaining % 60))"
...@@ -45,39 +47,36 @@ if [[ "$OSTYPE" = darwin* ]] ; then ...@@ -45,39 +47,36 @@ if [[ "$OSTYPE" = darwin* ]] ; then
} }
function battery_pct_prompt () { function battery_pct_prompt () {
if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then local battery_pct color
b=$(battery_pct_remaining) if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then
if [ $b -gt 50 ] ; then battery_pct=$(battery_pct_remaining)
if [[ $battery_pct -gt 50 ]]; then
color='green' color='green'
elif [ $b -gt 20 ] ; then elif [[ $battery_pct -gt 20 ]]; then
color='yellow' color='yellow'
else else
color='red' color='red'
fi fi
echo "%{$fg[$color]%}[$(battery_pct_remaining)%%]%{$reset_color%}" echo "%{$fg[$color]%}[${battery_pct}%%]%{$reset_color%}"
else else
echo "∞" echo "∞"
fi fi
} }
function battery_is_charging() { elif [[ "$OSTYPE" = freebsd* ]]; then
[[ $(ioreg -rc "AppleSmartBattery"| grep '^.*"IsCharging"\ =\ ' | sed -e 's/^.*"IsCharging"\ =\ //') == "Yes" ]]
}
elif [[ "$OSTYPE" = linux* ]] ; then
function battery_is_charging() { function battery_is_charging() {
! [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] [[ $(sysctl -n hw.acpi.battery.state) -eq 2 ]]
} }
function battery_pct() { function battery_pct() {
if (( $+commands[acpi] )) ; then if (( $+commands[sysctl] )); then
echo "$(acpi 2>/dev/null | cut -f2 -d ',' | tr -cd '[:digit:]')" sysctl -n hw.acpi.battery.life
fi fi
} }
function battery_pct_remaining() { function battery_pct_remaining() {
if [ ! $(battery_is_charging) ] ; then if ! battery_is_charging; then
battery_pct battery_pct
else else
echo "External Power" echo "External Power"
...@@ -85,76 +84,128 @@ elif [[ "$OSTYPE" = linux* ]] ; then ...@@ -85,76 +84,128 @@ elif [[ "$OSTYPE" = linux* ]] ; then
} }
function battery_time_remaining() { function battery_time_remaining() {
if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then local remaining_time
echo $(acpi 2>/dev/null | cut -f3 -d ',') remaining_time=$(sysctl -n hw.acpi.battery.time)
if [[ $remaining_time -ge 0 ]]; then
((hour = $remaining_time / 60 ))
((minute = $remaining_time % 60 ))
printf %02d:%02d $hour $minute
fi fi
} }
function battery_pct_prompt() { function battery_pct_prompt() {
b=$(battery_pct_remaining) local battery_pct color
if [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then battery_pct=$(battery_pct_remaining)
if [ $b -gt 50 ] ; then if battery_is_charging; then
echo "∞"
else
if [[ $battery_pct -gt 50 ]]; then
color='green' color='green'
elif [ $b -gt 20 ] ; then elif [[ $battery_pct -gt 20 ]]; then
color='yellow' color='yellow'
else else
color='red' color='red'
fi fi
echo "%{$fg[$color]%}$(battery_pct_remaining)%%%{$reset_color%}" echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
else fi
echo "∞" }
elif [[ "$OSTYPE" = linux* ]]; then
function battery_is_charging() {
! acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -q '^Battery.*Discharging'
}
function battery_pct() {
if (( $+commands[acpi] )); then
acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -E '^Battery.*(Disc|C)harging' | cut -f2 -d ',' | tr -cd '[:digit:]'
fi fi
} }
else
# Empty functions so we don't cause errors in prompts
function battery_pct_remaining() { function battery_pct_remaining() {
if ! battery_is_charging; then
battery_pct
else
echo "External Power"
fi
} }
function battery_time_remaining() { function battery_time_remaining() {
if ! battery_is_charging; then
acpi 2>/dev/null | command grep -v "rate information unavailable" | cut -f3 -d ','
fi
} }
function battery_pct_prompt() { function battery_pct_prompt() {
local battery_pct color
battery_pct=$(battery_pct_remaining)
if battery_is_charging; then
echo "∞"
else
if [[ $battery_pct -gt 50 ]]; then
color='green'
elif [[ $battery_pct -gt 20 ]]; then
color='yellow'
else
color='red'
fi
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi
} }
else
# Empty functions so we don't cause errors in prompts
function battery_is_charging { false }
function battery_pct \
battery_pct_remaining \
battery_time_remaining \
battery_pct_prompt { }
fi fi
function battery_level_gauge() { function battery_level_gauge() {
local gauge_slots=${BATTERY_GAUGE_SLOTS:-10}; local gauge_slots=${BATTERY_GAUGE_SLOTS:-10}
local green_threshold=${BATTERY_GREEN_THRESHOLD:-6}; local green_threshold=${BATTERY_GREEN_THRESHOLD:-$(( gauge_slots * 0.6 ))}
local yellow_threshold=${BATTERY_YELLOW_THRESHOLD:-4}; local yellow_threshold=${BATTERY_YELLOW_THRESHOLD:-$(( gauge_slots * 0.4 ))}
local color_green=${BATTERY_COLOR_GREEN:-%F{green}}; local color_green=${BATTERY_COLOR_GREEN:-%F{green}}
local color_yellow=${BATTERY_COLOR_YELLOW:-%F{yellow}}; local color_yellow=${BATTERY_COLOR_YELLOW:-%F{yellow}}
local color_red=${BATTERY_COLOR_RED:-%F{red}}; local color_red=${BATTERY_COLOR_RED:-%F{red}}
local color_reset=${BATTERY_COLOR_RESET:-%{%f%k%b%}}; local color_reset=${BATTERY_COLOR_RESET:-%{%f%k%b%}}
local battery_prefix=${BATTERY_GAUGE_PREFIX:-'['}; local battery_prefix=${BATTERY_GAUGE_PREFIX:-'['}
local battery_suffix=${BATTERY_GAUGE_SUFFIX:-']'}; local battery_suffix=${BATTERY_GAUGE_SUFFIX:-']'}
local filled_symbol=${BATTERY_GAUGE_FILLED_SYMBOL:-'▶'}; local filled_symbol=${BATTERY_GAUGE_FILLED_SYMBOL:-'▶'}
local empty_symbol=${BATTERY_GAUGE_EMPTY_SYMBOL:-'▷'}; local empty_symbol=${BATTERY_GAUGE_EMPTY_SYMBOL:-'▷'}
local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow}; local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow}
local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'}; local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'}
local battery_remaining_percentage=$(battery_pct); local battery_remaining_percentage=$(battery_pct)
local filled empty gauge_color
if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then
local filled=$(((( $battery_remaining_percentage + $gauge_slots - 1) / $gauge_slots))); filled=$(( ($battery_remaining_percentage * $gauge_slots) / 100 ))
local empty=$(($gauge_slots - $filled)); empty=$(( $gauge_slots - $filled ))
if [[ $filled -gt $green_threshold ]]; then local gauge_color=$color_green; if [[ $filled -gt $green_threshold ]]; then
elif [[ $filled -gt $yellow_threshold ]]; then local gauge_color=$color_yellow; gauge_color=$color_green
else local gauge_color=$color_red; elif [[ $filled -gt $yellow_threshold ]]; then
gauge_color=$color_yellow
else
gauge_color=$color_red
fi fi
else else
local filled=$gauge_slots; filled=$gauge_slots
local empty=0; empty=0
filled_symbol=${BATTERY_UNKNOWN_SYMBOL:-'.'}; filled_symbol=${BATTERY_UNKNOWN_SYMBOL:-'.'}
fi fi
local charging=' ' && battery_is_charging && charging=$charging_symbol; local charging=' '
battery_is_charging && charging=$charging_symbol
# Charging status and prefix
printf ${charging_color//\%/\%\%}$charging${color_reset//\%/\%\%}${battery_prefix//\%/\%\%}${gauge_color//\%/\%\%} printf ${charging_color//\%/\%\%}$charging${color_reset//\%/\%\%}${battery_prefix//\%/\%\%}${gauge_color//\%/\%\%}
printf ${filled_symbol//\%/\%\%}'%.0s' {1..$filled} # Filled slots
[[ $filled -gt 0 ]] && printf ${filled_symbol//\%/\%\%}'%.0s' {1..$filled}
# Empty slots
[[ $filled -lt $gauge_slots ]] && printf ${empty_symbol//\%/\%\%}'%.0s' {1..$empty} [[ $filled -lt $gauge_slots ]] && printf ${empty_symbol//\%/\%\%}'%.0s' {1..$empty}
# Suffix
printf ${color_reset//\%/\%\%}${battery_suffix//\%/\%\%}${color_reset//\%/\%\%} printf ${color_reset//\%/\%\%}${battery_suffix//\%/\%\%}${color_reset//\%/\%\%}
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
- adds completion for basic bundler commands - adds completion for basic bundler commands
- adds short aliases for common bundler commands - adds short aliases for common bundler commands
- `be` aliased to `bundle exec`. - `be` aliased to `bundle exec`.
It also supports aliases (if `rs` is `rails server`, `be rs` will bundle-exec `rails server`). It also supports aliases (if `rs` is `rails server`, `be rs` will bundle-exec `rails server`).
- `bl` aliased to `bundle list` - `bl` aliased to `bundle list`
- `bp` aliased to `bundle package` - `bp` aliased to `bundle package`
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
- calls `bundle exec <gem executable>` otherwise - calls `bundle exec <gem executable>` otherwise
Common gems wrapped by default (by name of the executable): Common gems wrapped by default (by name of the executable):
`annotate`, `cap`, `capify`, `cucumber`, `foodcritic`, `guard`, `hanami`, `irb`, `jekyll`, `kitchen`, `knife`, `middleman`, `nanoc`, `pry`, `puma`, `rackup`, `rainbows`, `rake`, `rspec`, `shotgun`, `sidekiq`, `spec`, `spork`, `spring`, `strainer`, `tailor`, `taps`, `thin`, `thor`, `unicorn` and `unicorn_rails`. `annotate`, `cap`, `capify`, `cucumber`, `foodcritic`, `guard`, `hanami`, `irb`, `jekyll`, `kitchen`, `knife`, `middleman`, `nanoc`, `pry`, `puma`, `rackup`, `rainbows`, `rake`, `rspec`, `rubocop`, `shotgun`, `sidekiq`, `spec`, `spork`, `spring`, `strainer`, `tailor`, `taps`, `thin`, `thor`, `unicorn` and `unicorn_rails`.
## Configuration ## Configuration
...@@ -42,7 +42,7 @@ This will exclude the `foreman` and `spin` gems (i.e. their executable) from bei ...@@ -42,7 +42,7 @@ This will exclude the `foreman` and `spin` gems (i.e. their executable) from bei
## Excluded gems ## Excluded gems
These gems should not be called with `bundle exec`. Please see [issue #2923](https://github.com/robbyrussell/oh-my-zsh/pull/2923) on GitHub for clarification. These gems should not be called with `bundle exec`. Please see [issue #2923](https://github.com/ohmyzsh/ohmyzsh/pull/2923) on GitHub for clarification.
`berks` `berks`
`foreman` `foreman`
......
...@@ -27,6 +27,7 @@ bundled_commands=( ...@@ -27,6 +27,7 @@ bundled_commands=(
rainbows rainbows
rake rake
rspec rspec
rubocop
shotgun shotgun
sidekiq sidekiq
spec spec
...@@ -81,7 +82,7 @@ _bundler-installed() { ...@@ -81,7 +82,7 @@ _bundler-installed() {
_within-bundled-project() { _within-bundled-project() {
local check_dir="$PWD" local check_dir="$PWD"
while [ "$check_dir" != "/" ]; do while [ "$check_dir" != "/" ]; do
[ -f "$check_dir/Gemfile" ] && return [ -f "$check_dir/Gemfile" -o -f "$check_dir/gems.rb" ] && return
check_dir="$(dirname $check_dir)" check_dir="$(dirname $check_dir)"
done done
false false
...@@ -94,7 +95,7 @@ _binstubbed() { ...@@ -94,7 +95,7 @@ _binstubbed() {
_run-with-bundler() { _run-with-bundler() {
if _bundler-installed && _within-bundled-project; then if _bundler-installed && _within-bundled-project; then
if _binstubbed $1; then if _binstubbed $1; then
./bin/$@ ./bin/${^^@}
else else
bundle exec $@ bundle exec $@
fi fi
......
# Bwana
This plugin provides a function to open `man` pages directly with [Bwana](https://www.bruji.com/bwana/).
To use it add bwana to the plugins array in your zshrc file.
```bash
plugins=(... bwana)
```
The `bwana` function opens the man page of the passed argument in the Bwana app.
For example: `bwana ln` opens the man page for `ln` in Bwana.
#
# Requires https://www.bruji.com/bwana/
#
if [[ -e /Applications/Bwana.app ]] ||
( system_profiler -detailLevel mini SPApplicationsDataType | grep -q Bwana )
then
function bwana() {
open "man:$1"
}
else
echo "Bwana lets you read man files in Safari through a man: URI scheme"
echo "To use it within Zsh, install it from https://www.bruji.com/bwana/"
fi
# cakephp3 plugin
The plugin adds aliases and autocompletion for [cakephp3](https://book.cakephp.org/3.0/en/index.html).
To use it, add `cakephp3` to the plugins array of your zshrc file:
```
plugins=(... cakephp3)
```
## Aliases
| Alias | Command |
|-----------|-------------------------------|
| c3 | `bin/cake` |
| c3cache | `bin/cake orm_cache clear` |
| c3migrate | `bin/cake migrations migrate` |
This diff is collapsed.
...@@ -17,10 +17,10 @@ Plugin for displaying images on the terminal using the the `catimg.sh` script pr ...@@ -17,10 +17,10 @@ Plugin for displaying images on the terminal using the the `catimg.sh` script pr
) )
``` ```
2. Reload the source file or restart your Terminal session: 2. Restart the shell or restart your Terminal session:
```console ```console
$ source ~/.zshrc $ exec zsh
$ $
``` ```
......
# chruby plugin
This plugin loads [chruby](https://github.com/postmodern/chruby), a tool that changes the
current Ruby version, and completion and a prompt function to display the Ruby version.
Supports brew and manual installation of chruby.
To use it, add `chruby` to the plugins array in your zshrc file:
```zsh
plugins=(... chruby)
```
## Usage
If you'd prefer to specify an explicit path to load chruby from
you can set variables like so:
```
zstyle :omz:plugins:chruby path /local/path/to/chruby.sh
zstyle :omz:plugins:chruby auto /local/path/to/auto.sh
```
# CloudApp plugin
[CloudApp](https://www.getcloudapp.com) brings screen recording, screenshots, and GIF creation to the cloud, in an easy-to-use enterprise-level app. The CloudApp plugin allows you to upload a file to your CloadApp account from the command line.
To use it, add `cloudapp` to the plugins array of your `~/.zshrc` file:
```
plugins=(... cloudapp)
```
## Requirements
1. [Aaron Russell's `cloudapp_api` gem](https://github.com/aaronrussell/cloudapp_api#installation)
2. That you set your CloudApp credentials in `~/.cloudapp` as a simple text file like below:
```
email
password
```
## Usage
- `cloudapp <filename>`: uploads `<filename>` to your CloudApp account, and if you're using
macOS, copies the URL to your clipboard.
# codeclimate plugin
This plugin adds autocompletion for the [`codeclimate` CLI](https://github.com/codeclimate/codeclimate).
To use it, add `codeclimate` to the plugins array in your zshrc file:
```zsh
plugins=(... codeclimate)
```
# Colemak plugin
This plugin remaps keys in `zsh`'s [`vi`-style navigation mode](http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Keymaps)
for a [Colemak](https://colemak.com/) keyboard layout, to match the QWERTY position:
![Colemak layout on a US keyboard](https://colemak.com/wiki/images/6/6c/Colemak2.png)
To use it, add it to the plugins array in your `~/.zshrc` file:
```
plugins=(... colemak)
```
You will also need to enable `vi` mode, so add another line to `~/.zshrc`:
```
bindkey -v
```
Restart your shell and hit the `<ESC>` key to activate `vicmd` (navigation) mode,
and start navigating `zsh` with your new keybindings!
## Key bindings for vicmd
| Old | New | Binding | Description |
|------------|------------|---------------------------|----------------------------------------------------|
| `CTRL`+`j` | `CTRL`+`n` | accept-line | Insert new line |
| `j` | `n` | down-line-or-history | Move one line down or command history forwards |
| `k` | `e` | up-line-or-history | Move one line up or command history backwards |
| `l` | `i` | vi-forward-char | Move one character to the right |
| `n` | `k` | vi-repeat-search | Repeat command search forwards |
| `N` | `K` | vi-rev-repeat-search | Repeat command search backwards |
| `i` | `u` | vi-insert | Enter insert mode |
| `I` | `U` | vi-insert-bol | Move to first non-blank char and enter insert mode |
| `<none>` | `l` | vi-undo-change | Undo change |
| `J` | `N` | vi-join | Join the current line with the next one |
| `e` | `j` | vi-forward-word-end | Move to the end of the next word |
| `E` | `J` | vi-forward-blank-word-end | Move to end of the current or next word |
## Key bindings for less
| Keyboard shortcut | `less` key binding |
|-------------------|--------------------|
| `n` | forw-line |
| `e` | back-line |
| `k` | repeat-search |
| `ESC`+`k` | repeat-search-all |
| `K` | reverse-search |
| `ESC`+`K` | reverse-search-all |
# Colored man pages plugin
This plugin adds colors to man pages.
To use it, add `colored-man-pages` to the plugins array in your zshrc file:
```zsh
plugins=(... colored-man-pages)
```
You can also try to color other pages by prefixing the respective command with `colored`:
```zsh
colored git help clone
```
...@@ -16,8 +16,8 @@ EOF ...@@ -16,8 +16,8 @@ EOF
fi fi
fi fi
function man() { function colored() {
env \ command env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \ LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \ LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \ LESS_TERMCAP_me=$(printf "\e[0m") \
...@@ -28,5 +28,9 @@ function man() { ...@@ -28,5 +28,9 @@ function man() {
PAGER="${commands[less]:-$PAGER}" \ PAGER="${commands[less]:-$PAGER}" \
_NROFF_U=1 \ _NROFF_U=1 \
PATH="$HOME/bin:$PATH" \ PATH="$HOME/bin:$PATH" \
man "$@" "$@"
}
function man() {
colored man "$@"
} }
...@@ -6,30 +6,43 @@ Colorize will highlight the content based on the filename extension. If it can't ...@@ -6,30 +6,43 @@ Colorize will highlight the content based on the filename extension. If it can't
method for a given extension, it will try to find one by looking at the file contents. If no highlight method method for a given extension, it will try to find one by looking at the file contents. If no highlight method
is found it will just cat the file normally, without syntax highlighting. is found it will just cat the file normally, without syntax highlighting.
To use it, add colorize to the plugins array of your zshrc file: ## Setup
To use it, add colorize to the plugins array of your `~/.zshrc` file:
``` ```
plugins=(... colorize) plugins=(... colorize)
``` ```
## Styles ## Configuration
Pygments offers multiple styles. By default, the `default` style is used, but you can choose another theme by setting the `ZSH_COLORIZE_STYLE` environment variable: ### Requirements
`ZSH_COLORIZE_STYLE="colorful"` This plugin requires that at least one of the following tools is installed:
## Usage * [Chroma](https://github.com/alecthomas/chroma)
* [Pygments](https://pygments.org/download/)
### Colorize tool
* `ccat <file> [files]`: colorize the contents of the file (or files, if more than one are provided). Colorize supports `pygmentize` and `chroma` as syntax highlighter. By default colorize uses `pygmentize` unless it's not installed and `chroma` is. This can be overridden by the `ZSH_COLORIZE_TOOL` environment variable:
If no arguments are passed it will colorize the standard input or stdin.
```
ZSH_COLORIZE_TOOL=chroma
```
* `cless <file> [files]`: colorize the contents of the file (or files, if more than one are provided) and ### Styles
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 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:
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. ZSH_COLORIZE_STYLE="colorful"
```
## Usage
## Requirements * `ccat <file> [files]`: colorize the contents of the file (or files, if more than one are provided).
If no files are passed it will colorize the standard input.
You have to install Pygments first: [pygments.org](http://pygments.org/download/) * `cless [less-options] <file> [files]`: colorize the contents of the file (or files, if more than one are provided) and open less.
If no files are passed it will colorize the standard input.
The LESSOPEN and LESSCLOSE will be overwritten for this to work, but only in a local scope.
# easier alias to use the plugin # Easier alias to use the plugin
alias ccat='colorize_via_pygmentize' alias ccat="colorize_cat"
alias cless='colorize_via_pygmentize_less' alias cless="colorize_less"
colorize_via_pygmentize() { # '$0:A' gets the absolute path of this file
if ! (( $+commands[pygmentize] )); then ZSH_COLORIZE_PLUGIN_PATH=$0:A
echo "package 'Pygments' is not installed!"
colorize_check_requirements() {
local available_tools=("chroma" "pygmentize")
if [ -z "$ZSH_COLORIZE_TOOL" ]; then
if (( $+commands[pygmentize] )); then
ZSH_COLORIZE_TOOL="pygmentize"
elif (( $+commands[chroma] )); then
ZSH_COLORIZE_TOOL="chroma"
else
echo "Neither 'pygments' nor 'chroma' is installed!" >&2
return 1
fi
fi
if [[ ${available_tools[(Ie)$ZSH_COLORIZE_TOOL]} -eq 0 ]]; then
echo "ZSH_COLORIZE_TOOL '$ZSH_COLORIZE_TOOL' not recognized. Available options are 'pygmentize' and 'chroma'." >&2
return 1
elif (( $+commands["$ZSH_COLORIZE_TOOL"] )); then
echo "Package '$ZSH_COLORIZE_TOOL' is not installed!" >&2
return 1
fi
}
colorize_cat() {
if ! colorize_check_requirements; then
return 1 return 1
fi fi
# If the environment varianle ZSH_COLORIZE_STYLE # If the environment variable ZSH_COLORIZE_STYLE
# is set, use that theme instead. Otherwise, # is set, use that theme instead. Otherwise,
# use the default. # use the default.
if [ -z $ZSH_COLORIZE_STYLE ]; then if [ -z "$ZSH_COLORIZE_STYLE" ]; then
ZSH_COLORIZE_STYLE="default" # Both pygmentize & chroma support 'emacs'
ZSH_COLORIZE_STYLE="emacs"
fi fi
# pygmentize stdin if no arguments passed # Use stdin if no arguments have been passed.
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g
else
chroma --style="$ZSH_COLORIZE_STYLE"
fi
return $? return $?
fi fi
# guess lexer from file extension, or # Guess lexer from file extension, or guess it from file contents if unsuccessful.
# guess it from file contents if unsuccessful
local FNAME lexer local FNAME lexer
for FNAME in "$@" for FNAME in "$@"; do
do if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then
lexer=$(pygmentize -N "$FNAME") lexer=$(pygmentize -N "$FNAME")
if [[ $lexer != text ]]; then if [[ $lexer != text ]]; then
pygmentize -O style="$ZSH_COLORIZE_STYLE" -l "$lexer" "$FNAME" pygmentize -O style="$ZSH_COLORIZE_STYLE" -l "$lexer" "$FNAME"
else
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g "$FNAME"
fi
else else
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g "$FNAME" chroma --style="$ZSH_COLORIZE_STYLE" "$FNAME"
fi fi
done done
} }
colorize_via_pygmentize_less() ( # The less option 'F - Forward forever; like "tail -f".' will not work in this implementation
# this function is a subshell so tmp_files can be shared to cleanup function # caused by the lack of the ability to follow the file within pygmentize.
declare -a tmp_files colorize_less() {
if ! colorize_check_requirements; then
return 1
fi
cleanup () { _cless() {
[[ ${#tmp_files} -gt 0 ]] && rm -f "${tmp_files[@]}" # LESS="-R $LESS" enables raw ANSI colors, while maintain already set options.
exit local LESS="-R $LESS"
}
trap 'cleanup' EXIT HUP TERM INT
while (( $# != 0 )); do #TODO: filter out less opts # This variable tells less to pipe every file through the specified command
tmp_file="$(mktemp -t "tmp.colorize.XXXX.$(sed 's/\//./g' <<< "$1")")" # (see the man page of less INPUT PREPROCESSOR).
tmp_files+=("$tmp_file") # 'zsh -ic "colorize_cat %s 2> /dev/null"' would not work for huge files like
colorize_via_pygmentize "$1" > "$tmp_file" # the ~/.zsh_history. For such files the tty of the preprocessor will be supended.
shift 1 # Therefore we must source this file to make colorize_cat available in the
done # preprocessor without the interactive mode.
# `2>/dev/null` will suppress the error for large files 'broken pipe' of the python
# script pygmentize, which will show up if less has not fully "loaded the file"
# (e.g. when not scrolled to the bottom) while already the next file will be displayed.
local LESSOPEN="| zsh -c 'source \"$ZSH_COLORIZE_PLUGIN_PATH\"; \
ZSH_COLORIZE_TOOL=$ZSH_COLORIZE_TOOL ZSH_COLORIZE_STYLE=$ZSH_COLORIZE_STYLE \
colorize_cat %s 2> /dev/null'"
less -f "${tmp_files[@]}" # LESSCLOSE will be set to prevent any errors by executing a user script
) # which assumes that his LESSOPEN has been executed.
local LESSCLOSE=""
LESS="$LESS" LESSOPEN="$LESSOPEN" LESSCLOSE="$LESSCLOSE" less "$@"
}
if [ -t 0 ]; then
_cless "$@"
else
# The input is not associated with a terminal, therefore colorize_cat will
# colorize this input and pass it to less.
# Less has now to decide what to use. If any files have been provided, less
# will ignore the input by default, otherwise the colorized input will be used.
# If files have been supplied and the input has been redirected, this will
# lead to unnecessary overhead, but retains the ability to use the less options
# without checking for them inside this script.
colorize_cat | _cless "$@"
fi
}
# Common Aliases Plugin
This plugin creates helpful shortcut aliases for many commonly used commands.
To use it add `common-aliases` to the plugins array in your zshrc file:
```zsh
plugins=(... common-aliases)
```
## Aliases
### ls command
| Alias | Command | Description |
|-------|---------------|--------------------------------------------------------------------------------|
| l | `ls -lFh` | List files as a long list, show size, type, human-readable |
| la | `ls -lAFh` | List almost all files as a long list show size, type, human-readable |
| lr | `ls -tRFh` | List files recursively sorted by date, show type, human-readable |
| lt | `ls -ltFh` | List files as a long list sorted by date, show type, human-readable |
| ll | `ls -l` | List files as a long list |
| ldot | `ls -ld .*` | List dot files as a long list |
| lS | `ls -1FSsh` | List files showing only size and name sorted by size |
| lart | `ls -1Fcart` | List all files sorted in reverse of create/modification time (oldest first) |
| lrt | `ls -1Fcrt` | List files sorted in reverse of create/modification time(oldest first) |
### File handling
| Alias | Command | Description |
|-------|-----------------------|------------------------------------------------------------------------------------|
| rm | `rm -i` | Remove a file |
| cp | `cp -i` | Copy a file |
| mv | `mv -i` | Move a file |
| zshrc | `${=EDITOR} ~/.zshrc` | Quickly access the ~/.zshrc file |
| dud | `du -d 1 -h` | Display the size of files at depth 1 in current location in human-readable form |
| duf | `du -sh` | Display the size of files in current location in human-readable form |
| t | `tail -f` | Shorthand for tail which outputs the last part of a file |
### find and grep
| Alias | Command | Description |
|-------|-----------------------------------------------------|-----------------------------------------|
| fd | `find . -type d -name` | Find a directory with the given name |
| ff | `find . -type f -name` | Find a file with the given name |
| grep | `grep --color` | Searches for a query string |
| sgrep | `grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS}` | Useful for searching within files |
### Other Aliases
| Alias | Command | Description |
|-----------|---------------------|-------------------------------------------------------------|
| h | `history` | Lists all recently used commands |
| hgrep | `fc -El 0 \| grep` | Searches for a word in the list of previously used commands |
| help | `man` | Opens up the man page for a command |
| p | `ps -f` | Displays currently executing processes |
| sortnr | `sort -n -r` | Used to sort the lines of a text file |
| unexport | `unset` | Used to unset an environment variable |
## Global aliases
These aliases are expanded in any position in the command line, meaning you can use them even at the
end of the command you've typed. Examples:
Quickly pipe to less:
```zsh
$ ls -l /var/log L
# will run
$ ls -l /var/log | less
```
Silences stderr output:
```zsh
$ find . -type f NE
# will run
$ find . -type f 2>/dev/null
```
| Alias | Command | Description |
|-------|-----------------------------|-------------------------------------------------------------|
| H | `\| head` | Pipes output to head which outputs the first part of a file |
| T | `\| tail` | Pipes output to tail which outputs the last part of a file |
| G | `\| grep` | Pipes output to grep to search for some word |
| L | `\| less` | Pipes output to less, useful for paging |
| M | `\| most` | Pipes output to more, useful for paging |
| LL | `2>&1 \| less` | Writes stderr to stdout and passes it to less |
| CA | `2>&1 \| cat -A` | Writes stderr to stdout and passes it to cat |
| NE | `2 > /dev/null` | Silences stderr |
| NUL | `> /dev/null 2>&1` | Silences both stdout and stderr |
| P | `2>&1\| pygmentize -l pytb` | Writes stderr to stdout and passes it to pygmentize |
## File extension aliases
These are special aliases that are triggered when a file name is passed as the command. For example,
if the pdf file extension is aliased to `acroread` (a popular Linux pdf reader), when running `file.pdf`
that file will be open with `acroread`.
### Reading Docs
| Alias | Command | Description |
|-------|-------------|-------------------------------------|
| pdf | `acroread` | Opens up a document using acroread |
| ps | `gv` | Opens up a .ps file using gv |
| dvi | `xdvi` | Opens up a .dvi file using xdvi |
| chm | `xchm` | Opens up a .chm file using xchm |
| djvu | `djview` | Opens up a .djvu file using djview |
### Listing files inside a packed file
| Alias | Command | Description |
|---------|-------------|-------------------------------------|
| zip | `unzip -l` | Lists files inside a .zip file |
| rar | `unrar l` | Lists files inside a .rar file |
| tar | `tar tf` | Lists files inside a .tar file |
| tar.gz | `echo` | Lists files inside a .tar.gz file |
| ace | `unace l` | Lists files inside a .ace file |
### Some other features
- Opens urls in terminal using browser specified by the variable `$BROWSER`
- Opens C, C++, Tex and text files using editor specified by the variable `$EDITOR`
- Opens images using image viewer specified by the variable `$XIVIEWER`
- Opens videos and other media using mplayer
...@@ -50,6 +50,7 @@ alias mv='mv -i' ...@@ -50,6 +50,7 @@ alias mv='mv -i'
# zsh is able to auto-do some kungfoo # zsh is able to auto-do some kungfoo
# depends on the SUFFIX :) # depends on the SUFFIX :)
autoload -Uz is-at-least
if is-at-least 4.2.0; then if is-at-least 4.2.0; then
# open browser on urls # open browser on urls
if [[ -n "$BROWSER" ]]; then if [[ -n "$BROWSER" ]]; then
......
# compleat plugin
This plugin looks for [compleat](https://github.com/mbrubeck/compleat) and loads its completion.
To use it, add compleat to the plugins array in your zshrc file:
```
plugins=(... compleat)
```
# copy the active line from the command line buffer # copy the active line from the command line buffer
# onto the system clipboard (requires clipcopy plugin) # onto the system clipboard
copybuffer () { copybuffer () {
if which clipcopy &>/dev/null; then if which clipcopy &>/dev/null; then
echo $BUFFER | clipcopy printf "%s" "$BUFFER" | clipcopy
else else
echo "clipcopy function not found. Please make sure you have Oh My Zsh installed correctly." echo "clipcopy function not found. Please make sure you have Oh My Zsh installed correctly."
fi fi
......
# Dash plugin
This plugin adds command line functionality for [Dash](https://kapeli.com/dash),
an API Documentation Browser for macOS. This plugin requires Dash to be installed
to work.
To use it, add `dash` to the plugins array in your zshrc file:
```zsh
plugins=(... dash)
```
## Usage
- Open and switch to the dash application.
```
dash
```
- Query for something in dash app: `dash query`
```
dash golang
```
- You can optionally provide a keyword: `dash [keyword:]query`
```
dash python:tuple
```
...@@ -35,36 +35,30 @@ _dash() { ...@@ -35,36 +35,30 @@ _dash() {
if [[ "$locator" == "platform" ]]; then if [[ "$locator" == "platform" ]]; then
# Since these are the only special cases right now, let's not do the # Since these are the only special cases right now, let's not do the
# expensive processing unless we have to # expensive processing unless we have to
if [[ "$keyword" == "python" || "$keyword" == "java" || \ if [[ "$keyword" = (python|java|qt|cocos2d) ]]; then
"$keyword" == "qt" || "$keyword" == "cocs2d" ]]; then
docsetName=`echo $doc | grep -Eo "docsetName = .*?;" | sed -e "s/docsetName = \(.*\);/\1/" -e "s/[\":]//g"` docsetName=`echo $doc | grep -Eo "docsetName = .*?;" | sed -e "s/docsetName = \(.*\);/\1/" -e "s/[\":]//g"`
if [[ "$keyword" == "python" ]]; then case "$keyword" in
if [[ "$docsetName" == "Python 2" ]]; then python)
keyword="python2" case "$docsetName" in
elif [[ "$docsetName" == "Python 3" ]]; then "Python 2") keyword="python2" ;;
keyword="python3" "Python 3") keyword="python3" ;;
fi esac ;;
elif [[ "$keyword" == "java" ]]; then java)
if [[ "$docsetName" == "Java SE7" ]]; then case "$docsetName" in
keyword="java7" "Java SE7") keyword="java7" ;;
elif [[ "$docsetName" == "Java SE6" ]]; then "Java SE6") keyword="java6" ;;
keyword="java6" "Java SE8") keyword="java8" ;;
elif [[ "$docsetName" == "Java SE8" ]]; then esac ;;
keyword="java8" qt)
fi case "$docsetName" in
elif [[ "$keyword" == "qt" ]]; then "Qt 5") keyword="qt5" ;;
if [[ "$docsetName" == "Qt 5" ]]; then "Qt 4"|Qt) keyword="qt4" ;;
keyword="qt5" esac ;;
elif [[ "$docsetName" == "Qt 4" ]]; then cocos2d)
keyword="qt4" case "$docsetName" in
elif [[ "$docsetName" == "Qt" ]]; then Cocos3D) keyword="cocos3d" ;;
keyword="qt4" esac ;;
fi esac
elif [[ "$keyword" == "cocos2d" ]]; then
if [[ "$docsetName" == "Cocos3D" ]]; then
keyword="cocos3d"
fi
fi
fi fi
fi fi
......
...@@ -72,7 +72,7 @@ if [[ $use_sudo -eq 1 ]]; then ...@@ -72,7 +72,7 @@ if [[ $use_sudo -eq 1 ]]; then
# commands using su ######### # commands using su #########
else else
alias aac="su -ls '$apt_pref autoclean' root" alias aac="su -ls '$apt_pref autoclean' root"
abd() { function abd() {
cmd="su -lc '$apt_pref build-dep $@' root" cmd="su -lc '$apt_pref build-dep $@' root"
print "$cmd" print "$cmd"
eval "$cmd" eval "$cmd"
...@@ -83,17 +83,17 @@ else ...@@ -83,17 +83,17 @@ else
alias adu="su -lc '$apt_pref update && aptitude dist-upgrade' root" alias adu="su -lc '$apt_pref update && aptitude dist-upgrade' root"
alias afu="su -lc '$apt-file update'" alias afu="su -lc '$apt-file update'"
alias au="su -lc '$apt_pref $apt_upgr' root" alias au="su -lc '$apt_pref $apt_upgr' root"
ai() { function ai() {
cmd="su -lc 'aptitude -P install $@' root" cmd="su -lc 'aptitude -P install $@' root"
print "$cmd" print "$cmd"
eval "$cmd" eval "$cmd"
} }
ap() { function ap() {
cmd="su -lc '$apt_pref -P purge $@' root" cmd="su -lc '$apt_pref -P purge $@' root"
print "$cmd" print "$cmd"
eval "$cmd" eval "$cmd"
} }
ar() { function ar() {
cmd="su -lc '$apt_pref -P remove $@' root" cmd="su -lc '$apt_pref -P remove $@' root"
print "$cmd" print "$cmd"
eval "$cmd" eval "$cmd"
...@@ -114,7 +114,7 @@ fi ...@@ -114,7 +114,7 @@ fi
# Registers a compdef for $1 that calls $apt_pref with the commands $2 # Registers a compdef for $1 that calls $apt_pref with the commands $2
# To do that it creates a new completion function called _apt_pref_$2 # To do that it creates a new completion function called _apt_pref_$2
# #
apt_pref_compdef() { function apt_pref_compdef() {
local f fb local f fb
f="_apt_pref_${2}" f="_apt_pref_${2}"
...@@ -151,7 +151,7 @@ alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc' ...@@ -151,7 +151,7 @@ alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc'
# Functions ################################################################# # Functions #################################################################
# create a simple script that can be used to 'duplicate' a system # create a simple script that can be used to 'duplicate' a system
apt-copy() { function apt-copy() {
print '#!/bin/sh'"\n" > apt-copy.sh print '#!/bin/sh'"\n" > apt-copy.sh
cmd='$apt_pref install' cmd='$apt_pref install'
...@@ -173,7 +173,7 @@ apt-copy() { ...@@ -173,7 +173,7 @@ apt-copy() {
# apt-history rollback # apt-history rollback
# apt-history list # apt-history list
# Based On: https://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html # Based On: https://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html
apt-history () { function apt-history() {
case "$1" in case "$1" in
install) install)
zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*) zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*)
...@@ -202,7 +202,7 @@ apt-history () { ...@@ -202,7 +202,7 @@ apt-history () {
} }
# Kernel-package building shortcut # Kernel-package building shortcut
kerndeb () { function kerndeb() {
# temporarily unset MAKEFLAGS ( '-j3' will fail ) # temporarily unset MAKEFLAGS ( '-j3' will fail )
MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' ) MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' )
print '$MAKEFLAGS set to '"'$MAKEFLAGS'" print '$MAKEFLAGS set to '"'$MAKEFLAGS'"
...@@ -216,10 +216,9 @@ kerndeb () { ...@@ -216,10 +216,9 @@ kerndeb () {
} }
# List packages by size # List packages by size
function apt-list-packages { function apt-list-packages() {
dpkg-query -W --showformat='${Installed-Size} ${Package} ${Status}\n' | \ dpkg-query -W --showformat='${Installed-Size} ${Package} ${Status}\n' | \
grep -v deinstall | \ grep -v deinstall | \
sort -n | \ sort -n | \
awk '{print $1" "$2}' awk '{print $1" "$2}'
} }
...@@ -15,10 +15,10 @@ This plugin enables directory navigation similar to using back and forward on br ...@@ -15,10 +15,10 @@ This plugin enables directory navigation similar to using back and forward on br
) )
``` ```
2. Reload the source file or restart your Terminal session: 2. Restart the shell or restart your Terminal session:
```console ```console
$ source ~/.zshrc $ exec zsh
$ $
``` ```
......
...@@ -53,7 +53,8 @@ function push_future() { ...@@ -53,7 +53,8 @@ function push_future() {
} }
# Called by zsh when directory changes # Called by zsh when directory changes
chpwd_functions+=(chpwd_dirhistory) autoload -U add-zsh-hook
add-zsh-hook chpwd chpwd_dirhistory
function chpwd_dirhistory() { function chpwd_dirhistory() {
push_past $PWD push_past $PWD
# If DIRHISTORY_CD is not set... # If DIRHISTORY_CD is not set...
......
...@@ -11,7 +11,8 @@ if [[ -f ${dirstack_file} ]] && [[ ${#dirstack[*]} -eq 0 ]] ; then ...@@ -11,7 +11,8 @@ if [[ -f ${dirstack_file} ]] && [[ ${#dirstack[*]} -eq 0 ]] ; then
[[ -d $dirstack[1] ]] && cd $dirstack[1] && cd $OLDPWD [[ -d $dirstack[1] ]] && cd $dirstack[1] && cd $OLDPWD
fi fi
chpwd_functions+=(chpwd_dirpersist) autoload -U add-zsh-hook
add-zsh-hook chpwd chpwd_dirpersist
chpwd_dirpersist() { chpwd_dirpersist() {
if (( $DIRSTACKSIZE <= 0 )) || [[ -z $dirstack_file ]]; then return; fi if (( $DIRSTACKSIZE <= 0 )) || [[ -z $dirstack_file ]]; then return; fi
local -ax my_stack local -ax my_stack
......
...@@ -374,7 +374,8 @@ _managepy-commands() { ...@@ -374,7 +374,8 @@ _managepy-commands() {
_applist() { _applist() {
local line local line
local -a apps local -a apps
_call_program help-command "python -c \"import os.path as op, re, django.conf, sys;\\ _call_program help-command "python -c \"import sys; del sys.path[0];\\
import os.path as op, re, django.conf;\\
bn=op.basename(op.abspath(op.curdir));[sys\\ bn=op.basename(op.abspath(op.curdir));[sys\\
.stdout.write(str(re.sub(r'^%s\.(.*?)$' % .stdout.write(str(re.sub(r'^%s\.(.*?)$' %
bn, r'\1', i)) + '\n') for i in django.conf.settings.\\ bn, r'\1', i)) + '\n') for i in django.conf.settings.\\
......
## Docker autocomplete plugin # Docker plugin
A copy of the completion script from the This plugin adds auto-completion for [docker](https://www.docker.com/).
[docker/cli](https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker)
git repo. To use it add `docker` to the plugins array in your zshrc file.
```zsh
plugins=(... docker)
```
A copy of the completion script from the docker/cli git repo:
https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker
...@@ -32,6 +32,8 @@ PORT=3001 ...@@ -32,6 +32,8 @@ PORT=3001
``` ```
You can even mix both formats, although it's probably a bad idea. You can even mix both formats, although it's probably a bad idea.
## Plugin options
### ZSH_DOTENV_FILE ### ZSH_DOTENV_FILE
You can also modify the name of the file to be loaded with the variable `ZSH_DOTENV_FILE`. You can also modify the name of the file to be loaded with the variable `ZSH_DOTENV_FILE`.
...@@ -43,6 +45,10 @@ For example, this will make the plugin look for files named `.dotenv` and load t ...@@ -43,6 +45,10 @@ For example, this will make the plugin look for files named `.dotenv` and load t
ZSH_DOTENV_FILE=.dotenv ZSH_DOTENV_FILE=.dotenv
``` ```
### ZSH_DOTENV_PROMPT
Set `ZSH_DOTENV_PROMPT=false` in your zshrc file if you don't want the confirmation message.
## Version Control ## Version Control
**It's strongly recommended to add `.env` file to `.gitignore`**, because usually it contains sensitive information such as your credentials, secret keys, passwords etc. You don't want to commit this file, it's supposed to be local only. **It's strongly recommended to add `.env` file to `.gitignore`**, because usually it contains sensitive information such as your credentials, secret keys, passwords etc. You don't want to commit this file, it's supposed to be local only.
......
source_env() { source_env() {
if [[ -f $ZSH_DOTENV_FILE ]]; then if [[ -f $ZSH_DOTENV_FILE ]]; then
if [ "$ZSH_DOTENV_PROMPT" != "false" ]; then
# confirm before sourcing file
local confirmation
# print same-line prompt and output newline character if necessary
echo -n "dotenv: source '$ZSH_DOTENV_FILE' file in the directory? (Y/n) "
read -k 1 confirmation; [[ "$confirmation" != $'\n' ]] && echo
# only bail out if confirmation character is n
if [[ "$confirmation" = [nN] ]]; then
return
fi
fi
# test .env syntax # test .env syntax
zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2 zsh -fn $ZSH_DOTENV_FILE || echo "dotenv: error when sourcing '$ZSH_DOTENV_FILE' file" >&2
......
# .NET Core CLI plugin
This plugin provides completion and useful aliases for [.NET Core CLI](https://dotnet.microsoft.com/).
To use it, add `dotnet` to the plugins array in your zshrc file.
```
plugins=(... dotnet)
```
## Aliases
| Alias | Command | Description |
|-------|------------------|-------------------------------------------------------------------|
| dn | dotnet new | Create a new .NET project or file. |
| dr | dotnet run | Build and run a .NET project output. |
| dt | dotnet test | Run unit tests using the test runner specified in a .NET project. |
| dw | dotnet watch | Watch for source file changes and restart the dotnet command. |
| dwr | dotnet watch run | Watch for source file changes and restart the `run` command. |
| ds | dotnet sln | Modify Visual Studio solution files. |
| da | dotnet add | Add a package or reference to a .NET project. |
| dp | dotnet pack | Create a NuGet package. |
| dng | dotnet nuget | Provides additional NuGet commands. |
# This scripts is copied from (MIT License):
# https://github.com/dotnet/toolset/blob/master/scripts/register-completions.zsh
_dotnet_zsh_complete()
{
local completions=("$(dotnet complete "$words")")
# If the completion list is empty, just continue with filename selection
if [ -z "$completions" ]
then
_arguments '*::arguments: _normal'
return
fi
# This is not a variable assigment, don't remove spaces!
_values = "${(ps:\n:)completions}"
}
compdef _dotnet_zsh_complete dotnet
# Aliases bellow are here for backwards compatibility
# added by Shaun Tabone (https://github.com/xontab)
alias dn='dotnet new'
alias dr='dotnet run'
alias dt='dotnet test'
alias dw='dotnet watch'
alias dwr='dotnet watch run'
alias ds='dotnet sln'
alias da='dotnet add'
alias dp='dotnet pack'
alias dng='dotnet nuget'
# eecms plugin
This plugin adds auto-completion of console commands for [`eecms`](https://github.com/ExpressionEngine/ExpressionEngine).
To use it, add `eecms` to the plugins array of your `.zshrc` file:
```
plugins=(... eecms)
```
It also adds the alias `eecms` which finds the eecms file in the current project
and runs it with php.
...@@ -20,7 +20,8 @@ _emacsfun() ...@@ -20,7 +20,8 @@ _emacsfun()
# tempfile. (first argument will be `--no-wait` passed in by the plugin.zsh) # tempfile. (first argument will be `--no-wait` passed in by the plugin.zsh)
if [ "$#" -ge "2" -a "$2" = "-" ] if [ "$#" -ge "2" -a "$2" = "-" ]
then then
tempfile="$(mktemp emacs-stdin-$USER.XXXXXXX --tmpdir)" tempfile="$(mktemp --tmpdir emacs-stdin-$USER.XXXXXXX 2>/dev/null \
|| mktemp -t emacs-stdin-$USER)" # support BSD mktemp
cat - > "$tempfile" cat - > "$tempfile"
_emacsfun --no-wait $tempfile _emacsfun --no-wait $tempfile
else else
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# FILE: emoji-clock.plugin.zsh # FILE: emoji-clock.plugin.zsh
# DESCRIPTION: The current time with half hour accuracy as an emoji symbol. # DESCRIPTION: The current time with half hour accuracy as an emoji symbol.
# Inspired by Andre Torrez' "Put A Burger In Your Shell" # Inspired by Andre Torrez' "Put A Burger In Your Shell"
# http://notes.torrez.org/2013/04/put-a-burger-in-your-shell.html # https://notes.torrez.org/2013/04/put-a-burger-in-your-shell.html
# AUTHOR: Alexis Hildebrandt (afh[at]surryhill.net) # AUTHOR: Alexis Hildebrandt (afh[at]surryhill.net)
# VERSION: 1.0.0 # VERSION: 1.0.0
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
......
# emotty plugin
This plugin returns an emoji for the current $TTY number so it can be used
in a prompt.
To use it, add emotty to the plugins array in your zshrc file:
```
plugins=(... emotty)
```
**NOTE:** it requires the [emoji plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/emoji).
## Usage
The function `emotty` displays an emoji from the current character set (default: `emoji`), based
on the number associated to the `$TTY`.
There are different sets of emoji characters available, to choose a different
set, set `$emotty_set` to the name of the set you would like to use, e.g.:
```
emotty_set=nature
```
### Character Sets
- emoji
- loral
- love
- nature
- stellar
- zodiac
Use the `display_emotty` function to list the emojis in the current character set, or
the character set passed as the first argument. For example:
```
$ display_emotty zodiac
<list of all the emojis in the zodiac character set>
```
...@@ -20,10 +20,10 @@ Alias plugin for encoding or decoding using `base64` command ...@@ -20,10 +20,10 @@ Alias plugin for encoding or decoding using `base64` command
) )
``` ```
2. Restart your terminal session or reload configuration by running: 2. Restart your terminal session or restart the shell:
```sh ```sh
source ~/.zshrc exec zsh
``` ```
## Usage and examples ## Usage and examples
......
...@@ -25,23 +25,32 @@ plugins=(... extract) ...@@ -25,23 +25,32 @@ plugins=(... extract)
| `gz` | Gzip file | | `gz` | Gzip file |
| `ipsw` | iOS firmware file | | `ipsw` | iOS firmware file |
| `jar` | Java Archive | | `jar` | Java Archive |
| `lrz` | LRZ archive |
| `lz4` | LZ4 archive |
| `lzma` | LZMA archive | | `lzma` | LZMA archive |
| `rar` | WinRAR archive | | `rar` | WinRAR archive |
| `rpm` | RPM package |
| `sublime-package` | Sublime Text package | | `sublime-package` | Sublime Text package |
| `tar` | Tarball | | `tar` | Tarball |
| `tar.bz2` | Tarball with bzip2 compression | | `tar.bz2` | Tarball with bzip2 compression |
| `tar.gz` | Tarball with gzip compression | | `tar.gz` | Tarball with gzip compression |
| `tar.lrz` | Tarball with lrzip compression |
| `tar.lz` | Tarball with lzip compression |
| `tar.lz4` | Tarball with lz4 compression |
| `tar.xz` | Tarball with lzma2 compression | | `tar.xz` | Tarball with lzma2 compression |
| `tar.zma` | Tarball with lzma compression | | `tar.zma` | Tarball with lzma compression |
| `tar.zst` | Tarball with zstd compression |
| `tbz` | Tarball with bzip compression | | `tbz` | Tarball with bzip compression |
| `tbz2` | Tarball with bzip2 compression | | `tbz2` | Tarball with bzip2 compression |
| `tgz` | Tarball with gzip compression | | `tgz` | Tarball with gzip compression |
| `tlz` | Tarball with lzma compression | | `tlz` | Tarball with lzma compression |
| `txz` | Tarball with lzma2 compression | | `txz` | Tarball with lzma2 compression |
| `tzst` | Tarball with zstd compression |
| `war` | Web Application archive (Java-based) | | `war` | Web Application archive (Java-based) |
| `xpi` | Mozilla XPI module file | | `xpi` | Mozilla XPI module file |
| `xz` | LZMA2 archive | | `xz` | LZMA2 archive |
| `zip` | Zip archive | | `zip` | Zip archive |
| `zst` | Zstandard file (zstd) |
See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for
more information regarding archive formats. more information regarding archive formats.
...@@ -3,5 +3,5 @@ ...@@ -3,5 +3,5 @@
_arguments \ _arguments \
'(-r --remove)'{-r,--remove}'[Remove archive.]' \ '(-r --remove)'{-r,--remove}'[Remove archive.]' \
"*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|deb|gz|ipsw|jar|lzma|rar|sublime-package|tar|tar.bz2|tar.gz|tar.xz|tar.zma|tbz|tbz2|tgz|tlz|txz|war|whl|xpi|xz|zip)(-.)'" \ "*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|deb|gz|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst)(-.)'" \
&& return 0 && return 0
...@@ -40,14 +40,24 @@ extract() { ...@@ -40,14 +40,24 @@ extract() {
tar --lzma --help &> /dev/null \ tar --lzma --help &> /dev/null \
&& tar --lzma -xvf "$1" \ && tar --lzma -xvf "$1" \
|| lzcat "$1" | tar xvf - ;; || lzcat "$1" | tar xvf - ;;
(*.tar.zst|*.tzst)
tar --zstd --help &> /dev/null \
&& tar --zstd -xvf "$1" \
|| zstdcat "$1" | tar xvf - ;;
(*.tar) tar xvf "$1" ;; (*.tar) tar xvf "$1" ;;
(*.gz) (( $+commands[pigz] )) && pigz -d "$1" || gunzip "$1" ;; (*.tar.lz) (( $+commands[lzip] )) && tar xvf "$1" ;;
(*.tar.lz4) lz4 -c -d "$1" | tar xvf - ;;
(*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$1" ;;
(*.gz) (( $+commands[pigz] )) && pigz -dk "$1" || gunzip -k "$1" ;;
(*.bz2) bunzip2 "$1" ;; (*.bz2) bunzip2 "$1" ;;
(*.xz) unxz "$1" ;; (*.xz) unxz "$1" ;;
(*.lrz) (( $+commands[lrunzip] )) && lrunzip "$1" ;;
(*.lz4) lz4 -d "$1" ;;
(*.lzma) unlzma "$1" ;; (*.lzma) unlzma "$1" ;;
(*.z) uncompress "$1" ;; (*.z) uncompress "$1" ;;
(*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d $extract_dir ;; (*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d $extract_dir ;;
(*.rar) unrar x -ad "$1" ;; (*.rar) unrar x -ad "$1" ;;
(*.rpm) mkdir "$extract_dir" && cd "$extract_dir" && rpm2cpio "../$1" | cpio --quiet -id && cd .. ;;
(*.7z) 7za x "$1" ;; (*.7z) 7za x "$1" ;;
(*.deb) (*.deb)
mkdir -p "$extract_dir/control" mkdir -p "$extract_dir/control"
...@@ -58,6 +68,7 @@ extract() { ...@@ -58,6 +68,7 @@ extract() {
cd ..; rm *.tar.* debian-binary cd ..; rm *.tar.* debian-binary
cd .. cd ..
;; ;;
(*.zst) unzstd "$1" ;;
(*) (*)
echo "extract: '$1' cannot be extracted" >&2 echo "extract: '$1' cannot be extracted" >&2
success=1 success=1
......
...@@ -4,10 +4,19 @@ ...@@ -4,10 +4,19 @@
local curcontext=$curcontext state line local curcontext=$curcontext state line
declare -A opt_args declare -A opt_args
declare target_list declare -a target_list
target_list=(`fab --shortlist 2>/dev/null`) target_list=("${(@f)$(fab -l 2>/dev/null | awk '{
if (NF == 0 || NR == 1) next
if (NF < 2) print $1
else {
docstring=substr($0, index($0,$2))
gsub(":", "\\:", docstring)
print $1":"docstring
}
}')}")
_targets() { _fab_targets() {
[[ -n "$target_list" ]] || return
_describe -t commands "fabric targets" target_list _describe -t commands "fabric targets" target_list
} }
...@@ -28,7 +37,7 @@ _arguments -w -S -C \ ...@@ -28,7 +37,7 @@ _arguments -w -S -C \
'(-)--shortlist[print non-verbose list of possible commands and exit]: :->noargs' \ '(-)--shortlist[print non-verbose list of possible commands and exit]: :->noargs' \
'(--reject-unknown-hosts)--reject-unknown-hosts[reject unknown hosts]' \ '(--reject-unknown-hosts)--reject-unknown-hosts[reject unknown hosts]' \
'(--no-pty)--no-pty[do not use pseudo-terminal in run/sudo]' \ '(--no-pty)--no-pty[do not use pseudo-terminal in run/sudo]' \
"(-d+ --display=-)"{-d+,--display=-}"[print detailed info about a given command]: :_targets" \ "(-d+ --display=-)"{-d+,--display=-}"[print detailed info about a given command]: :_fab_targets" \
'(-D --disable-known-hosts)'{-D,--disable-known-hosts}'[do not load user known_hosts file]' \ '(-D --disable-known-hosts)'{-D,--disable-known-hosts}'[do not load user known_hosts file]' \
'(-r --reject-unknown-hosts)'{-r,--reject-unknown-hosts}'[reject unknown hosts]' \ '(-r --reject-unknown-hosts)'{-r,--reject-unknown-hosts}'[reject unknown hosts]' \
'(-u+ --user=-)'{-u+,--user=-}'[username to use when connecting to remote hosts]: :' \ '(-u+ --user=-)'{-u+,--user=-}'[username to use when connecting to remote hosts]: :' \
...@@ -53,7 +62,7 @@ if [[ CURRENT -ge 1 ]]; then ...@@ -53,7 +62,7 @@ if [[ CURRENT -ge 1 ]]; then
levels) levels)
_describe -t commands "output levels" output_levels;; _describe -t commands "output levels" output_levels;;
*) *)
_targets;; _fab_targets;;
esac esac
return return
......
# fasd
[`Fasd`](https://github.com/clvv/fasd) (pronounced similar to "fast") is a command-line productivity booster. Fasd offers quick access to files and directories for POSIX shells.
To use it, add `fasd` to the plugins array in your zshrc file:
```zsh
plugins=(... fasd)
```
## Installation
Please find detailed installation guide [`here`](https://github.com/clvv/fasd#install)
## Aliases
| Alias | Command | Description |
|-------|-------------------------------------------|-------------------------------------------------------------|
| v | `fasd -f -e "$EDITOR"` | List frequent/recent files matching the given filename. |
| o | `fasd -a -e xdg-open` | List frequent/recent files and directories matching. |
| j | `fasd_cd -d -i` | cd with interactive selection |
# Fastfile plugin
This plugin adds a way to reference certain files or folders used frequently using
a global alias or shortcut.
To use it, add `fastfile` to the plugins array in your zshrc file:
```zsh
plugins=(... fastfile)
```
## Usage
Example: you access folder `/code/project/backend/database` very frequently.
First, generate a shortcut with the name `pjdb`:
```zsh
$ fastfile pjdb /code/project/backend/database
```
Next time you want to access it, use `§pjdb`. For example:
```zsh
$ cd §pjdb
$ subl §pjdb
```
where § is the fastfile prefix (see [below](#options) for how to change).
**Note:** shortcuts with spaces in the name are assigned a global alias
where the spaces have been substituted with underscores (`_`). For example:
a shortcut named `"hello world"` corresponds with `§hello_world`.
## Functions
- `fastfile <shortcut_name> <path/to/file/or/folder>`: generate a shortcut.
- `fastfile_print <shortcut_name>`: prints a shortcut, with the format
`<prefix><shortcut_name> -> <shortcut_path>`.
- `fastfile_ls`: lists all shortcuts.
- `fastfile_rm <shortcut_name> `: remove a shortcut.
- `fastfile_sync`: generates the global aliases for the shortcuts.
### Internal functions
- `fastfile_resolv <shortcut_name>`: resolves the location of the shortcut
file, i.e., the file in the fastfile directory where the shortcut path
is stored.
- `fastfile_get <shortcut_name>`: get the real path of the shortcut.
## Aliases
| Alias | Function |
|--------|------------------|
| ff | `fastfile` |
| ffp | `fastfile_print` |
| ffrm | `fastfile_rm` |
| ffls | `fastfile_ls` |
| ffsync | `fastfile_sync` |
## Options
These are options you can set to change certain parts of the plugin. To change
them, add `<variable>=<value>` to your zshrc file, before Oh My Zsh is sourced.
For example: `fastfile_var_prefix='@'`.
- `fastfile_var_prefix`: prefix for the global aliases created. Controls the prefix of the
created global aliases.
**Default:** `§` (section sign), easy to type in a german keyboard via the combination
[`⇧ Shift`+`3`](https://en.wikipedia.org/wiki/German_keyboard_layout#/media/File:KB_Germany.svg),
or using `⌥ Option`+`6` in macOS.
- `fastfile_dir`: directory where the fastfile shortcuts are stored. Needs to end
with a trailing slash.
**Default:** `$HOME/.fastfile/`.
## Author
- [Karolin Varner](https://github.com/koraa)
################################################################################
# FILE: fastfile.plugin.zsh
# DESCRIPTION: oh-my-zsh plugin file.
# AUTHOR: Michael Varner (musikmichael@web.de)
# VERSION: 1.0.0
#
# This plugin adds the ability to on the fly generate and access file shortcuts.
#
################################################################################
########################### ###########################
# Settings # Settings
# These can be overwritten any time. # These can be overwritten any time.
# If they are not set yet, they will be # If they are not set yet, they will be
...@@ -33,7 +23,7 @@ default fastfile_var_prefix "§" ...@@ -33,7 +23,7 @@ default fastfile_var_prefix "§"
function fastfile() { function fastfile() {
test "$2" || 2="." test "$2" || 2="."
file=$(readlink -f "$2") file=$(readlink -f "$2")
test "$1" || 1="$(basename "$file")" test "$1" || 1="$(basename "$file")"
name=$(echo "$1" | tr " " "_") name=$(echo "$1" | tr " " "_")
...@@ -51,7 +41,7 @@ function fastfile() { ...@@ -51,7 +41,7 @@ function fastfile() {
# Arguments: # Arguments:
# 1. name - The name of the shortcut # 1. name - The name of the shortcut
# STDOUT: # STDOUT:
# The path # The path to the shortcut file
# #
function fastfile_resolv() { function fastfile_resolv() {
echo "${fastfile_dir}${1}" echo "${fastfile_dir}${1}"
...@@ -88,12 +78,12 @@ function fastfile_print() { ...@@ -88,12 +78,12 @@ function fastfile_print() {
# (=> fastfle_print) for each shortcut # (=> fastfle_print) for each shortcut
# #
function fastfile_ls() { function fastfile_ls() {
for f in "${fastfile_dir}"/*; do for f in "${fastfile_dir}"/*; do
file=`basename "$f"` # To enable simpler handeling of spaces in file names file=`basename "$f"` # To enable simpler handeling of spaces in file names
varkey=`echo "$file" | tr " " "_"` varkey=`echo "$file" | tr " " "_"`
# Special format for colums # Special format for colums
echo "${fastfile_var_prefix}${varkey}|->|$(fastfile_get "$file")" echo "${fastfile_var_prefix}${varkey}|->|$(fastfile_get "$file")"
done | column -t -s "|" done | column -t -s "|"
} }
...@@ -102,7 +92,6 @@ function fastfile_ls() { ...@@ -102,7 +92,6 @@ function fastfile_ls() {
# #
# Arguments: # Arguments:
# 1. name - The name of the shortcut (default: name of the file) # 1. name - The name of the shortcut (default: name of the file)
# 2. file - The file or directory to make the shortcut for
# STDOUT: # STDOUT:
# => fastfle_print # => fastfle_print
# #
...@@ -115,11 +104,11 @@ function fastfile_rm() { ...@@ -115,11 +104,11 @@ function fastfile_rm() {
# Generate the aliases for the shortcuts # Generate the aliases for the shortcuts
# #
function fastfile_sync() { function fastfile_sync() {
for f in "${fastfile_dir}"/*; do for f in "${fastfile_dir}"/*; do
file=`basename "$f"` # To enable simpler handeling of spaces in file names file=`basename "$f"` # To enable simpler handeling of spaces in file names
varkey=`echo "$file" | tr " " "_"` varkey=`echo "$file" | tr " " "_"`
alias -g "${fastfile_var_prefix}${varkey}"="'$(fastfile_get "$file")'" alias -g "${fastfile_var_prefix}${varkey}"="'$(fastfile_get "$file")'"
done done
} }
...@@ -133,6 +122,6 @@ alias ffls=fastfile_ls ...@@ -133,6 +122,6 @@ alias ffls=fastfile_ls
alias ffsync=fastfile_sync alias ffsync=fastfile_sync
################################## ##################################
# Init # Init
fastfile_sync fastfile_sync
\ No newline at end of file
# fbterm
This plugin automatically starts [fbterm](https://github.com/zhangyuanwei/fbterm)
if on a real TTY (`/dev/tty*`).
To use it, add fbterm to the plugins array of your zshrc file:
```
plugins=(... fbterm)
```
The fedora plugin is deprecated. Use the [dnf plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/dnf) instead. The fedora plugin is deprecated. Use the [dnf plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/dnf) instead.
## Flutter plugin
The Flutter plugin provides completion and useful aliases
To use it, add flutter to the plugins array of your zshrc file:
```
plugins=(... flutter)
```
## Aliases
| Alias | Command | Description |
| :--------- | :--------------------- | :------------------------------------------------------------------------- |
| `fl` | `flutter` | Shorthand for flutter command |
| `flr` | `flutter run` | Runs flutter app |
| `fldoc` | `flutter doctor` | Runs flutter doctor |
| `flb` | `flutter build` | Build flutter application |
| `flattach` | `flutter attach` | Attaches flutter to a running flutter application with enabled observatory |
| `flget` | `flutter packages get` | Installs dependencies |
| `flc` | `flutter clean` | Cleans flutter porject |
#compdef flutter
#autoload
local -a _1st_arguments
_1st_arguments=(
"analyze":"Analyze the project's Dart code."
"assemble":"Assemble and build flutter resources."
"attach":"Attach to a running application."
"build":"Flutter build commands."
"channel":"List or switch flutter channels."
"clean":"Delete the build/ and .dart_tool/ directories."
"config":"Configure Flutter settings."
"create":"Create a new Flutter project."
"devices":"List all connected devices."
"doctor":"Show information about the installed tooling."
"drive":"Runs Flutter Driver tests for the current project."
"emulators":"List, launch and create emulators."
"format":" Format one or more dart files."
"help":"Display help information for flutter."
"install":"Install a Flutter app on an attached device."
"logs":"Show log output for running Flutter apps."
"make-host-app-editable":"Moves host apps from generated directories to non-generated directories so that they can be edited by developers."
"precache":"Populates the Flutter tool's cache of binary artifacts."
"pub":"Commands for managing Flutter packages."
"run":"Run your Flutter app on an attached device."
"screenshot":"Take a screenshot from a connected device."
"test":"Run Flutter unit tests for the current project."
"upgrade":"Upgrade your copy of Flutter."
"version":"List or switch flutter versions."
)
_arguments -C '*:: :->subcmds'
if (( CURRENT == 1 )); then
_describe -t commands "flutter command" _1st_arguments
return
fi
alias fl="flutter"
alias flr="flutter run"
alias fldoc="flutter doctor"
alias flb="flutter build"
alias flattach="flutter attach"
alias flget="flutter packages get"
alias flc="flutter clean"
...@@ -62,6 +62,10 @@ Available search contexts are: ...@@ -62,6 +62,10 @@ Available search contexts are:
If you want to have another context, open an Issue and tell us! If you want to have another context, open an Issue and tell us!
## Fallback search behaviour
The plugin will use Google as a fallback if the docs site for a search context does not have a search function. You can set the fallback search engine to DuckDuckGo by setting `FRONTEND_SEARCH_FALLBACK='duckduckgo'` in your `~/.zshrc` file before Oh My Zsh is sourced.
## Author ## Author
**Wilson Mendes (willmendesneto)** **Wilson Mendes (willmendesneto)**
......
...@@ -27,6 +27,17 @@ alias typescript='frontend typescript' ...@@ -27,6 +27,17 @@ alias typescript='frontend typescript'
alias unheap='frontend unheap' alias unheap='frontend unheap'
alias vuejs='frontend vuejs' alias vuejs='frontend vuejs'
function _frontend_fallback() {
local url
if [[ "$FRONTEND_SEARCH_FALLBACK" == duckduckgo ]]; then
url="https://duckduckgo.com/?sites=$1&q="
else
url="https://google.com/search?as_sitesearch=$1&as_q="
fi
echo "$url"
}
function frontend() { function frontend() {
emulate -L zsh emulate -L zsh
...@@ -34,8 +45,8 @@ function frontend() { ...@@ -34,8 +45,8 @@ function frontend() {
typeset -A urls typeset -A urls
urls=( urls=(
angular 'https://angular.io/?search=' angular 'https://angular.io/?search='
angularjs 'https://google.com/search?as_sitesearch=angularjs.org&as_q=' angularjs $(_frontend_fallback 'angularjs.org')
bem 'https://google.com/search?as_sitesearch=bem.info&as_q=' bem $(_frontend_fallback 'bem.info')
bootsnipp 'https://bootsnipp.com/search?q=' bootsnipp 'https://bootsnipp.com/search?q='
bundlephobia 'https://bundlephobia.com/result?p=' bundlephobia 'https://bundlephobia.com/result?p='
caniuse 'https://caniuse.com/#search=' caniuse 'https://caniuse.com/#search='
...@@ -43,24 +54,24 @@ function frontend() { ...@@ -43,24 +54,24 @@ function frontend() {
compassdoc 'http://compass-style.org/search?q=' compassdoc 'http://compass-style.org/search?q='
cssflow 'http://www.cssflow.com/search?q=' cssflow 'http://www.cssflow.com/search?q='
dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:' dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:'
emberjs 'https://www.google.com/search?as_sitesearch=emberjs.com/&as_q=' emberjs $(_frontend_fallback 'emberjs.com/')
flowtype 'https://google.com/search?as_sitesearch=flow.org/en/docs/&as_q=' flowtype $(_frontend_fallback 'flow.org/en/docs/')
fontello 'http://fontello.com/#search=' fontello 'http://fontello.com/#search='
github 'https://github.com/search?q=' github 'https://github.com/search?q='
html5please 'https://html5please.com/#' html5please 'https://html5please.com/#'
jestjs 'https://www.google.com/search?as_sitesearch=jestjs.io&as_q=' jestjs $(_frontend_fallback 'jestjs.io')
jquery 'https://api.jquery.com/?s=' jquery 'https://api.jquery.com/?s='
lodash 'https://devdocs.io/lodash/index#' lodash 'https://devdocs.io/lodash/index#'
mdn 'https://developer.mozilla.org/search?q=' mdn 'https://developer.mozilla.org/search?q='
nodejs 'https://www.google.com/search?as_sitesearch=nodejs.org/en/docs/&as_q=' nodejs $(_frontend_fallback 'nodejs.org/en/docs/')
npmjs 'https://www.npmjs.com/search?q=' npmjs 'https://www.npmjs.com/search?q='
qunit 'https://api.qunitjs.com/?s=' qunit 'https://api.qunitjs.com/?s='
reactjs 'https://google.com/search?as_sitesearch=facebook.github.io/react&as_q=' reactjs $(_frontend_fallback 'reactjs.org/')
smacss 'https://google.com/search?as_sitesearch=smacss.com&as_q=' smacss $(_frontend_fallback 'smacss.com')
stackoverflow 'https://stackoverflow.com/search?q=' stackoverflow 'https://stackoverflow.com/search?q='
typescript 'https://google.com/search?as_sitesearch=www.typescriptlang.org/docs&as_q=' typescript $(_frontend_fallback 'www.typescriptlang.org/docs')
unheap 'http://www.unheap.com/?s=' unheap 'http://www.unheap.com/?s='
vuejs 'https://www.google.com/search?as_sitesearch=vuejs.org&as_q=' vuejs $(_frontend_fallback 'vuejs.org')
) )
# show help for command list # show help for command list
......
test -d "${FZF_BASE}" && fzf_base="${FZF_BASE}" function setup_using_base_dir() {
# Declare all variables local not no mess with outside env in any way
if [[ -z "${fzf_base}" ]]; then local fzf_base
fzfdirs=( local fzf_shell
"${HOME}/.fzf" local fzfdirs
"/usr/local/opt/fzf" local dir
"/usr/share/fzf"
) test -d "${FZF_BASE}" && fzf_base="${FZF_BASE}"
for dir in ${fzfdirs}; do
if [[ -d "${dir}" ]]; then if [[ -z "${fzf_base}" ]]; then
fzf_base="${dir}" fzfdirs=(
break "${HOME}/.fzf"
fi "${HOME}/.nix-profile/share/fzf"
done "/usr/local/opt/fzf"
"/usr/share/fzf"
if [[ -z "${fzf_base}" ]]; then "/usr/local/share/examples/fzf"
if (( ${+commands[brew]} )) && dir="$(brew --prefix fzf 2>/dev/null)"; then )
if [[ -d "${dir}" ]]; then for dir in ${fzfdirs}; do
fzf_base="${dir}" if [[ -d "${dir}" ]]; then
fi fzf_base="${dir}"
fi break
fi fi
fi done
if [[ -n "${fzf_base}" ]]; then if [[ -z "${fzf_base}" ]]; then
if (( ${+commands[brew]} )) && dir="$(brew --prefix fzf 2>/dev/null)"; then
# Fix fzf shell directory for Archlinux package if [[ -d "${dir}" ]]; then
if [[ ! -d "${fzf_base}/shell" ]] && [[ -f /etc/arch-release ]]; then fzf_base="${dir}"
fzf_shell="${fzf_base}" fi
else fi
fzf_shell="${fzf_base}/shell" fi
fi fi
# Setup fzf if [[ -d "${fzf_base}" ]]; then
# --------- # Fix fzf shell directory for Arch Linux, NixOS or Void Linux packages
if ! (( ${+commands[fzf]} )) && [[ ! "$PATH" == *$fzf_base/bin* ]]; then if [[ ! -d "${fzf_base}/shell" ]]; then
export PATH="$PATH:$fzf_base/bin" fzf_shell="${fzf_base}"
fi else
fzf_shell="${fzf_base}/shell"
# Auto-completion fi
# ---------------
if [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then # Setup fzf binary path
[[ $- == *i* ]] && source "${fzf_shell}/completion.zsh" 2> /dev/null if ! (( ${+commands[fzf]} )) && [[ ! "$PATH" == *$fzf_base/bin* ]]; then
fi export PATH="$PATH:$fzf_base/bin"
fi
# Key bindings
# ------------ # Auto-completion
if [[ ! "$DISABLE_FZF_KEY_BINDINGS" == "true" ]]; then if [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then
source "${fzf_shell}/key-bindings.zsh" [[ $- == *i* ]] && source "${fzf_shell}/completion.zsh" 2> /dev/null
fi fi
else # Key bindings
print "[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.\n"\ if [[ ! "$DISABLE_FZF_KEY_BINDINGS" == "true" ]]; then
"Please add \`export FZF_BASE=/path/to/fzf/install/dir\` to your .zshrc" >&2 source "${fzf_shell}/key-bindings.zsh"
fi fi
else
unset fzf_base fzf_shell dir fzfdirs return 1
fi
}
function setup_using_debian_package() {
(( $+commands[dpkg] )) && dpkg -s fzf &> /dev/null
if (( $? )); then
# Either not a debian based distro, or no fzf installed. In any case skip ahead
return 1
fi
# NOTE: There is no need to configure PATH for debian package, all binaries
# are installed to /usr/bin by default
# Determine completion file path: first bullseye/sid, then buster/stretch
local completions="/usr/share/doc/fzf/examples/completion.zsh"
[[ -f "$completions" ]] || completions="/usr/share/zsh/vendor-completions/_fzf"
local key_bindings="/usr/share/doc/fzf/examples/key-bindings.zsh"
# Auto-completion
if [[ $- == *i* ]] && [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then
source $completions 2> /dev/null
fi
# Key bindings
if [[ ! "$DISABLE_FZF_KEY_BINDINGS" == "true" ]]; then
source $key_bindings
fi
return 0
}
function indicate_error() {
print "[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.\n"\
"Please add \`export FZF_BASE=/path/to/fzf/install/dir\` to your .zshrc" >&2
}
# Check for debian package first, because it easy to short cut
# Indicate to user that fzf installation not found if nothing worked
setup_using_debian_package || setup_using_base_dir || indicate_error
unset -f setup_using_debian_package setup_using_base_dir indicate_error
# Gas plugin
This plugin adds autocompletion for the [gas](http://walle.github.com/gas) command,
a utility to manage Git authors.
To use it, add `gas` to the plugins array of your zshrc file:
```zsh
plugins=(... gas)
```
# gcloud
This plugin provides completion support for the
[Google Cloud SDK CLI](https://cloud.google.com/sdk/gcloud/).
To use it, add `gcloud` to the plugins array in your zshrc file.
```zsh
plugins=(... gcloud)
```
It relies on you having installed the SDK using one of the supported options
listed [here](https://cloud.google.com/sdk/install).
## Plugin Options
* Set `CLOUDSDK_HOME` in your `zshrc` file before you load oh-my-zsh if you have
your GCloud SDK installed in a non-standard location. The plugin will use this
as the base for your SDK if it finds it set already.
* If you do not have a `python2` in your `PATH` you'll also need to set the
`CLOUDSDK_PYTHON` environment variable at the end of your `.zshrc`. This is
used by the SDK to call a compatible interpreter when you run one of the
SDK commands.
#####################################################
# gcloud plugin for oh-my-zsh #
# Author: Ian Chesal (github.com/ianchesal) #
#####################################################
if [[ -z "${CLOUDSDK_HOME}" ]]; then
search_locations=(
"$HOME/google-cloud-sdk"
"/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
"/usr/share/google-cloud-sdk"
"/snap/google-cloud-sdk/current"
"/usr/lib64/google-cloud-sdk/"
"/opt/google-cloud-sdk"
)
for gcloud_sdk_location in $search_locations; do
if [[ -d "${gcloud_sdk_location}" ]]; then
CLOUDSDK_HOME="${gcloud_sdk_location}"
break
fi
done
fi
if (( ${+CLOUDSDK_HOME} )); then
if (( ! $+commands[gcloud] )); then
# Only source this if GCloud isn't already on the path
if [[ -f "${CLOUDSDK_HOME}/path.zsh.inc" ]]; then
source "${CLOUDSDK_HOME}/path.zsh.inc"
fi
fi
source "${CLOUDSDK_HOME}/completion.zsh.inc"
export CLOUDSDK_HOME
fi
GIT_AUTO_FETCH_INTERVAL=${GIT_AUTO_FETCH_INTERVAL:=60} GIT_AUTO_FETCH_INTERVAL=${GIT_AUTO_FETCH_INTERVAL:=60}
function git-fetch-all { function git-fetch-all {
(`git rev-parse --is-inside-work-tree 2>/dev/null` && (`command git rev-parse --is-inside-work-tree 2>/dev/null` &&
dir=`git rev-parse --git-dir` && dir=`command git rev-parse --git-dir` &&
[[ ! -f $dir/NO_AUTO_FETCH ]] && [[ ! -f $dir/NO_AUTO_FETCH ]] &&
(( `date +%s` - `date -r $dir/FETCH_LOG +%s 2>/dev/null || echo 0` > $GIT_AUTO_FETCH_INTERVAL )) && (( `date +%s` - `date -r $dir/FETCH_LOG +%s 2>/dev/null || echo 0` > $GIT_AUTO_FETCH_INTERVAL )) &&
git fetch --all 2>/dev/null &>! $dir/FETCH_LOG &) GIT_SSH_COMMAND="command ssh -o BatchMode=yes" \
command git fetch --all 2>/dev/null &>! $dir/FETCH_LOG &)
} }
function git-auto-fetch { function git-auto-fetch {
`git rev-parse --is-inside-work-tree 2>/dev/null` || return `command git rev-parse --is-inside-work-tree 2>/dev/null` || return
guard="`git rev-parse --git-dir`/NO_AUTO_FETCH" guard="`command git rev-parse --git-dir`/NO_AUTO_FETCH"
(rm $guard 2>/dev/null && (rm $guard 2>/dev/null &&
echo "${fg_bold[green]}enabled${reset_color}") || echo "${fg_bold[green]}enabled${reset_color}") ||
...@@ -18,10 +19,18 @@ function git-auto-fetch { ...@@ -18,10 +19,18 @@ function git-auto-fetch {
echo "${fg_bold[red]}disabled${reset_color}") echo "${fg_bold[red]}disabled${reset_color}")
} }
eval "override-git-auto-fetch-$(declare -f zle-line-init)" # Override zle-line-init if it exists
if (( $+functions[zle-line-init] )); then
function zle-line-init () { eval "override-git-auto-fetch-$(declare -f zle-line-init)"
git-fetch-all
override-git-auto-fetch-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 zle -N zle-line-init
# Git Escape Magic
This plugin is copied from the original at
https://github.com/knu/zsh-git-escape-magic. All credit for the
functionality enabled by this plugin should go to @knu.
An excerpt from that project's readme explains its purpose.
> It eliminates the need for manually escaping those meta-characters. The zle function it provides is context aware and recognizes the characteristics of each subcommand of git. Every time you type one of these meta-characters on a git command line, it automatically escapes the meta-character with a backslash as necessary and as appropriate.
## Usage
To use this plugin, add it to your list of plugins in your `.zshrc` file.
**NOTE**: If you use url-quote-magic, it must be included before this
plugin runs to prevent any conflicts.
# -*- mode: sh -*-
#
# git-escape-magic - zle tweak for git command line arguments
#
# Copyright (c) 2011, 2012, 2014 Akinori MUSHA
# Licensed under the 2-clause BSD license.
#
# This tweak eliminates the need for manually escaping shell
# meta-characters such as [~^{}] that are used for specifying a git
# object (commit or tree). Every time you type one of these
# characters on a git command line, it is automatically escaped with a
# backslash as necessary and as appropriate.
#
# If you want to use this with url-quote-magic, make sure to enable it
# first.
#
# Usage:
# autoload -Uz git-escape-magic
# git-escape-magic
#
git-escape-magic.self-insert() {
emulate -L zsh
setopt extendedglob
local self_insert_function
zstyle -s ':git-escape-magic' self-insert-function self_insert_function
if [[ "$KEYS" == [{}~^]* ]] && {
local qkey="${(q)KEYS}"
[[ "$KEYS" != "$qkey" ]]
} && {
local lbuf="$LBUFFER$qkey"
[[ "${(Q)LBUFFER}$KEYS" == "${(Q)lbuf}" ]]
} && {
local -a words
words=("${(@Q)${(z)lbuf}}")
[[ "$words[(i)(*/|)git(|-[^/]##)]" -le $#words ]]
}
then
local i
i="$words[(I)([;(){\&]|\&[\&\!]|\|\||[=<>]\(*)]"
if [[ $i -gt 0 ]]; then
shift $((i-1)) words
if [[ "$words[1]" == [\=\<\>]\(* ]]; then
words[1]="${words[1]#[=<>]\(}"
else
[[ "$words[1]" == \; && $words[2] == (then|else|elif|do) ]] && shift words
shift words
fi
fi
while [[ "$words[1]" == (if|while|until|\!) ]]; do
shift words
done
while [[ "$words[1]" == [A-Za-z_][A-Za-z0-9_]#=* ]]; do
shift words
done
[[ "$words[1]" == (*/|)git(|-[^/]##) ]] && {
local subcommand
subcommand="${words[1]##*/git-}"
if [[ -z "$subcommand" ]]; then
shift words
subcommand="$words[1]"
fi
[[ $#words -ge 2 ]]
} &&
case "$subcommand" in
# commands that may take pathspec but never take refspec with [{}~^]
(add|rm|am|apply|check-attr|checkout-index|clean|clone|config|diff-files|hash-object|help|index-pack|mailinfo|mailsplit|merge-file|merge-index|mergetool|mktag|mv|pack-objects|pack-redundant|relink|send-email|show-index|show-ref|stage|status|verify-pack)
false ;;
# commands that may take pathspec but rarely take refspec with [{}~^]
(for-each-ref|grep|ls-files|update-index)
false ;;
(archive|ls-tree)
! [[ $#words -ge 3 &&
"$words[-2]" == [^-]* ]] ;;
(diff-tree)
! [[ $#words -ge 4 &&
"$words[-2]" == [^-]* &&
"$words[-3]" == [^-]* ]] ;;
(*)
[[ $words[(i)--] -gt $#words ]] ;;
esac &&
case "${words[-1]%%"$KEYS"}" in
(*[@^])
[[ "$KEYS" == [{~^]* ]] ;;
(*[@^]\{[^}]##)
[[ "$KEYS" == \}* ]] ;;
(?*)
[[ "$KEYS" == [~^]* ]] ;;
(*)
false ;;
esac &&
LBUFFER="$LBUFFER\\"
fi
zle "$self_insert_function"
}
git-escape-magic.on() {
emulate -L zsh
local self_insert_function="${$(zle -lL | awk \
'$1=="zle"&&$2=="-N"&&$3=="self-insert"{print $4;exit}'):-.self-insert}"
[[ "$self_insert_function" == git-escape-magic.self-insert ]] &&
return 0
# For url-quote-magic which does not zle -N itself
zle -la "$self_insert_function" || zle -N "$self_insert_function"
zstyle ':git-escape-magic' self-insert-function "$self_insert_function"
zle -A git-escape-magic.self-insert self-insert
return 0
}
git-escape-magic.off() {
emulate -L zsh
local self_insert_function
zstyle -s ':git-escape-magic' self-insert-function self_insert_function
[[ -n "$self_insert_function" ]] &&
zle -A "$self_insert_function" self-insert
return 0
}
zle -N git-escape-magic.self-insert
zle -N git-escape-magic.on
zle -N git-escape-magic.off
git-escape-magic() {
git-escape-magic.on
}
[[ -o kshautoload ]] || git-escape-magic "$@"
# Automatically detect and escape zsh globbing meta-characters when used with
# git refspec characters like `[^~{}]`. NOTE: This must be loaded _after_
# url-quote-magic.
#
# This trick is detailed at https://github.com/knu/zsh-git-escape-magic and is
# what allowed this plugin to exist.
autoload -Uz git-escape-magic
git-escape-magic
...@@ -20,9 +20,10 @@ function precmd_update_git_vars() { ...@@ -20,9 +20,10 @@ function precmd_update_git_vars() {
fi fi
} }
chpwd_functions+=(chpwd_update_git_vars) autoload -U add-zsh-hook
precmd_functions+=(precmd_update_git_vars) add-zsh-hook chpwd chpwd_update_git_vars
preexec_functions+=(preexec_update_git_vars) add-zsh-hook precmd precmd_update_git_vars
add-zsh-hook preexec preexec_update_git_vars
## Function definitions ## Function definitions
......
...@@ -4,26 +4,21 @@ from __future__ import print_function ...@@ -4,26 +4,21 @@ from __future__ import print_function
import os import os
import sys import sys
import re import re
import shlex
from subprocess import Popen, PIPE, check_output from subprocess import Popen, PIPE, check_output
def get_tagname_or_hash(): def get_tagname_or_hash():
"""return tagname if exists else hash""" """return tagname if exists else hash"""
cmd = 'git log -1 --format="%h%d"'
output = check_output(shlex.split(cmd)).decode('utf-8').strip()
hash_, tagname = None, None
# get hash # get hash
m = re.search('\(.*\)$', output) hash_cmd = ['git', 'rev-parse', '--short', 'HEAD']
if m: hash_ = check_output(hash_cmd).strip()
hash_ = output[:m.start()-1]
# get tagname # get tagname
m = re.search('tag: .*[,\)]', output) tags_cmd = ['git', 'for-each-ref', '--points-at=HEAD', '--count=2', '--sort=-version:refname', '--format=%(refname:short)', 'refs/tags']
if m: tags = check_output(tags_cmd).split()
tagname = 'tags/' + output[m.start()+len('tag: '): m.end()-1]
if tagname: if tags:
return tagname.replace(' ', '') return tags[0] + ('+' if len(tags) > 1 else '')
elif hash_: elif hash_:
return hash_ return hash_
return None return None
......
# git-remote-branch plugin
This plugin adds completion for [`grb`](https://github.com/webmat/git_remote_branch),
or `git_remote_branch`.
To use it, add `git-remote-branch` to the plugins array of your `.zshrc` file:
```
plugins=(... git-remote-branch)
```
## Deprecation
[git_remote_branch was archived in 2018](https://github.com/webmat/git_remote_branch#archived),
meaning it's not actively maintained anymore. Use at your own risk.
This diff is collapsed.
...@@ -42,7 +42,7 @@ alias gap='git apply' ...@@ -42,7 +42,7 @@ alias gap='git apply'
alias gb='git branch' alias gb='git branch'
alias gba='git branch -a' alias gba='git branch -a'
alias gbd='git branch -d' alias gbd='git branch -d'
alias gbda='git branch --no-color --merged | command grep -vE "^(\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d' alias gbda='git branch --no-color --merged | command grep -vE "^(\+|\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d'
alias gbD='git branch -D' alias gbD='git branch -D'
alias gbl='git blame -b -w' alias gbl='git blame -b -w'
alias gbnm='git branch --no-merged' alias gbnm='git branch --no-merged'
...@@ -207,7 +207,9 @@ alias grm='git rm' ...@@ -207,7 +207,9 @@ alias grm='git rm'
alias grmc='git rm --cached' alias grmc='git rm --cached'
alias grmv='git remote rename' alias grmv='git remote rename'
alias grrm='git remote remove' alias grrm='git remote remove'
alias grs='git restore'
alias grset='git remote set-url' alias grset='git remote set-url'
alias grss='git restore --source'
alias grt='cd "$(git rev-parse --show-toplevel || echo .)"' alias grt='cd "$(git rev-parse --show-toplevel || echo .)"'
alias gru='git reset --' alias gru='git reset --'
alias grup='git remote update' alias grup='git remote update'
...@@ -234,12 +236,15 @@ alias gstd='git stash drop' ...@@ -234,12 +236,15 @@ alias gstd='git stash drop'
alias gstl='git stash list' alias gstl='git stash list'
alias gstp='git stash pop' alias gstp='git stash pop'
alias gsts='git stash show --text' alias gsts='git stash show --text'
alias gstu='git stash --include-untracked'
alias gstall='git stash --all' alias gstall='git stash --all'
alias gsu='git submodule update' alias gsu='git submodule update'
alias gsw='git switch'
alias gswc='git switch -c'
alias gts='git tag -s' alias gts='git tag -s'
alias gtv='git tag | sort -V' alias gtv='git tag | sort -V'
alias gtl='gtl(){ git tag --sort=-v:refname -n -l ${1}* }; noglob gtl' alias gtl='gtl(){ git tag --sort=-v:refname -n -l "${1}*" }; noglob gtl'
alias gunignore='git update-index --no-assume-unchanged' alias gunignore='git update-index --no-assume-unchanged'
alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1' alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1'
...@@ -251,3 +256,17 @@ alias glum='git pull upstream master' ...@@ -251,3 +256,17 @@ alias glum='git pull upstream master'
alias gwch='git whatchanged -p --abbrev-commit --pretty=medium' alias gwch='git whatchanged -p --abbrev-commit --pretty=medium'
alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]"' alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]"'
function grename() {
if [[ -z "$1" || -z "$2" ]]; then
echo "Usage: $0 old_branch new_branch"
return 1
fi
# Rename branch locally
git branch -m "$1" "$2"
# Rename branch in origin remote
if git push origin :"$1"; then
git push --set-upstream origin "$2"
fi
}
...@@ -11,5 +11,5 @@ plugins=(... gitfast) ...@@ -11,5 +11,5 @@ plugins=(... gitfast)
## Aliases ## Aliases
An earlier version of the plugin also loaded the git plugin. If you want to keep those An earlier version of the plugin also loaded the git plugin. If you want to keep those
aliases enable the [git plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/git) aliases enable the [git plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git)
as well. as well.
...@@ -30,7 +30,7 @@ if [ -z "$script" ]; then ...@@ -30,7 +30,7 @@ if [ -z "$script" ]; then
local -a locations local -a locations
local e local e
locations=( locations=(
"$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash" $(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
'/etc/bash_completion.d/git' # fedora, old debian '/etc/bash_completion.d/git' # fedora, old debian
'/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian '/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian
'/usr/share/bash-completion/git' # gentoo '/usr/share/bash-completion/git' # gentoo
...@@ -39,7 +39,7 @@ if [ -z "$script" ]; then ...@@ -39,7 +39,7 @@ if [ -z "$script" ]; then
test -f $e && script="$e" && break test -f $e && script="$e" && break
done done
fi fi
ZSH_VERSION='' . "$script" GIT_SOURCING_ZSH_COMPLETION=y . "$script"
__gitcomp () __gitcomp ()
{ {
...@@ -93,13 +93,22 @@ __gitcomp_nl_append () ...@@ -93,13 +93,22 @@ __gitcomp_nl_append ()
compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0 compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
} }
__gitcomp_file_direct ()
{
emulate -L zsh
local IFS=$'\n'
compset -P '*[=:]'
compadd -f -- ${=1} && _ret=0
}
__gitcomp_file () __gitcomp_file ()
{ {
emulate -L zsh emulate -L zsh
local IFS=$'\n' local IFS=$'\n'
compset -P '*[=:]' compset -P '*[=:]'
compadd -Q -p "${2-}" -f -- ${=1} && _ret=0 compadd -p "${2-}" -f -- ${=1} && _ret=0
} }
__git_zsh_bash_func () __git_zsh_bash_func ()
...@@ -223,10 +232,8 @@ _git () ...@@ -223,10 +232,8 @@ _git ()
if (( $+functions[__${service}_zsh_main] )); then if (( $+functions[__${service}_zsh_main] )); then
__${service}_zsh_main __${service}_zsh_main
elif (( $+functions[__${service}_main] )); then else
emulate ksh -c __${service}_main emulate ksh -c __${service}_main
elif (( $+functions[_${service}] )); then
emulate ksh -c _${service}
fi fi
let _ret && _default && _ret=0 let _ret && _default && _ret=0
......
This diff is collapsed.
...@@ -219,7 +219,7 @@ __git_ps1_show_upstream () ...@@ -219,7 +219,7 @@ __git_ps1_show_upstream ()
if [[ -n "$count" && -n "$name" ]]; then if [[ -n "$count" && -n "$name" ]]; then
__git_ps1_upstream_name=$(git rev-parse \ __git_ps1_upstream_name=$(git rev-parse \
--abbrev-ref "$upstream" 2>/dev/null) --abbrev-ref "$upstream" 2>/dev/null)
if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then if [ "$pcmode" = yes ] && [ "$ps1_expanded" = yes ]; then
p="$p \${__git_ps1_upstream_name}" p="$p \${__git_ps1_upstream_name}"
else else
p="$p ${__git_ps1_upstream_name}" p="$p ${__git_ps1_upstream_name}"
...@@ -237,7 +237,7 @@ __git_ps1_show_upstream () ...@@ -237,7 +237,7 @@ __git_ps1_show_upstream ()
# to build a gitstring. # to build a gitstring.
__git_ps1_colorize_gitstring () __git_ps1_colorize_gitstring ()
{ {
if [[ -n ${ZSH_VERSION-} ]]; then if [[ -n "${ZSH_VERSION-}" ]]; then
local c_red='%F{red}' local c_red='%F{red}'
local c_green='%F{green}' local c_green='%F{green}'
local c_lblue='%F{blue}' local c_lblue='%F{blue}'
...@@ -255,7 +255,7 @@ __git_ps1_colorize_gitstring () ...@@ -255,7 +255,7 @@ __git_ps1_colorize_gitstring ()
local flags_color="$c_lblue" local flags_color="$c_lblue"
local branch_color="" local branch_color=""
if [ $detached = no ]; then if [ "$detached" = no ]; then
branch_color="$ok_color" branch_color="$ok_color"
else else
branch_color="$bad_color" branch_color="$bad_color"
...@@ -508,13 +508,13 @@ __git_ps1 () ...@@ -508,13 +508,13 @@ __git_ps1 ()
# NO color option unless in PROMPT_COMMAND mode or it's Zsh # NO color option unless in PROMPT_COMMAND mode or it's Zsh
if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then if [ "$pcmode" = yes ] || [ -n "${ZSH_VERSION-}" ]; then
__git_ps1_colorize_gitstring __git_ps1_colorize_gitstring
fi fi
fi fi
b=${b##refs/heads/} b=${b##refs/heads/}
if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then if [ "$pcmode" = yes ] && [ "$ps1_expanded" = yes ]; then
__git_ps1_branch_name=$b __git_ps1_branch_name=$b
b="\${__git_ps1_branch_name}" b="\${__git_ps1_branch_name}"
fi fi
...@@ -522,7 +522,7 @@ __git_ps1 () ...@@ -522,7 +522,7 @@ __git_ps1 ()
local f="$w$i$s$u" local f="$w$i$s$u"
local gitstring="$c$b${f:+$z$f}$r$p" local gitstring="$c$b${f:+$z$f}$r$p"
if [ $pcmode = yes ]; then if [ "$pcmode" = yes ]; then
if [ "${__git_printf_supports_v-}" != yes ]; then if [ "${__git_printf_supports_v-}" != yes ]; then
gitstring=$(printf -- "$printf_format" "$gitstring") gitstring=$(printf -- "$printf_format" "$gitstring")
else else
......
# glassfish
The glassfish plugin adds completion for the `asadmin` utility, a command to manage
[Oracle GlassFish](https://docs.oracle.com/cd/E18930_01/html/821-2416/giobi.html) servers.
To use it, add `glassfish` to the plugins array in your zshrc file:
```zsh
plugins=(... glassfish)
```
# if there is a user named 'glassfish' on the system, we'll assume
# that is the user asadmin should be run as
# grep -e '^glassfish' /etc/passwd > /dev/null && alias asadmin='sudo -u glassfish asadmin'
\ No newline at end of file
# gnu-utils plugin
This plugin binds GNU coreutils to their default names, so that you don't have
to call them using their prefixed name, which starts with `g`. This is useful
in systems which don't have GNU coreutils installed by default, mainly macOS
or FreeBSD, which use BSD coreutils.
To use it, add `gnu-utils` to the plugins array in your zshrc file:
```zsh
plugins=(... gnu-utils)
```
The plugin works by changing the path that the command hash points to, so
instead of `ls` pointing to `/bin/ls`, it points to wherever `gls` is
installed.
Since `hash -rf` or `rehash` refreshes the command hashes, it also wraps
`hash` and `rehash` so that the coreutils binding is always done again
after calling these two commands.
Look at the source code of the plugin to see which GNU coreutils are tried
to rebind. Open an issue if there are some missing.
## Other methods
The plugin also documents two other ways to do this:
1. Using a function wrapper, such that, for example, there exists a function
named `ls` which calls `gls` instead. Since functions have a higher preference
than commands, this ends up calling the GNU coreutil. It has also a higher
preference over shell builtins (`gecho` is called instead of the builtin `echo`).
2. Using an alias. This has an even higher preference than functions, but they
could be overridden because of a user setting.
## Author
- [Sorin Ionescu](https://github.com/sorin-ionescu).
...@@ -5,79 +5,79 @@ ...@@ -5,79 +5,79 @@
# VERSION: 1.0.0 # VERSION: 1.0.0
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Detect if GNU coreutils are installed by looking for gwhoami
if [[ ! -x "${commands[gwhoami]}" ]]; then
return
fi
if [[ -x "${commands[gwhoami]}" ]]; then __gnu_utils() {
__gnu_utils() { emulate -L zsh
emulate -L zsh local gcmds
local gcmds local gcmd
local gcmd local cmd
local cmd local prefix
local prefix
# coreutils # coreutils
gcmds=('g[' 'gbase64' 'gbasename' 'gcat' 'gchcon' 'gchgrp' 'gchmod' gcmds=('g[' 'gbase64' 'gbasename' 'gcat' 'gchcon' 'gchgrp' 'gchmod'
'gchown' 'gchroot' 'gcksum' 'gcomm' 'gcp' 'gcsplit' 'gcut' 'gdate' 'gchown' 'gchroot' 'gcksum' 'gcomm' 'gcp' 'gcsplit' 'gcut' 'gdate'
'gdd' 'gdf' 'gdir' 'gdircolors' 'gdirname' 'gdu' 'gecho' 'genv' 'gexpand' 'gdd' 'gdf' 'gdir' 'gdircolors' 'gdirname' 'gdu' 'gecho' 'genv' 'gexpand'
'gexpr' 'gfactor' 'gfalse' 'gfmt' 'gfold' 'ggroups' 'ghead' 'ghostid' 'gexpr' 'gfactor' 'gfalse' 'gfmt' 'gfold' 'ggroups' 'ghead' 'ghostid'
'gid' 'ginstall' 'gjoin' 'gkill' 'glink' 'gln' 'glogname' 'gls' 'gmd5sum' 'gid' 'ginstall' 'gjoin' 'gkill' 'glink' 'gln' 'glogname' 'gls' 'gmd5sum'
'gmkdir' 'gmkfifo' 'gmknod' 'gmktemp' 'gmv' 'gnice' 'gnl' 'gnohup' 'gnproc' 'gmkdir' 'gmkfifo' 'gmknod' 'gmktemp' 'gmv' 'gnice' 'gnl' 'gnohup' 'gnproc'
'god' 'gpaste' 'gpathchk' 'gpinky' 'gpr' 'gprintenv' 'gprintf' 'gptx' 'gpwd' 'god' 'gpaste' 'gpathchk' 'gpinky' 'gpr' 'gprintenv' 'gprintf' 'gptx' 'gpwd'
'greadlink' 'grm' 'grmdir' 'gruncon' 'gseq' 'gsha1sum' 'gsha224sum' 'greadlink' 'grm' 'grmdir' 'gruncon' 'gseq' 'gsha1sum' 'gsha224sum'
'gsha256sum' 'gsha384sum' 'gsha512sum' 'gshred' 'gshuf' 'gsleep' 'gsort' 'gsha256sum' 'gsha384sum' 'gsha512sum' 'gshred' 'gshuf' 'gsleep' 'gsort'
'gsplit' 'gstat' 'gstty' 'gsum' 'gsync' 'gtac' 'gtail' 'gtee' 'gtest' 'gsplit' 'gstat' 'gstty' 'gsum' 'gsync' 'gtac' 'gtail' 'gtee' 'gtest'
'gtimeout' 'gtouch' 'gtr' 'gtrue' 'gtruncate' 'gtsort' 'gtty' 'guname' 'gtimeout' 'gtouch' 'gtr' 'gtrue' 'gtruncate' 'gtsort' 'gtty' 'guname'
'gunexpand' 'guniq' 'gunlink' 'guptime' 'gusers' 'gvdir' 'gwc' 'gwho' 'gunexpand' 'guniq' 'gunlink' 'guptime' 'gusers' 'gvdir' 'gwc' 'gwho'
'gwhoami' 'gyes') 'gwhoami' 'gyes')
# findutils # findutils
gcmds+=('gfind' 'gxargs' 'glocate') gcmds+=('gfind' 'gxargs' 'glocate')
# Not part of either coreutils or findutils, installed separately. # Not part of either coreutils or findutils, installed separately.
gcmds+=('gsed' 'gtar' 'gtime') gcmds+=('gsed' 'gtar' 'gtime')
for gcmd in "${gcmds[@]}"; do for gcmd in "${gcmds[@]}"; do
# # Do nothing if the command isn't found
# This method allows for builtin commands to be primary but it's (( ${+commands[$gcmd]} )) || continue
# lost if hash -r or rehash -f is executed. Thus, those two
# functions have to be wrapped. # This method allows for builtin commands to be primary but it's
# # lost if hash -r or rehash -f is executed. Thus, those two
(( ${+commands[$gcmd]} )) && hash ${gcmd[2,-1]}=${commands[$gcmd]} # functions have to be wrapped.
#
hash ${gcmd[2,-1]}=${commands[$gcmd]}
# # This method generates wrapper functions.
# This method generates wrapper functions. # It will override shell builtins.
# It will override shell builtins. #
# # eval "function $gcmd[2,-1]() { \"${prefix}/${gcmd//"["/"\\["}\" \"\$@\"; }"
# (( ${+commands[$gcmd]} )) && \
# eval "function $gcmd[2,-1]() { \"${prefix}/${gcmd//"["/"\\["}\" \"\$@\"; }"
# # This method is inflexible since the aliases are at risk of being
# This method is inflexible since the aliases are at risk of being # overridden resulting in the BSD coreutils being called.
# overridden resulting in the BSD coreutils being called. #
# # alias "$gcmd[2,-1]"="${prefix}/${gcmd//"["/"\\["}"
# (( ${+commands[$gcmd]} )) && \ done
# alias "$gcmd[2,-1]"="${prefix}/${gcmd//"["/"\\["}"
done
return 0 return 0
} }
__gnu_utils; __gnu_utils
function hash() { function hash() {
if [[ "$*" =~ "-(r|f)" ]]; then if [[ "$*" =~ "-(r|f)" ]]; then
builtin hash "$@" builtin hash "$@"
__gnu_utils __gnu_utils
else else
builtin hash "$@" builtin hash "$@"
fi fi
} }
function rehash() { function rehash() {
if [[ "$*" =~ "-f" ]]; then if [[ "$*" =~ "-f" ]]; then
builtin rehash "$@" builtin rehash "$@"
__gnu_utils __gnu_utils
else else
builtin rehash "$@" builtin rehash "$@"
fi fi
} }
fi
The go plugin is deprecated. Use the [golang plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/golang) instead. The go plugin is deprecated. Use the [golang plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/golang) instead.
...@@ -7,7 +7,7 @@ gradle-or-gradlew() { ...@@ -7,7 +7,7 @@ gradle-or-gradlew() {
echo "executing gradlew instead of gradle"; echo "executing gradlew instead of gradle";
./gradlew "$@"; ./gradlew "$@";
else else
gradle "$@"; command gradle "$@";
fi fi
} }
...@@ -181,3 +181,4 @@ _gradlew_tasks () { ...@@ -181,3 +181,4 @@ _gradlew_tasks () {
############################################################################ ############################################################################
compdef _gradle_tasks gradle compdef _gradle_tasks gradle
compdef _gradlew_tasks gradlew compdef _gradlew_tasks gradlew
compdef _gradlew_tasks gw
...@@ -9,7 +9,7 @@ You can also use K and J in VI mode or ^P and ^N in EMACS mode for the same. ...@@ -9,7 +9,7 @@ You can also use K and J in VI mode or ^P and ^N in EMACS mode for the same.
[1]: https://fishshell.com [1]: https://fishshell.com
[2]: https://www.zsh.org/mla/users/2009/msg00818.html [2]: https://www.zsh.org/mla/users/2009/msg00818.html
[3]: https://sourceforge.net/projects/fizsh/ [3]: https://sourceforge.net/projects/fizsh/
[4]: https://github.com/robbyrussell/oh-my-zsh/pull/215 [4]: https://github.com/ohmyzsh/ohmyzsh/pull/215
[5]: https://github.com/zsh-users/zsh-history-substring-search [5]: https://github.com/zsh-users/zsh-history-substring-search
[6]: https://github.com/zsh-users/zsh-syntax-highlighting [6]: https://github.com/zsh-users/zsh-syntax-highlighting
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment