Update 30.01.2022

This commit is contained in:
Дмитрий Рамазанов 2022-01-30 00:39:21 +05:00
parent 3d6a64111c
commit 04423b8c5c
323 changed files with 44877 additions and 7114 deletions

View File

@ -5,6 +5,7 @@ plugins/genpass/ @atoponce
plugins/git-lfs/ @hellovietduc plugins/git-lfs/ @hellovietduc
plugins/gitfast/ @felipec plugins/gitfast/ @felipec
plugins/sdk/ @rgoldberg plugins/sdk/ @rgoldberg
plugins/shell-proxy/ @septs
plugins/universalarchive/ @Konfekt plugins/universalarchive/ @Konfekt
plugins/wp-cli/ @joshmedeski plugins/wp-cli/ @joshmedeski
plugins/zoxide/ @ajeetdsouza plugins/zoxide/ @ajeetdsouza

View File

@ -1,2 +1,2 @@
github: [robbyrussell, mcornella, larson-carter] github: [ohmyzsh, robbyrussell, mcornella, larson-carter]
open_collective: ohmyzsh open_collective: ohmyzsh

View File

@ -1,12 +1,11 @@
name: Bug report name: Report a bug
description: Create a report to help us improve Oh My Zsh description: Report a bug that isn't caused by Oh My Zsh. If unsure, use this form
labels: 'Bug'
body: body:
- type: markdown - type: markdown
attributes: attributes:
value: | value: |
## Self Check ## Self Check
- Try searching existing [GitHub Issues](https://github.com/ohmyzsh/ohmyzsh/issues?q=is%3Aissue) (open or closed) for similar issues. - Look for similar errors in existing [GitHub Issues](https://github.com/ohmyzsh/ohmyzsh/issues?q=is%3Aissue) (open or closed).
- Try reaching out on the [Discord server](https://discord.gg/ohmyzsh) for help. - Try reaching out on the [Discord server](https://discord.gg/ohmyzsh) for help.
- type: textarea - type: textarea
validations: validations:
@ -41,21 +40,21 @@ body:
validations: validations:
required: true required: true
attributes: attributes:
label: OS / Distro label: OS / Linux distribution
placeholder: e.g. Windows 10, Ubuntu 20.04, Arch Linux, macOS 10.15... placeholder: Windows 10, Ubuntu 20.04, Arch Linux, macOS 10.15...
- type: input - type: input
validations: validations:
required: true required: true
attributes: attributes:
label: Zsh version label: Zsh version
description: Run `echo $ZSH_VERSION` to check. description: Run `echo $ZSH_VERSION` to check.
placeholder: e.g. 5.6 placeholder: "5.6"
- type: input - type: input
validations: validations:
required: true required: true
attributes: attributes:
label: Terminal emulator label: Terminal emulator
placeholder: e.g. iTerm2, Gnome Terminal... placeholder: iTerm2, GNOME Terminal, Terminal.app...
- type: dropdown - type: dropdown
attributes: attributes:
label: If using WSL on Windows, which version of WSL label: If using WSL on Windows, which version of WSL

View File

@ -0,0 +1,77 @@
name: Report a bug in Oh My Zsh
description: Create a report to help us improve Oh My Zsh
labels: ['Bug']
body:
- type: markdown
attributes:
value: |
## Self Check
- **Make sure this bug only happens with Oh My Zsh enabled**.
- Look for similar errors in existing [GitHub Issues](https://github.com/ohmyzsh/ohmyzsh/issues?q=is%3Aissue) (open or closed).
- Try reaching out on the [Discord server](https://discord.gg/ohmyzsh) for help.
- type: textarea
validations:
required: true
attributes:
label: Describe the bug
description: A clear description of what the bug is.
- type: textarea
validations:
required: true
attributes:
label: Steps to reproduce
description: |
Steps to reproduce the problem.
placeholder: |
For example:
1. Enable plugin '...'
2. Run command '...' or try to complete command '...'
3. See error
- type: textarea
validations:
required: true
attributes:
label: Expected behavior
description: A brief description of what should happen.
- type: textarea
attributes:
label: Screenshots and recordings
description: |
If applicable, add screenshots to help explain your problem. You can also record an asciinema session: https://asciinema.org/
- type: input
validations:
required: true
attributes:
label: OS / Linux distribution
placeholder: Windows 10, Ubuntu 20.04, Arch Linux, macOS 10.15...
- type: input
validations:
required: true
attributes:
label: Zsh version
description: Run `echo $ZSH_VERSION` to check.
placeholder: "5.6"
- type: input
validations:
required: true
attributes:
label: Oh My Zsh version
description: Run `omz version` to check.
placeholder: master (bf303965)
- type: input
validations:
required: true
attributes:
label: Terminal emulator
placeholder: iTerm2, GNOME Terminal, Terminal.app...
- type: dropdown
attributes:
label: If using WSL on Windows, which version of WSL
description: Run `wsl -l -v` to check.
options:
- WSL1
- WSL2
- type: textarea
attributes:
label: Additional context
description: Add any other context about the problem here. This can be themes, plugins, custom settings...

View File

@ -1,7 +1,12 @@
name: Feature request name: Feature request
description: Suggest a feature for Oh My Zsh description: Suggest a feature for Oh My Zsh
labels: 'Feature' labels: ["Feature"]
body: body:
- type: markdown
attributes:
value: |
## Self Check
- Look for similar features in existing [GitHub Issues](https://github.com/ohmyzsh/ohmyzsh/issues?q=is%3Aissue) (open or closed).
- type: input - type: input
attributes: attributes:
label: If the feature request is for a plugin or theme, specify it here. label: If the feature request is for a plugin or theme, specify it here.

15
zsh/.github/actions/spelling/README.md vendored Normal file
View File

@ -0,0 +1,15 @@
# check-spelling/check-spelling configuration
File | Purpose | Format | Info
-|-|-|-
[dictionary.txt](dictionary.txt) | Replacement dictionary (creating this file will override the default dictionary) | one word per line | [dictionary](https://github.com/check-spelling/check-spelling/wiki/Configuration#dictionary)
[allow.txt](allow.txt) | Add words to the dictionary | one word per line (only letters and `'`s allowed) | [allow](https://github.com/check-spelling/check-spelling/wiki/Configuration#allow)
[reject.txt](reject.txt) | Remove words from the dictionary (after allow) | grep pattern matching whole dictionary words | [reject](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples%3A-reject)
[excludes.txt](excludes.txt) | Files to ignore entirely | perl regular expression | [excludes](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples%3A-excludes)
[only.txt](only.txt) | Only check matching files (applied after excludes) | perl regular expression | [only](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples%3A-only)
[patterns.txt](patterns.txt) | Patterns to ignore from checked lines | perl regular expression (order matters, first match wins) | [patterns](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples%3A-patterns)
[expect.txt](expect.txt) | Expected words that aren't in the dictionary | one word per line (sorted, alphabetically) | [expect](https://github.com/check-spelling/check-spelling/wiki/Configuration#expect)
[advice.md](advice.md) | Supplement for GitHub comment when unrecognized words are found | GitHub Markdown | [advice](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples%3A-advice)
Note: you can replace any of these files with a directory by the same name (minus the suffix)
and then include multiple files inside that directory (with that suffix) to merge multiple files together.

25
zsh/.github/actions/spelling/advice.md vendored Normal file
View File

@ -0,0 +1,25 @@
<!-- See https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples%3A-advice --> <!-- markdownlint-disable MD033 MD041 -->
<details><summary>If the flagged items do not appear to be text</summary>
If items relate to a ...
* well-formed pattern.
If you can write a [pattern](https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-patterns) that would match it,
try adding it to the `patterns.txt` file.
Patterns are Perl 5 Regular Expressions - you can [test](
https://www.regexplanet.com/advanced/perl/) yours before committing to verify it will match your lines.
Note that patterns can't match multiline strings.
* binary file.
Please add a file path to the `excludes.txt` file matching the containing file.
File paths are Perl 5 Regular Expressions - you can [test](
https://www.regexplanet.com/advanced/perl/) yours before committing to verify it will match your files.
`^` refers to the file's path from the root of the repository, so `^README\.md$` would exclude [README.md](
../tree/HEAD/README.md) (on whichever branch you're using).
</details>

View File

View File

@ -0,0 +1,41 @@
# See https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-excludes
(?:^|/)(?i)COPYRIGHT
(?:^|/)(?i)LICEN[CS]E
(?:^|/)package(?:-lock|)\.json$
(?:^|/)vendor/
ignore$
\.avi$
\.ico$
\.jpe?g$
\.lock$
\.map$
\.min\..
\.mod$
\.mp[34]$
\.png$
\.wav$
^\.github/
^\Qplugins/archlinux/archlinux.plugin.zsh\E$
^\Qplugins/cp/cp.plugin.zsh\E$
^\Qplugins/extract/_extract\E$
^\Qplugins/genpass/genpass.plugin.zsh\E$
^\Qplugins/gitignore/gitignore.plugin.zsh\E$
^\Qplugins/gnu-utils/gnu-utils.plugin.zsh\E$
^\Qplugins/hitchhiker/fortunes/hitchhiker\E$
^\Qplugins/jhbuild/jhbuild.plugin.zsh\E$
^\Qplugins/jhbuild/README.md\E$
^\Qplugins/jruby/jruby.plugin.zsh\E$
^\Qplugins/kubectl/kubectl.plugin.zsh\E$
^\Qplugins/lol/lol.plugin.zsh\E$
^\Qplugins/mosh/mosh.plugin.zsh\E$
^\Qplugins/npx/npx.plugin.zsh\E$
^\Qplugins/powder/_powder\E$
^\Qplugins/suse/suse.plugin.zsh\E$
^\Qplugins/thor/_thor\E$
^\Qplugins/universalarchive/_universalarchive\E$
^\Qplugins/vagrant/vagrant.plugin.zsh\E$
^\Qplugins/wp-cli/README.md\E$
^\Qplugins/wp-cli/wp-cli.plugin.zsh\E$
^\Qthemes/clean.zsh-theme\E$
^\Qthemes/philips.zsh-theme\E$
^\Qthemes/tonotdo.zsh-theme\E$

4494
zsh/.github/actions/spelling/expect.txt vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,73 @@
# See https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-patterns
# YouTube
https?://(?:(?:www\.|)youtube\.com|youtu.be)/(?:channel/|embed/|playlist\?list=|watch\?v=|v/|)[-a-zA-Z0-9?&=_]*
<\s*youtube\s+id=['"][-a-zA-Z0-9?_]*['"]
\bimg\.youtube\.com/vi/[-a-zA-Z0-9?&=_]*
# Google Analytics
\bgoogle-analytics\.com/collect.[-0-9a-zA-Z?%=&_.~]*
# Google APIs
\bgoogleapis\.com/[a-z]+/v\d+/[a-z]+/[@./?=\w]+
\b[-a-zA-Z0-9.]*\bstorage\d*\.googleapis\.com(?:/\S*|)
# Google Calendar
\bcalendar\.google\.com/calendar(?:/u/\d+|)/embed\?src=[@./?=\w&%]+
\w+\@group\.calendar\.google\.com\b
# Google DataStudio
\bdatastudio\.google\.com/(?:(?:c/|)u/\d+/|)(?:embed/|)(?:open|reporting|datasources|s)/[-0-9a-zA-Z]+(?:/page/[-0-9a-zA-Z]+|)
# The leading `/` here is as opposed to the `\b` above
# ... a short way to match `https://` or `http://` since most urls have one of those prefixes
# Google Docs
/docs\.google\.com/[a-z]+/d/(?:e/|)[0-9a-zA-Z_-]+/?
# Google Drive
\bdrive\.google\.com/file/d/[0-9a-zA-Z_?=]*
# Google Groups
\bgroups\.google\.com/(?:forum/#!|d/)(?:msg|topic)/[^/]+/[a-zA-Z0-9]+(?:/[a-zA-Z0-9]+|)
# Google themes
themes\.googleusercontent\.com/static/fonts/[^/]+/v\d+/[^.]+.
# Google CDN
\bclients2\.google(?:usercontent|)\.com[-0-9a-zA-Z/.]*
# Goo.gl
/goo\.gl/[a-zA-Z0-9]+
# Google Chrome Store
\bchrome\.google\.com/webstore/detail/\w*(?:/\w*|)
# Google Books
\bbooks\.google\.(?:\w{2,4})/books\?[-\w\d=&#.]*
# Google Fonts
\bfonts\.(?:googleapis|gstatic)\.com/[-/?=:;+&0-9a-zA-Z]*
# GitHub SHAs
\bapi.github\.com/repos/[^/]+/[^/]+/[^/]+/[0-9a-f]+\b
(?:\[[0-9a-f]+\]\(https:/|)/(?:www\.|)github\.com/[^/]+/[^/]+(?:/[^/]+/[0-9a-f]+(?:[-0-9a-zA-Z/#.]*|)\b|)
\bgithub\.com/[^/]+/[^/]+[@#][0-9a-f]+\b
# githubusercontent
/[-a-z0-9]+\.githubusercontent\.com/[-a-zA-Z0-9?&=_\/.]*
# gist github
/gist\.github\.com/[^/]+/[0-9a-f]+
# git.io
\bgit\.io/[0-9a-zA-Z]+
# GitHub JSON
"node_id": "[-a-zA-Z=;:/0-9+]*"
# Contributor
\[[^\]]+]\(https://github\.com/[^/]+\)
# GHSA
GHSA(?:-[0-9a-z]{4}){3}
LS_COLORS=(["']).*?\g{-1}
(\\?)%[a-zA-Z]+\g{-1}(?!%)
# URL escaped characters
\%[0-9A-F]{2}
# hex digits including css/html color classes:
(?:[\\0][xX]|\\u|[uU]\+|#x?|\%23)[0-9a-fA-FgGrR_]{2,}(?:[uU]?[lL]{0,2}|u\d+)\b
# https://www.gnu.org/software/groff/manual/groff.html
# man troff content
\\f[BCIPR]
# Compiler flags
[\t "'`=]-[LPWXY]
[\t "'`=]-D(?!ebian)
# ignore long runs of a single character:
\b([A-Za-z])\g{-1}{3,}\b

View File

@ -0,0 +1,7 @@
^attache$
benefitting
occurence
Sorce
^[Ss]pae
^untill
^wether

View File

@ -14,6 +14,7 @@ jobs:
tests: tests:
name: Run tests name: Run tests
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
if: github.repository == 'ohmyzsh/ohmyzsh'
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest, macos-latest] os: [ubuntu-latest, macos-latest]

131
zsh/.github/workflows/project.yml vendored Normal file
View File

@ -0,0 +1,131 @@
name: Project tracking
on:
issues:
types: [opened]
pull_request_target:
types: [opened, synchronize]
jobs:
add-to-project:
name: Add to project
runs-on: ubuntu-latest
if: github.repository == 'ohmyzsh/ohmyzsh'
env:
GITHUB_TOKEN: ${{ secrets.PROJECT_TOKEN }}
steps:
- name: Read project data
env:
ORGANIZATION: ohmyzsh
PROJECT_NUMBER: "1"
run: |
# Get Project data
gh api graphql -f query='
query($org: String!, $number: Int!) {
organization(login: $org){
projectNext(number: $number) {
id
fields(first:20) {
nodes {
id
name
}
}
}
}
}
' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json
# Parse project data
cat >> $GITHUB_ENV <<EOF
PROJECT_ID=$(jq '.data.organization.projectNext.id' project_data.json)
PLUGIN_FIELD_ID=$(jq '.data.organization.projectNext.fields.nodes[] | select(.name == "Plugin") | .id' project_data.json)
THEME_FIELD_ID=$(jq '.data.organization.projectNext.fields.nodes[] | select(.name == "Theme") | .id' project_data.json)
EOF
- name: Add to project
env:
ISSUE_OR_PR_ID: ${{ github.event.issue.node_id || github.event.pull_request.node_id }}
run: |
item_id="$(gh api graphql -f query='
mutation($project: ID!, $content: ID!) {
addProjectNextItem(input: {projectId: $project, contentId: $content}) {
projectNextItem {
id
}
}
}
' -f project=$PROJECT_ID -f content=$ISSUE_OR_PR_ID --jq '.data.addProjectNextItem.projectNextItem.id')"
echo "ITEM_ID=$item_id" >> $GITHUB_ENV
- name: Classify Pull Request
if: github.event_name == 'pull_request_target'
run: |
touch plugins.list themes.list
gh pr view ${{ github.event.pull_request.number }} \
--repo ${{ github.repository }} \
--json files --jq '.files.[].path' | awk -F/ '
/^plugins\// {
plugins[$2] = 1
}
/^themes\// {
gsub(/\.zsh-theme$/, "", $2)
themes[$2] = 1
}
END {
for (plugin in plugins) {
print plugin >> "plugins.list"
}
for (theme in themes) {
print theme >> "themes.list"
}
}
'
# If only one plugin is modified, add it to the plugin field
if [[ $(wc -l < plugins.list) = 1 ]]; then
echo "PLUGIN=$(cat plugins.list)" >> $GITHUB_ENV
fi
# If only one theme is modified, add it to the theme field
if [[ $(wc -l < themes.list) = 1 ]]; then
echo "THEME=$(cat themes.list)" >> $GITHUB_ENV
fi
- name: Fill Pull Request fields in project
if: github.event_name == 'pull_request_target'
run: |
gh api graphql -f query='
mutation (
$project: ID!
$item: ID!
$plugin_field: ID!
$plugin_value: String!
$theme_field: ID!
$theme_value: String!
) {
set_plugin: updateProjectNextItemField(input: {
projectId: $project
itemId: $item
fieldId: $plugin_field
value: $plugin_value
}) {
projectNextItem {
id
}
}
set_theme: updateProjectNextItemField(input: {
projectId: $project
itemId: $item
fieldId: $theme_field
value: $theme_value
}) {
projectNextItem {
id
}
}
}
' -f project=$PROJECT_ID -f item=$ITEM_ID \
-f plugin_field=$PLUGIN_FIELD_ID -f plugin_value=$PLUGIN \
-f theme_field=$THEME_FIELD_ID -f theme_value=$THEME \
--silent

View File

@ -202,7 +202,7 @@ type(scope)!: subject
feat(archlinux): add support for aura AUR helper (#9467) feat(archlinux): add support for aura AUR helper (#9467)
``` ```
- Formatted inline code by using backticks: the text inbetween backticks will also be highlighted by - Formatted inline code by using backticks: the text between backticks will also be highlighted by
the changelog tool: the changelog tool:
``` ```
feat(shell-proxy): enable unexported `DEFAULT_PROXY` setting (#9774) feat(shell-proxy): enable unexported `DEFAULT_PROXY` setting (#9774)

View File

@ -16,6 +16,7 @@ To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twi
[![Follow @ohmyzsh](https://img.shields.io/twitter/follow/ohmyzsh?label=Follow+@ohmyzsh&style=flat)](https://twitter.com/intent/follow?screen_name=ohmyzsh) [![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/ohmyzsh) [![Discord server](https://img.shields.io/discord/642496866407284746)](https://discord.gg/ohmyzsh)
[![Gitpod ready](https://img.shields.io/badge/Gitpod-ready-blue?logo=gitpod)](https://gitpod.io/#https://github.com/ohmyzsh/ohmyzsh) [![Gitpod ready](https://img.shields.io/badge/Gitpod-ready-blue?logo=gitpod)](https://gitpod.io/#https://github.com/ohmyzsh/ohmyzsh)
[![huntr.dev](https://cdn.huntr.dev/huntr_security_badge_mono.svg)](https://huntr.dev/bounties/disclose/?utm_campaign=ohmyzsh%2Fohmyzsh&utm_medium=social&utm_source=github&target=https%3A%2F%2Fgithub.com%2Fohmyzsh%2Fohmyzsh)
## Getting Started ## Getting Started
@ -36,13 +37,15 @@ Oh My Zsh is installed by running one of the following commands in your terminal
| **wget** | `sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` | | **wget** | `sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` |
| **fetch** | `sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` | | **fetch** | `sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` |
_Note that previous configuration in `.zshrc` will be placed in `.pre-oh-my-zsh`. After installation you can move configuration you want to preserve into `.zshrc`._
#### Manual inspection #### Manual inspection
It's a good idea to inspect the install script from projects you don't yet know. You can do It's a good idea to inspect the install script from projects you don't yet know. You can do
that by downloading the install script first, looking through it so everything looks normal, that by downloading the install script first, looking through it so everything looks normal,
then running it: then running it:
```shell ```sh
wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
sh install.sh sh install.sh
``` ```
@ -57,18 +60,18 @@ Oh My Zsh comes with a shitload of plugins for you to take advantage of. You can
Once you spot a plugin (or several) that you'd like to use with Oh My Zsh, you'll need to enable them in the `.zshrc` file. You'll find the zshrc file in your `$HOME` directory. Open it with your favorite text editor and you'll see a spot to list all the plugins you want to load. Once you spot a plugin (or several) that you'd like to use with Oh My Zsh, you'll need to enable them in the `.zshrc` file. You'll find the zshrc file in your `$HOME` directory. Open it with your favorite text editor and you'll see a spot to list all the plugins you want to load.
```shell ```sh
vi ~/.zshrc vi ~/.zshrc
``` ```
For example, this might begin to look like this: For example, this might begin to look like this:
```shell ```sh
plugins=( plugins=(
git git
bundler bundler
dotenv dotenv
osx macos
rake rake
rbenv rbenv
ruby ruby
@ -91,13 +94,13 @@ _Robby's theme is the default one. It's not the fanciest one. It's not the simpl
Once you find a theme that you'd like to use, you will need to edit the `~/.zshrc` file. You'll see an environment variable (all caps) in there that looks like: Once you find a theme that you'd like to use, you will need to edit the `~/.zshrc` file. You'll see an environment variable (all caps) in there that looks like:
```shell ```sh
ZSH_THEME="robbyrussell" ZSH_THEME="robbyrussell"
``` ```
To use a different theme, simply change the value to match the name of your desired theme. For example: To use a different theme, simply change the value to match the name of your desired theme. For example:
```shell ```sh
ZSH_THEME="agnoster" # (this is one of the fancy ones) ZSH_THEME="agnoster" # (this is one of the fancy ones)
# see https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#agnoster # see https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#agnoster
``` ```
@ -112,13 +115,13 @@ In case you did not find a suitable theme for your needs, please have a look at
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.
```shell ```sh
ZSH_THEME="random" # (...please let it be pie... please be some pie..) ZSH_THEME="random" # (...please let it be pie... please be some pie..)
``` ```
And if you want to pick random theme from a list of your favorite themes: And if you want to pick random theme from a list of your favorite themes:
```shell ```sh
ZSH_THEME_RANDOM_CANDIDATES=( ZSH_THEME_RANDOM_CANDIDATES=(
"robbyrussell" "robbyrussell"
"agnoster" "agnoster"
@ -127,7 +130,7 @@ ZSH_THEME_RANDOM_CANDIDATES=(
If you only know which themes you don't like, you can add them similarly to an ignored list: If you only know which themes you don't like, you can add them similarly to an ignored list:
```shell ```sh
ZSH_THEME_RANDOM_IGNORED=(pygmalion tjkirch_mod) ZSH_THEME_RANDOM_IGNORED=(pygmalion tjkirch_mod)
``` ```
@ -152,7 +155,7 @@ If you'd like to change the install directory with the `ZSH` environment variabl
`export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline `export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline
like this: like this:
```shell ```sh
ZSH="$HOME/.dotfiles/oh-my-zsh" sh install.sh ZSH="$HOME/.dotfiles/oh-my-zsh" sh install.sh
``` ```
@ -162,7 +165,7 @@ If you're running the Oh My Zsh install script as part of an automated install,
flag `--unattended` to the `install.sh` script. This will have the effect of not trying to change flag `--unattended` to the `install.sh` script. This will have the effect of not trying to change
the default shell, and also won't run `zsh` when the installation has finished. the default shell, and also won't run `zsh` when the installation has finished.
```shell ```sh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
``` ```
@ -185,7 +188,7 @@ The install script also accepts these variables to allow installation of a diffe
For example: For example:
```shell ```sh
REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh
``` ```
@ -193,13 +196,13 @@ REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh
##### 1. Clone the repository ##### 1. Clone the repository
```shell ```sh
git clone https://github.com/ohmyzsh/ohmyzsh.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
```shell ```sh
cp ~/.zshrc ~/.zshrc.orig cp ~/.zshrc ~/.zshrc.orig
``` ```
@ -207,13 +210,13 @@ cp ~/.zshrc ~/.zshrc.orig
You can create a new zsh config file by copying the template that we have included for you. You can create a new zsh config file by copying the template that we have included for you.
```shell ```sh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
``` ```
##### 4. Change your default shell ##### 4. Change your default shell
```shell ```sh
chsh -s $(which zsh) chsh -s $(which zsh)
``` ```
@ -242,23 +245,40 @@ If you would like to override the functionality of a plugin distributed with Oh
## Getting Updates ## Getting Updates
By default, you will be prompted to check for upgrades every few weeks. If you would like `oh-my-zsh` to automatically upgrade itself without prompting you, set the following in your `~/.zshrc`: By default, you will be prompted to check for updates every 2 weeks. You can choose other update modes by adding a line to your `~/.zshrc` file, **before Oh My Zsh is loaded**:
```shell 1. Automatic update without confirmation prompt:
DISABLE_UPDATE_PROMPT=true
```sh
zstyle ':omz:update' mode auto
``` ```
To disable automatic upgrades, set the following in your `~/.zshrc`: 2. Just offer a reminder every few days, if there are updates available:
```shell ```sh
DISABLE_AUTO_UPDATE=true zstyle ':omz:update' mode reminder
```
3. To disable automatic updates entirely:
```sh
zstyle ':omz:update' mode disabled
```
NOTE: you can control how often Oh My Zsh checks for updates with the following setting:
```sh
# This will check for updates every 7 days
zstyle ':omz:update' frequency 7
# This will check for updates every time you open the terminal (not recommended)
zstyle ':omz:update' frequency 0
``` ```
### Manual Updates ### Manual Updates
If you'd like to upgrade at any point in time (maybe someone just released a new plugin and you don't want to wait a week?) you just need to run: If you'd like to update at any point in time (maybe someone just released a new plugin and you don't want to wait a week?) you just need to run:
```shell ```sh
omz update omz update
``` ```

24
zsh/SECURITY.md Normal file
View File

@ -0,0 +1,24 @@
# Security Policy
## Supported Versions
At the moment Oh My Zsh only considers the very latest commit to be supported.
We combine that with our fast response to incidents and the automated updates
to minimize the time between vulnerability publication and patch release.
| Version | Supported |
|:-------------- |:------------------ |
| master | :white_check_mark: |
| other commits | :x: |
In the near future we will introduce versioning, so expect this section to change.
## Reporting a Vulnerability
**Do not submit an issue or pull request**: this might reveal the vulnerability.
Instead, you should email the maintainers directly at: [**security@ohmyz.sh**](mailto:security@ohmyz.sh).
We will deal with the vulnerability privately and submit a patch as soon as possible.
You can also submit your vulnerability report to [huntr.dev](https://huntr.dev/bounties/disclose/?utm_campaign=ohmyzsh%2Fohmyzsh&utm_medium=social&utm_source=github&target=https%3A%2F%2Fgithub.com%2Fohmyzsh%2Fohmyzsh) and see if you can get a bounty reward.

View File

@ -26,8 +26,10 @@ function _omz {
'help:Usage information' 'help:Usage information'
'plugin:Manage plugins' 'plugin:Manage plugins'
'pr:Manage Oh My Zsh Pull Requests' 'pr:Manage Oh My Zsh Pull Requests'
'reload:Reload the current zsh session'
'theme:Manage themes' 'theme:Manage themes'
'update:Update Oh My Zsh' 'update:Update Oh My Zsh'
'version:Show the version'
) )
if (( CURRENT == 2 )); then if (( CURRENT == 2 )); then
@ -35,7 +37,7 @@ function _omz {
elif (( CURRENT == 3 )); then elif (( CURRENT == 3 )); then
case "$words[2]" in case "$words[2]" in
changelog) local -a refs changelog) local -a refs
refs=("${(@f)$(command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}") refs=("${(@f)$(builtin cd -q "$ZSH"; command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}")
_describe 'command' refs ;; _describe 'command' refs ;;
plugin) subcmds=( plugin) subcmds=(
'disable:Disable plugin(s)' 'disable:Disable plugin(s)'
@ -59,17 +61,19 @@ function _omz {
# if command is "disable", only offer already enabled plugins # if command is "disable", only offer already enabled plugins
valid_plugins=($plugins) valid_plugins=($plugins)
else else
valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(.N:h:t)) valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
# if command is "enable", remove already enabled plugins # if command is "enable", remove already enabled plugins
[[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins}) [[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins})
fi fi
_describe 'plugin' valid_plugins ;; _describe 'plugin' valid_plugins ;;
plugin::info) plugin::info)
local -aU plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(.N:h:t)) local -aU plugins
plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
_describe 'plugin' plugins ;; _describe 'plugin' plugins ;;
theme::(set|use)) theme::(set|use))
local -aU themes=("$ZSH"/themes/*.zsh-theme(.N:t:r) "$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::)) local -aU themes
themes=("$ZSH"/themes/*.zsh-theme(-.N:t:r) "$ZSH_CUSTOM"/**/*.zsh-theme(-.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
_describe 'theme' themes ;; _describe 'theme' themes ;;
esac esac
elif (( CURRENT > 4 )); then elif (( CURRENT > 4 )); then
@ -81,7 +85,7 @@ function _omz {
# if command is "disable", only offer already enabled plugins # if command is "disable", only offer already enabled plugins
valid_plugins=($plugins) valid_plugins=($plugins)
else else
valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(.N:h:t)) valid_plugins=("$ZSH"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t) "$ZSH_CUSTOM"/plugins/*/{_*,*.plugin.zsh}(-.N:h:t))
# if command is "enable", remove already enabled plugins # if command is "enable", remove already enabled plugins
[[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins}) [[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins})
fi fi
@ -90,7 +94,8 @@ function _omz {
# NOTE: $(( CURRENT - 1 )) is the last plugin argument completely passed, i.e. that which # NOTE: $(( CURRENT - 1 )) is the last plugin argument completely passed, i.e. that which
# has a space after them. This is to avoid removing plugins partially passed, which makes # has a space after them. This is to avoid removing plugins partially passed, which makes
# the completion not add a space after the completed plugin. # the completion not add a space after the completed plugin.
local -a args=(${words[4,$(( CURRENT - 1))]}) local -a args
args=(${words[4,$(( CURRENT - 1))]})
valid_plugins=(${valid_plugins:|args}) valid_plugins=(${valid_plugins:|args})
_describe 'plugin' valid_plugins ;; _describe 'plugin' valid_plugins ;;
@ -159,8 +164,10 @@ Available commands:
changelog Print the changelog changelog Print the changelog
plugin <command> Manage plugins plugin <command> Manage plugins
pr <command> Manage Oh My Zsh Pull Requests pr <command> Manage Oh My Zsh Pull Requests
reload Reload the current zsh session
theme <command> Manage themes theme <command> Manage themes
update Update Oh My Zsh update Update Oh My Zsh
version Show the version
EOF EOF
} }
@ -168,11 +175,14 @@ EOF
function _omz::changelog { function _omz::changelog {
local version=${1:-HEAD} format=${3:-"--text"} local version=${1:-HEAD} format=${3:-"--text"}
if ! command git -C "$ZSH" show-ref --verify refs/heads/$version &>/dev/null && \ if (
! command git -C "$ZSH" show-ref --verify refs/tags/$version &>/dev/null && \ builtin cd -q "$ZSH"
! command git -C "$ZSH" rev-parse --verify "${version}^{commit}" &>/dev/null; then ! command git show-ref --verify refs/heads/$version && \
! command git show-ref --verify refs/tags/$version && \
! command git rev-parse --verify "${version}^{commit}"
) &>/dev/null; then
cat >&2 <<EOF cat >&2 <<EOF
Usage: omz changelog [version] Usage: ${(j: :)${(s.::.)0#_}} [version]
NOTE: <version> must be a valid branch, tag or commit. NOTE: <version> must be a valid branch, tag or commit.
EOF EOF
@ -183,9 +193,9 @@ EOF
} }
function _omz::plugin { function _omz::plugin {
(( $# > 0 && $+functions[_omz::plugin::$1] )) || { (( $# > 0 && $+functions[$0::$1] )) || {
cat >&2 <<EOF cat >&2 <<EOF
Usage: omz plugin <command> [options] Usage: ${(j: :)${(s.::.)0#_}} <command> [options]
Available commands: Available commands:
@ -202,17 +212,17 @@ EOF
local command="$1" local command="$1"
shift shift
_omz::plugin::$command "$@" $0::$command "$@"
} }
function _omz::plugin::disable { function _omz::plugin::disable {
if [[ -z "$1" ]]; then if [[ -z "$1" ]]; then
echo >&2 "Usage: omz plugin disable <plugin> [...]" echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin> [...]"
return 1 return 1
fi fi
# Check that plugin is in $plugins # Check that plugin is in $plugins
local -a dis_plugins=() local -a dis_plugins
for plugin in "$@"; do for plugin in "$@"; do
if [[ ${plugins[(Ie)$plugin]} -eq 0 ]]; then if [[ ${plugins[(Ie)$plugin]} -eq 0 ]]; then
_omz::log warn "plugin '$plugin' is not enabled." _omz::log warn "plugin '$plugin' is not enabled."
@ -266,9 +276,10 @@ multi == 1 && length(\$0) > 0 {
{ print \$0 } { print \$0 }
" "
awk "$awk_script" ~/.zshrc > ~/.zshrc.new \ local zdot="${ZDOTDIR:-$HOME}"
&& command mv -f ~/.zshrc ~/.zshrc.bck \ awk "$awk_script" "$zdot/.zshrc" > "$zdot/.zshrc.new" \
&& command mv -f ~/.zshrc.new ~/.zshrc && command mv -f "$zdot/.zshrc" "$zdot/.zshrc.bck" \
&& command mv -f "$zdot/.zshrc.new" "$zdot/.zshrc"
# Exit if the new .zshrc file wasn't created correctly # Exit if the new .zshrc file wasn't created correctly
[[ $? -eq 0 ]] || { [[ $? -eq 0 ]] || {
@ -278,10 +289,10 @@ multi == 1 && length(\$0) > 0 {
} }
# Exit if the new .zshrc file has syntax errors # Exit if the new .zshrc file has syntax errors
if ! zsh -n ~/.zshrc; then if ! command zsh -n "$zdot/.zshrc"; then
_omz::log error "broken syntax in ~/.zshrc. Rolling back changes..." _omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
command mv -f ~/.zshrc ~/.zshrc.new command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
command mv -f ~/.zshrc.bck ~/.zshrc command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
return 1 return 1
fi fi
@ -296,12 +307,12 @@ multi == 1 && length(\$0) > 0 {
function _omz::plugin::enable { function _omz::plugin::enable {
if [[ -z "$1" ]]; then if [[ -z "$1" ]]; then
echo >&2 "Usage: omz plugin enable <plugin> [...]" echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin> [...]"
return 1 return 1
fi fi
# Check that plugin is not in $plugins # Check that plugin is not in $plugins
local -a add_plugins=() local -a add_plugins
for plugin in "$@"; do for plugin in "$@"; do
if [[ ${plugins[(Ie)$plugin]} -ne 0 ]]; then if [[ ${plugins[(Ie)$plugin]} -ne 0 ]]; then
_omz::log warn "plugin '$plugin' is already enabled." _omz::log warn "plugin '$plugin' is already enabled."
@ -341,9 +352,10 @@ multi == 1 && /^[^#]*\)/ {
{ print \$0 } { print \$0 }
" "
awk "$awk_script" ~/.zshrc > ~/.zshrc.new \ local zdot="${ZDOTDIR:-$HOME}"
&& command mv -f ~/.zshrc ~/.zshrc.bck \ awk "$awk_script" "$zdot/.zshrc" > "$zdot/.zshrc.new" \
&& command mv -f ~/.zshrc.new ~/.zshrc && command mv -f "$zdot/.zshrc" "$zdot/.zshrc.bck" \
&& command mv -f "$zdot/.zshrc.new" "$zdot/.zshrc"
# Exit if the new .zshrc file wasn't created correctly # Exit if the new .zshrc file wasn't created correctly
[[ $? -eq 0 ]] || { [[ $? -eq 0 ]] || {
@ -353,10 +365,10 @@ multi == 1 && /^[^#]*\)/ {
} }
# Exit if the new .zshrc file has syntax errors # Exit if the new .zshrc file has syntax errors
if ! zsh -n ~/.zshrc; then if ! command zsh -n "$zdot/.zshrc"; then
_omz::log error "broken syntax in ~/.zshrc. Rolling back changes..." _omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
command mv -f ~/.zshrc ~/.zshrc.new command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
command mv -f ~/.zshrc.bck ~/.zshrc command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
return 1 return 1
fi fi
@ -371,7 +383,7 @@ multi == 1 && /^[^#]*\)/ {
function _omz::plugin::info { function _omz::plugin::info {
if [[ -z "$1" ]]; then if [[ -z "$1" ]]; then
echo >&2 "Usage: omz plugin info <plugin>" echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin>"
return 1 return 1
fi fi
@ -418,14 +430,12 @@ function _omz::plugin::list {
function _omz::plugin::load { function _omz::plugin::load {
if [[ -z "$1" ]]; then if [[ -z "$1" ]]; then
echo >&2 "Usage: omz plugin load <plugin> [...]" echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin> [...]"
return 1 return 1
fi fi
local plugins=("$@")
local plugin base has_completion=0 local plugin base has_completion=0
for plugin in "$@"; do
for plugin in $plugins; do
if [[ -d "$ZSH_CUSTOM/plugins/$plugin" ]]; then if [[ -d "$ZSH_CUSTOM/plugins/$plugin" ]]; then
base="$ZSH_CUSTOM/plugins/$plugin" base="$ZSH_CUSTOM/plugins/$plugin"
elif [[ -d "$ZSH/plugins/$plugin" ]]; then elif [[ -d "$ZSH/plugins/$plugin" ]]; then
@ -445,9 +455,9 @@ function _omz::plugin::load {
fi fi
# Check if it has completion to reload compinit # Check if it has completion to reload compinit
if [[ -f "$base/_$plugin" ]]; then local -a comp_files
has_completion=1 comp_files=($base/_*(N))
fi has_completion=$(( $#comp_files > 0 ))
# Load the plugin # Load the plugin
if [[ -f "$base/$plugin.plugin.zsh" ]]; then if [[ -f "$base/$plugin.plugin.zsh" ]]; then
@ -467,9 +477,9 @@ function _omz::plugin::load {
} }
function _omz::pr { function _omz::pr {
(( $# > 0 && $+functions[_omz::pr::$1] )) || { (( $# > 0 && $+functions[$0::$1] )) || {
cat >&2 <<EOF cat >&2 <<EOF
Usage: omz pr <command> [options] Usage: ${(j: :)${(s.::.)0#_}} <command> [options]
Available commands: Available commands:
@ -483,7 +493,7 @@ EOF
local command="$1" local command="$1"
shift shift
_omz::pr::$command "$@" $0::$command "$@"
} }
function _omz::pr::clean { function _omz::pr::clean {
@ -524,7 +534,7 @@ function _omz::pr::test {
# Check the input # Check the input
if ! [[ -n "$1" && "$1" =~ ^[[:digit:]]+$ ]]; then if ! [[ -n "$1" && "$1" =~ ^[[:digit:]]+$ ]]; then
echo >&2 "Usage: omz pr test <PR_NUMBER_or_URL>" echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <PR_NUMBER_or_URL>"
return 1 return 1
fi fi
@ -598,10 +608,20 @@ function _omz::pr::test {
) )
} }
function _omz::reload {
# Delete current completion cache
command rm -f $_comp_dumpfile $ZSH_COMPDUMP
# Old zsh versions don't have ZSH_ARGZERO
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
# Check whether to run a login shell
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
}
function _omz::theme { function _omz::theme {
(( $# > 0 && $+functions[_omz::theme::$1] )) || { (( $# > 0 && $+functions[$0::$1] )) || {
cat >&2 <<EOF cat >&2 <<EOF
Usage: omz theme <command> [options] Usage: ${(j: :)${(s.::.)0#_}} <command> [options]
Available commands: Available commands:
@ -616,7 +636,7 @@ EOF
local command="$1" local command="$1"
shift shift
_omz::theme::$command "$@" $0::$command "$@"
} }
function _omz::theme::list { function _omz::theme::list {
@ -630,22 +650,28 @@ function _omz::theme::list {
return return
fi fi
# Print theme in use
if [[ -n "$ZSH_THEME" ]]; then
print -Pn "%U%BCurrent theme%b%u: "
[[ $ZSH_THEME = random ]] && echo "$RANDOM_THEME (via random)" || echo "$ZSH_THEME"
echo
fi
# Print custom themes if there are any
if (( ${#custom_themes} )); then if (( ${#custom_themes} )); then
print -P "%U%BCustom themes%b%u:" print -P "%U%BCustom themes%b%u:"
print -l ${(q-)custom_themes} | column -x print -l ${(q-)custom_themes} | column -x
echo
fi fi
if (( ${#builtin_themes} )); then # Print built-in themes
(( ${#custom_themes} )) && echo # add a line of separation
print -P "%U%BBuilt-in themes%b%u:" print -P "%U%BBuilt-in themes%b%u:"
print -l ${(q-)builtin_themes} | column -x print -l ${(q-)builtin_themes} | column -x
fi
} }
function _omz::theme::set { function _omz::theme::set {
if [[ -z "$1" ]]; then if [[ -z "$1" ]]; then
echo >&2 "Usage: omz theme set <theme>" echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <theme>"
return 1 return 1
fi fi
@ -674,17 +700,18 @@ END {
} }
' '
awk "$awk_script" ~/.zshrc > ~/.zshrc.new \ local zdot="${ZDOTDIR:-$HOME}"
awk "$awk_script" "$zdot/.zshrc" > "$zdot/.zshrc.new" \
|| { || {
# Prepend ZSH_THEME= line to .zshrc if it doesn't exist # Prepend ZSH_THEME= line to .zshrc if it doesn't exist
cat <<EOF cat <<EOF
ZSH_THEME="$1" # set by \`omz\` ZSH_THEME="$1" # set by \`omz\`
EOF EOF
cat ~/.zshrc cat "$zdot/.zshrc"
} > ~/.zshrc.new \ } > "$zdot/.zshrc.new" \
&& command mv -f ~/.zshrc ~/.zshrc.bck \ && command mv -f "$zdot/.zshrc" "$zdot/.zshrc.bck" \
&& command mv -f ~/.zshrc.new ~/.zshrc && command mv -f "$zdot/.zshrc.new" "$zdot/.zshrc"
# Exit if the new .zshrc file wasn't created correctly # Exit if the new .zshrc file wasn't created correctly
[[ $? -eq 0 ]] || { [[ $? -eq 0 ]] || {
@ -694,10 +721,10 @@ EOF
} }
# Exit if the new .zshrc file has syntax errors # Exit if the new .zshrc file has syntax errors
if ! zsh -n ~/.zshrc; then if ! command zsh -n "$zdot/.zshrc"; then
_omz::log error "broken syntax in ~/.zshrc. Rolling back changes..." _omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
command mv -f ~/.zshrc ~/.zshrc.new command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
command mv -f ~/.zshrc.bck ~/.zshrc command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
return 1 return 1
fi fi
@ -712,7 +739,7 @@ EOF
function _omz::theme::use { function _omz::theme::use {
if [[ -z "$1" ]]; then if [[ -z "$1" ]]; then
echo >&2 "Usage: omz theme use <theme>" echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <theme>"
return 1 return 1
fi fi
@ -727,16 +754,20 @@ function _omz::theme::use {
_omz::log error "%B$1%b theme not found" _omz::log error "%B$1%b theme not found"
return 1 return 1
fi fi
# Update theme settings
ZSH_THEME="$1"
[[ $1 = random ]] || unset RANDOM_THEME
} }
function _omz::update { function _omz::update {
local last_commit=$(cd "$ZSH"; git rev-parse HEAD) local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD)
# Run update script # Run update script
if [[ "$1" != --unattended ]]; then if [[ "$1" != --unattended ]]; then
ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" --interactive ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" --interactive || return $?
else else
ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" || return $?
fi fi
# Update last updated file # Update last updated file
@ -746,10 +777,32 @@ function _omz::update {
command rm -rf "$ZSH/log/update.lock" command rm -rf "$ZSH/log/update.lock"
# Restart the zsh session if there were changes # Restart the zsh session if there were changes
if [[ "$1" != --unattended && "$(cd "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then if [[ "$1" != --unattended && "$(builtin cd -q "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then
# Old zsh versions don't have ZSH_ARGZERO # Old zsh versions don't have ZSH_ARGZERO
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}" local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
# Check whether to run a login shell # Check whether to run a login shell
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh" [[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
fi fi
} }
function _omz::version {
(
builtin cd -q "$ZSH"
# Get the version name:
# 1) try tag-like version
# 2) try branch name
# 3) try name-rev (tag~<rev> or branch~<rev>)
local version
version=$(command git describe --tags HEAD 2>/dev/null) \
|| version=$(command git symbolic-ref --quiet --short HEAD 2>/dev/null) \
|| version=$(command git name-rev --no-undefined --name-only --exclude="remotes/*" HEAD 2>/dev/null) \
|| version="<detached>"
# Get short hash for the current HEAD
local commit=$(command git rev-parse --short HEAD 2>/dev/null)
# Show version and commit hash
printf "%s (%s)\n" "$version" "$commit"
)
}

View File

@ -9,6 +9,7 @@ if [[ "$ENABLE_CORRECTION" == "true" ]]; then
alias mv='nocorrect mv' alias mv='nocorrect mv'
alias mysql='nocorrect mysql' alias mysql='nocorrect mysql'
alias sudo='nocorrect sudo' alias sudo='nocorrect sudo'
alias su='nocorrect su'
setopt correct_all setopt correct_all
fi fi

View File

@ -335,7 +335,7 @@ function _omz_diag_dump_os_specific_version() {
builtin echo "OS Version: $osname $osver build $(sw_vers -buildVersion)" builtin echo "OS Version: $osname $osver build $(sw_vers -buildVersion)"
;; ;;
cygwin) cygwin)
command systeminfo | command head -4 | command tail -2 command systeminfo | command head -n 4 | command tail -n 2
;; ;;
esac esac

View File

@ -9,7 +9,7 @@ alias -g .....='../../../..'
alias -g ......='../../../../..' alias -g ......='../../../../..'
alias -- -='cd -' alias -- -='cd -'
alias 1='cd -' alias 1='cd -1'
alias 2='cd -2' alias 2='cd -2'
alias 3='cd -3' alias 3='cd -3'
alias 4='cd -4' alias 4='cd -4'
@ -26,7 +26,7 @@ function d () {
if [[ -n $1 ]]; then if [[ -n $1 ]]; then
dirs "$@" dirs "$@"
else else
dirs -v | head -10 dirs -v | head -n 10
fi fi
} }
compdef _dirs d compdef _dirs d

View File

@ -1,7 +1,7 @@
function zsh_stats() { function zsh_stats() {
fc -l 1 \ fc -l 1 \
| awk '{ CMD[$2]++; count++; } END { for (a in CMD) print CMD[a] " " CMD[a]*100/count "% " a }' \ | awk '{ CMD[$2]++; count++; } END { for (a in CMD) print CMD[a] " " CMD[a]*100/count "% " a }' \
| grep -v "./" | sort -nr | head -20 | column -c3 -s " " -t | nl | grep -v "./" | sort -nr | head -n 20 | column -c3 -s " " -t | nl
} }
function uninstall_oh_my_zsh() { function uninstall_oh_my_zsh() {
@ -45,7 +45,7 @@ function takeurl() {
data="$(mktemp)" data="$(mktemp)"
curl -L "$1" > "$data" curl -L "$1" > "$data"
tar xf "$data" tar xf "$data"
thedir="$(tar tf "$data" | head -1)" thedir="$(tar tf "$data" | head -n 1)"
rm "$data" rm "$data"
cd "$thedir" cd "$thedir"
} }
@ -237,12 +237,11 @@ function omz_urldecode {
tmp=${tmp:gs/\\/\\\\/} tmp=${tmp:gs/\\/\\\\/}
# Handle %-escapes by turning them into `\xXX` printf escapes # Handle %-escapes by turning them into `\xXX` printf escapes
tmp=${tmp:gs/%/\\x/} tmp=${tmp:gs/%/\\x/}
local decoded local decoded="$(printf -- "$tmp")"
eval "decoded=\$'$tmp'"
# Now we have a UTF-8 encoded string in the variable. We need to re-encode # Now we have a UTF-8 encoded string in the variable. We need to re-encode
# it if caller is in a non-UTF-8 locale. # it if caller is in a non-UTF-8 locale.
local safe_encodings local -a safe_encodings
safe_encodings=(UTF-8 utf8 US-ASCII) safe_encodings=(UTF-8 utf8 US-ASCII)
if [[ -z ${safe_encodings[(r)$caller_encoding]} ]]; then if [[ -z ${safe_encodings[(r)$caller_encoding]} ]]; then
decoded=$(echo -E "$decoded" | iconv -f UTF-8 -t $caller_encoding) decoded=$(echo -E "$decoded" | iconv -f UTF-8 -t $caller_encoding)

View File

@ -29,7 +29,7 @@ function git_prompt_info() {
&& upstream=" -> ${upstream}" && upstream=" -> ${upstream}"
fi fi
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref}${upstream}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}" echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref:gs/%/%%}${upstream:gs/%/%%}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}"
} }
# Checks if working tree is dirty # Checks if working tree is dirty
@ -51,7 +51,7 @@ function parse_git_dirty() {
FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}" FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}"
;; ;;
esac esac
STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -1) STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n 1)
fi fi
if [[ -n $STATUS ]]; then if [[ -n $STATUS ]]; then
echo "$ZSH_THEME_GIT_PROMPT_DIRTY" echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
@ -82,7 +82,7 @@ function git_remote_status() {
fi fi
if [[ -n $ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_DETAILED ]]; then if [[ -n $ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_DETAILED ]]; then
git_remote_status="$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_PREFIX$remote$git_remote_status_detailed$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_SUFFIX" git_remote_status="$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_PREFIX${remote:gs/%/%%}$git_remote_status_detailed$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_SUFFIX"
fi fi
echo $git_remote_status echo $git_remote_status
@ -206,7 +206,8 @@ function git_prompt_status() {
STASHED UNMERGED AHEAD BEHIND DIVERGED STASHED UNMERGED AHEAD BEHIND DIVERGED
) )
local status_text="$(__git_prompt_git status --porcelain -b 2> /dev/null)" local status_text
status_text="$(__git_prompt_git status --porcelain -b 2> /dev/null)"
# Don't continue on a catastrophic failure # Don't continue on a catastrophic failure
if [[ $? -eq 128 ]]; then if [[ $? -eq 128 ]]; then

View File

@ -2,5 +2,5 @@
function nvm_prompt_info() { function nvm_prompt_info() {
which nvm &>/dev/null || return which nvm &>/dev/null || return
local nvm_prompt=${$(nvm current)#v} local nvm_prompt=${$(nvm current)#v}
echo "${ZSH_THEME_NVM_PROMPT_PREFIX}${nvm_prompt}${ZSH_THEME_NVM_PROMPT_SUFFIX}" echo "${ZSH_THEME_NVM_PROMPT_PREFIX}${nvm_prompt:gs/%/%%}${ZSH_THEME_NVM_PROMPT_SUFFIX}"
} }

View File

@ -30,7 +30,7 @@ function rvm_prompt_info() {
local rvm_prompt local rvm_prompt
rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${=ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null) rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${=ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null)
[[ -z "${rvm_prompt}" ]] && return 1 [[ -z "${rvm_prompt}" ]] && return 1
echo "${ZSH_THEME_RUBY_PROMPT_PREFIX}${rvm_prompt}${ZSH_THEME_RUBY_PROMPT_SUFFIX}" echo "${ZSH_THEME_RUBY_PROMPT_PREFIX}${rvm_prompt:gs/%/%%}${ZSH_THEME_RUBY_PROMPT_SUFFIX}"
} }
ZSH_THEME_RVM_PROMPT_OPTIONS="i v g" ZSH_THEME_RVM_PROMPT_OPTIONS="i v g"

View File

@ -20,16 +20,18 @@ done
# Show all 256 colors with color number # Show all 256 colors with color number
function spectrum_ls() { function spectrum_ls() {
setopt localoptions nopromptsubst
local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris} local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
for code in {000..255}; do for code in {000..255}; do
print -P -- "$code: $FG[$code]$ZSH_SPECTRUM_TEXT%{$reset_color%}" print -P -- "$code: ${FG[$code]}${ZSH_SPECTRUM_TEXT}%{$reset_color%}"
done done
} }
# Show all 256 colors where the background is set to specific color # Show all 256 colors where the background is set to specific color
function spectrum_bls() { function spectrum_bls() {
setopt localoptions nopromptsubst
local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris} local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
for code in {000..255}; do for code in {000..255}; do
print -P -- "$code: $BG[$code]$ZSH_SPECTRUM_TEXT%{$reset_color%}" print -P -- "$code: ${BG[$code]}${ZSH_SPECTRUM_TEXT}%{$reset_color%}"
done done
} }

View File

@ -7,10 +7,10 @@
# (In screen, only short_tab_title is used) # (In screen, only short_tab_title is used)
# Limited support for Apple Terminal (Terminal can't set window and tab separately) # Limited support for Apple Terminal (Terminal can't set window and tab separately)
function title { function title {
emulate -L zsh setopt localoptions nopromptsubst
setopt prompt_subst
[[ "$INSIDE_EMACS" == *term* ]] && return # Don't set the title if inside emacs, unless using vterm
[[ -n "${INSIDE_EMACS:-}" && "$INSIDE_EMACS" != vterm ]] && return
# if $2 is unset use $1 as default # if $2 is unset use $1 as default
# if it is set and empty, leave it as is # if it is set and empty, leave it as is
@ -29,12 +29,9 @@ function title {
print -Pn "\e]2;${2:q}\a" # set window name print -Pn "\e]2;${2:q}\a" # set window name
print -Pn "\e]1;${1:q}\a" # set tab name print -Pn "\e]1;${1:q}\a" # set tab name
else else
# Try to use terminfo to set the title # Try to use terminfo to set the title if the feature is available
# If the feature is available set title if (( ${+terminfo[fsl]} && ${+terminfo[tsl]} )); then
if [[ -n "$terminfo[fsl]" ]] && [[ -n "$terminfo[tsl]" ]]; then print -Pn "${terminfo[tsl]}$1${terminfo[fsl]}"
echoti tsl
print -Pn "$1"
echoti fsl
fi fi
fi fi
;; ;;
@ -50,13 +47,13 @@ fi
# Runs before showing the prompt # Runs before showing the prompt
function omz_termsupport_precmd { function omz_termsupport_precmd {
[[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return [[ "${DISABLE_AUTO_TITLE:-}" != true ]] || return
title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE title "$ZSH_THEME_TERM_TAB_TITLE_IDLE" "$ZSH_THEME_TERM_TITLE_IDLE"
} }
# Runs before executing the command # Runs before executing the command
function omz_termsupport_preexec { function omz_termsupport_preexec {
[[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return [[ "${DISABLE_AUTO_TITLE:-}" != true ]] || return
emulate -L zsh emulate -L zsh
setopt extended_glob setopt extended_glob
@ -99,16 +96,18 @@ function omz_termsupport_preexec {
fi fi
# cmd name only, or if this is sudo or ssh, the next cmd # cmd name only, or if this is sudo or ssh, the next cmd
local CMD=${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%} local CMD="${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%}"
local LINE="${2:gs/%/%%}" local LINE="${2:gs/%/%%}"
title '$CMD' '%100>...>$LINE%<<' title "$CMD" "%100>...>${LINE}%<<"
} }
autoload -U add-zsh-hook autoload -Uz add-zsh-hook
if [[ -z "$INSIDE_EMACS" || "$INSIDE_EMACS" = vterm ]]; then
add-zsh-hook precmd omz_termsupport_precmd add-zsh-hook precmd omz_termsupport_precmd
add-zsh-hook preexec omz_termsupport_preexec add-zsh-hook preexec omz_termsupport_preexec
fi
# Keep Apple Terminal.app's current working directory updated # Keep Apple Terminal.app's current working directory updated
# Based on this answer: https://superuser.com/a/315029 # Based on this answer: https://superuser.com/a/315029

View File

@ -40,7 +40,7 @@ if [[ "$DISABLE_LS_COLORS" != "true" ]]; then
fi fi
# enable diff color if possible. # enable diff color if possible.
if command diff --color . . &>/dev/null; then if command diff --color /dev/null /dev/null &>/dev/null; then
alias diff='diff --color' alias diff='diff --color'
fi fi

View File

@ -1,3 +1,43 @@
# Protect against non-zsh execution of Oh My Zsh (use POSIX syntax here)
[ -n "$ZSH_VERSION" ] || {
# ANSI formatting function (\033[<code>m)
# 0: reset, 1: bold, 4: underline, 22: no bold, 24: no underline, 31: red, 33: yellow
omz_f() {
[ $# -gt 0 ] || return
IFS=";" printf "\033[%sm" $*
}
# If stdout is not a terminal ignore all formatting
[ -t 1 ] || omz_f() { :; }
omz_ptree() {
# Get process tree of the current process
pid=$$; pids="$pid"
while [ ${pid-0} -ne 1 ] && ppid=$(ps -e -o pid,ppid | awk "\$1 == $pid { print \$2 }"); do
pids="$pids $pid"; pid=$ppid
done
# Show process tree
case "$(uname)" in
Linux) ps -o ppid,pid,command -f -p $pids 2>/dev/null ;;
Darwin|*) ps -o ppid,pid,command -p $pids 2>/dev/null ;;
esac
# If ps command failed, try Busybox ps
[ $? -eq 0 ] || ps -o ppid,pid,comm | awk "NR == 1 || index(\"$pids\", \$2) != 0"
}
{
shell=$(ps -o pid,comm | awk "\$1 == $$ { print \$2 }")
printf "$(omz_f 1 31)Error:$(omz_f 22) Oh My Zsh can't be loaded from: $(omz_f 1)${shell}$(omz_f 22). "
printf "You need to run $(omz_f 1)zsh$(omz_f 22) instead.$(omz_f 0)\n"
printf "$(omz_f 33)Here's the process tree:$(omz_f 22)\n\n"
omz_ptree
printf "$(omz_f 0)\n"
} >&2
return 1
}
# If ZSH is not defined, use the current script's directory. # If ZSH is not defined, use the current script's directory.
[[ -z "$ZSH" ]] && export ZSH="${${(%):-%x}:a:h}" [[ -z "$ZSH" ]] && export ZSH="${${(%):-%x}:a:h}"

View File

@ -0,0 +1,46 @@
if (( ${+commands[op]} )); then
eval "$(op completion zsh)"
compdef _op op
fi
# opswd puts the password of the named service into the clipboard. If there's a
# one time password, it will be copied into the clipboard after 5 seconds. The
# clipboard is cleared after another 10 seconds.
function opswd() {
if [[ $# -lt 1 ]]; then
echo "Usage: opswd <service>"
return 1
fi
local service=$1
# If not logged in, print error and return
op list users > /dev/null || return
local password
# Copy the password to the clipboard
if ! password=$(op get item "$service" --fields password 2>/dev/null); then
echo "error: could not obtain password for $service"
return 1
fi
echo -n "$password" | clipcopy
echo "✔ password for $service copied to clipboard"
# If there's a one time password, copy it to the clipboard after 5 seconds
local totp
if totp=$(op get totp "$service" 2>/dev/null) && [[ -n "$totp" ]]; then
sleep 10 && echo -n "$totp" | clipcopy
echo "✔ TOTP for $service copied to clipboard"
fi
(sleep 20 && clipcopy </dev/null 2>/dev/null) &!
}
function _opswd() {
local -a services
services=("${(@f)$(op list items --categories Login 2>/dev/null | op get item - --fields title 2>/dev/null)}")
[[ -z "$services" ]] || compadd -a -- services
}
compdef _opswd opswd

View File

@ -0,0 +1,35 @@
# 1Password
This plugin adds 1Password functionality to oh-my-zsh.
To use, add `1password` to the list of plugins in your `.zshrc` file:
```zsh
plugins=(... 1password)
```
Then, you can use the command `opswd` to copy passwords for services into your
clipboard.
## `opswd`
The `opswd` command is a wrapper around the `op` command. It takes a service
name as an argument and copies the password for that service to the clipboard.
If the service also contains a TOTP, it is copied to the clipboard after 10 seconds.
Finally, after 20 seconds, the clipboard is cleared.
The function has completion support, so you can use tab completion to select
which service you want to get.
For example, `opswd github.com` will put your GitHub password into your clipboard, and if
a TOTP is available, it will be copied to the clipboard after 10 seconds.
> NOTE: you need to be logged in for `opswd` to work. See:
>
> - [Sign in or out](https://support.1password.com/command-line/#sign-in-or-out)
> - [Session management](https://support.1password.com/command-line/#appendix-session-management)
## Requirements
- [1Password's command line utility](https://1password.com/downloads/command-line/).

1
zsh/plugins/aliases/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
__pycache__

View File

@ -1,21 +1,22 @@
## Aliases Cheatsheet # Aliases cheatsheet
**Maintainer:** [@hqingyi](https://github.com/hqingyi) **Maintainer:** [@hqingyi](https://github.com/hqingyi)
With lots of 3rd-party amazing aliases installed, this plugin helps list the shortcuts With lots of 3rd-party amazing aliases installed, this plugin helps list the shortcuts
that are currently available based on the plugins you have enabled. that are currently available based on the plugins you have enabled.
Enable this plugin by adding it to your `plugins` definition in `~/.zshrc`. To use it, add `aliases` to the plugins array in your zshrc file:
``` ```zsh
plugins=(aliases) plugins=(aliases)
``` ```
Requirements: Python needs to be installed. Requirements: Python needs to be installed.
### Usage ## Usage
``` - `acs`: show all aliases by group.
acs: group all alias
acs $keywordquickly filter alias & highlight - `acs <keyword>`: filter aliases by `<keyword>` and highlight.
```
![screenshot](https://cloud.githubusercontent.com/assets/3602957/11581913/cb54fb8a-9a82-11e5-846b-5a67f67ad9ad.png)

View File

@ -2,9 +2,10 @@
# #
# - acs: alias cheatsheet # - acs: alias cheatsheet
# group alias by command, pass addition argv to grep. # group alias by command, pass addition argv to grep.
ALIASES_PLUGIN_ROOT=$(cd `dirname $0` && pwd)
function acs(){ function acs(){
which python >>/dev/null (( $+commands[python] )) || {
[[ $? -eq 1 ]] && echo "[error]no python executable detected!" && return echo "[error] No python executable detected"
alias | python $ALIASES_PLUGIN_ROOT/cheatsheet.py $@ return
}
alias | python ${functions_source[$0]:h}/cheatsheet.py $@
} }

View File

@ -26,16 +26,16 @@ def cheatsheet(lines):
target_aliases.extend(group_list) target_aliases.extend(group_list)
return cheatsheet return cheatsheet
def pretty_print_group(key, aliases, hightlight=None): def pretty_print_group(key, aliases, highlight=None):
if len(aliases) == 0: if len(aliases) == 0:
return return
group_hl_formatter = lambda g, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'red') for part in ('[%s]' % g).split(hl)]) group_hl_formatter = lambda g, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'red') for part in ('[%s]' % g).split(hl)])
alias_hl_formatter = lambda alias, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'green') for part in ('\t%s = %s' % alias[0:2]).split(hl)]) alias_hl_formatter = lambda alias, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'green') for part in ('\t%s = %s' % alias[0:2]).split(hl)])
group_formatter = lambda g: termcolor.colored('[%s]' % g, 'red') group_formatter = lambda g: termcolor.colored('[%s]' % g, 'red')
alias_formatter = lambda alias: termcolor.colored('\t%s = %s' % alias[0:2], 'green') alias_formatter = lambda alias: termcolor.colored('\t%s = %s' % alias[0:2], 'green')
if hightlight and len(hightlight)>0: if highlight and len(highlight)>0:
print (group_hl_formatter(key, hightlight)) print (group_hl_formatter(key, highlight))
print ('\n'.join([alias_hl_formatter(alias, hightlight) for alias in aliases])) print ('\n'.join([alias_hl_formatter(alias, highlight) for alias in aliases]))
else: else:
print (group_formatter(key)) print (group_formatter(key))
print ('\n'.join([alias_formatter(alias) for alias in aliases])) print ('\n'.join([alias_formatter(alias) for alias in aliases]))

View File

@ -21,7 +21,7 @@
# #
# Author: Konstantin Lepa <konstantin.lepa@gmail.com> # Author: Konstantin Lepa <konstantin.lepa@gmail.com>
"""ANSII Color formatting for output in terminal.""" """ANSI Color formatting for output in terminal."""
from __future__ import print_function from __future__ import print_function
import os import os

View File

@ -2,9 +2,9 @@
This plugin provides completion for [Ant](https://ant.apache.org/). This plugin provides completion for [Ant](https://ant.apache.org/).
To use it add ant to the plugins array in your zshrc file. To use it, add `ant` to the plugins array in your zshrc file:
```bash ```zsh
plugins=(... ant) plugins=(... ant)
``` ```

22
zsh/plugins/ant/_ant Normal file
View File

@ -0,0 +1,22 @@
#compdef ant
_ant_does_target_list_need_generating () {
[[ ! -f .ant_targets ]] && return 0
[[ build.xml -nt .ant_targets ]] && return 0
return 1
}
_ant () {
if [[ ! -f build.xml ]]; then
return
fi
if ! _ant_does_target_list_need_generating; then
return
fi
ant -p | awk -F " " 'NR > 5 { print lastTarget } { lastTarget = $1 }' >| .ant_targets
compadd -- "$(cat .ant_targets)"
}
_ant "$@"

View File

@ -1,16 +1,2 @@
_ant_does_target_list_need_generating () { # Default to colored output
[ ! -f .ant_targets ] && return 0; export ANT_ARGS='-logger org.apache.tools.ant.listener.AnsiColorLogger'
[ build.xml -nt .ant_targets ] && return 0;
return 1;
}
_ant () {
if [ -f build.xml ]; then
if _ant_does_target_list_need_generating; then
ant -p | awk -F " " 'NR > 5 { print lastTarget }{lastTarget = $1}' > .ant_targets
fi
compadd -- `cat .ant_targets`
fi
}
compdef _ant ant

View File

@ -14,6 +14,7 @@ plugins=(... arcanist)
| ------- | ---------------------------------- | | ------- | ---------------------------------- |
| ara | `arc amend` | | ara | `arc amend` |
| arb | `arc branch` | | arb | `arc branch` |
| arbl | `arc bland` |
| arco | `arc cover` | | arco | `arc cover` |
| arci | `arc commit` | | arci | `arc commit` |
| ard | `arc diff` | | ard | `arc diff` |
@ -24,6 +25,7 @@ plugins=(... arcanist)
| ardpc | `arc diff --plan-changes` | | ardpc | `arc diff --plan-changes` |
| are | `arc export` | | are | `arc export` |
| arh | `arc help` | | arh | `arc help` |
| arho | `arc hotfix` |
| arl | `arc land` | | arl | `arc land` |
| arli | `arc lint` | | arli | `arc lint` |
| arls | `arc list` | | arls | `arc list` |

View File

@ -5,6 +5,7 @@
alias ara='arc amend' alias ara='arc amend'
alias arb='arc branch' alias arb='arc branch'
alias arbl='arc bland'
alias arco='arc cover' alias arco='arc cover'
alias arci='arc commit' alias arci='arc commit'
@ -17,6 +18,7 @@ alias ardp='arc diff --preview' # creates a new diff in the phab interface
alias are='arc export' alias are='arc export'
alias arh='arc help' alias arh='arc help'
alias arho='arc hotfix'
alias arl='arc land' alias arl='arc land'
alias arli='arc lint' alias arli='arc lint'
alias arls='arc list' alias arls='arc list'

View File

@ -17,8 +17,10 @@ plugins=(... archlinux)
| pacin | `sudo pacman -S` | Install packages from the repositories | | pacin | `sudo pacman -S` | Install packages from the repositories |
| pacins | `sudo pacman -U` | Install a package from a local file | | pacins | `sudo pacman -U` | Install a package from a local file |
| pacinsd | `sudo pacman -S --asdeps` | Install packages as dependencies of another package | | pacinsd | `sudo pacman -S --asdeps` | Install packages as dependencies of another package |
| paclean | `sudo pacman -Sc` | Clean out old and unused caches and packages |
| pacloc | `pacman -Qi` | Display information about a package in the local database | | pacloc | `pacman -Qi` | Display information about a package in the local database |
| paclocs | `pacman -Qs` | Search for packages in the local database | | paclocs | `pacman -Qs` | Search for packages in the local database |
| paclr | `sudo pacman -Scc` | Remove all files from the cache |
| paclsorphans | `sudo pacman -Qdt` | List all orphaned packages | | paclsorphans | `sudo pacman -Qdt` | List all orphaned packages |
| pacmir | `sudo pacman -Syy` | Force refresh of all package lists after updating mirrorlist | | pacmir | `sudo pacman -Syy` | Force refresh of all package lists after updating mirrorlist |
| pacre | `sudo pacman -R` | Remove packages, keeping its settings and dependencies | | pacre | `sudo pacman -R` | Remove packages, keeping its settings and dependencies |
@ -32,7 +34,7 @@ plugins=(... archlinux)
| pacfiles | `pacman -F` | Search package file names for matching strings | | pacfiles | `pacman -F` | Search package file names for matching strings |
| pacls | `pacman -Ql` | List files in a package | | pacls | `pacman -Ql` | List files in a package |
| pacown | `pacman -Qo` | Show which package owns a file | | pacown | `pacman -Qo` | Show which package owns a file |
| upgrade[²](#f2) | `sudo pacman -Syu` | Sync with repositories before upgrading packages | | upgrade[¹](#f1) | `sudo pacman -Syu` | Sync with repositories before upgrading packages |
| Function | Description | | Function | Description |
|----------------|-----------------------------------------------------------| |----------------|-----------------------------------------------------------|
@ -52,6 +54,8 @@ upgrades were available. Use `pacman -Que` instead.
| Alias | Command | Description | | Alias | Command | Description |
|---------|-------------------------------------------------|-------------------------------------------------------------------------| |---------|-------------------------------------------------|-------------------------------------------------------------------------|
| auclean | `sudo aura -Sc` | Clean out old and unused caches and packages |
| auclr | `sudo aura -Scc` | Remove all files from the cache |
| auin | `sudo aura -S` | Install packages from the repositories | | auin | `sudo aura -S` | Install packages from the repositories |
| aurin | `sudo aura -A` | Install packages from the repositories | | aurin | `sudo aura -A` | Install packages from the repositories |
| auins | `sudo aura -U` | Install a package from a local file | | auins | `sudo aura -U` | Install a package from a local file |
@ -73,7 +77,7 @@ upgrades were available. Use `pacman -Que` instead.
| auupd | `sudo aura -Sy` | Update and refresh local package, ABS and AUR databases | | auupd | `sudo aura -Sy` | Update and refresh local package, ABS and AUR databases |
| auupg | `sudo sh -c "aura -Syu && aura -Au"` | Sync with repositories before upgrading all packages (from AUR too) | | auupg | `sudo sh -c "aura -Syu && aura -Au"` | Sync with repositories before upgrading all packages (from AUR too) |
| ausu | `sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"` | Same as `auupg`, but without confirmation | | ausu | `sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"` | Same as `auupg`, but without confirmation |
| upgrade[²](#f2) | `sudo aura -Syu` | Sync with repositories before upgrading packages | | upgrade[¹](#f1) | `sudo aura -Syu` | Sync with repositories before upgrading packages |
| Function | Description | | Function | Description |
|-----------------|---------------------------------------------------------------------| |-----------------|---------------------------------------------------------------------|
@ -84,6 +88,8 @@ upgrades were available. Use `pacman -Que` instead.
| Alias | Command | Description | | Alias | Command | Description |
|---------|-----------------------------------|---------------------------------------------------------------------| |---------|-----------------------------------|---------------------------------------------------------------------|
| pacclean| `pacaur -Sc` | Clean out old and unused caches and packages |
| pacclr | `pacaur -Scc` | Remove all files from the cache |
| pain | `pacaur -S` | Install packages from the repositories | | pain | `pacaur -S` | Install packages from the repositories |
| pains | `pacaur -U` | Install a package from a local file | | pains | `pacaur -U` | Install a package from a local file |
| painsd | `pacaur -S --asdeps` | Install packages as dependencies of another package | | painsd | `pacaur -S --asdeps` | Install packages as dependencies of another package |
@ -99,13 +105,15 @@ upgrades were available. Use `pacman -Que` instead.
| paupd | `pacaur -Sy` | Update and refresh local package, ABS and AUR databases | | paupd | `pacaur -Sy` | Update and refresh local package, ABS and AUR databases |
| paupg | `pacaur -Syua` | Sync with repositories before upgrading all packages (from AUR too) | | paupg | `pacaur -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
| pasu | `pacaur -Syua --no-confirm` | Same as `paupg`, but without confirmation | | pasu | `pacaur -Syua --no-confirm` | Same as `paupg`, but without confirmation |
| upgrade[²](#f2) | `pacaur -Syu` | Sync with repositories before upgrading packages | | upgrade[¹](#f1) | `pacaur -Syu` | Sync with repositories before upgrading packages |
#### Trizen #### Trizen
| Alias | Command | Description | | Alias | Command | Description |
|---------|-----------------------------------|---------------------------------------------------------------------| |---------|-----------------------------------|---------------------------------------------------------------------|
| trconf | `trizen -C` | Fix all configuration files with vimdiff | | trconf | `trizen -C` | Fix all configuration files with vimdiff |
| trclean | `trizen -Sc` | Clean out old and unused caches and packages |
| trclr | `trizen -Scc` | Remove all files from the cache |
| trin | `trizen -S` | Install packages from the repositories | | trin | `trizen -S` | Install packages from the repositories |
| trins | `trizen -U` | Install a package from a local file | | trins | `trizen -U` | Install a package from a local file |
| trinsd | `trizen -S --asdeps` | Install packages as dependencies of another package | | trinsd | `trizen -S --asdeps` | Install packages as dependencies of another package |
@ -121,35 +129,15 @@ upgrades were available. Use `pacman -Que` instead.
| trupd | `trizen -Sy` | Update and refresh local package, ABS and AUR databases | | trupd | `trizen -Sy` | Update and refresh local package, ABS and AUR databases |
| trupg | `trizen -Syua` | Sync with repositories before upgrading all packages (from AUR too) | | trupg | `trizen -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
| trsu | `trizen -Syua --no-confirm` | Same as `trupg`, but without confirmation | | trsu | `trizen -Syua --no-confirm` | Same as `trupg`, but without confirmation |
| upgrade[²](#f2) | `trizen -Syu` | Sync with repositories before upgrading packages | | upgrade[¹](#f1) | `trizen -Syu` | Sync with repositories before upgrading packages |
#### Yaourt[¹](#f1) #### Yay
| Alias | Command | Description |
|---------|-----------------------------------|---------------------------------------------------------------------|
| yaconf | `yaourt -C` | Fix all configuration files with vimdiff |
| yain | `yaourt -S` | Install packages from the repositories |
| yains | `yaourt -U` | Install a package from a local file |
| yainsd | `yaourt -S --asdeps` | Install packages as dependencies of another package |
| yaloc | `yaourt -Qi` | Display information about a package in the local database |
| yalocs | `yaourt -Qs` | Search for packages in the local database |
| yalst | `yaourt -Qe` | List installed packages including from AUR (tagged as "local") |
| yamir | `yaourt -Syy` | Force refresh of all package lists after updating mirrorlist |
| yaorph | `yaourt -Qtd` | Remove orphans using yaourt |
| yare | `yaourt -R` | Remove packages, keeping its settings and dependencies |
| yarem | `yaourt -Rns` | Remove packages, including its settings and unneeded dependencies |
| yarep | `yaourt -Si` | Display information about a package in the repositories |
| yareps | `yaourt -Ss` | Search for packages in the repositories |
| yaupd | `yaourt -Sy` | Update and refresh local package, ABS and AUR databases |
| yaupg | `yaourt -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
| yasu | `yaourt -Syua --no-confirm` | Same as `yaupg`, but without confirmation |
| upgrade[²](#f2) | `yaourt -Syu` | Sync with repositories before upgrading packages |
#### Yay[¹](#f1)
| Alias | Command | Description | | Alias | Command | Description |
|---------|--------------------------------|-------------------------------------------------------------------| |---------|--------------------------------|-------------------------------------------------------------------|
| yaconf | `yay -Pg` | Print current configuration | | yaconf | `yay -Pg` | Print current configuration |
| yaclean | `yay -Sc` | Clean out old and unused caches and packages |
| yaclr | `yay -Scc` | Remove all files from the cache |
| yain | `yay -S` | Install packages from the repositories | | yain | `yay -S` | Install packages from the repositories |
| yains | `yay -U` | Install a package from a local file | | yains | `yay -U` | Install a package from a local file |
| yainsd | `yay -S --asdeps` | Install packages as dependencies of another package | | yainsd | `yay -S --asdeps` | Install packages as dependencies of another package |
@ -165,23 +153,19 @@ upgrades were available. Use `pacman -Que` instead.
| yaupd | `yay -Sy` | Update and refresh local package, ABS and AUR databases | | yaupd | `yay -Sy` | Update and refresh local package, ABS and AUR databases |
| yaupg | `yay -Syu` | Sync with repositories before upgrading packages | | yaupg | `yay -Syu` | Sync with repositories before upgrading packages |
| yasu | `yay -Syu --no-confirm` | Same as `yaupg`, but without confirmation | | yasu | `yay -Syu --no-confirm` | Same as `yaupg`, but without confirmation |
| upgrade[²](#f2) | `yay -Syu` | Sync with repositories before upgrading packages | | upgrade[¹](#f1) | `yay -Syu` | Sync with repositories before upgrading packages |
--- ---
<span id="f1">¹</span> <span id="f1">¹</span>
Yay and Yaourt aliases overlap. If both are installed, yay will take precedence.
<span id="f2">²</span>
The `upgrade` alias is set for all package managers. Its value will depend on The `upgrade` alias is set for all package managers. Its value will depend on
whether the package manager is installed, checked in the following order: whether the package manager is installed, checked in the following order:
1. `yay` 1. `yay`
2. `yaourt` 2. `trizen`
3. `trizen` 3. `pacaur`
4. `pacaur` 4. `aura`
5. `aura` 5. `pacman`
6. `pacman`
## Contributors ## Contributors
@ -196,3 +180,4 @@ whether the package manager is installed, checked in the following order:
- ornicar - thibault.duplessis@gmail.com - ornicar - thibault.duplessis@gmail.com
- Ybalrid (Arthur Brainville) - ybalrid@ybalrid.info - Ybalrid (Arthur Brainville) - ybalrid@ybalrid.info
- Jeff M. Hubbard - jeffmhubbard@gmail.com - Jeff M. Hubbard - jeffmhubbard@gmail.com
- K. Harishankar(harishnkr) - hari2menon1234@gmail.com

View File

@ -5,7 +5,9 @@
# Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips # Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
alias pacupg='sudo pacman -Syu' alias pacupg='sudo pacman -Syu'
alias pacin='sudo pacman -S' alias pacin='sudo pacman -S'
alias paclean='sudo pacman -Sc'
alias pacins='sudo pacman -U' alias pacins='sudo pacman -U'
alias paclr='sudo pacman -Scc'
alias pacre='sudo pacman -R' alias pacre='sudo pacman -R'
alias pacrem='sudo pacman -Rns' alias pacrem='sudo pacman -Rns'
alias pacrep='pacman -Si' alias pacrep='pacman -Si'
@ -88,6 +90,8 @@ fi
if (( $+commands[aura] )); then if (( $+commands[aura] )); then
alias auin='sudo aura -S' alias auin='sudo aura -S'
alias aurin='sudo aura -A' alias aurin='sudo aura -A'
alias auclean='sudo aura -Sc'
alias auclr='sudo aura -Scc'
alias auins='sudo aura -U' alias auins='sudo aura -U'
alias auinsd='sudo aura -S --asdeps' alias auinsd='sudo aura -S --asdeps'
alias aurinsd='sudo aura -A --asdeps' alias aurinsd='sudo aura -A --asdeps'
@ -115,6 +119,8 @@ if (( $+commands[aura] )); then
fi fi
if (( $+commands[pacaur] )); then if (( $+commands[pacaur] )); then
alias pacclean='pacaur -Sc'
alias pacclr='pacaur -Scc'
alias paupg='pacaur -Syu' alias paupg='pacaur -Syu'
alias pasu='pacaur -Syu --noconfirm' alias pasu='pacaur -Syu --noconfirm'
alias pain='pacaur -S' alias pain='pacaur -S'
@ -138,6 +144,8 @@ if (( $+commands[trizen] )); then
alias trupg='trizen -Syua' alias trupg='trizen -Syua'
alias trsu='trizen -Syua --noconfirm' alias trsu='trizen -Syua --noconfirm'
alias trin='trizen -S' alias trin='trizen -S'
alias trclean='trizen -Sc'
alias trclr='trizen -Scc'
alias trins='trizen -U' alias trins='trizen -U'
alias trre='trizen -R' alias trre='trizen -R'
alias trrem='trizen -Rns' alias trrem='trizen -Rns'
@ -153,28 +161,10 @@ if (( $+commands[trizen] )); then
alias upgrade='trizen -Syu' alias upgrade='trizen -Syu'
fi fi
if (( $+commands[yaourt] )); then
alias yaconf='yaourt -C'
alias yaupg='yaourt -Syua'
alias yasu='yaourt -Syua --noconfirm'
alias yain='yaourt -S'
alias yains='yaourt -U'
alias yare='yaourt -R'
alias yarem='yaourt -Rns'
alias yarep='yaourt -Si'
alias yareps='yaourt -Ss'
alias yaloc='yaourt -Qi'
alias yalocs='yaourt -Qs'
alias yalst='yaourt -Qe'
alias yaorph='yaourt -Qtd'
alias yainsd='yaourt -S --asdeps'
alias yamir='yaourt -Syy'
alias yaupd="yaourt -Sy"
alias upgrade='yaourt -Syu'
fi
if (( $+commands[yay] )); then if (( $+commands[yay] )); then
alias yaconf='yay -Pg' alias yaconf='yay -Pg'
alias yaclean='yay -Sc'
alias yaclr='yay -Scc'
alias yaupg='yay -Syu' alias yaupg='yay -Syu'
alias yasu='yay -Syu --noconfirm' alias yasu='yay -Syu --noconfirm'
alias yain='yay -S' alias yain='yay -S'
@ -192,4 +182,3 @@ if (( $+commands[yay] )); then
alias yaupd="yay -Sy" alias yaupd="yay -Sy"
alias upgrade='yay -Syu' alias upgrade='yay -Syu'
fi fi

View File

@ -2,10 +2,18 @@
ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}" ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
ASDF_COMPLETIONS="$ASDF_DIR/completions" ASDF_COMPLETIONS="$ASDF_DIR/completions"
# If not found, check for archlinux/AUR package (/opt/asdf-vm/)
if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/asdf.bash" ]] && [[ -f "/opt/asdf-vm/asdf.sh" ]]; then
ASDF_DIR="/opt/asdf-vm"
ASDF_COMPLETIONS="$ASDF_DIR"
fi
# If not found, check for Homebrew package # If not found, check for Homebrew package
if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/asdf.bash" ]] && (( $+commands[brew] )); then if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/asdf.bash" ]] && (( $+commands[brew] )); then
ASDF_DIR="$(brew --prefix asdf)" brew_prefix="$(brew --prefix asdf)"
ASDF_COMPLETIONS="$ASDF_DIR/etc/bash_completion.d" ASDF_DIR="${brew_prefix}/libexec"
ASDF_COMPLETIONS="${brew_prefix}/etc/bash_completion.d"
unset brew_prefix
fi fi
# Load command # Load command

View File

@ -8,6 +8,7 @@ autojump_paths=(
/etc/profile.d/autojump.zsh # manual installation /etc/profile.d/autojump.zsh # manual installation
/etc/profile.d/autojump.sh # Gentoo installation /etc/profile.d/autojump.sh # Gentoo installation
/usr/local/share/autojump/autojump.zsh # FreeBSD installation /usr/local/share/autojump/autojump.zsh # FreeBSD installation
/usr/pkg/share/autojump/autojump.zsh # NetBSD installation
/opt/local/etc/profile.d/autojump.sh # macOS with MacPorts /opt/local/etc/profile.d/autojump.sh # macOS with MacPorts
/usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default) /usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default)
/opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs) /opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs)

View File

@ -14,11 +14,12 @@ plugins=(... aws)
* `asp [<profile>]`: sets `$AWS_PROFILE` and `$AWS_DEFAULT_PROFILE` (legacy) to `<profile>`. * `asp [<profile>]`: sets `$AWS_PROFILE` and `$AWS_DEFAULT_PROFILE` (legacy) to `<profile>`.
It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI. It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI.
Run `asp` without arguments to clear the profile. Run `asp` without arguments to clear the profile.
* `asp [<profile>] login`: If AWS SSO has been configured in your aws profile, it will run the `aws sso login` command following profile selection.
* `acp [<profile>]`: in addition to `asp` functionality, it actually changes the profile by * `acp [<profile>] [<mfa_token>]`: in addition to `asp` functionality, it actually changes
assuming the role specified in the `<profile>` configuration. It supports MFA and sets the profile by assuming the role specified in the `<profile>` configuration. It supports
`$AWS_ACCESS_KEY_ID`, `$AWS_SECRET_ACCESS_KEY` and `$AWS_SESSION_TOKEN`, if obtained. It MFA and sets `$AWS_ACCESS_KEY_ID`, `$AWS_SECRET_ACCESS_KEY` and `$AWS_SESSION_TOKEN`, if
requires the roles to be configured as per the obtained. It requires the roles to be configured as per the
[official guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html). [official guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html).
Run `acp` without arguments to clear the profile. Run `acp` without arguments to clear the profile.

View File

@ -21,6 +21,10 @@ function asp() {
export AWS_DEFAULT_PROFILE=$1 export AWS_DEFAULT_PROFILE=$1
export AWS_PROFILE=$1 export AWS_PROFILE=$1
export AWS_EB_PROFILE=$1 export AWS_EB_PROFILE=$1
if [[ "$2" == "login" ]]; then
aws sso login
fi
} }
# AWS profile switch # AWS profile switch
@ -41,6 +45,7 @@ function acp() {
fi fi
local profile="$1" local profile="$1"
local mfa_token="$2"
# Get fallback credentials for if the aws command fails or no command is run # Get fallback credentials for if the aws command fails or no command is run
local aws_access_key_id="$(aws configure get aws_access_key_id --profile $profile)" local aws_access_key_id="$(aws configure get aws_access_key_id --profile $profile)"
@ -54,9 +59,10 @@ function acp() {
if [[ -n "$mfa_serial" ]]; then if [[ -n "$mfa_serial" ]]; then
local -a mfa_opt local -a mfa_opt
local mfa_token if [[ -z "$mfa_token" ]]; then
echo -n "Please enter your MFA token for $mfa_serial: " echo -n "Please enter your MFA token for $mfa_serial: "
read -r mfa_token read -r mfa_token
fi
if [[ -z "$sess_duration" ]]; then if [[ -z "$sess_duration" ]]; then
echo -n "Please enter the session duration in seconds (900-43200; default: 3600, which is the default maximum for a role): " echo -n "Please enter the session duration in seconds (900-43200; default: 3600, which is the default maximum for a role): "
read -r sess_duration read -r sess_duration
@ -151,8 +157,8 @@ compctl -K _aws_profiles asp acp aws_change_access_key
# AWS prompt # AWS prompt
function aws_prompt_info() { function aws_prompt_info() {
[[ -z $AWS_PROFILE ]] && return [[ -n "$AWS_PROFILE" ]] || return
echo "${ZSH_THEME_AWS_PREFIX:=<aws:}${AWS_PROFILE}${ZSH_THEME_AWS_SUFFIX:=>}" echo "${ZSH_THEME_AWS_PREFIX:=<aws:}${AWS_PROFILE:gs/%/%%}${ZSH_THEME_AWS_SUFFIX:=>}"
} }
if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then

View File

@ -8,15 +8,22 @@ To use, add `battery` to the list of plugins in your `.zshrc` file:
Then, add the `battery_pct_prompt` function to your custom theme. For example: Then, add the `battery_pct_prompt` function to your custom theme. For example:
``` ```zsh
RPROMPT='$(battery_pct_prompt) ...' RPROMPT='$(battery_pct_prompt) ...'
``` ```
## Requirements ## Requirements
On Linux, you must have the `acpi` tool installed on your operating system. - On Linux, you must have the `acpi` or `acpitool` commands installed on your operating system.
On Debian/Ubuntu, you can do that with `sudo apt install acpi` or `sudo apt install acpitool`.
Here's an example of how to install with apt: - On Android (via [Termux](https://play.google.com/store/apps/details?id=com.termux)), you must have:
```
sudo apt-get install acpi 1. The `Termux:API` addon app installed:
[Google Play](https://play.google.com/store/apps/details?id=com.termux.api) | [F-Droid](https://f-droid.org/packages/com.termux.api/)
2. The `termux-api` package installed within termux:
```sh
pkg install termux-api
``` ```

View File

@ -10,17 +10,17 @@
# Author: J (927589452) # # Author: J (927589452) #
# Modified to add support for FreeBSD # # Modified to add support for FreeBSD #
########################################### ###########################################
# Author: Avneet Singh (kalsi-avneet) #
# Modified to add support for Android #
###########################################
if [[ "$OSTYPE" = darwin* ]]; then if [[ "$OSTYPE" = darwin* ]]; then
function battery_is_charging() { function battery_is_charging() {
ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ Yes' ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ Yes'
} }
function battery_pct() { function battery_pct() {
pmset -g batt | grep -Eo "\d+%" | cut -d% -f1 pmset -g batt | grep -Eo "\d+%" | cut -d% -f1
} }
function battery_pct_remaining() { function battery_pct_remaining() {
if battery_is_charging; then if battery_is_charging; then
echo "External Power" echo "External Power"
@ -28,7 +28,6 @@ if [[ "$OSTYPE" = darwin* ]]; then
battery_pct battery_pct
fi fi
} }
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 | command grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]]; then if [[ $(echo $smart_battery_status | command grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]]; then
@ -42,7 +41,6 @@ if [[ "$OSTYPE" = darwin* ]]; then
echo "∞" echo "∞"
fi fi
} }
function battery_pct_prompt () { function battery_pct_prompt () {
local battery_pct color local battery_pct color
if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then
@ -61,17 +59,14 @@ if [[ "$OSTYPE" = darwin* ]]; then
} }
elif [[ "$OSTYPE" = freebsd* ]]; then elif [[ "$OSTYPE" = freebsd* ]]; then
function battery_is_charging() { function battery_is_charging() {
[[ $(sysctl -n hw.acpi.battery.state) -eq 2 ]] [[ $(sysctl -n hw.acpi.battery.state) -eq 2 ]]
} }
function battery_pct() { function battery_pct() {
if (( $+commands[sysctl] )); then if (( $+commands[sysctl] )); then
sysctl -n hw.acpi.battery.life 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
@ -79,7 +74,6 @@ elif [[ "$OSTYPE" = freebsd* ]]; then
echo "External Power" echo "External Power"
fi fi
} }
function battery_time_remaining() { function battery_time_remaining() {
local remaining_time local remaining_time
remaining_time=$(sysctl -n hw.acpi.battery.time) remaining_time=$(sysctl -n hw.acpi.battery.time)
@ -89,7 +83,6 @@ elif [[ "$OSTYPE" = freebsd* ]]; then
printf %02d:%02d $hour $minute printf %02d:%02d $hour $minute
fi fi
} }
function battery_pct_prompt() { function battery_pct_prompt() {
local battery_pct color local battery_pct color
battery_pct=$(battery_pct_remaining) battery_pct=$(battery_pct_remaining)
@ -106,19 +99,22 @@ elif [[ "$OSTYPE" = freebsd* ]]; then
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}" echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi fi
} }
elif [[ "$OSTYPE" = linux-android ]] && (( ${+commands[termux-battery-status]} )); then
elif [[ "$OSTYPE" = linux* ]]; then
function battery_is_charging() { function battery_is_charging() {
! acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -q '^Battery.*Discharging' termux-battery-status 2>/dev/null | command awk '/status/ { exit ($0 ~ /DISCHARGING/) }'
} }
function battery_pct() { function battery_pct() {
if (( $+commands[acpi] )); then # Sample output:
acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -E '^Battery.*(Full|(Disc|C)harging)' | cut -f2 -d ',' | tr -cd '[:digit:]' # {
fi # "health": "GOOD",
# "percentage": 93,
# "plugged": "UNPLUGGED",
# "status": "DISCHARGING",
# "temperature": 29.0,
# "current": 361816
# }
termux-battery-status 2>/dev/null | command awk '/percentage/ { gsub(/[,]/,""); print $2}'
} }
function battery_pct_remaining() { function battery_pct_remaining() {
if ! battery_is_charging; then if ! battery_is_charging; then
battery_pct battery_pct
@ -126,13 +122,72 @@ elif [[ "$OSTYPE" = linux* ]]; then
echo "External Power" echo "External Power"
fi fi
} }
function battery_time_remaining() { } # Not available on android
function battery_time_remaining() { function battery_pct_prompt() {
if ! battery_is_charging; then local battery_pct color
acpi 2>/dev/null | command grep -v "rate information unavailable" | cut -f3 -d ',' battery_pct=$(battery_pct_remaining)
fi 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
}
elif [[ "$OSTYPE" = linux* ]]; then
function battery_is_charging() {
if (( $+commands[acpitool] )); then
! acpitool 2>/dev/null | command grep -qE '^\s+Battery.*Discharging'
elif (( $+commands[acpi] )); then
! acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -q '^Battery.*Discharging'
fi
}
function battery_pct() {
if (( $+commands[acpitool] )); then
# Sample output:
# Battery #1 : Unknown, 99.55%
# Battery #2 : Discharging, 49.58%, 01:12:05
# All batteries : 62.60%, 02:03:03
local -i pct=$(acpitool 2>/dev/null | command awk -F, '
/^\s+All batteries/ {
gsub(/[^0-9.]/, "", $1)
pct=$1
exit
}
!pct && /^\s+Battery/ {
gsub(/[^0-9.]/, "", $2)
pct=$2
}
END { print pct }
')
echo $pct
elif (( $+commands[acpi] )); then
# Sample output:
# Battery 0: Discharging, 0%, rate information unavailable
# Battery 1: Full, 100%
acpi 2>/dev/null | command awk -F, '
/rate information unavailable/ { next }
/^Battery.*: /{ gsub(/[^0-9]/, "", $2); print $2; exit }
'
fi
}
function battery_pct_remaining() {
if ! battery_is_charging; then
battery_pct
else
echo "External Power"
fi
}
function battery_time_remaining() {
if ! battery_is_charging; then
acpi 2>/dev/null | command grep -v "rate information unavailable" | cut -f3 -d ','
fi
}
function battery_pct_prompt() { function battery_pct_prompt() {
local battery_pct color local battery_pct color
battery_pct=$(battery_pct_remaining) battery_pct=$(battery_pct_remaining)
@ -149,7 +204,6 @@ elif [[ "$OSTYPE" = linux* ]]; then
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}" echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi fi
} }
else else
# Empty functions so we don't cause errors in prompts # Empty functions so we don't cause errors in prompts
function battery_is_charging { false } function battery_is_charging { false }
@ -174,7 +228,7 @@ function battery_level_gauge() {
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 -i battery_remaining_percentage=$(battery_pct)
local filled empty gauge_color local filled empty gauge_color
if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then

View File

@ -164,7 +164,7 @@ _get_build_targets() {
;; ;;
esac esac
completions=(${$(_bazel_b query "kind(\"${rule_re}\", ${pkg}:all)" 2>/dev/null)##*:}) completions=(${$(_bazel_b query "kind(\"${rule_re}\", ${pkg}:all)" 2>/dev/null)##*:})
if ( (( ${#completions} > 0 )) && [[ $target_type != run ]] ); then if ( (( ${#completions} > 0 )) && [[ $target_type != bin ]] ); then
completions+=(all) completions+=(all)
fi fi
echo ${completions[*]} echo ${completions[*]}

View File

@ -20,6 +20,12 @@ if ! (type bgnotify_formatted | grep -q 'function'); then ## allow custom functi
} }
fi fi
currentAppId () {
if (( $+commands[osascript] )); then
osascript -e 'tell application (path to frontmost application as text) to id' 2>/dev/null
fi
}
currentWindowId () { currentWindowId () {
if hash osascript 2>/dev/null; then #osx if hash osascript 2>/dev/null; then #osx
osascript -e 'tell application (path to frontmost application as text) to id of front window' 2&> /dev/null || echo "0" osascript -e 'tell application (path to frontmost application as text) to id of front window' 2&> /dev/null || echo "0"
@ -32,11 +38,20 @@ currentWindowId () {
bgnotify () { ## args: (title, subtitle) bgnotify () { ## args: (title, subtitle)
if hash terminal-notifier 2>/dev/null; then #osx if hash terminal-notifier 2>/dev/null; then #osx
[[ "$TERM_PROGRAM" == 'iTerm.app' ]] && term_id='com.googlecode.iterm2'; local term_id="$bgnotify_appid"
[[ "$TERM_PROGRAM" == 'Apple_Terminal' ]] && term_id='com.apple.terminal'; if [[ -z "$term_id" ]]; then
case "$TERM_PROGRAM" in
iTerm.app) term_id='com.googlecode.iterm2' ;;
Apple_Terminal) term_id='com.apple.terminal' ;;
esac
fi
## now call terminal-notifier, (hopefully with $term_id!) ## now call terminal-notifier, (hopefully with $term_id!)
[ -z "$term_id" ] && terminal-notifier -message "$2" -title "$1" >/dev/null || if [[ -z "$term_id" ]]; then
terminal-notifier -message "$2" -title "$1" >/dev/null
else
terminal-notifier -message "$2" -title "$1" -activate "$term_id" -sender "$term_id" >/dev/null terminal-notifier -message "$2" -title "$1" -activate "$term_id" -sender "$term_id" >/dev/null
fi
elif hash growlnotify 2>/dev/null; then #osx growl elif hash growlnotify 2>/dev/null; then #osx growl
growlnotify -m "$1" "$2" growlnotify -m "$1" "$2"
elif hash notify-send 2>/dev/null; then #ubuntu gnome! elif hash notify-send 2>/dev/null; then #ubuntu gnome!
@ -54,6 +69,7 @@ bgnotify () { ## args: (title, subtitle)
bgnotify_begin() { bgnotify_begin() {
bgnotify_timestamp=$EPOCHSECONDS bgnotify_timestamp=$EPOCHSECONDS
bgnotify_lastcmd="${1:-$2}" bgnotify_lastcmd="${1:-$2}"
bgnotify_appid="$(currentAppId)"
bgnotify_windowid=$(currentWindowId) bgnotify_windowid=$(currentWindowId)
} }
@ -62,7 +78,7 @@ bgnotify_end() {
elapsed=$(( EPOCHSECONDS - bgnotify_timestamp )) elapsed=$(( EPOCHSECONDS - bgnotify_timestamp ))
past_threshold=$(( elapsed >= bgnotify_threshold )) past_threshold=$(( elapsed >= bgnotify_threshold ))
if (( bgnotify_timestamp > 0 )) && (( past_threshold )); then if (( bgnotify_timestamp > 0 )) && (( past_threshold )); then
if [ $(currentWindowId) != "$bgnotify_windowid" ]; then if [[ $(currentAppId) != "$bgnotify_appid" || $(currentWindowId) != "$bgnotify_windowid" ]]; then
print -n "\a" print -n "\a"
bgnotify_formatted "$didexit" "$bgnotify_lastcmd" "$elapsed" bgnotify_formatted "$didexit" "$bgnotify_lastcmd" "$elapsed"
fi fi

View File

@ -9,7 +9,7 @@ _bower_installed_packages () {
} }
_bower () _bower ()
{ {
local -a _1st_arguments _no_color _dopts _save_dev _force_lastest _production local -a _1st_arguments _no_color _dopts _save_dev _force_latest _production
local expl local expl
typeset -A opt_args typeset -A opt_args
@ -22,7 +22,7 @@ _bower ()
_save_dev=('(--save-dev)--save-dev[Save installed packages into the project"s bower.json devDependencies]') _save_dev=('(--save-dev)--save-dev[Save installed packages into the project"s bower.json devDependencies]')
_force_lastest=('(--force-latest)--force-latest[Force latest version on conflict]') _force_latest=('(--force-latest)--force-latest[Force latest version on conflict]')
_production=('(--production)--production[Do not install project devDependencies]') _production=('(--production)--production[Do not install project devDependencies]')
@ -54,7 +54,7 @@ _bower ()
_arguments \ _arguments \
$_dopts \ $_dopts \
$_save_dev \ $_save_dev \
$_force_lastest \ $_force_latest \
$_no_color \ $_no_color \
$_production $_production
;; ;;
@ -62,7 +62,7 @@ _bower ()
_arguments \ _arguments \
$_dopts \ $_dopts \
$_no_color \ $_no_color \
$_force_lastest $_force_latest
_bower_installed_packages _bower_installed_packages
compadd "$@" $(echo $bower_package_list) compadd "$@" $(echo $bower_package_list)
;; ;;

View File

@ -1,31 +1,47 @@
# Branch # Branch plugin
Displays the current Git or Mercurial branch fast. This plugin displays the current Git or Mercurial branch, fast. If in a Mercurial repository,
also display the current bookmark, if present.
To use it, add `branch` to the plugins array in your zshrc file:
```zsh
plugins=(... branch)
```
## Speed test ## Speed test
### Mercurial - `hg branch`:
```shell ```console
$ time hg branch $ time hg branch
0.11s user 0.14s system 70% cpu 0.355 total 0.11s user 0.14s system 70% cpu 0.355 total
``` ```
### Branch plugin - branch plugin:
```shell ```console
$ time zsh /tmp/branch_prompt_info_test.zsh $ time zsh /tmp/branch_prompt_info_test.zsh
0.00s user 0.01s system 78% cpu 0.014 total 0.00s user 0.01s system 78% cpu 0.014 total
``` ```
## Usage ## Usage
Edit your theme file (eg.: `~/.oh-my-zsh/theme/robbyrussell.zsh-theme`) Copy your theme to `$ZSH_CUSTOM/themes/` and modify it to add `$(branch_prompt_info)` in your prompt.
adding `$(branch_prompt_info)` in your prompt like this: This example is for the `robbyrussell` theme:
```diff ```diff
- PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}' diff --git a/themes/robbyrussell.zsh-theme b/themes/robbyrussell.zsh-theme
+ PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)$(branch_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}' index 2fd5f2cd..9d89a464 100644
--- a/themes/robbyrussell.zsh-theme
+++ b/themes/robbyrussell.zsh-theme
@@ -1,5 +1,5 @@
PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
-PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
+PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(branch_prompt_info)'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
``` ```
## Maintainer ## Maintainer

View File

@ -3,29 +3,33 @@
# Oct 2, 2015 # Oct 2, 2015
function branch_prompt_info() { function branch_prompt_info() {
# Defines path as current directory # Start checking in current working directory
local current_dir=$PWD local branch="" dir="$PWD"
# While current path is not root path while [[ "$dir" != '/' ]]; do
while [[ $current_dir != '/' ]] # Found .git directory
do if [[ -d "${dir}/.git" ]]; then
# Git repository branch="${"$(<"${dir}/.git/HEAD")"##*/}"
if [[ -d "${current_dir}/.git" ]] echo '±' "${branch:gs/%/%%}"
then return
echo '±' ${"$(<"$current_dir/.git/HEAD")"##*/}
return;
fi fi
# Mercurial repository
if [[ -d "${current_dir}/.hg" ]] # Found .hg directory
then if [[ -d "${dir}/.hg" ]]; then
if [[ -f "$current_dir/.hg/branch" ]] if [[ -f "${dir}/.hg/branch" ]]; then
then branch="$(<"${dir}/.hg/branch")"
echo '☿' $(<"$current_dir/.hg/branch")
else else
echo '☿ default' branch="default"
fi fi
return;
if [[ -f "${dir}/.hg/bookmarks.current" ]]; then
branch="${branch}/$(<"${dir}/.hg/bookmarks.current")"
fi fi
# Defines path as parent directory and keeps looking for :)
current_dir="${current_dir:h}" echo '☿' "${branch:gs/%/%%}"
return
fi
# Check parent directory
dir="${dir:h}"
done done
} }

View File

@ -1,5 +1,4 @@
alias brewp='brew pin' alias brewp='brew pin'
alias brews='brew list -1'
alias brewsp='brew list --pinned' alias brewsp='brew list --pinned'
alias bubo='brew update && brew outdated' alias bubo='brew update && brew outdated'
alias bubc='brew upgrade && brew cleanup' alias bubc='brew upgrade && brew cleanup'
@ -7,3 +6,16 @@ alias bubu='bubo && bubc'
alias buf='brew upgrade --formula' alias buf='brew upgrade --formula'
alias bcubo='brew update && brew outdated --cask' alias bcubo='brew update && brew outdated --cask'
alias bcubc='brew upgrade --cask && brew cleanup' alias bcubc='brew upgrade --cask && brew cleanup'
function brews() {
local formulae="$(brew leaves | xargs brew deps --installed --for-each)"
local casks="$(brew list --cask)"
local blue="$(tput setaf 4)"
local bold="$(tput bold)"
local off="$(tput sgr0)"
echo "${blue}==>${off} ${bold}Formulae${off}"
echo "${formulae}" | sed "s/^\(.*\):\(.*\)$/\1${blue}\2${off}/"
echo "\n${blue}==>${off} ${bold}Casks${off}\n${casks}"
}

View File

@ -18,6 +18,7 @@ case $state in
"check[Determine whether the requirements for your application are installed]" \ "check[Determine whether the requirements for your application are installed]" \
"list[Show all of the gems in the current bundle]" \ "list[Show all of the gems in the current bundle]" \
"show[Show the source location of a particular gem in the bundle]" \ "show[Show the source location of a particular gem in the bundle]" \
"info[Show details of a particular gem in the bundle]" \
"outdated[Show all of the outdated gems in the current bundle]" \ "outdated[Show all of the outdated gems in the current bundle]" \
"console[Start an IRB session in the context of the current bundle]" \ "console[Start an IRB session in the context of the current bundle]" \
"open[Open an installed gem in the editor]" \ "open[Open an installed gem in the editor]" \
@ -84,7 +85,7 @@ case $state in
'(--verbose)--verbose[Enable verbose output mode]' '(--verbose)--verbose[Enable verbose output mode]'
ret=0 ret=0
;; ;;
(open|show) (open|show|info)
_gems=( $(bundle show 2> /dev/null | sed -e '/^ \*/!d; s/^ \* \([^ ]*\) .*/\1/') ) _gems=( $(bundle show 2> /dev/null | sed -e '/^ \*/!d; s/^ \* \([^ ]*\) .*/\1/') )
if [[ $_gems != "" ]]; then if [[ $_gems != "" ]]; then
_values 'gems' $_gems && ret=0 _values 'gems' $_gems && ret=0

View File

@ -40,7 +40,7 @@ bundle_install() {
else else
local cores_num="$(nproc)" local cores_num="$(nproc)"
fi fi
bundle install --jobs="$cores_num" "$@" BUNDLE_JOBS="$cores_num" bundle install "$@"
} }
## Gem wrapper ## Gem wrapper
@ -81,14 +81,12 @@ bundled_commands=(
) )
# Remove $UNBUNDLED_COMMANDS from the bundled_commands list # Remove $UNBUNDLED_COMMANDS from the bundled_commands list
for cmd in $UNBUNDLED_COMMANDS; do bundled_commands=(${bundled_commands:|UNBUNDLED_COMMANDS})
bundled_commands=(${bundled_commands#$cmd}); unset UNBUNDLED_COMMANDS
done
# Add $BUNDLED_COMMANDS to the bundled_commands list # Add $BUNDLED_COMMANDS to the bundled_commands list
for cmd in $BUNDLED_COMMANDS; do bundled_commands+=($BUNDLED_COMMANDS)
bundled_commands+=($cmd); unset BUNDLED_COMMANDS
done
# Check if in the root or a subdirectory of a bundled project # Check if in the root or a subdirectory of a bundled project
_within-bundled-project() { _within-bundled-project() {
@ -126,5 +124,4 @@ for cmd in $bundled_commands; do
compdef "_$cmd" "bundled_$cmd"="$cmd" compdef "_$cmd" "bundled_$cmd"="$cmd"
fi fi
done done
unset cmd bundled_commands unset cmd bundled_commands

View File

@ -1,11 +1,3 @@
# cargo # cargo
This plugin adds completion for the Rust build tool [`Cargo`](https://github.com/rust-lang/cargo). **Deprecated: use the [`rust`](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/rust) plugin instead.**
To use it, add `cargo` to the plugins array in your zshrc file:
```zsh
plugins=(... cargo)
```
Updated on March 3rd, 2019, from [Cargo 0.34.0](https://github.com/rust-lang/cargo/releases/tag/0.34.0).

View File

@ -1,23 +1,15 @@
if (( $+commands[rustup] && $+commands[cargo] )); then print ${(%):-'%F{yellow}The `cargo` plugin is deprecated and has been moved to the `rust` plugin.'}
# remove old generated completion file print ${(%):-'Please update your .zshrc to use the `%Brust%b` plugin instead.%f'}
command rm -f "${0:A:h}/_cargo"
# generate new completion file # TODO: 2021-12-28: remove this block
ver="$(cargo --version)" # Handle $0 according to the standard:
ver_file="$ZSH_CACHE_DIR/cargo_version" # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
comp_file="$ZSH_CACHE_DIR/completions/_cargo" 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"
# Remove old generated completion file
command rm -f "${0:A:h}/_cargo" "$ZSH_CACHE_DIR/cargo_version"
mkdir -p "${comp_file:h}" (( ${fpath[(Ie)$ZSH/plugins/rust]} )) || {
(( ${fpath[(Ie)${comp_file:h}]} )) || fpath=("${comp_file:h}" $fpath) fpath=("$ZSH/plugins/rust" $fpath)
source "$ZSH/plugins/rust/rust.plugin.zsh"
if [[ ! -f "$comp_file" || ! -f "$ver_file" || "$ver" != "$(< "$ver_file")" ]]; then }
rustup completions zsh cargo >| "$comp_file"
echo "$ver" >| "$ver_file"
fi
declare -A _comps
autoload -Uz _cargo
_comps[cargo]=_cargo
unset ver ver_file comp_file
fi

View File

@ -2,7 +2,7 @@
# catimg script by Eduardo San Martin Morote aka Posva # # catimg script by Eduardo San Martin Morote aka Posva #
# https://posva.net # # https://posva.net #
# # # #
# Ouput the content of an image to the stdout using the 256 colors of the # # Output the content of an image to the stdout using the 256 colors of the #
# terminal. # # terminal. #
# GitHub: https://github.com/posva/catimg # # GitHub: https://github.com/posva/catimg #
################################################################################ ################################################################################

View File

@ -2,7 +2,7 @@
# catimg script by Eduardo San Martin Morote aka Posva # # catimg script by Eduardo San Martin Morote aka Posva #
# https://posva.net # # https://posva.net #
# # # #
# Ouput the content of an image to the stdout using the 256 colors of the # # Output the content of an image to the stdout using the 256 colors of the #
# terminal. # # terminal. #
# GitHub: https://github.com/posva/catimg # # GitHub: https://github.com/posva/catimg #
################################################################################ ################################################################################

View File

@ -5,6 +5,7 @@ current Ruby version, and completion and a prompt function to display the Ruby v
Supports brew and manual installation of chruby. Supports brew and manual installation of chruby.
To use it, add `chruby` to the plugins array in your zshrc file: To use it, add `chruby` to the plugins array in your zshrc file:
```zsh ```zsh
plugins=(... chruby) plugins=(... chruby)
``` ```
@ -14,7 +15,7 @@ plugins=(... chruby)
If you'd prefer to specify an explicit path to load chruby from If you'd prefer to specify an explicit path to load chruby from
you can set variables like so: you can set variables like so:
``` ```zsh
zstyle :omz:plugins:chruby path /local/path/to/chruby.sh zstyle :omz:plugins:chruby path /local/path/to/chruby.sh
zstyle :omz:plugins:chruby auto /local/path/to/auto.sh zstyle :omz:plugins:chruby auto /local/path/to/auto.sh
``` ```

View File

@ -1,65 +1,10 @@
# ## load chruby from different locations
# INSTRUCTIONS
#
# With either a manual or brew installed chruby things should just work.
#
# 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
#
# TODO
# - autodetermine correct source path on non OS X systems
# - completion if ruby-install exists
# rvm and rbenv plugins also provide this alias _source-from-omz-settings() {
alias rubies='chruby' local _chruby_path _chruby_auto
zstyle -s :omz:plugins:chruby path _chruby_path || return 1
_homebrew-installed() { zstyle -s :omz:plugins:chruby auto _chruby_auto || return 1
whence brew &> /dev/null
_xit=$?
if [ $_xit -eq 0 ];then
# ok , we have brew installed
# speculatively we check default brew prefix
if [ -h /usr/local/opt/chruby ];then
_brew_prefix="/usr/local/opt/chruby"
else
# ok , it is not default prefix
# this call to brew is expensive ( about 400 ms ), so at least let's make it only once
_brew_prefix=$(brew --prefix chruby)
fi
return 0
else
return $_xit
fi
}
_chruby-from-homebrew-installed() {
[ -r $_brew_prefix ] &> /dev/null
}
_ruby-build_installed() {
whence ruby-build &> /dev/null
}
_ruby-install-installed() {
whence ruby-install &> /dev/null
}
# Simple definition completer for ruby-build
if _ruby-build_installed; then
_ruby-build() { compadd $(ruby-build --definitions) }
compdef _ruby-build ruby-build
fi
_source_from_omz_settings() {
local _chruby_path
local _chruby_auto
zstyle -s :omz:plugins:chruby path _chruby_path
zstyle -s :omz:plugins:chruby auto _chruby_auto
if [[ -r ${_chruby_path} ]]; then if [[ -r ${_chruby_path} ]]; then
source ${_chruby_path} source ${_chruby_path}
@ -70,52 +15,80 @@ _source_from_omz_settings() {
fi fi
} }
_chruby_dirs() { _source-from-homebrew() {
chrubydirs=($HOME/.rubies/ $PREFIX/opt/rubies) (( $+commands[brew] )) || return 1
for dir in chrubydirs; do
if [[ -d $dir ]]; then local _brew_prefix
RUBIES+=$dir # check default brew prefix
if [[ -h /usr/local/opt/chruby ]];then
_brew_prefix="/usr/local/opt/chruby"
else
# ok , it is not default prefix
# this call to brew is expensive ( about 400 ms ), so at least let's make it only once
_brew_prefix=$(brew --prefix chruby)
fi
[[ -r "$_brew_prefix" ]] || return 1
source $_brew_prefix/share/chruby/chruby.sh
source $_brew_prefix/share/chruby/auto.sh
}
_load-chruby-dirs() {
local dir
for dir in "$HOME/.rubies" "$PREFIX/opt/rubies"; do
if [[ -d "$dir" ]]; then
RUBIES+=("$dir")
fi fi
done done
} }
if _homebrew-installed && _chruby-from-homebrew-installed ; then # Load chruby
source $_brew_prefix/share/chruby/chruby.sh if _source-from-omz-settings; then
source $_brew_prefix/share/chruby/auto.sh _load-chruby-dirs
_chruby_dirs
elif [[ -r "/usr/local/share/chruby/chruby.sh" ]] ; then elif [[ -r "/usr/local/share/chruby/chruby.sh" ]] ; then
source /usr/local/share/chruby/chruby.sh source /usr/local/share/chruby/chruby.sh
source /usr/local/share/chruby/auto.sh source /usr/local/share/chruby/auto.sh
_chruby_dirs _load-chruby-dirs
else elif _source-from-homebrew; then
_source_from_omz_settings _load-chruby-dirs
_chruby_dirs
fi fi
function ensure_chruby() { unfunction _source-from-homebrew _source-from-omz-settings _load-chruby-dirs
$(whence chruby)
}
## chruby utility functions and aliases
# rvm and rbenv plugins also provide this alias
alias rubies='chruby'
function current_ruby() { function current_ruby() {
local _ruby local ruby
_ruby="$(chruby |grep \* |tr -d '* ')" ruby="$(chruby | grep \* | tr -d '* ')"
if [[ $(chruby | grep -c \*) -eq 1 ]]; then if [[ $(chruby | grep -c \*) -eq 1 ]]; then
echo ${_ruby} echo ${ruby}
else else
echo "system" echo "system"
fi fi
} }
function chruby_prompt_info() { function chruby_prompt_info() {
echo "$(current_ruby)" echo "${$(current_ruby):gs/%/%%}"
} }
# complete on installed rubies # Complete chruby command with installed rubies
_chruby() { _chruby() {
compadd $(chruby | tr -d '* ') compadd $(chruby | tr -d '* ')
local default_path='/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin' if PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" command ruby &>/dev/null; then
if PATH=${default_path} type ruby &> /dev/null; then
compadd system compadd system
fi fi
} }
compdef _chruby chruby compdef _chruby chruby
# Simple definition completer for ruby-build
if command ruby-build &> /dev/null; then
_ruby-build() { compadd $(ruby-build --definitions) }
compdef _ruby-build ruby-build
fi

View File

@ -1,8 +1,6 @@
# chucknorris # chucknorris
Chuck Norris fortunes plugin for oh-my-zsh. Perfectly suitable as MOTD. Chuck Norris fortunes plugin for Oh My Zsh. Perfectly suitable as MOTD.
**Maintainers**: [apjanke](https://github.com/apjanke) [maff](https://github.com/maff)
To use it add `chucknorris` to the plugins array in you zshrc file. To use it add `chucknorris` to the plugins array in you zshrc file.

View File

@ -1,28 +1,24 @@
# chucknorris: Chuck Norris fortunes
# Automatically generate or update Chuck's compiled fortune data file
# $0 must be used outside a local function. This variable name is unlikly to collide.
CHUCKNORRIS_PLUGIN_DIR=${0:h}
() { () {
local DIR=$CHUCKNORRIS_PLUGIN_DIR/fortunes # %x: name of file containing code being executed
if [[ ! -f $DIR/chucknorris.dat ]] || [[ $DIR/chucknorris.dat -ot $DIR/chucknorris ]]; then local fortunes_dir="${${(%):-%x}:h}/fortunes"
# For some reason, Cygwin puts strfile in /usr/sbin, which is not on the path by default
local strfile=strfile
if ! which strfile &>/dev/null && [[ -f /usr/sbin/strfile ]]; then
strfile=/usr/sbin/strfile
fi
if which $strfile &> /dev/null; then
$strfile $DIR/chucknorris $DIR/chucknorris.dat >/dev/null
else
echo "[oh-my-zsh] chucknorris depends on strfile, which is not installed" >&2
echo "[oh-my-zsh] strfile is often provided as part of the 'fortune' package" >&2
fi
fi
# Aliases # Aliases
alias chuck="fortune -a $DIR" alias chuck="fortune -a $fortunes_dir"
alias chuck_cow="chuck | cowthink" alias chuck_cow="chuck | cowthink"
}
unset CHUCKNORRIS_PLUGIN_DIR # Automatically generate or update Chuck's compiled fortune data file
if [[ "$fortunes_dir/chucknorris" -ot "$fortunes_dir/chucknorris.dat" ]]; then
return
fi
# For some reason, Cygwin puts strfile in /usr/sbin, which is not on the path by default
local strfile="${commands[strfile]:-/usr/sbin/strfile}"
if [[ ! -x "$strfile" ]]; then
echo "[oh-my-zsh] chucknorris depends on strfile, which is not installed" >&2
echo "[oh-my-zsh] strfile is often provided as part of the 'fortune' package" >&2
return
fi
# Generate the compiled fortune data file
$strfile "$fortunes_dir/chucknorris" "$fortunes_dir/chucknorris.dat" >/dev/null
}

View File

@ -228,7 +228,7 @@ Chuck Norris once punched the ground to stop an earthquake. The resulting afters
% %
Chuck Norris once round-house kicked a salesman. Over the phone. Chuck Norris once round-house kicked a salesman. Over the phone.
% %
Chuck Norris once rounhouse kicked a football. The astronomical society now considers it a planet. Chuck Norris once roundhouse kicked a football. The astronomical society now considers it a planet.
% %
Chuck Norris once thought he was wrong. He was, however, mistaken. Chuck Norris once thought he was wrong. He was, however, mistaken.
% %
@ -342,7 +342,7 @@ Every time there's an earthquake, you know Chuck Norris is hungry. The earthquak
% %
Evolution's driving mechanism is nature's desperate attempt to escape Chuck Norris. Evolution's driving mechanism is nature's desperate attempt to escape Chuck Norris.
% %
Fear of spiders is arachnaphobia. Fear of tight spaces is claustrophobia. Fear of Chuck Norris is called Logic. Fear of spiders is arachnophobia. Fear of tight spaces is claustrophobia. Fear of Chuck Norris is called Logic.
% %
Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face. Fool me once, shame on you. Fool Chuck Norris once and he will roundhouse you in the face.
% %
@ -426,7 +426,7 @@ Some people ask for a Kleenex when they sneeze, Chuck Norris asks for a body bag
% %
Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre. Someone once videotaped Chuck Norris getting pissed off. It was called Walker: Texas Chain Saw Massacre.
% %
Staring at Chuck Norris for extended periods of time without proper eye protection will cause blindess, and possibly foot sized brusies on the face. Staring at Chuck Norris for extended periods of time without proper eye protection will cause blindness, and possibly foot sized bruises on the face.
% %
Taking Karate Lessons = $100, Buying MMA DVD's = $150, Subscribing to a UFC event = $50, Getting a Roundhouse Kick from Chuck Norris = PRICELESS. Taking Karate Lessons = $100, Buying MMA DVD's = $150, Subscribing to a UFC event = $50, Getting a Roundhouse Kick from Chuck Norris = PRICELESS.
% %
@ -452,7 +452,7 @@ The best part of waking up is not Folgers in your cup. it's knowing that Chuck N
% %
The chief export of Chuck Norris is pain. The chief export of Chuck Norris is pain.
% %
The dictionary references Chuck Norris several times, he is metioned under Fear, Law, Order and Chucktatorship. The dictionary references Chuck Norris several times, he is mentioned under Fear, Law, Order and Chucktatorship.
% %
The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer. The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
% %
@ -468,7 +468,7 @@ The only way sharks will come near CN underwater is when CN is inside of a cage.
% %
The only word that rhymes with orange is Chuck Norris. The only word that rhymes with orange is Chuck Norris.
% %
The producers of the movie "The Last Airbender" are now in talks with Chuck Norris in Order to star him in their next sequal "The Last Skull Bender". The producers of the movie "The Last Airbender" are now in talks with Chuck Norris in Order to star him in their next sequel "The Last Skull Bender".
% %
The quickest way to a man's heart is with Chuck Norris' fist. The quickest way to a man's heart is with Chuck Norris' fist.
% %
@ -558,3 +558,11 @@ You know Chuck Norris' pet lizard, right? Last I heard, he was in the movie "God
% %
http://chucknorrisfacts.com/ is built in Drupal because Chuck Norris knows a good CMS when he sees one. http://chucknorrisfacts.com/ is built in Drupal because Chuck Norris knows a good CMS when he sees one.
% %
Chuck Norris made the first Giraffe by uppercutting a horse.
%
Chuck Norris can hear sign language.
%
Chuck Norris make onions cry.
%
Chuck Norris doesn't shake hands, he makes them tremble.
%

View File

@ -19,6 +19,11 @@ bindkey -a 'N' vi-join
bindkey -a 'j' vi-forward-word-end bindkey -a 'j' vi-forward-word-end
bindkey -a 'J' vi-forward-blank-word-end bindkey -a 'J' vi-forward-blank-word-end
# Handle $0 according to the standard:
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"
# New less versions will read this file directly # New less versions will read this file directly
export LESSKEYIN="${0:h:A}/colemak-less" export LESSKEYIN="${0:h:A}/colemak-less"

View File

@ -16,8 +16,13 @@ less_termcap[se]="${reset_color}"
less_termcap[us]="${fg_bold[green]}" less_termcap[us]="${fg_bold[green]}"
less_termcap[ue]="${reset_color}" less_termcap[ue]="${reset_color}"
# Handle $0 according to the standard:
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"
# Absolute path to this file's directory. # Absolute path to this file's directory.
typeset __colored_man_pages_dir="${0:A:h}" typeset -g __colored_man_pages_dir="${0:A:h}"
function colored() { function colored() {
local -a environment local -a environment

View File

@ -82,7 +82,7 @@ colorize_less() {
# This variable tells less to pipe every file through the specified command # This variable tells less to pipe every file through the specified command
# (see the man page of less INPUT PREPROCESSOR). # (see the man page of less INPUT PREPROCESSOR).
# 'zsh -ic "colorize_cat %s 2> /dev/null"' would not work for huge files like # 'zsh -ic "colorize_cat %s 2> /dev/null"' would not work for huge files like
# the ~/.zsh_history. For such files the tty of the preprocessor will be supended. # the ~/.zsh_history. For such files the tty of the preprocessor will be suspended.
# Therefore we must source this file to make colorize_cat available in the # Therefore we must source this file to make colorize_cat available in the
# preprocessor without the interactive mode. # preprocessor without the interactive mode.
# `2>/dev/null` will suppress the error for large files 'broken pipe' of the python # `2>/dev/null` will suppress the error for large files 'broken pipe' of the python

View File

@ -29,5 +29,6 @@ It works out of the box with the command-not-found packages for:
- [Fedora](https://fedoraproject.org/wiki/Features/PackageKitCommandNotFound) - [Fedora](https://fedoraproject.org/wiki/Features/PackageKitCommandNotFound)
- [NixOS](https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/command-not-found) - [NixOS](https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/command-not-found)
- [Termux](https://github.com/termux/command-not-found) - [Termux](https://github.com/termux/command-not-found)
- [SUSE](https://www.unix.com/man-page/suse/1/command-not-found/)
You can add support for other platforms by submitting a Pull Request. You can add support for other platforms by submitting a Pull Request.

View File

@ -50,13 +50,20 @@ fi
# NixOS: https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/command-not-found # NixOS: https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/command-not-found
if [[ -x /run/current-system/sw/bin/command-not-found ]]; then if [[ -x /run/current-system/sw/bin/command-not-found ]]; then
command_not_found_handler() { command_not_found_handler() {
/run/current-system/sw/bin/command-not-found -- "$@" /run/current-system/sw/bin/command-not-found "$@"
} }
fi fi
# Termux: https://github.com/termux/command-not-found # Termux: https://github.com/termux/command-not-found
if [[ -x /data/data/com.termux/files/usr/libexec/termux/command-not-found ]]; then if [[ -x /data/data/com.termux/files/usr/libexec/termux/command-not-found ]]; then
command_not_found_handler() { command_not_found_handler() {
/data/data/com.termux/files/usr/libexec/termux/command-not-found -- "$1" /data/data/com.termux/files/usr/libexec/termux/command-not-found "$1"
}
fi
# SUSE and derivates: https://www.unix.com/man-page/suse/1/command-not-found/
if [[ -x /usr/bin/command-not-found ]]; then
command_not_found_handler() {
/usr/bin/command-not-found "$1"
} }
fi fi

View File

@ -13,7 +13,7 @@ plugins=(... common-aliases)
### ls command ### ls command
| Alias | Command | Description | | Alias | Command | Description |
|-------|---------------|--------------------------------------------------------------------------------| | ----- | ------------ | --------------------------------------------------------------------------- |
| l | `ls -lFh` | List files as a long list, show size, type, human-readable | | 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 | | 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 | | lr | `ls -tRFh` | List files recursively sorted by date, show type, human-readable |
@ -23,11 +23,13 @@ plugins=(... common-aliases)
| lS | `ls -1FSsh` | List files showing only size and name sorted by size | | 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) | | 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) | | lrt | `ls -1Fcrt` | List files sorted in reverse of create/modification time(oldest first) |
| lsr | `ls -lARFh` | List all files and directories recursively |
| lsn | `ls -1` | List files and directories in a single column |
### File handling ### File handling
| Alias | Command | Description | | Alias | Command | Description |
|-------|-----------------------|------------------------------------------------------------------------------------| | ----- | --------------------- | ------------------------------------------------------------------------------- |
| rm | `rm -i` | Remove a file | | rm | `rm -i` | Remove a file |
| cp | `cp -i` | Copy a file | | cp | `cp -i` | Copy a file |
| mv | `mv -i` | Move a file | | mv | `mv -i` | Move a file |
@ -39,7 +41,7 @@ plugins=(... common-aliases)
### find and grep ### find and grep
| Alias | Command | Description | | Alias | Command | Description |
|-------|-----------------------------------------------------|-----------------------------------------| | ----- | -------------------------------------------------- | ------------------------------------ |
| fd\* | `find . -type d -name` | Find a directory with the given name | | fd\* | `find . -type d -name` | Find a directory with the given name |
| ff | `find . -type f -name` | Find a file with the given name | | ff | `find . -type f -name` | Find a file with the given name |
| grep | `grep --color` | Searches for a query string | | grep | `grep --color` | Searches for a query string |
@ -50,7 +52,7 @@ plugins=(... common-aliases)
### Other Aliases ### Other Aliases
| Alias | Command | Description | | Alias | Command | Description |
|-----------|---------------------|-------------------------------------------------------------| | -------- | ------------------ | ----------------------------------------------------------- |
| h | `history` | Lists all recently used commands | | h | `history` | Lists all recently used commands |
| hgrep | `fc -El 0 \| grep` | Searches for a word in the list of previously 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 | | help | `man` | Opens up the man page for a command |
@ -77,7 +79,7 @@ $ find . -type f 2>/dev/null
``` ```
| Alias | Command | Description | | Alias | Command | Description |
|-------|-----------------------------|-------------------------------------------------------------| | ----- | --------------------------- | ----------------------------------------------------------- |
| H | `\| head` | Pipes output to head which outputs the first part of a file | | 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 | | 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 | | G | `\| grep` | Pipes output to grep to search for some word |
@ -98,7 +100,7 @@ that file will be open with `acroread`.
### Reading Docs ### Reading Docs
| Alias | Command | Description | | Alias | Command | Description |
|-------|-------------|-------------------------------------| | ----- | ---------- | ---------------------------------- |
| pdf | `acroread` | Opens up a document using acroread | | pdf | `acroread` | Opens up a document using acroread |
| ps | `gv` | Opens up a .ps file using gv | | ps | `gv` | Opens up a .ps file using gv |
| dvi | `xdvi` | Opens up a .dvi file using xdvi | | dvi | `xdvi` | Opens up a .dvi file using xdvi |
@ -108,7 +110,7 @@ that file will be open with `acroread`.
### Listing files inside a packed file ### Listing files inside a packed file
| Alias | Command | Description | | Alias | Command | Description |
|---------|-------------|-------------------------------------| | ------ | ---------- | --------------------------------- |
| zip | `unzip -l` | Lists files inside a .zip file | | zip | `unzip -l` | Lists files inside a .zip file |
| rar | `unrar l` | Lists files inside a .rar file | | rar | `unrar l` | Lists files inside a .rar file |
| tar | `tar tf` | Lists files inside a .tar file | | tar | `tar tf` | Lists files inside a .tar file |

View File

@ -12,6 +12,8 @@ alias ldot='ls -ld .*'
alias lS='ls -1FSsh' alias lS='ls -1FSsh'
alias lart='ls -1Fcart' alias lart='ls -1Fcart'
alias lrt='ls -1Fcrt' alias lrt='ls -1Fcrt'
alias lsr='ls -lARFh' #Recursive list of files and directories
alias lsn='ls -1' #A column contains name of files and directories
alias zshrc='${=EDITOR} ${ZDOTDIR:-$HOME}/.zshrc' # Quick access to the .zshrc file alias zshrc='${=EDITOR} ${ZDOTDIR:-$HOME}/.zshrc' # Quick access to the .zshrc file

View File

@ -10,22 +10,26 @@ To use it add `composer` to the plugins array in your zshrc file.
plugins=(... composer) plugins=(... composer)
``` ```
Original author: Daniel Gomes <me@danielcsgomes.com>
## Aliases ## Aliases
| Alias | Command | Description | | Alias | Command | Description |
| ------ | ------------------------------------------- | --------------------------------------------------------------------------------------- | | ------ | ---------------------------------- | --------------------------------------------------------------------------------------- |
| `c` | `composer` | Starts composer | | `c` | `composer` | Starts composer |
| `csu` | `composer self-update` | Updates composer to the latest version |
| `cu` | `composer update` | Updates composer dependencies and `composer.lock` file |
| `cr` | `composer require` | Adds new packages to `composer.json` |
| `crm` | `composer remove` | Removes packages from `composer.json` |
| `ci` | `composer install` | Resolves and installs dependencies from `composer.json` |
| `ccp` | `composer create-project` | Create new project from an existing package | | `ccp` | `composer create-project` | Create new project from an existing package |
| `cdu` | `composer dump-autoload` | Updates the autoloader |
| `cdo` | `composer dump-autoload -o` | Converts PSR-0/4 autoloading to classmap for a faster autoloader (good for production) | | `cdo` | `composer dump-autoload -o` | Converts PSR-0/4 autoloading to classmap for a faster autoloader (good for production) |
| `cgu` | `composer global update` | Allows update command to run on COMPOSER_HOME directory | | `cdu` | `composer dump-autoload` | Updates the autoloader |
| `cget` | `curl -s <installer> \| php` | Installs composer in the current directory |
| `cgr` | `composer global require` | Allows require command to run on COMPOSER_HOME directory | | `cgr` | `composer global require` | Allows require command to run on COMPOSER_HOME directory |
| `cgrm` | `composer global remove` | Allows remove command to run on COMPOSER_HOME directory | | `cgrm` | `composer global remove` | Allows remove command to run on COMPOSER_HOME directory |
| `cget` | `curl -s https://getcomposer.org/installer` | Installs composer in the current directory | | `cgu` | `composer global update` | Allows update command to run on COMPOSER_HOME directory |
| `ci` | `composer install` | Resolves and installs dependencies from `composer.json` |
| `co` | `composer outdated` | Shows a list of installed packages with available updates | | `co` | `composer outdated` | Shows a list of installed packages with available updates |
| `cod` | `composer outdated --direct` | Shows a list of installed packages with available updates which are direct dependencies | | `cod` | `composer outdated --direct` | Shows a list of installed packages with available updates which are direct dependencies |
| `cr` | `composer require` | Adds new packages to `composer.json` |
| `crm` | `composer remove` | Removes packages from `composer.json` |
| `cs` | `composer show` | Lists available packages, with optional filtering |
| `csu` | `composer self-update` | Updates composer to the latest version |
| `cu` | `composer update` | Updates composer dependencies and `composer.lock` file |
| `cuh` | `composer update -d <config-home>` | Updates globally installed packages |

View File

@ -1,58 +1,68 @@
# ------------------------------------------------------------------------------ ## Basic Composer command completion
# FILE: composer.plugin.zsh # Since Zsh 5.7, an improved composer command completion is provided
# DESCRIPTION: oh-my-zsh composer plugin file. if ! is-at-least 5.7; then
# AUTHOR: Daniel Gomes (me@danielcsgomes.com)
# VERSION: 1.0.0
# ------------------------------------------------------------------------------
# Composer basic command completion
_composer_get_command_list () {
$_comp_command1 --no-ansi 2>/dev/null | sed "1,/Available commands/d" | awk '/^[ \t]*[a-z]+/ { print $1 }'
}
_composer_get_required_list () {
$_comp_command1 show -s --no-ansi 2>/dev/null | sed '1,/requires/d' | awk 'NF > 0 && !/^requires \(dev\)/{ print $1 }'
}
_composer () { _composer () {
local curcontext="$curcontext" state line local curcontext="$curcontext" state line
typeset -A opt_args typeset -A opt_args
_arguments \ _arguments '*:: :->subcmds'
'*:: :->subcmds'
if (( CURRENT == 1 )) || ( ((CURRENT == 2)) && [ "$words[1]" = "global" ] ) ; then if (( CURRENT == 1 )) || ( (( CURRENT == 2 )) && [[ "$words[1]" = "global" ]] ); then
compadd $(_composer_get_command_list) # Command list
local -a subcmds
subcmds=("${(@f)"$($_comp_command1 --no-ansi 2>/dev/null | awk '
/Available commands/{ r=1 }
r == 1 && /^[ \t]*[a-z]+/{
gsub(/^[ \t]+/, "")
gsub(/ +/, ":")
print $0
}
')"}")
_describe -t commands 'composer command' subcmds
else else
compadd $(_composer_get_required_list) # Required list
compadd $($_comp_command1 show -s --no-ansi 2>/dev/null \
| sed '1,/requires/d' \
| awk 'NF > 0 && !/^requires \(dev\)/{ print $1 }')
fi fi
} }
compdef _composer composer compdef _composer composer
compdef _composer composer.phar compdef _composer composer.phar
fi
# Aliases
## Aliases
alias c='composer' alias c='composer'
alias csu='composer self-update'
alias cu='composer update'
alias cr='composer require'
alias crm='composer remove'
alias ci='composer install'
alias ccp='composer create-project' alias ccp='composer create-project'
alias cdu='composer dump-autoload'
alias cdo='composer dump-autoload -o' alias cdo='composer dump-autoload -o'
alias cgu='composer global update' alias cdu='composer dump-autoload'
alias cget='curl -s https://getcomposer.org/installer | php'
alias cgr='composer global require' alias cgr='composer global require'
alias cgrm='composer global remove' alias cgrm='composer global remove'
alias cgu='composer global update'
alias ci='composer install'
alias co='composer outdated' alias co='composer outdated'
alias cod='composer outdated --direct' alias cod='composer outdated --direct'
alias cr='composer require'
alias crm='composer remove'
alias cs='composer show'
alias csu='composer self-update'
alias cu='composer update'
alias cuh='composer update --working-dir=$(composer config -g home)'
# install composer in the current directory
alias cget='curl -s https://getcomposer.org/installer | php'
# Add Composer's global binaries to PATH, using Composer if available. ## If Composer not found, try to add known directories to $PATH
if (( $+commands[composer] )); then if (( ! $+commands[composer] )); then
[[ -d "$HOME/.composer/vendor/bin" ]] && export PATH="$PATH:$HOME/.composer/vendor/bin"
[[ -d "$HOME/.config/composer/vendor/bin" ]] && export PATH="$PATH:$HOME/.config/composer/vendor/bin"
# If still not found, don't do the rest of the script
(( $+commands[composer] )) || return 0
fi
## Add Composer's global binaries to PATH
autoload -Uz _store_cache _retrieve_cache _cache_invalid autoload -Uz _store_cache _retrieve_cache _cache_invalid
_retrieve_cache composer _retrieve_cache composer
if [[ -z $__composer_bin_dir ]]; then if [[ -z $__composer_bin_dir ]]; then
@ -64,7 +74,3 @@ if (( $+commands[composer] )); then
export PATH="$PATH:$__composer_bin_dir" export PATH="$PATH:$__composer_bin_dir"
unset __composer_bin_dir unset __composer_bin_dir
else
[ -d $HOME/.composer/vendor/bin ] && export PATH=$PATH:$HOME/.composer/vendor/bin
[ -d $HOME/.config/composer/vendor/bin ] && export PATH=$PATH:$HOME/.config/composer/vendor/bin
fi

View File

@ -36,7 +36,7 @@ arguments=(
'--reinstall[Reinstall the distribution even if you already have the latest version installed]' '--reinstall[Reinstall the distribution even if you already have the latest version installed]'
'--interactive[Turn on interactive configure]' '--interactive[Turn on interactive configure]'
'--scandeps[Scan the depencencies of given modules and output the tree in a text format]' '--scandeps[Scan the dependencies of given modules and output the tree in a text format]'
'--format[Specify what format to display the scanned dependency tree]:scandeps format:(tree json yaml dists)' '--format[Specify what format to display the scanned dependency tree]:scandeps format:(tree json yaml dists)'
'--save-dists[Specify the optional directory path to copy downloaded tarballs]' '--save-dists[Specify the optional directory path to copy downloaded tarballs]'

View File

@ -33,20 +33,22 @@ Set `$apt_pref` and `$apt_upgr` to whatever command you want (before sourcing Oh
| Alias | Command | Description | | Alias | Command | Description |
| -------- | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | | -------- | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| `aac` | `sudo $apt_pref autoclean` | Clears out the local repository of retrieved package files | | `aac` | `sudo $apt_pref autoclean` | Clears out the local repository of retrieved package files |
| `aar` | `sudo $apt_pref autoremove` | Removes packages installed automatically that are no longer needed |
| `abd` | `sudo $apt_pref build-dep` | Installs all dependencies for building packages | | `abd` | `sudo $apt_pref build-dep` | Installs all dependencies for building packages |
| `ac` | `sudo $apt_pref clean` | Clears out the local repository of retrieved package files except lock files | | `ac` | `sudo $apt_pref clean` | Clears out the local repository of retrieved package files except lock files |
| `ad` | `sudo $apt_pref update` | Updates the package lists for upgrades for packages | | `ad` | `sudo $apt_pref update` | Updates the package lists for upgrades for packages |
| `adg` | `sudo $apt_pref update && sudo $apt_pref $apt_upgr` | Update and upgrade packages | | `adg` | `sudo $apt_pref update && sudo $apt_pref $apt_upgr` | Update and upgrade packages |
| `ads` | `sudo apt-get dselect-upgrade` | Installs packages from list and removes all not in the list |
| `adu` | `sudo $apt_pref update && sudo $apt_pref dist-upgrade` | Smart upgrade that handles dependencies | | `adu` | `sudo $apt_pref update && sudo $apt_pref dist-upgrade` | Smart upgrade that handles dependencies |
| `afu` | `sudo apt-file update` | Update the files in packages | | `afu` | `sudo apt-file update` | Update the files in packages |
| `au` | `sudo $apt_pref $apt_upgr` | Install package upgrades |
| `ai` | `sudo $apt_pref install` | Command-line tool to install package | | `ai` | `sudo $apt_pref install` | Command-line tool to install package |
| `ail` | `sed -e 's/ */ /g' -e 's/ *//' \| cut -s -d ' ' -f 1 \| xargs sudo $apt_pref install` | Install all packages given on the command line while using only the first word of each line | | `ail` | `sed -e 's/ */ /g' -e 's/ *//' \| cut -s -d ' ' -f 1 \| xargs sudo $apt_pref install` | Install all packages given on the command line while using only the first word of each line |
| `alu` | `sudo apt update && apt list -u && sudo apt upgrade` | Update, list and upgrade packages |
| `ap` | `sudo $apt_pref purge` | Removes packages along with configuration files | | `ap` | `sudo $apt_pref purge` | Removes packages along with configuration files |
| `ar` | `sudo $apt_pref remove` | Removes packages, keeps the configuration files | | `ar` | `sudo $apt_pref remove` | Removes packages, keeps the configuration files |
| `ads` | `sudo apt-get dselect-upgrade` | Installs packages from list and removes all not in the list | | `au` | `sudo $apt_pref $apt_upgr` | Install package upgrades |
| `dia` | `sudo dpkg -i ./*.deb` | Install all .deb files in the current directory |
| `di` | `sudo dpkg -i` | Install all .deb files in the current directory | | `di` | `sudo dpkg -i` | Install all .deb files in the current directory |
| `dia` | `sudo dpkg -i ./*.deb` | Install all .deb files in the current directory |
| `kclean` | `sudo aptitude remove -P ?and(~i~nlinux-(ima\|hea) ?not(~n$(uname -r)))` | Remove ALL kernel images and headers EXCEPT the one in use | | `kclean` | `sudo aptitude remove -P ?and(~i~nlinux-(ima\|hea) ?not(~n$(uname -r)))` | Remove ALL kernel images and headers EXCEPT the one in use |
## Aliases - Commands using `su` ## Aliases - Commands using `su`
@ -54,6 +56,7 @@ Set `$apt_pref` and `$apt_upgr` to whatever command you want (before sourcing Oh
| Alias | Command | | Alias | Command |
| ----- | --------------------------------------------------------- | | ----- | --------------------------------------------------------- |
| `aac` | `su -ls "$apt_pref autoclean" root` | | `aac` | `su -ls "$apt_pref autoclean" root` |
| `aar` | `su -ls "$apt_pref autoremove" root` |
| `ac` | `su -ls "$apt_pref clean" root` | | `ac` | `su -ls "$apt_pref clean" root` |
| `ad` | `su -lc "$apt_pref update" root` | | `ad` | `su -lc "$apt_pref update" root` |
| `adg` | `su -lc "$apt_pref update && aptitude $apt_upgr" root` | | `adg` | `su -lc "$apt_pref update && aptitude $apt_upgr" root` |
@ -75,8 +78,8 @@ Set `$apt_pref` and `$apt_upgr` to whatever command you want (before sourcing Oh
| ------------------- | --------------------------------------------------------------- | | ------------------- | --------------------------------------------------------------- |
| `apt-copy` | Create a simple script that can be used to 'duplicate' a system | | `apt-copy` | Create a simple script that can be used to 'duplicate' a system |
| `apt-history` | Displays apt history for a command | | `apt-history` | Displays apt history for a command |
| `kerndeb` | Builds kernel packages |
| `apt-list-packages` | List packages by size | | `apt-list-packages` | List packages by size |
| `kerndeb` | Builds kernel packages |
## Authors ## Authors

View File

@ -52,13 +52,18 @@ if [[ $use_sudo -eq 1 ]]; then
alias ai="sudo $apt_pref install" alias ai="sudo $apt_pref install"
# Install all packages given on the command line while using only the first word of each line: # Install all packages given on the command line while using only the first word of each line:
# acs ... | ail # acs ... | ail
alias ail="sed -e 's/ */ /g' -e 's/ *//' | cut -s -d ' ' -f 1 | xargs sudo $apt_pref install" alias ail="sed -e 's/ */ /g' -e 's/ *//' | cut -s -d ' ' -f 1 | xargs sudo $apt_pref install"
alias ap="sudo $apt_pref purge" alias ap="sudo $apt_pref purge"
alias ar="sudo $apt_pref remove" alias ar="sudo $apt_pref remove"
alias aar="sudo $apt_pref autoremove"
# apt-get only # apt-get only
alias ads="sudo apt-get dselect-upgrade" alias ads="sudo apt-get dselect-upgrade"
# apt only
alias alu="sudo apt update && apt list -u && sudo apt upgrade"
# Install all .deb files in the current directory. # Install all .deb files in the current directory.
# Warning: you will need to put the glob in single quotes if you use: # Warning: you will need to put the glob in single quotes if you use:
# glob_subst # glob_subst
@ -98,7 +103,11 @@ else
print "$cmd" print "$cmd"
eval "$cmd" eval "$cmd"
} }
function aar() {
cmd="su -lc '$apt_pref -P autoremove $@' root"
print "$cmd"
eval "$cmd"
}
# Install all .deb files in the current directory # Install all .deb files in the current directory
# Assumes glob_subst is off # Assumes glob_subst is off
alias dia='su -lc "dpkg -i ./*.deb" root' alias dia='su -lc "dpkg -i ./*.deb" root'
@ -139,6 +148,7 @@ apt_pref_compdef ai "install"
apt_pref_compdef ail "install" apt_pref_compdef ail "install"
apt_pref_compdef ap "purge" apt_pref_compdef ap "purge"
apt_pref_compdef ar "remove" apt_pref_compdef ar "remove"
apt_pref_compdef aar "autoremove"
apt_pref_compdef ads "dselect-upgrade" apt_pref_compdef ads "dselect-upgrade"
# Misc. ##################################################################### # Misc. #####################################################################

View File

@ -13,6 +13,7 @@ This plugin sets up completion and aliases for [Deno](https://deno.land).
| dh | deno help | | dh | deno help |
| dli | deno lint | | dli | deno lint |
| drn | deno run | | drn | deno run |
| drA | deno run -A |
| drw | deno run --watch | | drw | deno run --watch |
| dts | deno test | | dts | deno test |
| dup | deno upgrade | | dup | deno upgrade |

View File

@ -6,30 +6,35 @@ alias dfmt='deno fmt'
alias dh='deno help' alias dh='deno help'
alias dli='deno lint' alias dli='deno lint'
alias drn='deno run' alias drn='deno run'
alias drA='deno run -A'
alias drw='deno run --watch' alias drw='deno run --watch'
alias dts='deno test' alias dts='deno test'
alias dup='deno upgrade' alias dup='deno upgrade'
# COMPLETION FUNCTION # COMPLETION FUNCTION
if (( $+commands[deno] )); then if (( ! $+commands[deno] )); then
# remove old generated completion file return
command rm -f "${0:A:h}/_deno"
ver="$(deno --version)"
ver_file="$ZSH_CACHE_DIR/deno_version"
comp_file="$ZSH_CACHE_DIR/completions/_deno"
mkdir -p "${comp_file:h}"
(( ${fpath[(Ie)${comp_file:h}]} )) || fpath=("${comp_file:h}" $fpath)
if [[ ! -f "$comp_file" || ! -f "$ver_file" || "$ver" != "$(< "$ver_file")" ]]; then
deno completions zsh >| "$comp_file"
echo "$ver" >| "$ver_file"
fi fi
declare -A _comps # TODO: 2021-12-28: remove this block
# Handle $0 according to the standard:
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"
# Remove old generated files
command rm -f "${0:A:h}/_deno" "$ZSH_CACHE_DIR/deno_version"
# TODO: 2021-12-28: remove this bit of code as it exists in oh-my-zsh.sh
# Add completions folder in $ZSH_CACHE_DIR
command mkdir -p "$ZSH_CACHE_DIR/completions"
(( ${fpath[(Ie)"$ZSH_CACHE_DIR/completions"]} )) || fpath=("$ZSH_CACHE_DIR/completions" $fpath)
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `deno`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_deno" ]]; then
typeset -g -A _comps
autoload -Uz _deno autoload -Uz _deno
_comps[deno]=_deno _comps[deno]=_deno
unset ver ver_file comp_file
fi fi
deno completions zsh >| "$ZSH_CACHE_DIR/completions/_deno" &|

View File

@ -12,19 +12,27 @@ plugins=(... dirhistory)
| Shortcut | Description | | Shortcut | Description |
|-----------------------------------|-----------------------------------------------------------| |-----------------------------------|-----------------------------------------------------------|
| <kbd>alt</kbd> + <kbd>left</kbd> | Go to previous directory | | <kbd>Alt</kbd> + <kbd>Left</kbd> | Go to previous directory |
| <kbd>alt</kbd> + <kbd>right</kbd> | Undo <kbd>alt</kbd> + <kbd>left</kbd> | | <kbd>Alt</kbd> + <kbd>Right</kbd> | Go to next directory |
| <kbd>alt</kbd> + <kbd>up</kbd> | Move into the parent directory | | <kbd>Alt</kbd> + <kbd>Up</kbd> | Move into the parent directory |
| <kbd>alt</kbd> + <kbd>down</kbd> | Move into the first child directory by alphabetical order | | <kbd>Alt</kbd> + <kbd>Down</kbd> | Move into the first child directory by alphabetical order |
NOTE: some terminals might override the ALT+Arrows key bindings (Windows Terminal, for example). **For macOS: use the Option key (<kbd></kbd>) instead of <kbd>Alt</kbd>**.
If these don't work check your terminal settings and change them to a different keyboard shortcut.
> NOTE: some terminals might override the <kbd>Alt</kbd> + Arrows key bindings (e.g. Windows Terminal).
> If these don't work check your terminal settings and change them to a different keyboard shortcut.
## Usage ## Usage
This plugin allows you to navigate the history of previous current-working-directories using ALT-LEFT and ALT-RIGHT. ALT-LEFT moves back to directories that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT. MAC users may alternately use OPT-LEFT and OPT-RIGHT. This plugin allows you to navigate the history of previous working directories using <kbd>Alt</kbd> + <kbd>Left</kbd>
and <kbd>Alt</kbd> + <kbd>Right</kbd>. <kbd>Alt</kbd> + <kbd>Left</kbd> moves to past directories, and
<kbd>Alt</kbd> + <kbd>Right</kbd> goes back to recent directories.
Also, navigate directory **hierarchy** using ALT-UP and ALT-DOWN. (mac keybindings not yet implemented). ALT-UP moves to higher hierarchy (shortcut for 'cd ..'). ALT-DOWN moves into the first directory found in alphabetical order (useful to navigate long empty directories e.g. java packages) **NOTE: the maximum directory history size is 30.**
You can also navigate **directory hierarchies** using <kbd>Alt</kbd> + <kbd>Up</kbd> and <kbd>Alt</kbd> + <kbd>Down</kbd>.
<kbd>Alt</kbd> + <kbd>Up</kbd> moves to the parent directory, while <kbd>Alt</kbd> + <kbd>Down</kbd> moves into the first
child directory found in alphabetical order (useful to navigate long empty directories, e.g. Java packages).
For example, if the shell was started, and the following commands were entered: For example, if the shell was started, and the following commands were entered:
@ -35,8 +43,20 @@ cd share
cd doc cd doc
``` ```
Then entering ALT-LEFT at the prompt would change directory from /usr/share/doc to /usr/share, then if pressed again to /usr/, then ~. If ALT-RIGHT were pressed the directory would be changed to /usr/ again. the directory stack (`dirs -v`) would look like this:
After that, ALT-DOWN will probably go to /usr/bin (depends on your /usr structure), ALT-UP will return to /usr, then ALT-UP will get you to / ```console
$ dirs -v
0 /usr/share/doc
1 /usr/share
2 /usr
3 ~
```
**Currently the max history size is 30**. The navigation should work for xterm, PuTTY xterm mode, GNU screen, and on MAC with alternate keys as mentioned above. then entering <kbd>Alt</kbd> + <kbd>Left</kbd> at the prompt would change directory from `/usr/share/doc` to `/usr/share`,
then if pressed again to `/usr`, then `~`. If <kbd>Alt</kbd> + <kbd>Right</kbd> were pressed the directory would be changed
to `/usr` again.
After that, <kbd>Alt</kbd> + <kbd>Down</kbd> will probably go to `/usr/bin` if `bin` is the first directory in alphabetical
order (depends on your `/usr` folder structure). <kbd>Alt</kbd> + <kbd>Up</kbd> will return to `/usr`, and once more will get
you to the root folder (`/`).

View File

@ -19,14 +19,14 @@ export DIRHISTORY_SIZE=30
# Returns the element if the array was not empty, # Returns the element if the array was not empty,
# otherwise returns empty string. # otherwise returns empty string.
function pop_past() { function pop_past() {
eval "$1='$dirhistory_past[$#dirhistory_past]'" typeset -g $1="${dirhistory_past[$#dirhistory_past]}"
if [[ $#dirhistory_past -gt 0 ]]; then if [[ $#dirhistory_past -gt 0 ]]; then
dirhistory_past[$#dirhistory_past]=() dirhistory_past[$#dirhistory_past]=()
fi fi
} }
function pop_future() { function pop_future() {
eval "$1='$dirhistory_future[$#dirhistory_future]'" typeset -g $1="${dirhistory_future[$#dirhistory_future]}"
if [[ $#dirhistory_future -gt 0 ]]; then if [[ $#dirhistory_future -gt 0 ]]; then
dirhistory_future[$#dirhistory_future]=() dirhistory_future[$#dirhistory_future]=()
fi fi
@ -121,36 +121,39 @@ function dirhistory_zle_dirhistory_future() {
} }
zle -N dirhistory_zle_dirhistory_back zle -N dirhistory_zle_dirhistory_back
# xterm in normal mode
bindkey "\e[3D" dirhistory_zle_dirhistory_back
bindkey "\e[1;3D" dirhistory_zle_dirhistory_back
# Terminal.app
if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then
bindkey "^[b" dirhistory_zle_dirhistory_back
fi
# iTerm2
if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
bindkey "^[^[[D" dirhistory_zle_dirhistory_back
fi
# Putty:
bindkey "\e\e[D" dirhistory_zle_dirhistory_back
# GNU screen:
bindkey "\eO3D" dirhistory_zle_dirhistory_back
zle -N dirhistory_zle_dirhistory_future zle -N dirhistory_zle_dirhistory_future
bindkey "\e[3C" dirhistory_zle_dirhistory_future
bindkey "\e[1;3C" dirhistory_zle_dirhistory_future
# Terminal.app
if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then
bindkey "^[f" dirhistory_zle_dirhistory_future
fi
# iTerm2
if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
bindkey "^[^[[C" dirhistory_zle_dirhistory_future
fi
bindkey "\e\e[C" dirhistory_zle_dirhistory_future
bindkey "\eO3C" dirhistory_zle_dirhistory_future
for keymap in emacs vicmd viins; do
# dirhistory_back
bindkey -M $keymap "\e[3D" dirhistory_zle_dirhistory_back # xterm in normal mode
bindkey -M $keymap "\e[1;3D" dirhistory_zle_dirhistory_back # xterm in normal mode
bindkey -M $keymap "\e\e[D" dirhistory_zle_dirhistory_back # Putty
bindkey -M $keymap "\eO3D" dirhistory_zle_dirhistory_back # GNU screen
case "$TERM_PROGRAM" in
Apple_Terminal) bindkey -M $keymap "^[b" dirhistory_zle_dirhistory_back ;; # Terminal.app
iTerm.app) bindkey -M $keymap "^[^[[D" dirhistory_zle_dirhistory_back ;; # iTerm2
esac
if (( ${+terminfo[kcub1]} )); then
bindkey -M $keymap "^[${terminfo[kcub1]}" dirhistory_zle_dirhistory_back # urxvt
fi
# dirhistory_future
bindkey -M $keymap "\e[3C" dirhistory_zle_dirhistory_future # xterm in normal mode
bindkey -M $keymap "\e[1;3C" dirhistory_zle_dirhistory_future # xterm in normal mode
bindkey -M $keymap "\e\e[C" dirhistory_zle_dirhistory_future # Putty
bindkey -M $keymap "\eO3C" dirhistory_zle_dirhistory_future # GNU screen
case "$TERM_PROGRAM" in
Apple_Terminal) bindkey -M $keymap "^[f" dirhistory_zle_dirhistory_future ;; # Terminal.app
iTerm.app) bindkey -M $keymap "^[^[[C" dirhistory_zle_dirhistory_future ;; # iTerm2
esac
if (( ${+terminfo[kcuf1]} )); then
bindkey -M $keymap "^[${terminfo[kcuf1]}" dirhistory_zle_dirhistory_future # urxvt
fi
done
# #
# HIERARCHY Implemented in this section, in case someone wants to split it to another plugin if it clashes bindings # HIERARCHY Implemented in this section, in case someone wants to split it to another plugin if it clashes bindings
@ -181,22 +184,38 @@ function dirhistory_zle_dirhistory_down() {
} }
zle -N dirhistory_zle_dirhistory_up zle -N dirhistory_zle_dirhistory_up
# xterm in normal mode
bindkey "\e[3A" dirhistory_zle_dirhistory_up
bindkey "\e[1;3A" dirhistory_zle_dirhistory_up
if [[ "$TERM_PROGRAM" == "Apple_Terminal" || "$TERM_PROGRAM" == "iTerm.app" ]]; then
bindkey "^[[A" dirhistory_zle_dirhistory_up
fi
# Putty:
bindkey "\e\e[A" dirhistory_zle_dirhistory_up
# GNU screen:
bindkey "\eO3A" dirhistory_zle_dirhistory_up
zle -N dirhistory_zle_dirhistory_down zle -N dirhistory_zle_dirhistory_down
bindkey "\e[3B" dirhistory_zle_dirhistory_down
bindkey "\e[1;3B" dirhistory_zle_dirhistory_down for keymap in emacs vicmd viins; do
if [[ "$TERM_PROGRAM" == "Apple_Terminal" || "$TERM_PROGRAM" == "iTerm.app" ]]; then # dirhistory_up
bindkey "^[[B" dirhistory_zle_dirhistory_down bindkey -M $keymap "\e[3A" dirhistory_zle_dirhistory_up # xterm in normal mode
bindkey -M $keymap "\e[1;3A" dirhistory_zle_dirhistory_up # xterm in normal mode
bindkey -M $keymap "\e\e[A" dirhistory_zle_dirhistory_up # Putty
bindkey -M $keymap "\eO3A" dirhistory_zle_dirhistory_up # GNU screen
case "$TERM_PROGRAM" in
Apple_Terminal) bindkey -M $keymap "^[[A" dirhistory_zle_dirhistory_up ;; # Terminal.app
iTerm.app) bindkey -M $keymap "^[^[[A" dirhistory_zle_dirhistory_up ;; # iTerm2
esac
if (( ${+terminfo[kcuu1]} )); then
bindkey -M $keymap "^[${terminfo[kcuu1]}" dirhistory_zle_dirhistory_up # urxvt
fi fi
bindkey "\e\e[B" dirhistory_zle_dirhistory_down
bindkey "\eO3B" dirhistory_zle_dirhistory_down # dirhistory_down
bindkey -M $keymap "\e[3B" dirhistory_zle_dirhistory_down # xterm in normal mode
bindkey -M $keymap "\e[1;3B" dirhistory_zle_dirhistory_down # xterm in normal mode
bindkey -M $keymap "\e\e[B" dirhistory_zle_dirhistory_down # Putty
bindkey -M $keymap "\eO3B" dirhistory_zle_dirhistory_down # GNU screen
case "$TERM_PROGRAM" in
Apple_Terminal) bindkey -M $keymap "^[[B" dirhistory_zle_dirhistory_down ;; # Terminal.app
iTerm.app) bindkey -M $keymap "^[^[[B" dirhistory_zle_dirhistory_down ;; # iTerm2
esac
if (( ${+terminfo[kcud1]} )); then
bindkey -M $keymap "^[${terminfo[kcud1]}" dirhistory_zle_dirhistory_down # urxvt
fi
done
unset keymap

View File

@ -121,12 +121,6 @@ __docker-compose_subcommand() {
'--parallel[Build images in parallel.]' \ '--parallel[Build images in parallel.]' \
'*:services:__docker-compose_services_from_build' && ret=0 '*:services:__docker-compose_services_from_build' && ret=0
;; ;;
(bundle)
_arguments \
$opts_help \
'--push-images[Automatically push images for any services which have a `build` option specified.]' \
'(--output -o)'{--output,-o}'[Path to write the bundle file to. Defaults to "<project name>.dab".]:file:_files' && ret=0
;;
(config) (config)
_arguments \ _arguments \
$opts_help \ $opts_help \
@ -290,7 +284,7 @@ __docker-compose_subcommand() {
(up) (up)
_arguments \ _arguments \
$opts_help \ $opts_help \
'(--abort-on-container-exit)-d[Detached mode: Run containers in the background, print new container names. Incompatible with --abort-on-container-exit.]' \ '(--abort-on-container-exit)-d[Detached mode: Run containers in the background, print new container names. Incompatible with --abort-on-container-exit and --attach-dependencies.]' \
$opts_no_color \ $opts_no_color \
$opts_no_deps \ $opts_no_deps \
$opts_force_recreate \ $opts_force_recreate \
@ -298,6 +292,7 @@ __docker-compose_subcommand() {
$opts_no_build \ $opts_no_build \
"(--no-build)--build[Build images before starting containers.]" \ "(--no-build)--build[Build images before starting containers.]" \
"(-d)--abort-on-container-exit[Stops all containers if any container was stopped. Incompatible with -d.]" \ "(-d)--abort-on-container-exit[Stops all containers if any container was stopped. Incompatible with -d.]" \
"(-d)--attach-dependencies[Attach to dependent containers. Incompatible with -d.]" \
'(-t --timeout)'{-t,--timeout}"[Use this timeout in seconds for container shutdown when attached or when containers are already running. (default: 10)]:seconds: " \ '(-t --timeout)'{-t,--timeout}"[Use this timeout in seconds for container shutdown when attached or when containers are already running. (default: 10)]:seconds: " \
'--scale[SERVICE=NUM Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present.]:service scale SERVICE=NUM: ' \ '--scale[SERVICE=NUM Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present.]:service scale SERVICE=NUM: ' \
'--exit-code-from=[Return the exit code of the selected service container. Implies --abort-on-container-exit]:service:__docker-compose_services' \ '--exit-code-from=[Return the exit code of the selected service container. Implies --abort-on-container-exit]:service:__docker-compose_services' \
@ -341,11 +336,13 @@ _docker-compose() {
'(- :)'{-h,--help}'[Get help]' \ '(- :)'{-h,--help}'[Get help]' \
'*'{-f,--file}"[${file_description}]:file:_files -g '*.yml'" \ '*'{-f,--file}"[${file_description}]:file:_files -g '*.yml'" \
'(-p --project-name)'{-p,--project-name}'[Specify an alternate project name (default: directory name)]:project name:' \ '(-p --project-name)'{-p,--project-name}'[Specify an alternate project name (default: directory name)]:project name:' \
'--env-file[Specify an alternate environment file (default: .env)]:env-file:_files' \
"--compatibility[If set, Compose will attempt to convert keys in v3 files to their non-Swarm equivalent]" \ "--compatibility[If set, Compose will attempt to convert keys in v3 files to their non-Swarm equivalent]" \
'(- :)'{-v,--version}'[Print version and exit]' \ '(- :)'{-v,--version}'[Print version and exit]' \
'--verbose[Show more output]' \ '--verbose[Show more output]' \
'--log-level=[Set log level]:level:(DEBUG INFO WARNING ERROR CRITICAL)' \ '--log-level=[Set log level]:level:(DEBUG INFO WARNING ERROR CRITICAL)' \
'--no-ansi[Do not print ANSI control characters]' \ '--no-ansi[Do not print ANSI control characters]' \
'--ansi=[Control when to print ANSI control characters]:when:(never always auto)' \
'(-H --host)'{-H,--host}'[Daemon socket to connect to]:host:' \ '(-H --host)'{-H,--host}'[Daemon socket to connect to]:host:' \
'--tls[Use TLS; implied by --tlsverify]' \ '--tls[Use TLS; implied by --tlsverify]' \
'--tlscacert=[Trust certs signed only by this CA]:ca path:' \ '--tlscacert=[Trust certs signed only by this CA]:ca path:' \
@ -359,6 +356,7 @@ _docker-compose() {
local -a relevant_compose_flags relevant_compose_repeatable_flags relevant_docker_flags compose_options docker_options local -a relevant_compose_flags relevant_compose_repeatable_flags relevant_docker_flags compose_options docker_options
relevant_compose_flags=( relevant_compose_flags=(
"--env-file"
"--file" "-f" "--file" "-f"
"--host" "-H" "--host" "-H"
"--project-name" "-p" "--project-name" "-p"

View File

@ -1,28 +1,22 @@
# Authors: # support Compose v2 as docker CLI plugin
# https://github.com/tristola (( ${+commands[docker-compose]} )) && dccmd='docker-compose' || dccmd='docker compose'
#
# Docker-compose related zsh aliases
# Aliases ################################################################### alias dco="$dccmd"
alias dcb="$dccmd build"
alias dce="$dccmd exec"
alias dcps="$dccmd ps"
alias dcrestart="$dccmd restart"
alias dcrm="$dccmd rm"
alias dcr="$dccmd run"
alias dcstop="$dccmd stop"
alias dcup="$dccmd up"
alias dcupb="$dccmd up --build"
alias dcupd="$dccmd up -d"
alias dcdn="$dccmd down"
alias dcl="$dccmd logs"
alias dclf="$dccmd logs -f"
alias dcpull="$dccmd pull"
alias dcstart="$dccmd start"
alias dck="$dccmd kill"
# Use dco as alias for docker-compose, since dc on *nix is 'dc - an arbitrary precision calculator' unset dccmd
# https://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html
alias dco='docker-compose'
alias dcb='docker-compose build'
alias dce='docker-compose exec'
alias dcps='docker-compose ps'
alias dcrestart='docker-compose restart'
alias dcrm='docker-compose rm'
alias dcr='docker-compose run'
alias dcstop='docker-compose stop'
alias dcup='docker-compose up'
alias dcupb='docker-compose up --build'
alias dcupd='docker-compose up -d'
alias dcdn='docker-compose down'
alias dcl='docker-compose logs'
alias dclf='docker-compose logs -f'
alias dcpull='docker-compose pull'
alias dcstart='docker-compose start'
alias dck='docker-compose kill'

View File

@ -90,7 +90,7 @@ __docker-machine_filters() {
} }
__get_swarm_discovery() { __get_swarm_discovery() {
declare -a masters serivces declare -a masters services
local service local service
services=() services=()
masters=($(docker-machine ls -f {{.Swarm}} |grep '(master)' |awk '{print $1}')) masters=($(docker-machine ls -f {{.Swarm}} |grep '(master)' |awk '{print $1}'))
@ -169,7 +169,7 @@ __get_create_argument() {
__docker-machine_subcommand() { __docker-machine_subcommand() {
local -a opts_help local -a opts_help
opts_help=("(- :)--help[Print usage]") opts_help=("(- :)--help[Print usage]")
local -a opts_only_host opts_driver opts_storage_driver opts_stragery local -a opts_only_host opts_driver opts_storage_driver opts_state
opts_only_host=( opts_only_host=(
"$opts_help" "$opts_help"
"*:host:__docker-machine_hosts_all" "*:host:__docker-machine_hosts_all"
@ -330,7 +330,7 @@ _docker-machine() {
_arguments -C \ _arguments -C \
"(- :)"{-h,--help}"[Show help]" \ "(- :)"{-h,--help}"[Show help]" \
"(-D --debug)"{-D,--debug}"[Enable debug mode]" \ "(-D --debug)"{-D,--debug}"[Enable debug mode]" \
'(-s --stroage-path)'{-s,--storage-path}'[Configures storage path]:file:_files' \ '(-s --storage-path)'{-s,--storage-path}'[Configures storage path]:file:_files' \
'--tls-ca-cert[CA to verify remotes against]:file:_files' \ '--tls-ca-cert[CA to verify remotes against]:file:_files' \
'--tls-ca-key[Private key to generate certificates]:file:_files' \ '--tls-ca-key[Private key to generate certificates]:file:_files' \
'--tls-client-cert[Client cert to use for TLS]:file:_files' \ '--tls-client-cert[Client cert to use for TLS]:file:_files' \

View File

@ -23,12 +23,12 @@ source_env() {
touch "$ZSH_DOTENV_DISALLOWED_LIST" touch "$ZSH_DOTENV_DISALLOWED_LIST"
# early return if disallowed # early return if disallowed
if command grep -q "$dirpath" "$ZSH_DOTENV_DISALLOWED_LIST" &>/dev/null; then if command grep -Fx -q "$dirpath" "$ZSH_DOTENV_DISALLOWED_LIST" &>/dev/null; then
return return
fi fi
# check if current directory's .env file is allowed or ask for confirmation # check if current directory's .env file is allowed or ask for confirmation
if ! command grep -q "$dirpath" "$ZSH_DOTENV_ALLOWED_LIST" &>/dev/null; then if ! command grep -Fx -q "$dirpath" "$ZSH_DOTENV_ALLOWED_LIST" &>/dev/null; then
# get cursor column and print new line before prompt if not at line beginning # get cursor column and print new line before prompt if not at line beginning
local column local column
echo -ne "\e[6n" > /dev/tty echo -ne "\e[6n" > /dev/tty

View File

@ -21,3 +21,4 @@ plugins=(... dotnet)
| da | dotnet add | Add a package or reference to a .NET project. | | da | dotnet add | Add a package or reference to a .NET project. |
| dp | dotnet pack | Create a NuGet package. | | dp | dotnet pack | Create a NuGet package. |
| dng | dotnet nuget | Provides additional NuGet commands. | | dng | dotnet nuget | Provides additional NuGet commands. |
| db | dotnet build | Build a .NET project |

View File

@ -12,7 +12,7 @@ _dotnet_zsh_complete()
return return
fi fi
# This is not a variable assigment, don't remove spaces! # This is not a variable assignment, don't remove spaces!
_values = "${(ps:\n:)completions}" _values = "${(ps:\n:)completions}"
} }
@ -30,3 +30,4 @@ alias ds='dotnet sln'
alias da='dotnet add' alias da='dotnet add'
alias dp='dotnet pack' alias dp='dotnet pack'
alias dng='dotnet nuget' alias dng='dotnet nuget'
alias db='dotnet build'

View File

@ -1,83 +1,66 @@
# Drush # Drush
## Description This plugin adds aliases and functions for [Drush](https://www.drush.org), a command-line shell
This plugin offers aliases and functions to make the work with drush easier and more productive. and Unix scripting interface for Drupal. It also adds completion for the `drush` command.
To enable it, add the `drush` to your `plugins` array in `~/.zshrc`: To enable it, add `drush` to the plugins array in zshrc file:
``` ```zsh
plugins=(... drush) plugins=(... drush)
``` ```
## Aliases ## Aliases
| Alias | Description | Command |
|-------|-----------------------------------------------------------------------|-----------------------------| | Alias | Command | Description |
| dr | Display drush help | drush | | ------- | ----------------------------------------------------------- | -------------------------------------------------------------------- |
| drca | Clear all drupal caches. | drush cc all | | `dr` | `drush` | Display drush help |
| drcb | Clear block cache. | drush cc block | | `drca` | `drush cc all` | _(Deprecated in Drush 8)_ Clear all drupal caches |
| drcg | Clear registry cache. | drush cc registry | | `drcb` | `drush cc block` | _(Deprecated in Drush 8)_ Clear block cache |
| drcj | Clear css-js cache. | drush cc css-js | | `drcex` | `drush config:export -y` | Export Drupal configuration to a directory |
| drcm | Clear menu cache. | drush cc menu | | `drcg` | `drush cc registry` | _(Deprecated in Drush 8)_ Clear registry cache |
| drcml | Clear module-list cache. | drush cc module-list | | `drcim` | `drush config:import -y` | Import config from a config directory |
| drcr | Run all cron hooks in all active modules for specified site. | drush core-cron | | `drcj` | `drush cc css-js` | Clear css-js cache |
| drct | Clear theme-registry cache. | drush cc theme-registry | | `drcm` | `drush cc menu` | Clear menu cache |
| drcv | Clear views cache. (Make sure that the views module is enabled) | drush cc views | | `drcml` | `drush cc module-list` | Clear module-list cache |
| drdmp | Backup database in a new dump.sql file | drush drush sql-dump --ordered-dump --result-file=dump.sql| | `drcr` | `drush core-cron` | Run all cron hooks in all active modules for specified site |
| drf | Display features status | drush features | | `drct` | `drush cc theme-registry` | Clear theme-registry cache |
| drfr | Revert a feature module on your site. | drush features-revert -y | | `drcv` | `drush cc views` | Clear views cache _(make sure that the views module is enabled)_ |
| drfu | Update a feature module on your site. | drush features-update -y | | `drdmp` | `drush drush sql-dump --ordered-dump --result-file=dumpsql` | Backup database in a new dump.sql file |
| drfra | Revert all enabled feature module on your site. | drush features-revert-all | | `drf` | `drush features` | Display features status |
| drif | Flush all derived images. | drush image-flush --all | | `drfr` | `drush features-revert -y` | Revert a feature module on your site |
| drpm | Show a list of available modules. | drush pm-list --type=module | | `drfra` | `drush features-revert-all` | Revert all enabled feature module on your site |
| drst | Provides a birds-eye view of the current Drupal installation, if any. | drush core-status | | `drfu` | `drush features-update -y` | Update a feature module on your site |
| drup | Apply any database updates required (as with running update.php). | drush updatedb | | `drif` | `drush image-flush --all` | Flush all derived images |
| drups | List any pending database updates. | drush updatedb-status | | `drpm` | `drush pm-list --type=module` | Show a list of available modules |
| drv | Show drush version. | drush version | | `drst` | `drush core-status` | Provides a birds-eye view of the current Drupal installation, if any |
| drvd | Delete a variable. | drush variable-del | | `druli` | `drush user:login` | Display a one time login link for user ID 1, or another user |
| drvg | Get a list of some or all site variables and values. | drush variable-get | | `drup` | `drush updatedb` | Apply any database updates required (as with running update.php) |
| drvs | Set a variable. | drush variable-set | | `drups` | `drush updatedb-status` | List any pending database updates |
| `drv` | `drush version` | Show drush version |
| `drvd` | `drush variable-del` | Delete a variable |
| `drvg` | `drush variable-get` | Get a list of some or all site variables and values |
| `drvs` | `drush variable-set` | Set a variable |
| `drws` | `drush watchdog:show` | Show watchdog messages |
| `drwse` | `drush watchdog:show --extended` | Show watchdog messages with extended information |
| `drwst` | `drush watchdog:tail` | Tail watchdog messages |
## Functions ## Functions
### dren - `dren`: download and enable one or more extensions (modules or themes). Must be
Download and enable one or more extensions (modules or themes). invoked with one or more parameters, e.g.: `dren devel` or `dren devel module_filter views`.
Must be invoked with one or more parameters. e.g.:
`dren devel` or `dren devel module_filter views`
### drf - `drf`: edit drushrc, site alias, and Drupal settings.php files.
Edit drushrc, site alias, and Drupal settings.php files. Can be invoked with one or without parameters, e.g.: `drf 1`.
Can be invoked with one or without parameters. e.g.:
`drf 1`
### dris - `dris`: disable one or more extensions (modules or themes). Must be invoked with
Disable one or more extensions (modules or themes) one or more parameters, e.g.: `dris devel` or `dris devel module_filter views`.
Must be invoked with one or more parameters. e.g.:
`dris devel` or `dris devel module_filter views`
### drpu - `drpu`: uninstall one or more modules. Must be invoked with one or more
Uninstall one or more modules. parameters, e.g.: `drpu devel` or `drpu devel module_filter views`.
Must be invoked with one or more parameters. e.g.:
`drpu devel` or `drpu devel module_filter views`
### drnew - `drnew`: creates a brand new drupal website. Note: as soon as the installation
Creates a brand new drupal website. is complete, `drush` will print a username and a random password into the terminal:
Note: As soon as the installation is complete, drush will print a username and a random password into the terminal:
``` ```text
Installation complete. User name: admin User password: cf7t8yqNEm Installation complete. User name: admin User password: cf7t8yqNEm
``` ```
## Additional features
### Autocomplete
The [completion script for drush](https://github.com/drush-ops/drush/blob/8.0.1/drush.complete.sh) comes enabled with this plugin.
So, it is possible to type a command:
```
drush sql
```
And as soon as the tab key is pressed, the script will display the available commands:
```
drush sql
sqlc sql-conf sql-create sql-dump sql-query sql-sanitize
sql-cli sql-connect sql-drop sqlq sqlsan sql-sync
```

View File

@ -1,19 +1,18 @@
# Drush support. # Functions
function dren() { function dren() {
drush en $@ -y drush en "$@" -y
} }
function dris() { function dris() {
drush pm-disable $@ -y drush pm-disable "$@" -y
} }
function drpu() { function drpu() {
drush pm-uninstall $@ -y drush pm-uninstall "$@" -y
} }
function drf() { function drf() {
if [[ $1 == "" ]] then if [[ -z "$1" ]] then
drush core-config drush core-config
else else
drush core-config --choice=$1 drush core-config --choice=$1
@ -21,18 +20,16 @@ function drf() {
} }
function drfi() { function drfi() {
if [[ $1 == "fields" ]]; then case "$1" in
drush field-info fields fields) drush field-info fields ;;
elif [[ $1 == "types" ]]; then types) drush field-info types ;;
drush field-info types *) drush field-info ;;
else esac
drush field-info
fi
} }
function drnew() { function drnew() {
(
cd ~ cd
echo "Website's name: " echo "Website's name: "
read WEBSITE_NAME read WEBSITE_NAME
@ -69,14 +66,16 @@ function drnew() {
open_command $HOST$WEBSITE_NAME open_command $HOST$WEBSITE_NAME
echo "Done" echo "Done"
)
} }
# Aliases, sorted alphabetically. # Aliases
alias dr="drush" alias dr="drush"
alias drca="drush cc all" # Deprecated for Drush 8 alias drca="drush cc all" # Deprecated for Drush 8
alias drcb="drush cc block" # Deprecated for Drush 8 alias drcb="drush cc block" # Deprecated for Drush 8
alias drcex="drush config:export -y"
alias drcg="drush cc registry" # Deprecated for Drush 8 alias drcg="drush cc registry" # Deprecated for Drush 8
alias drcim="drush config:import -y"
alias drcj="drush cc css-js" alias drcj="drush cc css-js"
alias drcm="drush cc menu" alias drcm="drush cc menu"
alias drcml="drush cc module-list" alias drcml="drush cc module-list"
@ -86,17 +85,21 @@ alias drcv="drush cc views"
alias drdmp="drush sql-dump --ordered-dump --result-file=dump.sql" alias drdmp="drush sql-dump --ordered-dump --result-file=dump.sql"
alias drf="drush features" alias drf="drush features"
alias drfr="drush features-revert -y" alias drfr="drush features-revert -y"
alias drfu="drush features-update -y"
alias drfra="drush features-revert-all" alias drfra="drush features-revert-all"
alias drfu="drush features-update -y"
alias drif="drush image-flush --all" alias drif="drush image-flush --all"
alias drpm="drush pm-list --type=module" alias drpm="drush pm-list --type=module"
alias drst="drush core-status" alias drst="drush core-status"
alias druli="drush user:login"
alias drup="drush updatedb" alias drup="drush updatedb"
alias drups="drush updatedb-status" alias drups="drush updatedb-status"
alias drv="drush version" alias drv="drush version"
alias drvd="drush variable-del" alias drvd="drush variable-del"
alias drvg="drush variable-get" alias drvg="drush variable-get"
alias drvs="drush variable-set" alias drvs="drush variable-set"
alias drws="drush watchdog:show"
alias drwse="drush watchdog:show --extended"
alias drwst="drush watchdog:tail"
# Enable drush autocomplete support # Enable drush autocomplete support
autoload bashcompinit autoload bashcompinit

View File

@ -9,9 +9,17 @@
# - You can share opened buffered across opened frames. # - You can share opened buffered across opened frames.
# - Configuration changes made at runtime are applied to all frames. # - Configuration changes made at runtime are applied to all frames.
# Require emacs version to be minimum 24
autoload -Uz is-at-least
is-at-least 24 "${${(Az)"$(emacsclient --version 2>/dev/null)"}[2]}" || return 0
if "$ZSH/tools/require_tool.sh" emacsclient 24 2>/dev/null ; then # Handle $0 according to the standard:
export EMACS_PLUGIN_LAUNCHER="$ZSH/plugins/emacs/emacsclient.sh" # https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"
# Path to custom emacsclient launcher
export EMACS_PLUGIN_LAUNCHER="${0:A:h}/emacsclient.sh"
# set EDITOR if not already defined. # set EDITOR if not already defined.
export EDITOR="${EDITOR:-${EMACS_PLUGIN_LAUNCHER}}" export EDITOR="${EDITOR:-${EMACS_PLUGIN_LAUNCHER}}"
@ -41,25 +49,20 @@ if "$ZSH/tools/require_tool.sh" emacsclient 24 2>/dev/null ; then
# opened in the current buffer. # opened in the current buffer.
function efile { function efile {
local cmd="(buffer-file-name (window-buffer))" local cmd="(buffer-file-name (window-buffer))"
"$EMACS_PLUGIN_LAUNCHER" --eval "$cmd" | tr -d \" local file="$("$EMACS_PLUGIN_LAUNCHER" --eval "$cmd" | tr -d \")"
if [[ -z "$file" ]]; then
echo "Can't deduce current buffer filename." >&2
return 1
fi
echo "$file"
} }
# Write to standard output the directory of the file # Write to standard output the directory of the file
# opened in the the current buffer # opened in the the current buffer
function ecd { function ecd {
local cmd="(let ((buf-name (buffer-file-name (window-buffer)))) local file
(if buf-name (file-name-directory buf-name)))" file="$(efile)" || return $?
echo "${file:h}"
local dir="$($EMACS_PLUGIN_LAUNCHER --eval $cmd | tr -d \")"
if [ -n "$dir" ] ;then
echo "$dir"
else
echo "can not deduce current buffer filename." >/dev/stderr
return 1
fi
} }
fi
## Local Variables:
## mode: sh
## End:

View File

@ -1,29 +1,38 @@
#!/bin/sh #!/bin/sh
_emacsfun() emacsfun() {
{ local cmd frames
# get list of emacs frames.
frameslist=`emacsclient --alternate-editor '' --eval '(frame-list)' 2>/dev/null | egrep -o '(frame)+'`
if [ "$(echo "$frameslist" | sed -n '$=')" -ge 2 ] ;then # Build the Emacs Lisp command to check for suitable frames
# prevent creating another X frame if there is at least one present. # See https://www.gnu.org/software/emacs/manual/html_node/elisp/Frames.html#index-framep
emacsclient --alternate-editor "" "$@" case "$*" in
else *-t*|*--tty*|*-nw*) cmd="(memq 't (mapcar 'framep (frame-list)))" ;; # if != nil, there are tty frames
# Create one if there is no X window yet. *) cmd="(delete 't (mapcar 'framep (frame-list)))" ;; # if != nil, there are graphical terminals (x, w32, ns)
esac
# Check if there are suitable frames
frames="$(emacsclient -a '' -n -e "$cmd" 2>/dev/null)"
# Only create another X frame if there isn't one present
if [ -z "$frames" -o "$frames" = nil ]; then
emacsclient --alternate-editor "" --create-frame "$@" emacsclient --alternate-editor "" --create-frame "$@"
return $?
fi fi
emacsclient --alternate-editor "" "$@"
} }
# Adapted from https://github.com/davidshepherd7/emacs-read-stdin/blob/master/emacs-read-stdin.sh
# adopted from https://github.com/davidshepherd7/emacs-read-stdin/blob/master/emacs-read-stdin.sh
# If the second argument is - then write stdin to a tempfile and open the # If the second argument is - then write stdin to a tempfile and open the
# 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 # Create a tempfile to hold stdin
tempfile="$(mktemp --tmpdir emacs-stdin-$USERNAME.XXXXXXX 2>/dev/null \ tempfile="$(mktemp --tmpdir emacs-stdin-$USERNAME.XXXXXXX 2>/dev/null \
|| mktemp -t emacs-stdin-$USERNAME)" # support BSD mktemp || mktemp -t emacs-stdin-$USERNAME)" # support BSD mktemp
# Redirect stdin to the tempfile
cat - > "$tempfile" cat - > "$tempfile"
_emacsfun --no-wait $tempfile # Reset $2 to the tempfile so that "$@" works as expected
else set -- "$1" "$tempfile" "${@:3}"
_emacsfun "$@"
fi fi
emacsfun "$@"

View File

@ -1,22 +1,33 @@
# Ember CLI # Ember CLI
**Maintainers:** [BilalBudhani](https://github.com/BilalBudhani), [eubenesa](https://github.com/eubenesa), [scottkidder](https://github.com/scottkidder] This plugin adds completion and aliases for using [`ember-cli`](https://cli.emberjs.com/).
Ember CLI (https://www.ember-cli.com/) To use it, add `ember-cli` to the plugins array in your zshrc file:
### List of Aliases ```zsh
plugins=(... ember-cli)
```
Alias | Ember-CLI command ## Aliases
----- | -----------------
**es** | *ember serve* | Alias | Command |
**ea** | *ember addon* | ----- | -------------------- |
**eb** | *ember build* | `ea` | `ember addon` |
**ed** | *ember destroy* | `eb` | `ember build` |
**eg** | *ember generate* | `ed` | `ember destroy` |
**eh** | *ember help* | `eg` | `ember generate` |
**ein** | *ember init* | `eh` | `ember help` |
**ei** | *ember install* | `ei` | `ember install` |
**et** | *ember test* | `ein` | `ember init` |
**ets** | *ember test --serve* | `es` | `ember serve` |
**eu** | *ember update* | `et` | `ember test` |
**ev** | *ember version* | `ets` | `ember test --serve` |
| `eu` | `ember update` |
| `ev` | `ember version` |
## Maintainers
- [BilalBudhani](https://github.com/BilalBudhani)
- [eubenesa](https://github.com/eubenesa)
- [scottkidder](https://github.com/scottkidder]
- [t-sauer](https://www.github.com/t-sauer)

View File

@ -0,0 +1,189 @@
#compdef ember
local curcontext="$curcontext" state line ret=1
_arguments -C -A "--version" -A "--help" \
'(- 1 *)--help' \
'(- 1 *)--version' \
'1: :->cmds' \
'*:: :->args' && ret=0
case $state in
cmds)
_values "ember command" \
"addon[Generates a new folder structure for building an addon, complete with test harness]" \
"asset-sizes[Shows the sizes of your asset files]" \
"build[Builds your app and places it into the output path (dist/ by default)]" \
"destroy[Destroys code generated by generate command]" \
"generate[Generates new code from blueprints]" \
"help[Outputs the usage instructions for all commands or the provided command]" \
"init[Creates a new ember-cli project in the current folder]" \
"install[Installs an ember-cli addon from npm]" \
"new[Creates a new directory and runs ember init in it]" \
"serve[Builds and serves your app, rebuilding on file changes]" \
"test[Runs your app's test suite]" \
"version[outputs ember-cli version]"
ret=0
;;
args)
case $line[1] in
help)
_values 'commands' \
'addon' \
'asset-sizes' \
'build' \
'destroy' \
'generate' \
'help' \
'init' \
'install' \
'new' \
'serve' \
'test' \
'vesion' && ret=0
;;
addon)
_arguments \
'(--blueprint)--blueprint=-' \
'(--directory)--directory=-' \
'(--dry-run)--dry-run' \
'(--skip-bower)--skip-bower' \
'(--skip-git)--skip-git' \
'(--skip-npm)--skip-npm' \
'(--verbose)--verbose'
;;
asset-sizes)
_arguments \
'(--output-path)--output-path=-'
;;
build)
_arguments \
'(--environment)--environment=-' \
'(--output-path)--output-path=-' \
'(--output-path)--suppress-sizes' \
'(--watch)--watch' \
'(--watcher)--watcher=-' \
'(-dev)-dev' \
'(-prod)-prod'
;;
destroy|generate)
_values 'arguments' \
'(--classic)--classic' \
'(--dry-run)--dry-run' \
'(--dummy)--dummy' \
'(--in-repo-addon)--in-repo-addon-=' \
'(--pod)--pod' \
'(--verbose)--verbose' && ret=0
_values 'blueprints' \
'acceptance-test' \
'adapter' \
'adapter-test' \
'component' \
'component-addon' \
'component-test' \
'controller' \
'controller-test' \
'helper' \
'helper-addon' \
'helper-test' \
'initializer' \
'initializer-addon' \
'initializer-test' \
'instance-initializer' \
'instance-initializer-addon' \
'instance-initializer-test' \
'mixin' \
'mixin-test' \
'model' \
'model-test' \
'resource' \
'route' \
'route-addon' \
'route-test' \
'serializer' \
'serializer-test' \
'service' \
'service-test' \
'template' \
'test-helper' \
'transform' \
'transform-test' \
'util' \
'util-test' \
'view' \
'view-test' \
'addon' \
'addon-import' \
'app' \
'blueprint' \
'http-mock' \
'http-proxy' \
'in-repo-addon' \
'lib' \
'server' \
'vendor-shim' && ret=0
;;
init)
_arguments \
'(--blueprint)--blueprint=-' \
'(--name)--name=-' \
'(--dry-run)--dry-run' \
'(--skip-bower)--skip-bower' \
'(--skip-npm)--skip-npm' \
'(--verbose)--verbose'
;;
install)
_arguments \
'(--save-dev)--save-dev' \
'(--save)--save'
;;
new)
_arguments \
'(--blueprint)--blueprint=-' \
'(--directory)--directory=-' \
'(--dry-run)--dry-run' \
'(--skip-bower)--skip-bower' \
'(--skip-git)--skip-git' \
'(--skip-npm)--skip-npm' \
'(--verbose)--verbose'
;;
serve)
_arguments \
'(--port)--port=-[To use a port different than 4200. Pass 0 to automatically pick an available port.]' \
'(--host)--host=-[Listens on all interfaces by default]' \
'(--proxy)--proxy=-' \
'(--secure-proxy)--secure-proxy[Set to false to proxy self-signed SSL certificates]' \
'(--transparent-proxy)--transparent-proxy[Set to false to omit x-forwarded-* headers when proxying]' \
'(--watcher)--watcher=-' \
'(--live-reload)--live-reload' \
'(--live-reload-host)--live-reload-host=-[Defaults to host]' \
'(--live-reload-base-url)--live-reload-base-url=-[Defaults to baseURL]' \
'(--live-reload-port)--live-reload-port=-[Defaults to port number within \[49152...65535\]]' \
'(--environment)--environment=-' \
'(--output-path)--output-path=-' \
'(--ssl)--ssl' \
'(--ssl-key)--ssl-key=-' \
'(--ssl-cert)--ssl-cert=-'
;;
test)
_arguments \
'(--environment)--environment=-' \
'(--config-file)--config-file=-' \
'(--server)--server' \
'(--host)--host=-' \
'(--test-port)--test-port=-[The test port to use when running with --server.]' \
'(--filter)--filter=-[A string to filter tests to run]' \
'(--module)--module=-[The name of a test module to run]' \
'(--watcher)--watcher=-' \
'(--launch)--launch=-[A comma separated list of browsers to launch for tests.]' \
'(--reporter)--reporter=-[Test reporter to use \[tap|dot|xunit\] (default: tap)]' \
'(--silent)--silent[Suppress any output except for the test report]' \
'(--test-page)--test-page=-[Test page to invoke]' \
'(--path)--path=-[Reuse an existing build at given path.]' \
'(--query)--query=-[A query string to append to the test page URL.]'
;;
esac
;;
esac
return ret

View File

@ -1,17 +1,12 @@
# Ember CLI
# Visit https://www.ember-cli.com/ to view user guide
alias es='ember serve'
alias ea='ember addon' alias ea='ember addon'
alias eb='ember build' alias eb='ember build'
alias ed='ember destroy' alias ed='ember destroy'
alias eg='ember generate' alias eg='ember generate'
alias eh='ember help' alias eh='ember help'
alias ein='ember init'
alias ei='ember install' alias ei='ember install'
alias ein='ember init'
alias es='ember serve'
alias et='ember test' alias et='ember test'
alias ets='ember test --serve' alias ets='ember test --serve'
alias eu='ember update' alias eu='ember update'
# version
alias ev='ember version' alias ev='ember version'

View File

@ -10,7 +10,7 @@ This plugin provides support for working with Unicode emoji characters in `zsh`
Variable | Description Variable | Description
----------------- | -------------------------------- ----------------- | --------------------------------
$emoji | Maps emoji names to characters $emoji | Maps emoji names to characters (except flags)
$emoji_flags | Maps country names to flag characters (using region indicators) $emoji_flags | Maps country names to flag characters (using region indicators)
$emoji_groups | Named groups of emoji. Keys are group names; values are whitespace-separated lists of character names $emoji_groups | Named groups of emoji. Keys are group names; values are whitespace-separated lists of character names
@ -55,10 +55,8 @@ The defined group names can be found with `echo ${(k)emoji_groups}`.
To list all available emoji with their names, use: To list all available emoji with their names, use:
``` ```
$> display_emoji $> display_emoji
$> display_emoji fruits
$> display_emoji animals
$> display_emoji vehicles
$> display_emoji faces $> display_emoji faces
$> display_emoji people
``` ```
To use emoji in a prompt: To use emoji in a prompt:
@ -73,13 +71,13 @@ PROMPT="$surfer > "
The emoji names and codes are sourced from Unicode Technical Report \#51, which provides information on emoji support in Unicode. It can be found at https://www.unicode.org/reports/tr51/index.html. The emoji names and codes are sourced from Unicode Technical Report \#51, which provides information on emoji support in Unicode. It can be found at https://www.unicode.org/reports/tr51/index.html.
The group definitions are added by this OMZ plugin. They are not based on external definitions. (As far as I can tell. -apjanke) The group definitions are added by this OMZ plugin. They are not based on external definitions.
The values in the `$emoji*` maps are the emoji characters themselves, not escape sequences or other forms that require interpretation. They can be used in any context and do not require escape sequence support from commands like `echo` or `print`. The values in the `$emoji*` maps are the emoji characters themselves, not escape sequences or other forms that require interpretation. They can be used in any context and do not require escape sequence support from commands like `echo` or `print`.
The emoji in the main `$emoji` map are standalone character sequences which can all be output on their own, without worrying about combining characters. The values may actually be multi-code-point sequences, instead of a single code point, and may include combining characters in those sequences. But they're arranged so their effects do not extend beyond that sequence. The emoji in the main `$emoji` map are standalone character sequences which can all be output on their own, without worrying about combining characters. The values may actually be multi-code-point sequences, instead of a single code point, and may include combining characters in those sequences. But they're arranged so their effects do not extend beyond that sequence.
The exception to this is the skin tone variation selectors. These are included in the main `$emoji` map because they can be displayed on their own, as well as used as combining characters. (If they follow a character that is not one of the emoji characters they combine with, they are displayed as color swatches.) The exception to this is the skin tone / hair style variation selectors. These are included in the main `$emoji` map because they can be displayed on their own, as well as used as combining characters. (If they follow a character that is not one of the emoji characters they combine with, they are displayed as color swatches.)
## Experimental Features ## Experimental Features
@ -90,7 +88,6 @@ Variables:
Variable | Description Variable | Description
----------------- | -------------------------------- ----------------- | --------------------------------
$emoji2 | Auxiliary and combining characters
$emoji_skintone | Skin tone modifiers (from Unicode 8.0) $emoji_skintone | Skin tone modifiers (from Unicode 8.0)
@ -105,31 +102,26 @@ The "variation selectors" are combining characters which change the appearance o
The `$emoji_skintone` associative array maps skin tone IDs to the variation selector characters. To use one, output it immediately following a smiley or other human emoji. The `$emoji_skintone` associative array maps skin tone IDs to the variation selector characters. To use one, output it immediately following a smiley or other human emoji.
``` ```
echo "$emoji[smiling_face_with_open_mouth]$emoji_skintone[4]" echo $emoji[waving_hand]$emoji_skintone[5]
``` ```
Note that `$emoji_skintone` is an associative array, and its keys are the *names* of "Fitzpatrick Skin Type" groups, not linear indexes into a normal array. The names are `1_2`, `3`, `4`, `5`, and `6`. (Types 1 and 2 are combined into a single color.) See the [Diversity section in Unicode TR 51](https://www.unicode.org/reports/tr51/index.html#Diversity) for details. Note that `$emoji_skintone` is an associative array, and its keys are the *names* of "Fitzpatrick Skin Type" groups, not linear indexes into a normal array. The names are `1_2`, `3`, `4`, `5`, and `6`. (Types 1 and 2 are combined into a single color.) See the [Diversity section in Unicode TR 51](https://www.unicode.org/reports/tr51/index.html#Diversity) for details.
#### Gemoji support
The [gemoji project](https://github.com/github/gemoji) seems to be the de facto main source for short names and other emoji-related metadata that isn't included in the official Unicode reports. So, our list of emojis incorporates some of their aliases to make your life more convenient:
```
echo $emoji[grinning_face_with_smiling_eyes]
echo $emoji[smile]
```
These two commands yield the same emoji (😄). The first name is the official one, in the Unicode reference, and the second one is the alias that was in Gemoji's database.
## TODO ## TODO
These are things that could be enhanced in future revisions of the plugin. These are things that could be enhanced in future revisions of the plugin.
* Incorporate CLDR data for ordering and groupings * Incorporate CLDR data for ordering and groupings
* Short :bracket: style names (from gemoji) * Short :bracket: style names (from gemoji)
* Incorporate `gemoji` data
* Country codes for flags
* ZWJ combining function? * ZWJ combining function?
#### Gemoji support
The [gemoji project](https://github.com/github/gemoji) seems to be the de facto main source for short names and other emoji-related metadata that isn't included in the official Unicode reports. (I'm saying this just from looking at the google results for "emoji short names" and related searches. -apjanke)
If this plugin is updated to provide short names, CLDR sorting data, and similar stuff, it should probably be changed to use the Gemoji project, and the `update_emoji.pl` script be rewritten in Ruby so it can use the Gemoji library directly instead of parsing its data files.
This does *not* mean that it should use Gemoji at run time. None of the `zsh` plugin stuff should call Gemoji or Ruby code. Rather, the "build time" `update_emoji.pl` script should be rewritten to use Gemoji to generate a pure-native-`zsh` character definition file which would be checked in to the repo and can be called by OMZ users without having Gemoji installed.
#### ZWJ combining function
One of the newer features of Unicode emoji is the ability to use the "Zero-Width Joiner" character to compose multiple emoji characters in to a single "emoji ligature" glyph. For example, this is [how Apple supports "family" emoji with various genders and skin tones](https://www.unicode.org/reports/tr51/index.html#ZWJ_Sequences).
These are a pain to write out (and probably worse to read), and it might be convenient to have a couple functions for concisely composing them, if wider support for them appears.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,15 +4,17 @@
# #
# See the README for documentation. # See the README for documentation.
# Handle $0 according to the standard:
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}"
_omz_emoji_plugin_dir="${0:h}" _omz_emoji_plugin_dir="${0:h}"
() { () {
local LC_ALL=en_US.UTF-8 local LC_ALL=en_US.UTF-8
typeset -gAH emoji_groups
typeset -gAH emoji_con
typeset -gAH emoji2
typeset -gAH emoji_skintone typeset -gAH emoji_skintone
source "$_omz_emoji_plugin_dir/emoji-char-definitions.zsh" source "$_omz_emoji_plugin_dir/emoji-char-definitions.zsh"
@ -20,12 +22,11 @@ unset _omz_emoji_plugin_dir
# These additional emoji are not in the definition file, but are useful in conjunction with it # These additional emoji are not in the definition file, but are useful in conjunction with it
# This is a combinin character that can be placed after any other character to surround # This is a combining character that can be placed after any other character to surround
# it in a "keycap" symbol. # it in a "keycap" symbol.
# The digits 0-9 are already in the emoji table as keycap_digit_<N>, keycap_ten, etc. # The digits 0-9 are already in the emoji table as keycap_digit_<N>, keycap_ten, etc.
# It's unclear whether this should be in the $emoji array, because those characters are all ones # It's unclear whether this should be in the $emoji array, because those characters are all ones
# which can be displayed on their own. # which can be displayed on their own.
#emoji[combining_enclosing_keycap]="\U20E3"
emoji[regional_indicator_symbol_letter_d_regional_indicator_symbol_letter_e]=$'\xF0\x9F\x87\xA9\xF0\x9F\x87\xAA' emoji[regional_indicator_symbol_letter_d_regional_indicator_symbol_letter_e]=$'\xF0\x9F\x87\xA9\xF0\x9F\x87\xAA'
emoji[regional_indicator_symbol_letter_g_regional_indicator_symbol_letter_b]=$'\xF0\x9F\x87\xAC\xF0\x9F\x87\xA7' emoji[regional_indicator_symbol_letter_g_regional_indicator_symbol_letter_b]=$'\xF0\x9F\x87\xAC\xF0\x9F\x87\xA7'
@ -38,209 +39,12 @@ emoji[regional_indicator_symbol_letter_i_regional_indicator_symbol_letter_t]=$'\
emoji[regional_indicator_symbol_letter_u_regional_indicator_symbol_letter_s]=$'\xF0\x9F\x87\xBA\xF0\x9F\x87\xB8' emoji[regional_indicator_symbol_letter_u_regional_indicator_symbol_letter_s]=$'\xF0\x9F\x87\xBA\xF0\x9F\x87\xB8'
emoji[regional_indicator_symbol_letter_r_regional_indicator_symbol_letter_u]=$'\xF0\x9F\x87\xB7\xF0\x9F\x87\xBA' emoji[regional_indicator_symbol_letter_r_regional_indicator_symbol_letter_u]=$'\xF0\x9F\x87\xB7\xF0\x9F\x87\xBA'
# Nonstandard alias names
emoji[vulcan_salute]=$'\U1F596'
# Emoji combining and auxiliary characters
# "Variation Selectors" for controlling text vs emoji style presentation
# These apply to the immediately preceding character
emoji2[text_style]=$'\UFE0E'
emoji2[emoji_style]=$'\UFE0F'
# Joiner that indicates a single combined-form glyph (ligature) should be used
emoji2[zero_width_joiner]=$'\U200D'
# Skin tone modifiers
emoji2[emoji_modifier_fitzpatrick_type_1_2]=$'\U1F3FB'
emoji2[emoji_modifier_fitzpatrick_type_3]=$'\U1F3FC'
emoji2[emoji_modifier_fitzpatrick_type_4]=$'\U1F3FD'
emoji2[emoji_modifier_fitzpatrick_type_5]=$'\U1F3FE'
emoji2[emoji_modifier_fitzpatrick_type_6]=$'\U1F3FF'
# Various other combining characters. (Incomplete list; I selected ones that sound useful)
emoji2[combining_enclosing_circle]=$'\U20DD'
emoji2[combining_enclosing_square]=$'\U20DE'
emoji2[combining_enclosing_diamond]=$'\U20DF'
emoji2[combining_enclosing_circle_backslash]=$'\U20E0'
emoji2[combining_enclosing_screen]=$'\U20E2'
emoji2[combining_enclosing_keycap]=$'\U20E3'
emoji2[combining_enclosing_upward_pointing_triangle]=$'\U20E4'
# Easier access to skin tone modifiers # Easier access to skin tone modifiers
emoji_skintone[1_2]=$'\U1F3FB' emoji_skintone[1_2]=$'\U1F3FB'
emoji_skintone[3]=$'\U1F3FC' emoji_skintone[3]=$'\U1F3FC'
emoji_skintone[4]=$'\U1F3FD' emoji_skintone[4]=$'\U1F3FD'
emoji_skintone[5]=$'\U1F3FE' emoji_skintone[5]=$'\U1F3FE'
emoji_skintone[6]=$'\U1F3FF' emoji_skintone[6]=$'\U1F3FF'
# Emoji groups
# These are stored in a single associative array, $emoji_groups, to avoid cluttering up the global
# namespace, and to allow adding additional group definitions at run time.
# The keys are the group names, and the values are whitespace-separated lists of emoji character names.
emoji_groups[fruits]="
tomato
aubergine
grapes
melon
watermelon
tangerine
banana
pineapple
red_apple
green_apple
peach
cherries
strawberry
lemon
pear
"
emoji_groups[vehicles]="
airplane
rocket
railway_car
high_speed_train
high_speed_train_with_bullet_nose
bus
ambulance
fire_engine
police_car
taxi
automobile
recreational_vehicle
delivery_truck
ship
speedboat
bicycle
helicopter
steam_locomotive
train
light_rail
tram
oncoming_bus
trolleybus
minibus
oncoming_police_car
oncoming_taxi
oncoming_automobile
articulated_lorry
tractor
monorail
mountain_railway
suspension_railway
mountain_cableway
aerial_tramway
rowboat
bicyclist
mountain_bicyclist
sailboat
"
emoji_groups[animals]="
snail
snake
horse
sheep
monkey
chicken
boar
elephant
octopus
spiral_shell
bug
ant
honeybee
lady_beetle
fish
tropical_fish
blowfish
turtle
hatching_chick
baby_chick
front_facing_baby_chick
bird
penguin
koala
poodle
bactrian_camel
dolphin
mouse_face
cow_face
tiger_face
rabbit_face
cat_face
dragon_face
spouting_whale
horse_face
monkey_face
dog_face
pig_face
frog_face
hamster_face
wolf_face
bear_face
panda_face
rat
mouse
ox
water_buffalo
cow
tiger
leopard
rabbit
cat
dragon
crocodile
whale
ram
goat
rooster
dog
pig
dromedary_camel
"
emoji_groups[faces]="
grinning_face_with_smiling_eyes
face_with_tears_of_joy
smiling_face_with_open_mouth
smiling_face_with_open_mouth_and_smiling_eyes
smiling_face_with_open_mouth_and_cold_sweat
smiling_face_with_open_mouth_and_tightly_closed_eyes
winking_face
smiling_face_with_smiling_eyes
face_savouring_delicious_food
relieved_face
smiling_face_with_heart_shaped_eyes
smirking_face
unamused_face
face_with_cold_sweat
pensive_face
confounded_face
face_throwing_a_kiss
kissing_face_with_closed_eyes
face_with_stuck_out_tongue_and_winking_eye
face_with_stuck_out_tongue_and_tightly_closed_eyes
disappointed_face
angry_face
pouting_face
crying_face
persevering_face
face_with_look_of_triumph
disappointed_but_relieved_face
fearful_face
weary_face
sleepy_face
tired_face
loudly_crying_face
face_with_open_mouth_and_cold_sweat
face_screaming_in_fear
astonished_face
flushed_face
dizzy_face
face_with_medical_mask
"
} }
# Prints a random emoji character # Prints a random emoji character
@ -259,7 +63,11 @@ function random_emoji() {
[[ $list_size -eq 0 ]] && return 1 [[ $list_size -eq 0 ]] && return 1
local random_index=$(( ( RANDOM % $list_size ) + 1 )) local random_index=$(( ( RANDOM % $list_size ) + 1 ))
local name=${names[$random_index]} local name=${names[$random_index]}
if [[ "$group" == "flags" ]]; then
echo ${emoji_flags[$name]}
else
echo ${emoji[$name]} echo ${emoji[$name]}
fi
} }
# Displays a listing of emoji with their names # Displays a listing of emoji with their names
@ -276,12 +84,26 @@ function display_emoji() {
fi fi
# The extra spaces in output here are a hack for readability, since some # The extra spaces in output here are a hack for readability, since some
# terminals treat these emoji chars as single-width. # terminals treat these emoji chars as single-width.
local counter=1
for i in $names; do for i in $names; do
if [[ "$group" == "flags" ]]; then
printf '%s ' "$emoji_flags[$i]"
else
printf '%s ' "$emoji[$i]" printf '%s ' "$emoji[$i]"
fi
# New line every 20 emoji, to avoid weirdnesses
if (($counter % 20 == 0)); then
printf "\n"
fi
let counter=$counter+1
done done
print print
for i in $names; do for i in $names; do
if [[ "$group" == "flags" ]]; then
echo "${emoji_flags[$i]} = $i"
else
echo "${emoji[$i]} = $i" echo "${emoji[$i]} = $i"
fi
done done
} }

File diff suppressed because it is too large Load Diff

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