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/gitfast/ @felipec
plugins/sdk/ @rgoldberg
plugins/shell-proxy/ @septs
plugins/universalarchive/ @Konfekt
plugins/wp-cli/ @joshmedeski
plugins/zoxide/ @ajeetdsouza

View File

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

View File

@ -1,12 +1,11 @@
name: Bug report
description: Create a report to help us improve Oh My Zsh
labels: 'Bug'
name: Report a bug
description: Report a bug that isn't caused by Oh My Zsh. If unsure, use this form
body:
- type: markdown
attributes:
value: |
## 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.
- type: textarea
validations:
@ -41,21 +40,21 @@ body:
validations:
required: true
attributes:
label: OS / Distro
placeholder: e.g. Windows 10, Ubuntu 20.04, Arch Linux, macOS 10.15...
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: e.g. 5.6
placeholder: "5.6"
- type: input
validations:
required: true
attributes:
label: Terminal emulator
placeholder: e.g. iTerm2, Gnome Terminal...
placeholder: iTerm2, GNOME Terminal, Terminal.app...
- type: dropdown
attributes:
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
description: Suggest a feature for Oh My Zsh
labels: 'Feature'
labels: ["Feature"]
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
attributes:
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:
name: Run tests
runs-on: ${{ matrix.os }}
if: github.repository == 'ohmyzsh/ohmyzsh'
strategy:
matrix:
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)
```
- 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:
```
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)
[![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)
[![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
@ -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)"` |
| **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
It's a good idea to inspect the install script from projects you don't yet know. You can do
that by downloading the install script first, looking through it so everything looks normal,
then running it:
```shell
```sh
wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/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.
```shell
```sh
vi ~/.zshrc
```
For example, this might begin to look like this:
```shell
```sh
plugins=(
git
bundler
dotenv
osx
macos
rake
rbenv
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:
```shell
```sh
ZSH_THEME="robbyrussell"
```
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)
# 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.
```shell
```sh
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:
```shell
```sh
ZSH_THEME_RANDOM_CANDIDATES=(
"robbyrussell"
"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:
```shell
```sh
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
like this:
```shell
```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
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
```
@ -185,7 +188,7 @@ The install script also accepts these variables to allow installation of a diffe
For example:
```shell
```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
```shell
```sh
git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
```
##### 2. *Optionally*, backup your existing `~/.zshrc` file
```shell
```sh
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.
```shell
```sh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
```
##### 4. Change your default shell
```shell
```sh
chsh -s $(which zsh)
```
@ -242,23 +245,40 @@ If you would like to override the functionality of a plugin distributed with Oh
## 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
DISABLE_UPDATE_PROMPT=true
```
1. Automatic update without confirmation prompt:
To disable automatic upgrades, set the following in your `~/.zshrc`:
```sh
zstyle ':omz:update' mode auto
```
```shell
DISABLE_AUTO_UPDATE=true
2. Just offer a reminder every few days, if there are updates available:
```sh
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
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
```

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'
'plugin:Manage plugins'
'pr:Manage Oh My Zsh Pull Requests'
'reload:Reload the current zsh session'
'theme:Manage themes'
'update:Update Oh My Zsh'
'version:Show the version'
)
if (( CURRENT == 2 )); then
@ -35,7 +37,7 @@ function _omz {
elif (( CURRENT == 3 )); then
case "$words[2]" in
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 ;;
plugin) subcmds=(
'disable:Disable plugin(s)'
@ -59,17 +61,19 @@ function _omz {
# if command is "disable", only offer already enabled plugins
valid_plugins=($plugins)
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
[[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins})
fi
_describe 'plugin' valid_plugins ;;
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 ;;
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 ;;
esac
elif (( CURRENT > 4 )); then
@ -81,7 +85,7 @@ function _omz {
# if command is "disable", only offer already enabled plugins
valid_plugins=($plugins)
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
[[ "${words[3]}" = enable ]] && valid_plugins=(${valid_plugins:|plugins})
fi
@ -90,7 +94,8 @@ function _omz {
# 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
# 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})
_describe 'plugin' valid_plugins ;;
@ -159,8 +164,10 @@ Available commands:
changelog Print the changelog
plugin <command> Manage plugins
pr <command> Manage Oh My Zsh Pull Requests
reload Reload the current zsh session
theme <command> Manage themes
update Update Oh My Zsh
version Show the version
EOF
}
@ -168,11 +175,14 @@ EOF
function _omz::changelog {
local version=${1:-HEAD} format=${3:-"--text"}
if ! command git -C "$ZSH" show-ref --verify refs/heads/$version &>/dev/null && \
! command git -C "$ZSH" show-ref --verify refs/tags/$version &>/dev/null && \
! command git -C "$ZSH" rev-parse --verify "${version}^{commit}" &>/dev/null; then
if (
builtin cd -q "$ZSH"
! 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
Usage: omz changelog [version]
Usage: ${(j: :)${(s.::.)0#_}} [version]
NOTE: <version> must be a valid branch, tag or commit.
EOF
@ -183,9 +193,9 @@ EOF
}
function _omz::plugin {
(( $# > 0 && $+functions[_omz::plugin::$1] )) || {
(( $# > 0 && $+functions[$0::$1] )) || {
cat >&2 <<EOF
Usage: omz plugin <command> [options]
Usage: ${(j: :)${(s.::.)0#_}} <command> [options]
Available commands:
@ -202,17 +212,17 @@ EOF
local command="$1"
shift
_omz::plugin::$command "$@"
$0::$command "$@"
}
function _omz::plugin::disable {
if [[ -z "$1" ]]; then
echo >&2 "Usage: omz plugin disable <plugin> [...]"
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin> [...]"
return 1
fi
# Check that plugin is in $plugins
local -a dis_plugins=()
local -a dis_plugins
for plugin in "$@"; do
if [[ ${plugins[(Ie)$plugin]} -eq 0 ]]; then
_omz::log warn "plugin '$plugin' is not enabled."
@ -266,9 +276,10 @@ multi == 1 && length(\$0) > 0 {
{ print \$0 }
"
awk "$awk_script" ~/.zshrc > ~/.zshrc.new \
&& command mv -f ~/.zshrc ~/.zshrc.bck \
&& command mv -f ~/.zshrc.new ~/.zshrc
local zdot="${ZDOTDIR:-$HOME}"
awk "$awk_script" "$zdot/.zshrc" > "$zdot/.zshrc.new" \
&& 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
[[ $? -eq 0 ]] || {
@ -278,10 +289,10 @@ multi == 1 && length(\$0) > 0 {
}
# Exit if the new .zshrc file has syntax errors
if ! zsh -n ~/.zshrc; then
_omz::log error "broken syntax in ~/.zshrc. Rolling back changes..."
command mv -f ~/.zshrc ~/.zshrc.new
command mv -f ~/.zshrc.bck ~/.zshrc
if ! command zsh -n "$zdot/.zshrc"; then
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
return 1
fi
@ -296,12 +307,12 @@ multi == 1 && length(\$0) > 0 {
function _omz::plugin::enable {
if [[ -z "$1" ]]; then
echo >&2 "Usage: omz plugin enable <plugin> [...]"
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin> [...]"
return 1
fi
# Check that plugin is not in $plugins
local -a add_plugins=()
local -a add_plugins
for plugin in "$@"; do
if [[ ${plugins[(Ie)$plugin]} -ne 0 ]]; then
_omz::log warn "plugin '$plugin' is already enabled."
@ -341,9 +352,10 @@ multi == 1 && /^[^#]*\)/ {
{ print \$0 }
"
awk "$awk_script" ~/.zshrc > ~/.zshrc.new \
&& command mv -f ~/.zshrc ~/.zshrc.bck \
&& command mv -f ~/.zshrc.new ~/.zshrc
local zdot="${ZDOTDIR:-$HOME}"
awk "$awk_script" "$zdot/.zshrc" > "$zdot/.zshrc.new" \
&& 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
[[ $? -eq 0 ]] || {
@ -353,10 +365,10 @@ multi == 1 && /^[^#]*\)/ {
}
# Exit if the new .zshrc file has syntax errors
if ! zsh -n ~/.zshrc; then
_omz::log error "broken syntax in ~/.zshrc. Rolling back changes..."
command mv -f ~/.zshrc ~/.zshrc.new
command mv -f ~/.zshrc.bck ~/.zshrc
if ! command zsh -n "$zdot/.zshrc"; then
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
return 1
fi
@ -371,7 +383,7 @@ multi == 1 && /^[^#]*\)/ {
function _omz::plugin::info {
if [[ -z "$1" ]]; then
echo >&2 "Usage: omz plugin info <plugin>"
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin>"
return 1
fi
@ -418,14 +430,12 @@ function _omz::plugin::list {
function _omz::plugin::load {
if [[ -z "$1" ]]; then
echo >&2 "Usage: omz plugin load <plugin> [...]"
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin> [...]"
return 1
fi
local plugins=("$@")
local plugin base has_completion=0
for plugin in $plugins; do
for plugin in "$@"; do
if [[ -d "$ZSH_CUSTOM/plugins/$plugin" ]]; then
base="$ZSH_CUSTOM/plugins/$plugin"
elif [[ -d "$ZSH/plugins/$plugin" ]]; then
@ -445,9 +455,9 @@ function _omz::plugin::load {
fi
# Check if it has completion to reload compinit
if [[ -f "$base/_$plugin" ]]; then
has_completion=1
fi
local -a comp_files
comp_files=($base/_*(N))
has_completion=$(( $#comp_files > 0 ))
# Load the plugin
if [[ -f "$base/$plugin.plugin.zsh" ]]; then
@ -467,9 +477,9 @@ function _omz::plugin::load {
}
function _omz::pr {
(( $# > 0 && $+functions[_omz::pr::$1] )) || {
(( $# > 0 && $+functions[$0::$1] )) || {
cat >&2 <<EOF
Usage: omz pr <command> [options]
Usage: ${(j: :)${(s.::.)0#_}} <command> [options]
Available commands:
@ -483,7 +493,7 @@ EOF
local command="$1"
shift
_omz::pr::$command "$@"
$0::$command "$@"
}
function _omz::pr::clean {
@ -524,7 +534,7 @@ function _omz::pr::test {
# Check the input
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
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 {
(( $# > 0 && $+functions[_omz::theme::$1] )) || {
(( $# > 0 && $+functions[$0::$1] )) || {
cat >&2 <<EOF
Usage: omz theme <command> [options]
Usage: ${(j: :)${(s.::.)0#_}} <command> [options]
Available commands:
@ -616,7 +636,7 @@ EOF
local command="$1"
shift
_omz::theme::$command "$@"
$0::$command "$@"
}
function _omz::theme::list {
@ -630,22 +650,28 @@ function _omz::theme::list {
return
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
print -P "%U%BCustom themes%b%u:"
print -l ${(q-)custom_themes} | column -x
echo
fi
if (( ${#builtin_themes} )); then
(( ${#custom_themes} )) && echo # add a line of separation
print -P "%U%BBuilt-in themes%b%u:"
print -l ${(q-)builtin_themes} | column -x
fi
# Print built-in themes
print -P "%U%BBuilt-in themes%b%u:"
print -l ${(q-)builtin_themes} | column -x
}
function _omz::theme::set {
if [[ -z "$1" ]]; then
echo >&2 "Usage: omz theme set <theme>"
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <theme>"
return 1
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
cat <<EOF
ZSH_THEME="$1" # set by \`omz\`
EOF
cat ~/.zshrc
} > ~/.zshrc.new \
&& command mv -f ~/.zshrc ~/.zshrc.bck \
&& command mv -f ~/.zshrc.new ~/.zshrc
cat "$zdot/.zshrc"
} > "$zdot/.zshrc.new" \
&& 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
[[ $? -eq 0 ]] || {
@ -694,10 +721,10 @@ EOF
}
# Exit if the new .zshrc file has syntax errors
if ! zsh -n ~/.zshrc; then
_omz::log error "broken syntax in ~/.zshrc. Rolling back changes..."
command mv -f ~/.zshrc ~/.zshrc.new
command mv -f ~/.zshrc.bck ~/.zshrc
if ! command zsh -n "$zdot/.zshrc"; then
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
return 1
fi
@ -712,7 +739,7 @@ EOF
function _omz::theme::use {
if [[ -z "$1" ]]; then
echo >&2 "Usage: omz theme use <theme>"
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <theme>"
return 1
fi
@ -727,16 +754,20 @@ function _omz::theme::use {
_omz::log error "%B$1%b theme not found"
return 1
fi
# Update theme settings
ZSH_THEME="$1"
[[ $1 = random ]] || unset RANDOM_THEME
}
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
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
ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh"
ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" || return $?
fi
# Update last updated file
@ -746,10 +777,32 @@ function _omz::update {
command rm -rf "$ZSH/log/update.lock"
# 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
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
# Check whether to run a login shell
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
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 mysql='nocorrect mysql'
alias sudo='nocorrect sudo'
alias su='nocorrect su'
setopt correct_all
fi

View File

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

View File

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

View File

@ -1,7 +1,7 @@
function zsh_stats() {
fc -l 1 \
| 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() {
@ -45,7 +45,7 @@ function takeurl() {
data="$(mktemp)"
curl -L "$1" > "$data"
tar xf "$data"
thedir="$(tar tf "$data" | head -1)"
thedir="$(tar tf "$data" | head -n 1)"
rm "$data"
cd "$thedir"
}
@ -237,12 +237,11 @@ function omz_urldecode {
tmp=${tmp:gs/\\/\\\\/}
# Handle %-escapes by turning them into `\xXX` printf escapes
tmp=${tmp:gs/%/\\x/}
local decoded
eval "decoded=\$'$tmp'"
local decoded="$(printf -- "$tmp")"
# 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.
local safe_encodings
local -a safe_encodings
safe_encodings=(UTF-8 utf8 US-ASCII)
if [[ -z ${safe_encodings[(r)$caller_encoding]} ]]; then
decoded=$(echo -E "$decoded" | iconv -f UTF-8 -t $caller_encoding)

View File

@ -29,7 +29,7 @@ function git_prompt_info() {
&& upstream=" -> ${upstream}"
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
@ -51,7 +51,7 @@ function parse_git_dirty() {
FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}"
;;
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
if [[ -n $STATUS ]]; then
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
@ -82,7 +82,7 @@ function git_remote_status() {
fi
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
echo $git_remote_status
@ -206,7 +206,8 @@ function git_prompt_status() {
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
if [[ $? -eq 128 ]]; then

View File

@ -2,5 +2,5 @@
function nvm_prompt_info() {
which nvm &>/dev/null || return
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
rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${=ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null)
[[ -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"

View File

@ -20,16 +20,18 @@ done
# Show all 256 colors with color number
function spectrum_ls() {
setopt localoptions nopromptsubst
local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
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
}
# Show all 256 colors where the background is set to specific color
function spectrum_bls() {
setopt localoptions nopromptsubst
local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
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
}

View File

@ -7,10 +7,10 @@
# (In screen, only short_tab_title is used)
# Limited support for Apple Terminal (Terminal can't set window and tab separately)
function title {
emulate -L zsh
setopt prompt_subst
setopt localoptions nopromptsubst
[[ "$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 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]1;${1:q}\a" # set tab name
else
# Try to use terminfo to set the title
# If the feature is available set title
if [[ -n "$terminfo[fsl]" ]] && [[ -n "$terminfo[tsl]" ]]; then
echoti tsl
print -Pn "$1"
echoti fsl
# Try to use terminfo to set the title if the feature is available
if (( ${+terminfo[fsl]} && ${+terminfo[tsl]} )); then
print -Pn "${terminfo[tsl]}$1${terminfo[fsl]}"
fi
fi
;;
@ -50,13 +47,13 @@ fi
# Runs before showing the prompt
function omz_termsupport_precmd {
[[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return
title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
[[ "${DISABLE_AUTO_TITLE:-}" != true ]] || return
title "$ZSH_THEME_TERM_TAB_TITLE_IDLE" "$ZSH_THEME_TERM_TITLE_IDLE"
}
# Runs before executing the command
function omz_termsupport_preexec {
[[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return
[[ "${DISABLE_AUTO_TITLE:-}" != true ]] || return
emulate -L zsh
setopt extended_glob
@ -99,16 +96,18 @@ function omz_termsupport_preexec {
fi
# 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/%/%%}"
title '$CMD' '%100>...>$LINE%<<'
title "$CMD" "%100>...>${LINE}%<<"
}
autoload -U add-zsh-hook
add-zsh-hook precmd omz_termsupport_precmd
add-zsh-hook preexec omz_termsupport_preexec
autoload -Uz add-zsh-hook
if [[ -z "$INSIDE_EMACS" || "$INSIDE_EMACS" = vterm ]]; then
add-zsh-hook precmd omz_termsupport_precmd
add-zsh-hook preexec omz_termsupport_preexec
fi
# Keep Apple Terminal.app's current working directory updated
# Based on this answer: https://superuser.com/a/315029

View File

@ -40,7 +40,7 @@ if [[ "$DISABLE_LS_COLORS" != "true" ]]; then
fi
# 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'
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.
[[ -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)
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.
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:
```
plugins=(aliases)
```
```zsh
plugins=(aliases)
```
Requirements: Python needs to be installed.
### Usage
## Usage
```
acs: group all alias
acs $keywordquickly filter alias & highlight
```
- `acs`: show all aliases by group.
- `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
# group alias by command, pass addition argv to grep.
ALIASES_PLUGIN_ROOT=$(cd `dirname $0` && pwd)
function acs(){
which python >>/dev/null
[[ $? -eq 1 ]] && echo "[error]no python executable detected!" && return
alias | python $ALIASES_PLUGIN_ROOT/cheatsheet.py $@
(( $+commands[python] )) || {
echo "[error] No python executable detected"
return
}
alias | python ${functions_source[$0]:h}/cheatsheet.py $@
}

View File

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

View File

@ -21,7 +21,7 @@
#
# 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
import os

View File

@ -2,9 +2,9 @@
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)
```

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 () {
[ ! -f .ant_targets ] && return 0;
[ 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
# Default to colored output
export ANT_ARGS='-logger org.apache.tools.ant.listener.AnsiColorLogger'

View File

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

View File

@ -5,6 +5,7 @@
alias ara='arc amend'
alias arb='arc branch'
alias arbl='arc bland'
alias arco='arc cover'
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 arh='arc help'
alias arho='arc hotfix'
alias arl='arc land'
alias arli='arc lint'
alias arls='arc list'

View File

@ -17,8 +17,10 @@ plugins=(... archlinux)
| pacin | `sudo pacman -S` | Install packages from the repositories |
| pacins | `sudo pacman -U` | Install a package from a local file |
| 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 |
| 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 |
| pacmir | `sudo pacman -Syy` | Force refresh of all package lists after updating mirrorlist |
| 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 |
| pacls | `pacman -Ql` | List files in a package |
| 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 |
|----------------|-----------------------------------------------------------|
@ -52,6 +54,8 @@ upgrades were available. Use `pacman -Que` instead.
| 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 |
| aurin | `sudo aura -A` | Install packages from the repositories |
| 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 |
| 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 |
| upgrade[²](#f2) | `sudo aura -Syu` | Sync with repositories before upgrading packages |
| upgrade[¹](#f1) | `sudo aura -Syu` | Sync with repositories before upgrading packages |
| Function | Description |
|-----------------|---------------------------------------------------------------------|
@ -84,6 +88,8 @@ upgrades were available. Use `pacman -Que` instead.
| 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 |
| pains | `pacaur -U` | Install a package from a local file |
| 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 |
| paupg | `pacaur -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
| 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
| Alias | Command | Description |
|---------|-----------------------------------|---------------------------------------------------------------------|
| 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 |
| trins | `trizen -U` | Install a package from a local file |
| 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 |
| trupg | `trizen -Syua` | Sync with repositories before upgrading all packages (from AUR too) |
| 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)
| 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)
#### Yay
| Alias | Command | Description |
|---------|--------------------------------|-------------------------------------------------------------------|
| 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 |
| yains | `yay -U` | Install a package from a local file |
| 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 |
| yaupg | `yay -Syu` | Sync with repositories before upgrading packages |
| 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>
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
whether the package manager is installed, checked in the following order:
1. `yay`
2. `yaourt`
3. `trizen`
4. `pacaur`
5. `aura`
6. `pacman`
2. `trizen`
3. `pacaur`
4. `aura`
5. `pacman`
## Contributors
@ -196,3 +180,4 @@ whether the package manager is installed, checked in the following order:
- ornicar - thibault.duplessis@gmail.com
- Ybalrid (Arthur Brainville) - ybalrid@ybalrid.info
- 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
alias pacupg='sudo pacman -Syu'
alias pacin='sudo pacman -S'
alias paclean='sudo pacman -Sc'
alias pacins='sudo pacman -U'
alias paclr='sudo pacman -Scc'
alias pacre='sudo pacman -R'
alias pacrem='sudo pacman -Rns'
alias pacrep='pacman -Si'
@ -88,6 +90,8 @@ fi
if (( $+commands[aura] )); then
alias auin='sudo aura -S'
alias aurin='sudo aura -A'
alias auclean='sudo aura -Sc'
alias auclr='sudo aura -Scc'
alias auins='sudo aura -U'
alias auinsd='sudo aura -S --asdeps'
alias aurinsd='sudo aura -A --asdeps'
@ -104,7 +108,7 @@ if (( $+commands[aura] )); then
alias auras='aura -As --both'
alias auupd="sudo aura -Sy"
alias auupg='sudo sh -c "aura -Syu && aura -Au"'
alias ausu='sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"'
alias ausu='sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"'
alias upgrade='sudo aura -Syu'
# extra bonus specially for aura
@ -115,6 +119,8 @@ if (( $+commands[aura] )); then
fi
if (( $+commands[pacaur] )); then
alias pacclean='pacaur -Sc'
alias pacclr='pacaur -Scc'
alias paupg='pacaur -Syu'
alias pasu='pacaur -Syu --noconfirm'
alias pain='pacaur -S'
@ -138,6 +144,8 @@ if (( $+commands[trizen] )); then
alias trupg='trizen -Syua'
alias trsu='trizen -Syua --noconfirm'
alias trin='trizen -S'
alias trclean='trizen -Sc'
alias trclr='trizen -Scc'
alias trins='trizen -U'
alias trre='trizen -R'
alias trrem='trizen -Rns'
@ -153,28 +161,10 @@ if (( $+commands[trizen] )); then
alias upgrade='trizen -Syu'
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
alias yaconf='yay -Pg'
alias yaclean='yay -Sc'
alias yaclr='yay -Scc'
alias yaupg='yay -Syu'
alias yasu='yay -Syu --noconfirm'
alias yain='yay -S'
@ -192,4 +182,3 @@ if (( $+commands[yay] )); then
alias yaupd="yay -Sy"
alias upgrade='yay -Syu'
fi

View File

@ -2,18 +2,26 @@
ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
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 [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/asdf.bash" ]] && (( $+commands[brew] )); then
ASDF_DIR="$(brew --prefix asdf)"
ASDF_COMPLETIONS="$ASDF_DIR/etc/bash_completion.d"
brew_prefix="$(brew --prefix asdf)"
ASDF_DIR="${brew_prefix}/libexec"
ASDF_COMPLETIONS="${brew_prefix}/etc/bash_completion.d"
unset brew_prefix
fi
# Load command
if [[ -f "$ASDF_DIR/asdf.sh" ]]; then
. "$ASDF_DIR/asdf.sh"
. "$ASDF_DIR/asdf.sh"
# Load completions
if [[ -f "$ASDF_COMPLETIONS/asdf.bash" ]]; then
. "$ASDF_COMPLETIONS/asdf.bash"
fi
# Load completions
if [[ -f "$ASDF_COMPLETIONS/asdf.bash" ]]; then
. "$ASDF_COMPLETIONS/asdf.bash"
fi
fi

View File

@ -8,6 +8,7 @@ autojump_paths=(
/etc/profile.d/autojump.zsh # manual installation
/etc/profile.d/autojump.sh # Gentoo 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
/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)

View File

@ -14,11 +14,12 @@ plugins=(... aws)
* `asp [<profile>]`: sets `$AWS_PROFILE` and `$AWS_DEFAULT_PROFILE` (legacy) to `<profile>`.
It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI.
Run `asp` without arguments to clear the profile.
* `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
assuming the role specified in the `<profile>` configuration. It supports MFA and sets
`$AWS_ACCESS_KEY_ID`, `$AWS_SECRET_ACCESS_KEY` and `$AWS_SESSION_TOKEN`, if obtained. It
requires the roles to be configured as per the
* `acp [<profile>] [<mfa_token>]`: in addition to `asp` functionality, it actually changes
the profile by assuming the role specified in the `<profile>` configuration. It supports
MFA and sets `$AWS_ACCESS_KEY_ID`, `$AWS_SECRET_ACCESS_KEY` and `$AWS_SESSION_TOKEN`, if
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).
Run `acp` without arguments to clear the profile.

View File

@ -21,6 +21,10 @@ function asp() {
export AWS_DEFAULT_PROFILE=$1
export AWS_PROFILE=$1
export AWS_EB_PROFILE=$1
if [[ "$2" == "login" ]]; then
aws sso login
fi
}
# AWS profile switch
@ -41,6 +45,7 @@ function acp() {
fi
local profile="$1"
local mfa_token="$2"
# 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)"
@ -54,9 +59,10 @@ function acp() {
if [[ -n "$mfa_serial" ]]; then
local -a mfa_opt
local mfa_token
echo -n "Please enter your MFA token for $mfa_serial: "
read -r mfa_token
if [[ -z "$mfa_token" ]]; then
echo -n "Please enter your MFA token for $mfa_serial: "
read -r mfa_token
fi
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): "
read -r sess_duration
@ -151,8 +157,8 @@ compctl -K _aws_profiles asp acp aws_change_access_key
# AWS prompt
function aws_prompt_info() {
[[ -z $AWS_PROFILE ]] && return
echo "${ZSH_THEME_AWS_PREFIX:=<aws:}${AWS_PROFILE}${ZSH_THEME_AWS_SUFFIX:=>}"
[[ -n "$AWS_PROFILE" ]] || return
echo "${ZSH_THEME_AWS_PREFIX:=<aws:}${AWS_PROFILE:gs/%/%%}${ZSH_THEME_AWS_SUFFIX:=>}"
}
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:
```
```zsh
RPROMPT='$(battery_pct_prompt) ...'
```
## 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:
```
sudo apt-get install acpi
```
- On Android (via [Termux](https://play.google.com/store/apps/details?id=com.termux)), you must have:
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) #
# Modified to add support for FreeBSD #
###########################################
# Author: Avneet Singh (kalsi-avneet) #
# Modified to add support for Android #
###########################################
if [[ "$OSTYPE" = darwin* ]]; then
function battery_is_charging() {
ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ Yes'
}
function battery_pct() {
pmset -g batt | grep -Eo "\d+%" | cut -d% -f1
}
function battery_pct_remaining() {
if battery_is_charging; then
echo "External Power"
@ -28,7 +28,6 @@ if [[ "$OSTYPE" = darwin* ]]; then
battery_pct
fi
}
function battery_time_remaining() {
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
if [[ $(echo $smart_battery_status | command grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]]; then
@ -42,7 +41,6 @@ if [[ "$OSTYPE" = darwin* ]]; then
echo "∞"
fi
}
function battery_pct_prompt () {
local battery_pct color
if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then
@ -61,17 +59,14 @@ if [[ "$OSTYPE" = darwin* ]]; then
}
elif [[ "$OSTYPE" = freebsd* ]]; then
function battery_is_charging() {
[[ $(sysctl -n hw.acpi.battery.state) -eq 2 ]]
}
function battery_pct() {
if (( $+commands[sysctl] )); then
sysctl -n hw.acpi.battery.life
fi
}
function battery_pct_remaining() {
if ! battery_is_charging; then
battery_pct
@ -79,7 +74,6 @@ elif [[ "$OSTYPE" = freebsd* ]]; then
echo "External Power"
fi
}
function battery_time_remaining() {
local remaining_time
remaining_time=$(sysctl -n hw.acpi.battery.time)
@ -89,7 +83,6 @@ elif [[ "$OSTYPE" = freebsd* ]]; then
printf %02d:%02d $hour $minute
fi
}
function battery_pct_prompt() {
local battery_pct color
battery_pct=$(battery_pct_remaining)
@ -106,19 +99,22 @@ elif [[ "$OSTYPE" = freebsd* ]]; then
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi
}
elif [[ "$OSTYPE" = linux* ]]; then
elif [[ "$OSTYPE" = linux-android ]] && (( ${+commands[termux-battery-status]} )); then
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() {
if (( $+commands[acpi] )); then
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
# Sample output:
# {
# "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() {
if ! battery_is_charging; then
battery_pct
@ -126,13 +122,72 @@ elif [[ "$OSTYPE" = linux* ]]; then
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_time_remaining() { } # Not available on android
function battery_pct_prompt() {
local battery_pct color
battery_pct=$(battery_pct_remaining)
if battery_is_charging; then
echo "∞"
else
if [[ $battery_pct -gt 50 ]]; then
color='green'
elif [[ $battery_pct -gt 20 ]]; then
color='yellow'
else
color='red'
fi
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi
}
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() {
local battery_pct color
battery_pct=$(battery_pct_remaining)
@ -149,7 +204,6 @@ elif [[ "$OSTYPE" = linux* ]]; then
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi
}
else
# Empty functions so we don't cause errors in prompts
function battery_is_charging { false }
@ -174,7 +228,7 @@ function battery_level_gauge() {
local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow}
local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'}
local battery_remaining_percentage=$(battery_pct)
local -i battery_remaining_percentage=$(battery_pct)
local filled empty gauge_color
if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then

View File

@ -164,7 +164,7 @@ _get_build_targets() {
;;
esac
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)
fi
echo ${completions[*]}

View File

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

View File

@ -9,7 +9,7 @@ _bower_installed_packages () {
}
_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
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]')
_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]')
@ -54,7 +54,7 @@ _bower ()
_arguments \
$_dopts \
$_save_dev \
$_force_lastest \
$_force_latest \
$_no_color \
$_production
;;
@ -62,7 +62,7 @@ _bower ()
_arguments \
$_dopts \
$_no_color \
$_force_lastest
$_force_latest
_bower_installed_packages
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
### Mercurial
- `hg branch`:
```shell
$ time hg branch
0.11s user 0.14s system 70% cpu 0.355 total
```
```console
$ time hg branch
0.11s user 0.14s system 70% cpu 0.355 total
```
### Branch plugin
- branch plugin:
```shell
$ time zsh /tmp/branch_prompt_info_test.zsh
0.00s user 0.01s system 78% cpu 0.014 total
```
```console
$ time zsh /tmp/branch_prompt_info_test.zsh
0.00s user 0.01s system 78% cpu 0.014 total
```
## Usage
Edit your theme file (eg.: `~/.oh-my-zsh/theme/robbyrussell.zsh-theme`)
adding `$(branch_prompt_info)` in your prompt like this:
Copy your theme to `$ZSH_CUSTOM/themes/` and modify it to add `$(branch_prompt_info)` in your prompt.
This example is for the `robbyrussell` theme:
```diff
- PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
+ PROMPT='${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)$(branch_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
diff --git a/themes/robbyrussell.zsh-theme b/themes/robbyrussell.zsh-theme
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

View File

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

View File

@ -1,5 +1,4 @@
alias brewp='brew pin'
alias brews='brew list -1'
alias brewsp='brew list --pinned'
alias bubo='brew update && brew outdated'
alias bubc='brew upgrade && brew cleanup'
@ -7,3 +6,16 @@ alias bubu='bubo && bubc'
alias buf='brew upgrade --formula'
alias bcubo='brew update && brew outdated --cask'
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]" \
"list[Show all of the gems in the current 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]" \
"console[Start an IRB session in the context of the current bundle]" \
"open[Open an installed gem in the editor]" \
@ -84,7 +85,7 @@ case $state in
'(--verbose)--verbose[Enable verbose output mode]'
ret=0
;;
(open|show)
(open|show|info)
_gems=( $(bundle show 2> /dev/null | sed -e '/^ \*/!d; s/^ \* \([^ ]*\) .*/\1/') )
if [[ $_gems != "" ]]; then
_values 'gems' $_gems && ret=0

View File

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

View File

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

View File

@ -1,23 +1,15 @@
if (( $+commands[rustup] && $+commands[cargo] )); then
# remove old generated completion file
command rm -f "${0:A:h}/_cargo"
print ${(%):-'%F{yellow}The `cargo` plugin is deprecated and has been moved to the `rust` plugin.'}
print ${(%):-'Please update your .zshrc to use the `%Brust%b` plugin instead.%f'}
# generate new completion file
ver="$(cargo --version)"
ver_file="$ZSH_CACHE_DIR/cargo_version"
comp_file="$ZSH_CACHE_DIR/completions/_cargo"
# 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 completion file
command rm -f "${0:A:h}/_cargo" "$ZSH_CACHE_DIR/cargo_version"
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
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
(( ${fpath[(Ie)$ZSH/plugins/rust]} )) || {
fpath=("$ZSH/plugins/rust" $fpath)
source "$ZSH/plugins/rust/rust.plugin.zsh"
}

View File

@ -2,7 +2,7 @@
# catimg script by Eduardo San Martin Morote aka Posva #
# 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. #
# GitHub: https://github.com/posva/catimg #
################################################################################

View File

@ -2,7 +2,7 @@
# catimg script by Eduardo San Martin Morote aka Posva #
# 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. #
# 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.
To use it, add `chruby` to the plugins array in your zshrc file:
```zsh
plugins=(... chruby)
```
@ -14,7 +15,7 @@ plugins=(... chruby)
If you'd prefer to specify an explicit path to load chruby from
you can set variables like so:
```
```zsh
zstyle :omz:plugins:chruby path /local/path/to/chruby.sh
zstyle :omz:plugins:chruby auto /local/path/to/auto.sh
```

View File

@ -1,121 +1,94 @@
#
# 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
## load chruby from different locations
_source-from-omz-settings() {
local _chruby_path _chruby_auto
zstyle -s :omz:plugins:chruby path _chruby_path || return 1
zstyle -s :omz:plugins:chruby auto _chruby_auto || return 1
if [[ -r ${_chruby_path} ]]; then
source ${_chruby_path}
fi
if [[ -r ${_chruby_auto} ]]; then
source ${_chruby_auto}
fi
}
_source-from-homebrew() {
(( $+commands[brew] )) || return 1
local _brew_prefix
# 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
done
}
# Load chruby
if _source-from-omz-settings; then
_load-chruby-dirs
elif [[ -r "/usr/local/share/chruby/chruby.sh" ]] ; then
source /usr/local/share/chruby/chruby.sh
source /usr/local/share/chruby/auto.sh
_load-chruby-dirs
elif _source-from-homebrew; then
_load-chruby-dirs
fi
unfunction _source-from-homebrew _source-from-omz-settings _load-chruby-dirs
## chruby utility functions and aliases
# rvm and rbenv plugins also provide this alias
alias rubies='chruby'
_homebrew-installed() {
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
source ${_chruby_path}
fi
if [[ -r ${_chruby_auto} ]]; then
source ${_chruby_auto}
fi
}
_chruby_dirs() {
chrubydirs=($HOME/.rubies/ $PREFIX/opt/rubies)
for dir in chrubydirs; do
if [[ -d $dir ]]; then
RUBIES+=$dir
fi
done
}
if _homebrew-installed && _chruby-from-homebrew-installed ; then
source $_brew_prefix/share/chruby/chruby.sh
source $_brew_prefix/share/chruby/auto.sh
_chruby_dirs
elif [[ -r "/usr/local/share/chruby/chruby.sh" ]] ; then
source /usr/local/share/chruby/chruby.sh
source /usr/local/share/chruby/auto.sh
_chruby_dirs
else
_source_from_omz_settings
_chruby_dirs
fi
function ensure_chruby() {
$(whence chruby)
}
function current_ruby() {
local _ruby
_ruby="$(chruby |grep \* |tr -d '* ')"
if [[ $(chruby |grep -c \*) -eq 1 ]]; then
echo ${_ruby}
else
echo "system"
fi
local ruby
ruby="$(chruby | grep \* | tr -d '* ')"
if [[ $(chruby | grep -c \*) -eq 1 ]]; then
echo ${ruby}
else
echo "system"
fi
}
function chruby_prompt_info() {
echo "$(current_ruby)"
echo "${$(current_ruby):gs/%/%%}"
}
# complete on installed rubies
# Complete chruby command with installed rubies
_chruby() {
compadd $(chruby | tr -d '* ')
local default_path='/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'
if PATH=${default_path} type ruby &> /dev/null; then
compadd system
fi
compadd $(chruby | tr -d '* ')
if PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" command ruby &>/dev/null; then
compadd system
fi
}
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
Chuck Norris fortunes plugin for oh-my-zsh. Perfectly suitable as MOTD.
**Maintainers**: [apjanke](https://github.com/apjanke) [maff](https://github.com/maff)
Chuck Norris fortunes plugin for Oh My Zsh. Perfectly suitable as MOTD.
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
if [[ ! -f $DIR/chucknorris.dat ]] || [[ $DIR/chucknorris.dat -ot $DIR/chucknorris ]]; then
# 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
# %x: name of file containing code being executed
local fortunes_dir="${${(%):-%x}:h}/fortunes"
# Aliases
alias chuck="fortune -a $fortunes_dir"
alias chuck_cow="chuck | cowthink"
# Automatically generate or update Chuck's compiled fortune data file
if [[ "$fortunes_dir/chucknorris" -ot "$fortunes_dir/chucknorris.dat" ]]; then
return
fi
if which $strfile &> /dev/null; then
$strfile $DIR/chucknorris $DIR/chucknorris.dat >/dev/null
else
# 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
fi
# Aliases
alias chuck="fortune -a $DIR"
alias chuck_cow="chuck | cowthink"
# Generate the compiled fortune data file
$strfile "$fortunes_dir/chucknorris" "$fortunes_dir/chucknorris.dat" >/dev/null
}
unset CHUCKNORRIS_PLUGIN_DIR

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 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.
%
@ -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.
%
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.
%
@ -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.
%
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.
%
@ -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 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.
%
@ -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 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.
%
@ -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.
%
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-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
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[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.
typeset __colored_man_pages_dir="${0:A:h}"
typeset -g __colored_man_pages_dir="${0:A:h}"
function colored() {
local -a environment

View File

@ -82,7 +82,7 @@ colorize_less() {
# This variable tells less to pipe every file through the specified command
# (see the man page of less INPUT PREPROCESSOR).
# 'zsh -ic "colorize_cat %s 2> /dev/null"' would not work for huge files like
# the ~/.zsh_history. For such files the tty of the preprocessor will be supended.
# 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
# preprocessor without the interactive mode.
# `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)
- [NixOS](https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/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.

View File

@ -50,13 +50,20 @@ fi
# 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
command_not_found_handler() {
/run/current-system/sw/bin/command-not-found -- "$@"
/run/current-system/sw/bin/command-not-found "$@"
}
fi
# Termux: https://github.com/termux/command-not-found
if [[ -x /data/data/com.termux/files/usr/libexec/termux/command-not-found ]]; then
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

View File

@ -12,51 +12,53 @@ plugins=(... common-aliases)
### ls command
| Alias | Command | Description |
|-------|---------------|--------------------------------------------------------------------------------|
| l | `ls -lFh` | List files as a long list, show size, type, human-readable |
| la | `ls -lAFh` | List almost all files as a long list show size, type, human-readable |
| lr | `ls -tRFh` | List files recursively sorted by date, show type, human-readable |
| lt | `ls -ltFh` | List files as a long list sorted by date, show type, human-readable |
| ll | `ls -l` | List files as a long list |
| ldot | `ls -ld .*` | List dot files as a long list |
| lS | `ls -1FSsh` | List files showing only size and name sorted by size |
| lart | `ls -1Fcart` | List all files sorted in reverse of create/modification time (oldest first) |
| lrt | `ls -1Fcrt` | List files sorted in reverse of create/modification time(oldest first) |
| Alias | Command | Description |
| ----- | ------------ | --------------------------------------------------------------------------- |
| l | `ls -lFh` | List files as a long list, show size, type, human-readable |
| la | `ls -lAFh` | List almost all files as a long list show size, type, human-readable |
| lr | `ls -tRFh` | List files recursively sorted by date, show type, human-readable |
| lt | `ls -ltFh` | List files as a long list sorted by date, show type, human-readable |
| ll | `ls -l` | List files as a long list |
| ldot | `ls -ld .*` | List dot files as a long list |
| lS | `ls -1FSsh` | List files showing only size and name sorted by size |
| lart | `ls -1Fcart` | List all files sorted in reverse of create/modification time (oldest first) |
| lrt | `ls -1Fcrt` | List files sorted in reverse of create/modification time(oldest first) |
| lsr | `ls -lARFh` | List all files and directories recursively |
| lsn | `ls -1` | List files and directories in a single column |
### File handling
| Alias | Command | Description |
|-------|-----------------------|------------------------------------------------------------------------------------|
| rm | `rm -i` | Remove a file |
| cp | `cp -i` | Copy a file |
| mv | `mv -i` | Move a file |
| zshrc | `${=EDITOR} ~/.zshrc` | Quickly access the ~/.zshrc file |
| dud | `du -d 1 -h` | Display the size of files at depth 1 in current location in human-readable form |
| duf | `du -sh` | Display the size of files in current location in human-readable form |
| t | `tail -f` | Shorthand for tail which outputs the last part of a file |
| Alias | Command | Description |
| ----- | --------------------- | ------------------------------------------------------------------------------- |
| rm | `rm -i` | Remove a file |
| cp | `cp -i` | Copy a file |
| mv | `mv -i` | Move a file |
| zshrc | `${=EDITOR} ~/.zshrc` | Quickly access the ~/.zshrc file |
| dud | `du -d 1 -h` | Display the size of files at depth 1 in current location in human-readable form |
| duf | `du -sh` | Display the size of files in current location in human-readable form |
| t | `tail -f` | Shorthand for tail which outputs the last part of a file |
### find and grep
| Alias | Command | Description |
|-------|-----------------------------------------------------|-----------------------------------------|
| fd\* | `find . -type d -name` | Find a directory with the given name |
| ff | `find . -type f -name` | Find a file with the given name |
| grep | `grep --color` | Searches for a query string |
| sgrep | `grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS}` | Useful for searching within files |
| Alias | Command | Description |
| ----- | -------------------------------------------------- | ------------------------------------ |
| fd\* | `find . -type d -name` | Find a directory with the given name |
| ff | `find . -type f -name` | Find a file with the given name |
| grep | `grep --color` | Searches for a query string |
| sgrep | `grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS}` | Useful for searching within files |
\* Only if the [`fd`](https://github.com/sharkdp/fd) command isn't installed.
### Other Aliases
| Alias | Command | Description |
|-----------|---------------------|-------------------------------------------------------------|
| h | `history` | Lists all recently used commands |
| hgrep | `fc -El 0 \| grep` | Searches for a word in the list of previously used commands |
| help | `man` | Opens up the man page for a command |
| p | `ps -f` | Displays currently executing processes |
| sortnr | `sort -n -r` | Used to sort the lines of a text file |
| unexport | `unset` | Used to unset an environment variable |
| Alias | Command | Description |
| -------- | ------------------ | ----------------------------------------------------------- |
| h | `history` | Lists all recently used commands |
| hgrep | `fc -El 0 \| grep` | Searches for a word in the list of previously used commands |
| help | `man` | Opens up the man page for a command |
| p | `ps -f` | Displays currently executing processes |
| sortnr | `sort -n -r` | Used to sort the lines of a text file |
| unexport | `unset` | Used to unset an environment variable |
## Global aliases
@ -77,7 +79,7 @@ $ find . -type f 2>/dev/null
```
| Alias | Command | Description |
|-------|-----------------------------|-------------------------------------------------------------|
| ----- | --------------------------- | ----------------------------------------------------------- |
| H | `\| head` | Pipes output to head which outputs the first part of a file |
| T | `\| tail` | Pipes output to tail which outputs the last part of a file |
| G | `\| grep` | Pipes output to grep to search for some word |
@ -97,23 +99,23 @@ that file will be open with `acroread`.
### Reading Docs
| Alias | Command | Description |
|-------|-------------|-------------------------------------|
| pdf | `acroread` | Opens up a document using acroread |
| ps | `gv` | Opens up a .ps file using gv |
| dvi | `xdvi` | Opens up a .dvi file using xdvi |
| chm | `xchm` | Opens up a .chm file using xchm |
| djvu | `djview` | Opens up a .djvu file using djview |
| Alias | Command | Description |
| ----- | ---------- | ---------------------------------- |
| pdf | `acroread` | Opens up a document using acroread |
| ps | `gv` | Opens up a .ps file using gv |
| dvi | `xdvi` | Opens up a .dvi file using xdvi |
| chm | `xchm` | Opens up a .chm file using xchm |
| djvu | `djview` | Opens up a .djvu file using djview |
### Listing files inside a packed file
| Alias | Command | Description |
|---------|-------------|-------------------------------------|
| zip | `unzip -l` | Lists files inside a .zip file |
| rar | `unrar l` | Lists files inside a .rar file |
| tar | `tar tf` | Lists files inside a .tar file |
| tar.gz | `echo` | Lists files inside a .tar.gz file |
| ace | `unace l` | Lists files inside a .ace file |
| Alias | Command | Description |
| ------ | ---------- | --------------------------------- |
| zip | `unzip -l` | Lists files inside a .zip file |
| rar | `unrar l` | Lists files inside a .rar file |
| tar | `tar tf` | Lists files inside a .tar file |
| tar.gz | `echo` | Lists files inside a .tar.gz file |
| ace | `unace l` | Lists files inside a .ace file |
### Some other features

View File

@ -12,6 +12,8 @@ alias ldot='ls -ld .*'
alias lS='ls -1FSsh'
alias lart='ls -1Fcart'
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

View File

@ -10,22 +10,26 @@ To use it add `composer` to the plugins array in your zshrc file.
plugins=(... composer)
```
Original author: Daniel Gomes <me@danielcsgomes.com>
## Aliases
| Alias | Command | Description |
| ------ | ------------------------------------------- | --------------------------------------------------------------------------------------- |
| `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 |
| `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) |
| `cgu` | `composer global update` | Allows update 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 |
| `cget` | `curl -s https://getcomposer.org/installer` | Installs composer in the current directory |
| `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 |
| Alias | Command | Description |
| ------ | ---------------------------------- | --------------------------------------------------------------------------------------- |
| `c` | `composer` | Starts composer |
| `ccp` | `composer create-project` | Create new project from an existing package |
| `cdo` | `composer dump-autoload -o` | Converts PSR-0/4 autoloading to classmap for a faster autoloader (good for production) |
| `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 |
| `cgrm` | `composer global remove` | Allows remove command to run on COMPOSER_HOME 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 |
| `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,70 +1,76 @@
# ------------------------------------------------------------------------------
# FILE: composer.plugin.zsh
# DESCRIPTION: oh-my-zsh composer plugin file.
# 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 () {
## Basic Composer command completion
# Since Zsh 5.7, an improved composer command completion is provided
if ! is-at-least 5.7; then
_composer () {
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments \
'*:: :->subcmds'
_arguments '*:: :->subcmds'
if (( CURRENT == 1 )) || ( ((CURRENT == 2)) && [ "$words[1]" = "global" ] ) ; then
compadd $(_composer_get_command_list)
if (( CURRENT == 1 )) || ( (( CURRENT == 2 )) && [[ "$words[1]" = "global" ]] ); then
# 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
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
}
}
compdef _composer composer
compdef _composer composer.phar
compdef _composer composer
compdef _composer composer.phar
fi
# Aliases
## Aliases
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 cdu='composer dump-autoload'
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 cgrm='composer global remove'
alias cgu='composer global update'
alias ci='composer install'
alias co='composer outdated'
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 (( $+commands[composer] )); then
autoload -Uz _store_cache _retrieve_cache _cache_invalid
## If Composer not found, try to add known directories to $PATH
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"
_retrieve_cache composer
if [[ -z $__composer_bin_dir ]]; then
__composer_bin_dir=$(composer global config bin-dir --absolute 2>/dev/null)
_store_cache composer __composer_bin_dir
fi
# Add Composer's global binaries to PATH
export PATH="$PATH:$__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
# 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
_retrieve_cache composer
if [[ -z $__composer_bin_dir ]]; then
__composer_bin_dir=$(composer global config bin-dir --absolute 2>/dev/null)
_store_cache composer __composer_bin_dir
fi
# Add Composer's global binaries to PATH
export PATH="$PATH:$__composer_bin_dir"
unset __composer_bin_dir

View File

@ -36,7 +36,7 @@ arguments=(
'--reinstall[Reinstall the distribution even if you already have the latest version installed]'
'--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)'
'--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 |
| -------- | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| `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 |
| `ac` | `sudo $apt_pref clean` | Clears out the local repository of retrieved package files except lock files |
| `ad` | `sudo $apt_pref update` | Updates the package lists for upgrades for packages |
| `adg` | `sudo $apt_pref update && sudo $apt_pref $apt_upgr` | Update and upgrade packages |
| `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 |
| `afu` | `sudo apt-file update` | Update the files in packages |
| `au` | `sudo $apt_pref $apt_upgr` | Install package upgrades |
| `ai` | `sudo $apt_pref install` | Command-line tool to install package |
| `ail` | `sed -e 's/ */ /g' -e 's/ *//' \| cut -s -d ' ' -f 1 \| xargs sudo $apt_pref install` | Install all packages given on the command line while using only the first word of each line |
| `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 |
| `ar` | `sudo $apt_pref remove` | Removes packages, keeps the configuration files |
| `ads` | `sudo apt-get dselect-upgrade` | Installs packages from list and removes all not in the list |
| `dia` | `sudo dpkg -i ./*.deb` | Install all .deb files in the current directory |
| `au` | `sudo $apt_pref $apt_upgr` | Install package upgrades |
| `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 |
## Aliases - Commands using `su`
@ -54,6 +56,7 @@ Set `$apt_pref` and `$apt_upgr` to whatever command you want (before sourcing Oh
| Alias | Command |
| ----- | --------------------------------------------------------- |
| `aac` | `su -ls "$apt_pref autoclean" root` |
| `aar` | `su -ls "$apt_pref autoremove" root` |
| `ac` | `su -ls "$apt_pref clean" root` |
| `ad` | `su -lc "$apt_pref update" root` |
| `adg` | `su -lc "$apt_pref update && aptitude $apt_upgr" root` |
@ -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-history` | Displays apt history for a command |
| `kerndeb` | Builds kernel packages |
| `apt-list-packages` | List packages by size |
| `kerndeb` | Builds kernel packages |
## Authors

View File

@ -52,13 +52,18 @@ if [[ $use_sudo -eq 1 ]]; then
alias ai="sudo $apt_pref install"
# Install all packages given on the command line while using only the first word of each line:
# acs ... | ail
alias ail="sed -e 's/ */ /g' -e 's/ *//' | cut -s -d ' ' -f 1 | xargs sudo $apt_pref install"
alias ap="sudo $apt_pref purge"
alias ar="sudo $apt_pref remove"
alias aar="sudo $apt_pref autoremove"
# apt-get only
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.
# Warning: you will need to put the glob in single quotes if you use:
# glob_subst
@ -98,7 +103,11 @@ else
print "$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
# Assumes glob_subst is off
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 ap "purge"
apt_pref_compdef ar "remove"
apt_pref_compdef aar "autoremove"
apt_pref_compdef ads "dselect-upgrade"
# Misc. #####################################################################

View File

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

View File

@ -6,30 +6,35 @@ alias dfmt='deno fmt'
alias dh='deno help'
alias dli='deno lint'
alias drn='deno run'
alias drA='deno run -A'
alias drw='deno run --watch'
alias dts='deno test'
alias dup='deno upgrade'
# COMPLETION FUNCTION
if (( $+commands[deno] )); then
# remove old generated completion file
command rm -f "${0:A:h}/_deno"
if (( ! $+commands[deno] )); then
return
fi
ver="$(deno --version)"
ver_file="$ZSH_CACHE_DIR/deno_version"
comp_file="$ZSH_CACHE_DIR/completions/_deno"
# 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"
mkdir -p "${comp_file:h}"
(( ${fpath[(Ie)${comp_file:h}]} )) || fpath=("${comp_file:h}" $fpath)
# 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 [[ ! -f "$comp_file" || ! -f "$ver_file" || "$ver" != "$(< "$ver_file")" ]]; then
deno completions zsh >| "$comp_file"
echo "$ver" >| "$ver_file"
fi
declare -A _comps
# 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
_comps[deno]=_deno
unset ver ver_file comp_file
fi
deno completions zsh >| "$ZSH_CACHE_DIR/completions/_deno" &|

View File

@ -12,19 +12,27 @@ plugins=(... dirhistory)
| Shortcut | Description |
|-----------------------------------|-----------------------------------------------------------|
| <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>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>Left</kbd> | Go to previous directory |
| <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>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).
If these don't work check your terminal settings and change them to a different keyboard shortcut.
**For macOS: use the Option key (<kbd></kbd>) instead of <kbd>Alt</kbd>**.
> 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
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:
@ -35,8 +43,20 @@ cd share
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

@ -1,7 +1,7 @@
##
# Navigate directory history using ALT-LEFT and ALT-RIGHT. ALT-LEFT moves back to directories
##
# Navigate directory history 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.
#
#
# Navigate directory hierarchy using ALT-UP and ALT-DOWN.
# ALT-UP moves to higher hierarchy (cd ..)
# ALT-DOWN moves into the first directory found in alphabetical order
@ -14,25 +14,25 @@ export dirhistory_future
export DIRHISTORY_SIZE=30
# Pop the last element of dirhistory_past.
# Pass the name of the variable to return the result in.
# Pop the last element of dirhistory_past.
# Pass the name of the variable to return the result in.
# Returns the element if the array was not empty,
# otherwise returns empty string.
function pop_past() {
eval "$1='$dirhistory_past[$#dirhistory_past]'"
typeset -g $1="${dirhistory_past[$#dirhistory_past]}"
if [[ $#dirhistory_past -gt 0 ]]; then
dirhistory_past[$#dirhistory_past]=()
fi
}
function pop_future() {
eval "$1='$dirhistory_future[$#dirhistory_future]'"
typeset -g $1="${dirhistory_future[$#dirhistory_future]}"
if [[ $#dirhistory_future -gt 0 ]]; then
dirhistory_future[$#dirhistory_future]=()
fi
}
# Push a new element onto the end of dirhistory_past. If the size of the array
# Push a new element onto the end of dirhistory_past. If the size of the array
# is >= DIRHISTORY_SIZE, the array is shifted
function push_past() {
if [[ $#dirhistory_past -ge $DIRHISTORY_SIZE ]]; then
@ -76,7 +76,7 @@ function dirhistory_back() {
local d=""
# Last element in dirhistory_past is the cwd.
pop_past cw
pop_past cw
if [[ "" == "$cw" ]]; then
# Someone overwrote our variable. Recover it.
dirhistory_past=($PWD)
@ -121,40 +121,43 @@ function dirhistory_zle_dirhistory_future() {
}
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
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
#
#
# Move up in hierarchy
function dirhistory_up() {
@ -181,22 +184,38 @@ function dirhistory_zle_dirhistory_down() {
}
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
bindkey "\e[3B" dirhistory_zle_dirhistory_down
bindkey "\e[1;3B" dirhistory_zle_dirhistory_down
if [[ "$TERM_PROGRAM" == "Apple_Terminal" || "$TERM_PROGRAM" == "iTerm.app" ]]; then
bindkey "^[[B" dirhistory_zle_dirhistory_down
fi
bindkey "\e\e[B" dirhistory_zle_dirhistory_down
bindkey "\eO3B" dirhistory_zle_dirhistory_down
for keymap in emacs vicmd viins; do
# dirhistory_up
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
# 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.]' \
'*: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)
_arguments \
$opts_help \
@ -290,7 +284,7 @@ __docker-compose_subcommand() {
(up)
_arguments \
$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_deps \
$opts_force_recreate \
@ -298,6 +292,7 @@ __docker-compose_subcommand() {
$opts_no_build \
"(--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)--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: " \
'--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' \
@ -341,11 +336,13 @@ _docker-compose() {
'(- :)'{-h,--help}'[Get help]' \
'*'{-f,--file}"[${file_description}]:file:_files -g '*.yml'" \
'(-p --project-name)'{-p,--project-name}'[Specify an alternate project name (default: directory name)]:project name:' \
'--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]" \
'(- :)'{-v,--version}'[Print version and exit]' \
'--verbose[Show more output]' \
'--log-level=[Set log level]:level:(DEBUG INFO WARNING ERROR CRITICAL)' \
'--no-ansi[Do not print ANSI control characters]' \
'--ansi=[Control when to print ANSI control characters]:when:(never always auto)' \
'(-H --host)'{-H,--host}'[Daemon socket to connect to]:host:' \
'--tls[Use TLS; implied by --tlsverify]' \
'--tlscacert=[Trust certs signed only by this CA]:ca path:' \
@ -359,6 +356,7 @@ _docker-compose() {
local -a relevant_compose_flags relevant_compose_repeatable_flags relevant_docker_flags compose_options docker_options
relevant_compose_flags=(
"--env-file"
"--file" "-f"
"--host" "-H"
"--project-name" "-p"

View File

@ -1,28 +1,22 @@
# Authors:
# https://github.com/tristola
#
# Docker-compose related zsh aliases
# support Compose v2 as docker CLI plugin
(( ${+commands[docker-compose]} )) && dccmd='docker-compose' || dccmd='docker compose'
# 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'
# 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'
unset dccmd

View File

@ -90,7 +90,7 @@ __docker-machine_filters() {
}
__get_swarm_discovery() {
declare -a masters serivces
declare -a masters services
local service
services=()
masters=($(docker-machine ls -f {{.Swarm}} |grep '(master)' |awk '{print $1}'))
@ -169,7 +169,7 @@ __get_create_argument() {
__docker-machine_subcommand() {
local -a opts_help
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_help"
"*:host:__docker-machine_hosts_all"
@ -330,7 +330,7 @@ _docker-machine() {
_arguments -C \
"(- :)"{-h,--help}"[Show help]" \
"(-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-key[Private key to generate certificates]: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"
# 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
fi
# 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
local column
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. |
| dp | dotnet pack | Create a NuGet package. |
| dng | dotnet nuget | Provides additional NuGet commands. |
| db | dotnet build | Build a .NET project |

View File

@ -12,7 +12,7 @@ _dotnet_zsh_complete()
return
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}"
}
@ -30,3 +30,4 @@ alias ds='dotnet sln'
alias da='dotnet add'
alias dp='dotnet pack'
alias dng='dotnet nuget'
alias db='dotnet build'

View File

@ -1,83 +1,66 @@
# Drush
## Description
This plugin offers aliases and functions to make the work with drush easier and more productive.
This plugin adds aliases and functions for [Drush](https://www.drush.org), a command-line shell
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)
```
## Aliases
| Alias | Description | Command |
|-------|-----------------------------------------------------------------------|-----------------------------|
| dr | Display drush help | drush |
| drca | Clear all drupal caches. | drush cc all |
| drcb | Clear block cache. | drush cc block |
| drcg | Clear registry cache. | drush cc registry |
| drcj | Clear css-js cache. | drush cc css-js |
| drcm | Clear menu cache. | drush cc menu |
| drcml | Clear module-list cache. | drush cc module-list |
| drcr | Run all cron hooks in all active modules for specified site. | drush core-cron |
| drct | Clear theme-registry cache. | drush cc theme-registry |
| drcv | Clear views cache. (Make sure that the views module is enabled) | drush cc views |
| drdmp | Backup database in a new dump.sql file | drush drush sql-dump --ordered-dump --result-file=dump.sql|
| drf | Display features status | drush features |
| drfr | Revert a feature module on your site. | drush features-revert -y |
| drfu | Update a feature module on your site. | drush features-update -y |
| drfra | Revert all enabled feature module on your site. | drush features-revert-all |
| drif | Flush all derived images. | drush image-flush --all |
| drpm | Show a list of available modules. | drush pm-list --type=module |
| drst | Provides a birds-eye view of the current Drupal installation, if any. | drush core-status |
| drup | Apply any database updates required (as with running update.php). | drush updatedb |
| drups | List any pending database updates. | drush updatedb-status |
| drv | Show drush version. | drush version |
| drvd | Delete a variable. | drush variable-del |
| drvg | Get a list of some or all site variables and values. | drush variable-get |
| drvs | Set a variable. | drush variable-set |
| Alias | Command | Description |
| ------- | ----------------------------------------------------------- | -------------------------------------------------------------------- |
| `dr` | `drush` | Display drush help |
| `drca` | `drush cc all` | _(Deprecated in Drush 8)_ Clear all drupal caches |
| `drcb` | `drush cc block` | _(Deprecated in Drush 8)_ Clear block cache |
| `drcex` | `drush config:export -y` | Export Drupal configuration to a directory |
| `drcg` | `drush cc registry` | _(Deprecated in Drush 8)_ Clear registry cache |
| `drcim` | `drush config:import -y` | Import config from a config directory |
| `drcj` | `drush cc css-js` | Clear css-js cache |
| `drcm` | `drush cc menu` | Clear menu cache |
| `drcml` | `drush cc module-list` | Clear module-list cache |
| `drcr` | `drush core-cron` | Run all cron hooks in all active modules for specified site |
| `drct` | `drush cc theme-registry` | Clear theme-registry cache |
| `drcv` | `drush cc views` | Clear views cache _(make sure that the views module is enabled)_ |
| `drdmp` | `drush drush sql-dump --ordered-dump --result-file=dumpsql` | Backup database in a new dump.sql file |
| `drf` | `drush features` | Display features status |
| `drfr` | `drush features-revert -y` | Revert a feature module on your site |
| `drfra` | `drush features-revert-all` | Revert all enabled feature module on your site |
| `drfu` | `drush features-update -y` | Update a feature module on your site |
| `drif` | `drush image-flush --all` | Flush all derived images |
| `drpm` | `drush pm-list --type=module` | Show a list of available modules |
| `drst` | `drush core-status` | Provides a birds-eye view of the current Drupal installation, if any |
| `druli` | `drush user:login` | Display a one time login link for user ID 1, or another user |
| `drup` | `drush updatedb` | Apply any database updates required (as with running update.php) |
| `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
### dren
Download and enable one or more extensions (modules or themes).
Must be invoked with one or more parameters. e.g.:
`dren devel` or `dren devel module_filter views`
- `dren`: download and enable one or more extensions (modules or themes). Must be
invoked with one or more parameters, e.g.: `dren devel` or `dren devel module_filter views`.
### drf
Edit drushrc, site alias, and Drupal settings.php files.
Can be invoked with one or without parameters. e.g.:
`drf 1`
- `drf`: edit drushrc, site alias, and Drupal settings.php files.
Can be invoked with one or without parameters, e.g.: `drf 1`.
### dris
Disable one or more extensions (modules or themes)
Must be invoked with one or more parameters. e.g.:
`dris devel` or `dris devel module_filter views`
- `dris`: disable one or more extensions (modules or themes). Must be invoked with
one or more parameters, e.g.: `dris devel` or `dris devel module_filter views`.
### drpu
Uninstall one or more modules.
Must be invoked with one or more parameters. e.g.:
`drpu devel` or `drpu devel module_filter views`
- `drpu`: uninstall one or more modules. Must be invoked with one or more
parameters, e.g.: `drpu devel` or `drpu devel module_filter views`.
### drnew
Creates a brand new drupal website.
Note: As soon as the installation is complete, drush will print a username and a random password into the terminal:
```
Installation complete. User name: admin User password: cf7t8yqNEm
```
- `drnew`: creates a brand new drupal website. Note: as soon as the installation
is complete, `drush` will print a username and a random password into the terminal:
## 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
```
```text
Installation complete. User name: admin User password: cf7t8yqNEm
```

View File

@ -1,19 +1,18 @@
# Drush support.
# Functions
function dren() {
drush en $@ -y
drush en "$@" -y
}
function dris() {
drush pm-disable $@ -y
drush pm-disable "$@" -y
}
function drpu() {
drush pm-uninstall $@ -y
drush pm-uninstall "$@" -y
}
function drf() {
if [[ $1 == "" ]] then
if [[ -z "$1" ]] then
drush core-config
else
drush core-config --choice=$1
@ -21,62 +20,62 @@ function drf() {
}
function drfi() {
if [[ $1 == "fields" ]]; then
drush field-info fields
elif [[ $1 == "types" ]]; then
drush field-info types
else
drush field-info
fi
case "$1" in
fields) drush field-info fields ;;
types) drush field-info types ;;
*) drush field-info ;;
esac
}
function drnew() {
(
cd
echo "Website's name: "
read WEBSITE_NAME
cd ~
echo "Website's name: "
read WEBSITE_NAME
HOST=http://$(hostname -i)/
HOST=http://$(hostname -i)/
if [[ $WEBSITE_NAME == "" ]] then
MINUTES=$(date +%M:%S)
WEBSITE_NAME="Drupal-$MINUTES"
echo "Your website will be named: $WEBSITE_NAME"
fi
if [[ $WEBSITE_NAME == "" ]] then
MINUTES=$(date +%M:%S)
WEBSITE_NAME="Drupal-$MINUTES"
echo "Your website will be named: $WEBSITE_NAME"
fi
drush dl drupal --drupal-project-rename=$WEBSITE_NAME
drush dl drupal --drupal-project-rename=$WEBSITE_NAME
echo "Type your localhost directory: (Leave empty for /var/www/html/)"
read DIRECTORY
echo "Type your localhost directory: (Leave empty for /var/www/html/)"
read DIRECTORY
if [[ $DIRECTORY == "" ]] then
DIRECTORY="/var/www/html/"
fi
if [[ $DIRECTORY == "" ]] then
DIRECTORY="/var/www/html/"
fi
echo "Moving to $DIRECTORY$WEBSITE_NAME"
sudo mv $WEBSITE_NAME $DIRECTORY
cd $DIRECTORY$WEBSITE_NAME
echo "Moving to $DIRECTORY$WEBSITE_NAME"
sudo mv $WEBSITE_NAME $DIRECTORY
cd $DIRECTORY$WEBSITE_NAME
echo "Database's user: "
read DATABASE_USR
echo "Database's password: "
read -s DATABASE_PWD
echo "Database's name for your project: "
read DATABASE
echo "Database's user: "
read DATABASE_USR
echo "Database's password: "
read -s DATABASE_PWD
echo "Database's name for your project: "
read DATABASE
DB_URL="mysql://$DATABASE_USR:$DATABASE_PWD@localhost/$DATABASE"
drush site-install standard --db-url=$DB_URL --site-name=$WEBSITE_NAME
open_command $HOST$WEBSITE_NAME
echo "Done"
DB_URL="mysql://$DATABASE_USR:$DATABASE_PWD@localhost/$DATABASE"
drush site-install standard --db-url=$DB_URL --site-name=$WEBSITE_NAME
open_command $HOST$WEBSITE_NAME
echo "Done"
)
}
# Aliases, sorted alphabetically.
# Aliases
alias dr="drush"
alias drca="drush cc all" # 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 drcim="drush config:import -y"
alias drcj="drush cc css-js"
alias drcm="drush cc menu"
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 drf="drush features"
alias drfr="drush features-revert -y"
alias drfu="drush features-update -y"
alias drfra="drush features-revert-all"
alias drfu="drush features-update -y"
alias drif="drush image-flush --all"
alias drpm="drush pm-list --type=module"
alias drst="drush core-status"
alias druli="drush user:login"
alias drup="drush updatedb"
alias drups="drush updatedb-status"
alias drv="drush version"
alias drvd="drush variable-del"
alias drvg="drush variable-get"
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
autoload bashcompinit

View File

@ -9,57 +9,60 @@
# - You can share opened buffered across opened 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
export EMACS_PLUGIN_LAUNCHER="$ZSH/plugins/emacs/emacsclient.sh"
# 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}"
# set EDITOR if not already defined.
export EDITOR="${EDITOR:-${EMACS_PLUGIN_LAUNCHER}}"
# Path to custom emacsclient launcher
export EMACS_PLUGIN_LAUNCHER="${0:A:h}/emacsclient.sh"
alias emacs="$EMACS_PLUGIN_LAUNCHER --no-wait"
alias e=emacs
# open terminal emacsclient
alias te="$EMACS_PLUGIN_LAUNCHER -nw"
# set EDITOR if not already defined.
export EDITOR="${EDITOR:-${EMACS_PLUGIN_LAUNCHER}}"
# same than M-x eval but from outside Emacs.
alias eeval="$EMACS_PLUGIN_LAUNCHER --eval"
# create a new X frame
alias eframe='emacsclient --alternate-editor "" --create-frame'
alias emacs="$EMACS_PLUGIN_LAUNCHER --no-wait"
alias e=emacs
# open terminal emacsclient
alias te="$EMACS_PLUGIN_LAUNCHER -nw"
# Emacs ANSI Term tracking
if [[ -n "$INSIDE_EMACS" ]]; then
chpwd_emacs() { print -P "\033AnSiTc %d"; }
print -P "\033AnSiTc %d" # Track current working directory
print -P "\033AnSiTu %n" # Track username
# same than M-x eval but from outside Emacs.
alias eeval="$EMACS_PLUGIN_LAUNCHER --eval"
# create a new X frame
alias eframe='emacsclient --alternate-editor "" --create-frame'
# add chpwd hook
autoload -Uz add-zsh-hook
add-zsh-hook chpwd chpwd_emacs
fi
# Emacs ANSI Term tracking
if [[ -n "$INSIDE_EMACS" ]]; then
chpwd_emacs() { print -P "\033AnSiTc %d"; }
print -P "\033AnSiTc %d" # Track current working directory
print -P "\033AnSiTu %n" # Track username
# Write to standard output the path to the file
# opened in the current buffer.
function efile {
local cmd="(buffer-file-name (window-buffer))"
"$EMACS_PLUGIN_LAUNCHER" --eval "$cmd" | tr -d \"
}
# Write to standard output the directory of the file
# opened in the the current buffer
function ecd {
local cmd="(let ((buf-name (buffer-file-name (window-buffer))))
(if buf-name (file-name-directory buf-name)))"
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
}
# add chpwd hook
autoload -Uz add-zsh-hook
add-zsh-hook chpwd chpwd_emacs
fi
## Local Variables:
## mode: sh
## End:
# Write to standard output the path to the file
# opened in the current buffer.
function efile {
local cmd="(buffer-file-name (window-buffer))"
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
# opened in the the current buffer
function ecd {
local file
file="$(efile)" || return $?
echo "${file:h}"
}

View File

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

View File

@ -1,22 +1,33 @@
# 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
----- | -----------------
**es** | *ember serve*
**ea** | *ember addon*
**eb** | *ember build*
**ed** | *ember destroy*
**eg** | *ember generate*
**eh** | *ember help*
**ein** | *ember init*
**ei** | *ember install*
**et** | *ember test*
**ets** | *ember test --serve*
**eu** | *ember update*
**ev** | *ember version*
## Aliases
| Alias | Command |
| ----- | -------------------- |
| `ea` | `ember addon` |
| `eb` | `ember build` |
| `ed` | `ember destroy` |
| `eg` | `ember generate` |
| `eh` | `ember help` |
| `ei` | `ember install` |
| `ein` | `ember init` |
| `es` | `ember serve` |
| `et` | `ember test` |
| `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 eb='ember build'
alias ed='ember destroy'
alias eg='ember generate'
alias eh='ember help'
alias ein='ember init'
alias ei='ember install'
alias ein='ember init'
alias es='ember serve'
alias et='ember test'
alias ets='ember test --serve'
alias eu='ember update'
# 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
----------------- | --------------------------------
$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_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:
```
$> display_emoji
$> display_emoji fruits
$> display_emoji animals
$> display_emoji vehicles
$> display_emoji faces
$> display_emoji people
```
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 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 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
@ -90,7 +88,6 @@ Variables:
Variable | Description
----------------- | --------------------------------
$emoji2 | Auxiliary and combining characters
$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.
```
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.
#### 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
These are things that could be enhanced in future revisions of the plugin.
* Incorporate CLDR data for ordering and groupings
* Short :bracket: style names (from gemoji)
* Incorporate `gemoji` data
* Country codes for flags
* 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.
* ZWJ combining function?

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.
# 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}"
() {
local LC_ALL=en_US.UTF-8
typeset -gAH emoji_groups
typeset -gAH emoji_con
typeset -gAH emoji2
typeset -gAH emoji_skintone
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
# 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.
# 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
# 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_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_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
emoji_skintone[1_2]=$'\U1F3FB'
emoji_skintone[3]=$'\U1F3FC'
emoji_skintone[4]=$'\U1F3FD'
emoji_skintone[5]=$'\U1F3FE'
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
@ -259,7 +63,11 @@ function random_emoji() {
[[ $list_size -eq 0 ]] && return 1
local random_index=$(( ( RANDOM % $list_size ) + 1 ))
local name=${names[$random_index]}
echo ${emoji[$name]}
if [[ "$group" == "flags" ]]; then
echo ${emoji_flags[$name]}
else
echo ${emoji[$name]}
fi
}
# Displays a listing of emoji with their names
@ -276,12 +84,26 @@ function display_emoji() {
fi
# The extra spaces in output here are a hack for readability, since some
# terminals treat these emoji chars as single-width.
local counter=1
for i in $names; do
printf '%s ' "$emoji[$i]"
if [[ "$group" == "flags" ]]; then
printf '%s ' "$emoji_flags[$i]"
else
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
print
for i in $names; do
echo "${emoji[$i]} = $i"
if [[ "$group" == "flags" ]]; then
echo "${emoji_flags[$i]} = $i"
else
echo "${emoji[$i]} = $i"
fi
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