oh-my-zsh
This commit is contained in:
parent
bf1d50a4f2
commit
a885d09805
150 changed files with 5761 additions and 2905 deletions
|
@ -1,47 +1,40 @@
|
|||
<p align="center">
|
||||
<img src="https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png" alt="Oh My Zsh">
|
||||
</p>
|
||||
<p align="center"><img src="https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png" alt="Oh My Zsh"></p>
|
||||
|
||||
Oh My Zsh is an open source, community-driven framework for managing your [zsh](https://www.zsh.org/) configuration.
|
||||
|
||||
Sounds boring. Let's try again.
|
||||
|
||||
__Oh My Zsh will not make you a 10x developer...but you may feel like one.__
|
||||
**Oh My Zsh will not make you a 10x developer...but you may feel like one.**
|
||||
|
||||
Once installed, your terminal shell will become the talk of the town _or your money back!_ With each keystroke in your command prompt, you'll take advantage of the hundreds of powerful plugins and beautiful themes. Strangers will come up to you in cafés and ask you, _"that is amazing! are you some sort of genius?"_
|
||||
|
||||
Finally, you'll begin to get the sort of attention that you have always felt you deserved. ...or maybe you'll use the time that you're saving to start flossing more often. 😬
|
||||
|
||||
To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter, and/or join us on Discord.
|
||||
To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter, and join us on [Discord](https://discord.gg/ohmyzsh).
|
||||
|
||||
[![CI](https://github.com/ohmyzsh/ohmyzsh/workflows/CI/badge.svg)](https://github.com/ohmyzsh/ohmyzsh/actions?query=workflow%3ACI)
|
||||
[![Follow @ohmyzsh](https://img.shields.io/twitter/follow/ohmyzsh?label=Follow+@ohmyzsh&style=flat)](https://twitter.com/intent/follow?screen_name=ohmyzsh)
|
||||
[![Discord server](https://img.shields.io/discord/642496866407284746)](https://discord.gg/ohmyzsh)
|
||||
[![Gitpod ready](https://img.shields.io/badge/Gitpod-ready-blue?logo=gitpod)](https://gitpod.io/#https://github.com/ohmyzsh/ohmyzsh)
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Prerequisites
|
||||
|
||||
* A Unix-like operating system: macOS, Linux, BSD. On Windows: WSL is preferred, but cygwin or msys also mostly work.
|
||||
* [Zsh](https://www.zsh.org) should be installed (v4.3.9 or more recent). If not pre-installed (run `zsh --version` to confirm), check the following instructions here: [Installing ZSH](https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH)
|
||||
* `curl` or `wget` should be installed
|
||||
* `git` should be installed (recommended v1.7.2 or higher)
|
||||
- A Unix-like operating system: macOS, Linux, BSD. On Windows: WSL2 is preferred, but cygwin or msys also mostly work.
|
||||
- [Zsh](https://www.zsh.org) should be installed (v4.3.9 or more recent is fine but we prefer 5.0.8 and newer). If not pre-installed (run `zsh --version` to confirm), check the following wiki instructions here: [Installing ZSH](https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH)
|
||||
- `curl` or `wget` should be installed
|
||||
- `git` should be installed (recommended v2.4.11 or higher)
|
||||
|
||||
### Basic Installation
|
||||
|
||||
Oh My Zsh is installed by running one of the following commands in your terminal. You can install this via the command-line with either `curl` or `wget`.
|
||||
Oh My Zsh is installed by running one of the following commands in your terminal. You can install this via the command-line with either `curl`, `wget` or another similar tool.
|
||||
|
||||
#### via curl
|
||||
|
||||
```shell
|
||||
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
|
||||
```
|
||||
|
||||
#### via wget
|
||||
|
||||
```shell
|
||||
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
|
||||
```
|
||||
| Method | Command |
|
||||
|:----------|:--------------------------------------------------------------------------------------------------|
|
||||
| **curl** | `sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` |
|
||||
| **wget** | `sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` |
|
||||
| **fetch** | `sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"` |
|
||||
|
||||
#### Manual inspection
|
||||
|
||||
|
@ -50,7 +43,7 @@ that by downloading the install script first, looking through it so everything l
|
|||
then running it:
|
||||
|
||||
```shell
|
||||
curl -Lo install.sh https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
|
||||
wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
|
||||
sh install.sh
|
||||
```
|
||||
|
||||
|
@ -58,7 +51,7 @@ sh install.sh
|
|||
|
||||
### Plugins
|
||||
|
||||
Oh My Zsh comes with a shitload of plugins to take advantage of. You can take a look in the [plugins](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins) directory and/or the [wiki](https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins) to see what's currently available.
|
||||
Oh My Zsh comes with a shitload of plugins for you to take advantage of. You can take a look in the [plugins](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins) directory and/or the [wiki](https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins) to see what's currently available.
|
||||
|
||||
#### Enabling Plugins
|
||||
|
||||
|
@ -82,15 +75,15 @@ plugins=(
|
|||
)
|
||||
```
|
||||
|
||||
_Note that the plugins are separated by whitespace. **Do not** use commas between them._
|
||||
_Note that the plugins are separated by whitespace (spaces, tabs, new lines...). **Do not** use commas between them or it will break._
|
||||
|
||||
#### Using Plugins
|
||||
|
||||
Most plugins (should! we're working on this) include a __README__, which documents how to use them.
|
||||
Each plugin includes a __README__, documenting it. This README should show the aliases (if the plugin adds any) and extra goodies that are included in that particular plugin.
|
||||
|
||||
### Themes
|
||||
|
||||
We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme happy. We have over one hundred themes now bundled. Most of them have [screenshots](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes) on the wiki. Check them out!
|
||||
We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme happy. We have over one hundred and fifty themes now bundled. Most of them have [screenshots](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes) on the wiki (We are working on updating this!). Check them out!
|
||||
|
||||
#### Selecting a Theme
|
||||
|
||||
|
@ -119,7 +112,6 @@ 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
|
||||
ZSH_THEME="random" # (...please let it be pie... please be some pie..)
|
||||
```
|
||||
|
@ -133,10 +125,10 @@ ZSH_THEME_RANDOM_CANDIDATES=(
|
|||
)
|
||||
```
|
||||
|
||||
If you only know which themes you don't like, you can add them similarly to a blacklist:
|
||||
If you only know which themes you don't like, you can add them similarly to an ignored list:
|
||||
|
||||
```shell
|
||||
ZSH_THEME_RANDOM_BLACKLIST=(pygmalion tjkirch_mod)
|
||||
ZSH_THEME_RANDOM_IGNORED=(pygmalion tjkirch_mod)
|
||||
```
|
||||
|
||||
### FAQ
|
||||
|
@ -154,7 +146,7 @@ the installer accepts (these settings are also documented at the top of the inst
|
|||
|
||||
#### Custom Directory
|
||||
|
||||
The default location is `~/.oh-my-zsh` (hidden in your home directory)
|
||||
The default location is `~/.oh-my-zsh` (hidden in your home directory, you can access it with `cd ~/.oh-my-zsh`)
|
||||
|
||||
If you'd like to change the install directory with the `ZSH` environment variable, either by running
|
||||
`export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline
|
||||
|
@ -199,13 +191,13 @@ REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh
|
|||
|
||||
#### Manual Installation
|
||||
|
||||
##### 1. Clone the repository:
|
||||
##### 1. Clone the repository
|
||||
|
||||
```shell
|
||||
git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
|
||||
```
|
||||
|
||||
##### 2. *Optionally*, backup your existing `~/.zshrc` file:
|
||||
##### 2. *Optionally*, backup your existing `~/.zshrc` file
|
||||
|
||||
```shell
|
||||
cp ~/.zshrc ~/.zshrc.orig
|
||||
|
@ -235,9 +227,9 @@ Once you open up a new terminal window, it should load zsh with Oh My Zsh's conf
|
|||
|
||||
If you have any hiccups installing, here are a few common fixes.
|
||||
|
||||
* You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after
|
||||
- You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after
|
||||
switching to `oh-my-zsh`.
|
||||
* If you installed manually or changed the install location, check the `ZSH` environment variable in
|
||||
- If you installed manually or changed the install location, check the `ZSH` environment variable in
|
||||
`~/.zshrc`.
|
||||
|
||||
### Custom Plugins and Themes
|
||||
|
@ -267,7 +259,7 @@ DISABLE_AUTO_UPDATE=true
|
|||
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:
|
||||
|
||||
```shell
|
||||
upgrade_oh_my_zsh
|
||||
omz update
|
||||
```
|
||||
|
||||
Magic! 🎉
|
||||
|
@ -300,10 +292,12 @@ Thank you so much!
|
|||
|
||||
## Follow Us
|
||||
|
||||
We're on the social media.
|
||||
We're on social media:
|
||||
|
||||
* [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. You should follow it.
|
||||
* [Oh My Zsh](https://www.facebook.com/Oh-My-Zsh-296616263819290/) on Facebook.
|
||||
- [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. You should follow it.
|
||||
- [FaceBook](https://www.facebook.com/Oh-My-Zsh-296616263819290/) poke us.
|
||||
- [Instagram](https://www.instagram.com/_ohmyzsh/) tag us in your post showing Oh My Zsh!
|
||||
- [Discord](https://discord.gg/ohmyzsh) to chat with us!
|
||||
|
||||
## Merchandise
|
||||
|
||||
|
|
|
@ -4,7 +4,5 @@ root = true
|
|||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
charset = utf-8
|
||||
|
||||
[*.sh]
|
||||
indent_size = 4
|
||||
indent_style = tab
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# Plugin owners
|
||||
plugins/gitfast/ @felipec
|
||||
plugins/sdk/ @rgoldberg
|
||||
plugins/aws/ @maksyms
|
||||
plugins/git-lfs/ @vietduc01100001
|
||||
plugins/gitfast/ @felipec
|
||||
plugins/sdk/ @rgoldberg
|
||||
|
|
2
dot_oh-my-zsh/dot_github/FUNDING.yml
Normal file
2
dot_oh-my-zsh/dot_github/FUNDING.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
github: [robbyrussell, mcornella, larson-carter]
|
||||
open_collective: ohmyzsh
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve Oh My Zsh
|
||||
labels: 'Type: support'
|
||||
|
||||
---
|
||||
|
||||
|
@ -26,11 +25,21 @@ A brief description of what should happen.
|
|||
If applicable, add screenshots to help explain your problem.
|
||||
You can also record an asciinema session: https://asciinema.org/
|
||||
|
||||
**Self Check**
|
||||
|
||||
- Have you tried reaching out on the [Discord server](https://discord.gg/ohmyzsh)?
|
||||
This can help cut down on filling up issues. We always have a few people
|
||||
online that are in a variety of timezones that are willing to help you!
|
||||
|
||||
- Also searching existing [GitHub Issues](https://github.com/ohmyzsh/ohmyzsh/issues?q=) might help you get quicker support
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
|
||||
- OS / Distro: [e.g. Arch Linux, macOS]
|
||||
- Latest ohmyzsh Update?: [e.g. Yes/No]
|
||||
- If on Windows what version of WSL: [e.g. WSL1, WSL2]
|
||||
- Latest ohmyzsh update?: [e.g. Yes/No]
|
||||
- ZSH Version: [e.g. 5.6]
|
||||
- Terminal emulator [e.g. iTerm2]
|
||||
- Terminal emulator: [e.g. iTerm2]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here. This can be themes, plugins, custom configs.
|
||||
|
|
5
dot_oh-my-zsh/dot_github/ISSUE_TEMPLATE/config.yml
Normal file
5
dot_oh-my-zsh/dot_github/ISSUE_TEMPLATE/config.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
blank_issues_enabled: true
|
||||
contact_links:
|
||||
- name: Get help on Discord
|
||||
url: https://discord.gg/ohmyzsh
|
||||
about: Have a quick question? Join the Discord server and ask on the appropriate channel.
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
name: Feature request
|
||||
about: Suggest a feature for Oh My Zsh
|
||||
labels: 'Type: feature'
|
||||
labels: 'Feature'
|
||||
|
||||
---
|
||||
|
||||
|
@ -11,16 +11,19 @@ an issue where no sections have been filled will be deleted without comment.
|
|||
-->
|
||||
|
||||
**Is your feature request related to a particular plugin or theme? If so, specify it.**
|
||||
The name of the plugin or theme that you would like us to improve. [...]
|
||||
The name of the plugin, theme or alias that you would like us to improve. [...]
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A description of what you want to happen.
|
||||
A description of what you want to happen. [...]
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A description of any alternative solutions or features you've considered. This can also include other plugins or aliases.
|
||||
A description of any alternative solutions or features you've considered. This can also include other plugins or themes.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here. Also if you have any PRs related to this issue that are already open that you would like us to look at.
|
||||
Add any other context, screenshots or discord conversations about the feature request here. Also if you have any PRs related to this issue that are already open that you would like us to look at.
|
||||
|
||||
**Related Issues**
|
||||
Is there any open or closed issues that is related to this feature request? If so please link them below! [...]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
name: Support
|
||||
about: Request support for any problem you're having with Oh My Zsh
|
||||
labels: 'Type: support'
|
||||
labels: 'Support'
|
||||
|
||||
---
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
## Standards checklist:
|
||||
|
||||
<!-- Fill with an x the ones that apply. Example: [x] -->
|
||||
|
||||
- [ ] The PR title is descriptive.
|
||||
- [ ] The PR doesn't replicate another PR which is already open.
|
||||
- [ ] I have read the contribution guide and followed all the instructions.
|
||||
|
|
5
dot_oh-my-zsh/dot_gitpod.Dockerfile
Normal file
5
dot_oh-my-zsh/dot_gitpod.Dockerfile
Normal file
|
@ -0,0 +1,5 @@
|
|||
FROM gitpod/workspace-full
|
||||
|
||||
RUN sudo apt-get update && \
|
||||
sudo apt-get install -y zsh && \
|
||||
sudo rm -rf /var/lib/apt/lists/*
|
9
dot_oh-my-zsh/dot_gitpod.yml
Normal file
9
dot_oh-my-zsh/dot_gitpod.yml
Normal file
|
@ -0,0 +1,9 @@
|
|||
image:
|
||||
file: .gitpod.Dockerfile
|
||||
|
||||
tasks:
|
||||
- init: |
|
||||
export EDITOR="command gp open -w" VISUAL="command gp open -w"
|
||||
cp -f /workspace/ohmyzsh/templates/zshrc.zsh-template ~/.zshrc
|
||||
ln -sf /workspace/ohmyzsh ~/.oh-my-zsh
|
||||
command: exec zsh
|
|
@ -23,15 +23,27 @@ function _omz {
|
|||
local -a cmds subcmds
|
||||
cmds=(
|
||||
'help:Usage information'
|
||||
'pr:Commands for Oh My Zsh Pull Requests'
|
||||
'plugin:Commands for Oh My Zsh plugins management'
|
||||
'pr:Commands for Oh My Zsh Pull Requests management'
|
||||
'theme:Commands for Oh My Zsh themes management'
|
||||
'update:Update Oh My Zsh'
|
||||
)
|
||||
|
||||
if (( CURRENT == 2 )); then
|
||||
_describe 'command' cmds
|
||||
elif (( CURRENT == 3 )); then
|
||||
case "$words[2]" in
|
||||
pr) subcmds=( 'test:Test a Pull Request' 'clean:Delete all Pull Request branches' )
|
||||
plugin) subcmds=('list:List plugins')
|
||||
_describe 'command' subcmds ;;
|
||||
pr) subcmds=('test:Test a Pull Request' 'clean:Delete all Pull Request branches')
|
||||
_describe 'command' subcmds ;;
|
||||
theme) subcmds=('use:Load a theme' 'list:List themes')
|
||||
_describe 'command' subcmds ;;
|
||||
esac
|
||||
elif (( CURRENT == 4 )); then
|
||||
case "$words[2]::$words[3]" in
|
||||
theme::use) compadd "$ZSH"/themes/*.zsh-theme(.N:t:r) \
|
||||
"$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::) ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
|
@ -48,22 +60,41 @@ Usage: omz <command> [options]
|
|||
Available commands:
|
||||
|
||||
help Print this help message
|
||||
pr <command> Commands for Oh My Zsh Pull Requests
|
||||
plugin <command> Manage plugins
|
||||
pr <command> Manage Oh My Zsh Pull Requests
|
||||
theme <command> Manage themes
|
||||
update Update Oh My Zsh
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
function _omz::confirm {
|
||||
# If question supplied, ask it before reading the answer
|
||||
# NOTE: uses the logname of the caller function
|
||||
if [[ -n "$1" ]]; then
|
||||
_omz::log prompt "$1" "${${functrace[1]#_}%:*}"
|
||||
fi
|
||||
|
||||
# Read one character
|
||||
read -r -k 1
|
||||
|
||||
# If no newline entered, add a newline
|
||||
if [[ "$REPLY" != $'\n' ]]; then
|
||||
echo
|
||||
fi
|
||||
}
|
||||
|
||||
function _omz::log {
|
||||
# if promptsubst is set, a message with `` or $()
|
||||
# will be run even if quoted due to `print -P`
|
||||
setopt localoptions nopromptsubst
|
||||
|
||||
# $1 = info|warn|error|debug
|
||||
# $@ = text
|
||||
# $2 = text
|
||||
# $3 = (optional) name of the logger
|
||||
|
||||
local logtype=$1
|
||||
local logname=${${functrace[1]#_}%:*}
|
||||
shift
|
||||
local logname=${3:-${${functrace[1]#_}%:*}}
|
||||
|
||||
# Don't print anything if debug is not active
|
||||
if [[ $logtype = debug && -z $_OMZ_DEBUG ]]; then
|
||||
|
@ -72,14 +103,57 @@ function _omz::log {
|
|||
|
||||
# Choose coloring based on log type
|
||||
case "$logtype" in
|
||||
prompt) print -Pn "%S%F{blue}$logname%f%s: $@" ;;
|
||||
debug) print -P "%F{white}$logname%f: $@" ;;
|
||||
info) print -P "%F{green}$logname%f: $@" ;;
|
||||
warn) print -P "%S%F{yellow}$logname%f%s: $@" ;;
|
||||
error) print -P "%S%F{red}$logname%f%s: $@" ;;
|
||||
prompt) print -Pn "%S%F{blue}$logname%f%s: $2" ;;
|
||||
debug) print -P "%F{white}$logname%f: $2" ;;
|
||||
info) print -P "%F{green}$logname%f: $2" ;;
|
||||
warn) print -P "%S%F{yellow}$logname%f%s: $2" ;;
|
||||
error) print -P "%S%F{red}$logname%f%s: $2" ;;
|
||||
esac >&2
|
||||
}
|
||||
|
||||
function _omz::plugin {
|
||||
(( $# > 0 && $+functions[_omz::plugin::$1] )) || {
|
||||
cat <<EOF
|
||||
Usage: omz plugin <command> [options]
|
||||
|
||||
Available commands:
|
||||
|
||||
list List all available Oh My Zsh plugins
|
||||
|
||||
EOF
|
||||
return 1
|
||||
}
|
||||
|
||||
local command="$1"
|
||||
shift
|
||||
|
||||
_omz::plugin::$command "$@"
|
||||
}
|
||||
|
||||
function _omz::plugin::list {
|
||||
local -a custom_plugins builtin_plugins
|
||||
custom_plugins=("$ZSH_CUSTOM"/plugins/*(-/N:t))
|
||||
builtin_plugins=("$ZSH"/plugins/*(-/N:t))
|
||||
|
||||
# If the command is being piped, print all found line by line
|
||||
if [[ ! -t 1 ]]; then
|
||||
print -l ${(q-)custom_plugins} ${(q-)builtin_plugins}
|
||||
return
|
||||
fi
|
||||
|
||||
if (( ${#custom_plugins} )); then
|
||||
print -P "%U%BCustom plugins%b%u:"
|
||||
print -l ${(q-)custom_plugins} | column
|
||||
fi
|
||||
|
||||
if (( ${#builtin_plugins} )); then
|
||||
(( ${#custom_plugins} )) && echo # add a line of separation
|
||||
|
||||
print -P "%U%BBuilt-in plugins%b%u:"
|
||||
print -l ${(q-)builtin_plugins} | column
|
||||
fi
|
||||
}
|
||||
|
||||
function _omz::pr {
|
||||
(( $# > 0 && $+functions[_omz::pr::$1] )) || {
|
||||
cat <<EOF
|
||||
|
@ -105,6 +179,24 @@ function _omz::pr::clean {
|
|||
set -e
|
||||
builtin cd -q "$ZSH"
|
||||
|
||||
# Check if there are PR branches
|
||||
local fmt branches
|
||||
fmt="%(color:bold blue)%(align:18,right)%(refname:short)%(end)%(color:reset) %(color:dim bold red)%(objectname:short)%(color:reset) %(color:yellow)%(contents:subject)"
|
||||
branches="$(command git for-each-ref --sort=-committerdate --color --format="$fmt" "refs/heads/ohmyzsh/pull-*")"
|
||||
|
||||
# Exit if there are no PR branches
|
||||
if [[ -z "$branches" ]]; then
|
||||
_omz::log info "there are no Pull Request branches to remove."
|
||||
return
|
||||
fi
|
||||
|
||||
# Print found PR branches
|
||||
echo "$branches\n"
|
||||
# Confirm before removing the branches
|
||||
_omz::confirm "do you want remove these Pull Request branches? [Y/n] "
|
||||
# Only proceed if the answer is a valid yes option
|
||||
[[ "$REPLY" != [yY$'\n'] ]] && return
|
||||
|
||||
_omz::log info "removing all Oh My Zsh Pull Request branches..."
|
||||
command git branch --list 'ohmyzsh/pull-*' | while read branch; do
|
||||
command git branch -D "$branch"
|
||||
|
@ -179,9 +271,9 @@ function _omz::pr::test {
|
|||
command zsh -l
|
||||
|
||||
# After testing, go back to the previous HEAD if the user wants
|
||||
_omz::log prompt "do you want to go back to the previous branch? [Y/n] "
|
||||
read -r -k 1
|
||||
[[ "$REPLY" = [nN] ]] && return
|
||||
_omz::confirm "do you want to go back to the previous branch? [Y/n] "
|
||||
# Only proceed if the answer is a valid yes option
|
||||
[[ "$REPLY" != [yY$'\n'] ]] && return
|
||||
|
||||
(
|
||||
set -e
|
||||
|
@ -193,3 +285,76 @@ function _omz::pr::test {
|
|||
}
|
||||
)
|
||||
}
|
||||
|
||||
function _omz::theme {
|
||||
(( $# > 0 && $+functions[_omz::theme::$1] )) || {
|
||||
cat <<EOF
|
||||
Usage: omz theme <command> [options]
|
||||
|
||||
Available commands:
|
||||
|
||||
list List all available Oh My Zsh themes
|
||||
use <theme> Load an Oh My Zsh theme
|
||||
|
||||
EOF
|
||||
return 1
|
||||
}
|
||||
|
||||
local command="$1"
|
||||
shift
|
||||
|
||||
_omz::theme::$command "$@"
|
||||
}
|
||||
|
||||
function _omz::theme::list {
|
||||
local -a custom_themes builtin_themes
|
||||
custom_themes=("$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::))
|
||||
builtin_themes=("$ZSH"/themes/*.zsh-theme(.N:t:r))
|
||||
|
||||
# If the command is being piped, print all found line by line
|
||||
if [[ ! -t 1 ]]; then
|
||||
print -l ${(q-)custom_themes} ${(q-)builtin_themes}
|
||||
return
|
||||
fi
|
||||
|
||||
if (( ${#custom_themes} )); then
|
||||
print -P "%U%BCustom themes%b%u:"
|
||||
print -l ${(q-)custom_themes} | column
|
||||
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
|
||||
fi
|
||||
}
|
||||
|
||||
function _omz::theme::use {
|
||||
if [[ -z "$1" ]]; then
|
||||
echo >&2 "Usage: omz theme use <theme>"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Respect compatibility with old lookup order
|
||||
if [[ -f "$ZSH_CUSTOM/$1.zsh-theme" ]]; then
|
||||
source "$ZSH_CUSTOM/$1.zsh-theme"
|
||||
elif [[ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]]; then
|
||||
source "$ZSH_CUSTOM/themes/$1.zsh-theme"
|
||||
elif [[ -f "$ZSH/themes/$1.zsh-theme" ]]; then
|
||||
source "$ZSH/themes/$1.zsh-theme"
|
||||
else
|
||||
_omz::log error "theme '$1' not found"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function _omz::update {
|
||||
# Run update script
|
||||
env ZSH="$ZSH" sh "$ZSH/tools/upgrade.sh"
|
||||
# Update last updated file
|
||||
zmodload zsh/datetime
|
||||
echo "LAST_EPOCH=$(( EPOCHSECONDS / 60 / 60 / 24 ))" >! "${ZSH_CACHE_DIR}/.zsh-update"
|
||||
# Remove update lock if it exists
|
||||
command rm -rf "$ZSH/log/update.lock"
|
||||
}
|
||||
|
|
|
@ -60,16 +60,15 @@ zstyle '*' single-ignored show
|
|||
|
||||
if [[ $COMPLETION_WAITING_DOTS = true ]]; then
|
||||
expand-or-complete-with-dots() {
|
||||
# toggle line-wrapping off and back on again
|
||||
[[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti rmam
|
||||
print -Pn "%{%F{red}......%f%}"
|
||||
[[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti smam
|
||||
|
||||
print -Pn "%F{red}…%f"
|
||||
zle expand-or-complete
|
||||
zle redisplay
|
||||
}
|
||||
zle -N expand-or-complete-with-dots
|
||||
bindkey "^I" expand-or-complete-with-dots
|
||||
# Set the function as the default tab completion widget
|
||||
bindkey -M emacs "^I" expand-or-complete-with-dots
|
||||
bindkey -M viins "^I" expand-or-complete-with-dots
|
||||
bindkey -M vicmd "^I" expand-or-complete-with-dots
|
||||
fi
|
||||
|
||||
# automatically load bash completion functions
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
function zsh_stats() {
|
||||
fc -l 1 | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n20
|
||||
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 -n20 | column -c3 -s " " -t | nl
|
||||
}
|
||||
|
||||
function uninstall_oh_my_zsh() {
|
||||
|
@ -7,7 +9,16 @@ function uninstall_oh_my_zsh() {
|
|||
}
|
||||
|
||||
function upgrade_oh_my_zsh() {
|
||||
if (( $+functions[_omz::update] )); then
|
||||
echo >&2 "${fg[yellow]}Note: \`$0\` is deprecated. Use \`omz update\` instead.$reset_color"
|
||||
fi
|
||||
|
||||
# Run update script
|
||||
env ZSH="$ZSH" sh "$ZSH/tools/upgrade.sh"
|
||||
# Update last updated file
|
||||
zmodload zsh/datetime
|
||||
echo "LAST_EPOCH=$(( EPOCHSECONDS / 60 / 60 / 24 ))" >! "${ZSH_CACHE_DIR}/.zsh-update"
|
||||
# Remove update lock if it exists
|
||||
command rm -rf "$ZSH/log/update.lock"
|
||||
}
|
||||
|
||||
|
@ -123,6 +134,7 @@ zmodload zsh/langinfo
|
|||
# -P causes spaces to be encoded as '%20' instead of '+'
|
||||
function omz_urlencode() {
|
||||
emulate -L zsh
|
||||
local -a opts
|
||||
zparseopts -D -E -a opts r m P
|
||||
|
||||
local in_str=$1
|
||||
|
|
|
@ -1,9 +1,20 @@
|
|||
# The git prompt's git commands are read-only and should not interfere with
|
||||
# other processes. This environment variable is equivalent to running with `git
|
||||
# --no-optional-locks`, but falls back gracefully for older versions of git.
|
||||
# See git(1) for and git-status(1) for a description of that flag.
|
||||
#
|
||||
# We wrap in a local function instead of exporting the variable directly in
|
||||
# order to avoid interfering with manually-run git commands by the user.
|
||||
function __git_prompt_git() {
|
||||
GIT_OPTIONAL_LOCKS=0 command git "$@"
|
||||
}
|
||||
|
||||
# Outputs current branch info in prompt format
|
||||
function git_prompt_info() {
|
||||
local ref
|
||||
if [[ "$(command git config --get oh-my-zsh.hide-status 2>/dev/null)" != "1" ]]; then
|
||||
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
|
||||
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0
|
||||
if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-status 2>/dev/null)" != "1" ]]; then
|
||||
ref=$(__git_prompt_git symbolic-ref HEAD 2> /dev/null) || \
|
||||
ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) || return 0
|
||||
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
||||
fi
|
||||
}
|
||||
|
@ -13,11 +24,11 @@ function parse_git_dirty() {
|
|||
local STATUS
|
||||
local -a FLAGS
|
||||
FLAGS=('--porcelain')
|
||||
if [[ "$(command git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then
|
||||
if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then
|
||||
if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then
|
||||
if [[ "${DISABLE_UNTRACKED_FILES_DIRTY:-}" == "true" ]]; then
|
||||
FLAGS+='--untracked-files=no'
|
||||
fi
|
||||
case "$GIT_STATUS_IGNORE_SUBMODULES" in
|
||||
case "${GIT_STATUS_IGNORE_SUBMODULES:-}" in
|
||||
git)
|
||||
# let git decide (this respects per-repo config in .gitmodules)
|
||||
;;
|
||||
|
@ -27,7 +38,7 @@ function parse_git_dirty() {
|
|||
FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}"
|
||||
;;
|
||||
esac
|
||||
STATUS=$(command git status ${FLAGS} 2> /dev/null | tail -n1)
|
||||
STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n1)
|
||||
fi
|
||||
if [[ -n $STATUS ]]; then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
|
||||
|
@ -39,10 +50,10 @@ function parse_git_dirty() {
|
|||
# Gets the difference between the local and remote branches
|
||||
function git_remote_status() {
|
||||
local remote ahead behind git_remote_status git_remote_status_detailed
|
||||
remote=${$(command git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/}
|
||||
remote=${$(__git_prompt_git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/}
|
||||
if [[ -n ${remote} ]]; then
|
||||
ahead=$(command git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
|
||||
behind=$(command git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
|
||||
ahead=$(__git_prompt_git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
|
||||
behind=$(__git_prompt_git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
|
||||
|
||||
if [[ $ahead -eq 0 ]] && [[ $behind -eq 0 ]]; then
|
||||
git_remote_status="$ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE"
|
||||
|
@ -71,11 +82,11 @@ function git_remote_status() {
|
|||
# it's not a symbolic ref, but in a Git repo.
|
||||
function git_current_branch() {
|
||||
local ref
|
||||
ref=$(command git symbolic-ref --quiet HEAD 2> /dev/null)
|
||||
ref=$(__git_prompt_git symbolic-ref --quiet HEAD 2> /dev/null)
|
||||
local ret=$?
|
||||
if [[ $ret != 0 ]]; then
|
||||
[[ $ret == 128 ]] && return # no git repo.
|
||||
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
|
||||
ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) || return
|
||||
fi
|
||||
echo ${ref#refs/heads/}
|
||||
}
|
||||
|
@ -83,8 +94,8 @@ function git_current_branch() {
|
|||
|
||||
# Gets the number of commits ahead from remote
|
||||
function git_commits_ahead() {
|
||||
if command git rev-parse --git-dir &>/dev/null; then
|
||||
local commits="$(git rev-list --count @{upstream}..HEAD 2>/dev/null)"
|
||||
if __git_prompt_git rev-parse --git-dir &>/dev/null; then
|
||||
local commits="$(__git_prompt_git rev-list --count @{upstream}..HEAD 2>/dev/null)"
|
||||
if [[ -n "$commits" && "$commits" != 0 ]]; then
|
||||
echo "$ZSH_THEME_GIT_COMMITS_AHEAD_PREFIX$commits$ZSH_THEME_GIT_COMMITS_AHEAD_SUFFIX"
|
||||
fi
|
||||
|
@ -93,8 +104,8 @@ function git_commits_ahead() {
|
|||
|
||||
# Gets the number of commits behind remote
|
||||
function git_commits_behind() {
|
||||
if command git rev-parse --git-dir &>/dev/null; then
|
||||
local commits="$(git rev-list --count HEAD..@{upstream} 2>/dev/null)"
|
||||
if __git_prompt_git rev-parse --git-dir &>/dev/null; then
|
||||
local commits="$(__git_prompt_git rev-list --count HEAD..@{upstream} 2>/dev/null)"
|
||||
if [[ -n "$commits" && "$commits" != 0 ]]; then
|
||||
echo "$ZSH_THEME_GIT_COMMITS_BEHIND_PREFIX$commits$ZSH_THEME_GIT_COMMITS_BEHIND_SUFFIX"
|
||||
fi
|
||||
|
@ -103,21 +114,21 @@ function git_commits_behind() {
|
|||
|
||||
# Outputs if current branch is ahead of remote
|
||||
function git_prompt_ahead() {
|
||||
if [[ -n "$(command git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then
|
||||
if [[ -n "$(__git_prompt_git rev-list origin/$(git_current_branch)..HEAD 2> /dev/null)" ]]; then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
|
||||
fi
|
||||
}
|
||||
|
||||
# Outputs if current branch is behind remote
|
||||
function git_prompt_behind() {
|
||||
if [[ -n "$(command git rev-list HEAD..origin/$(git_current_branch) 2> /dev/null)" ]]; then
|
||||
if [[ -n "$(__git_prompt_git rev-list HEAD..origin/$(git_current_branch) 2> /dev/null)" ]]; then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_BEHIND"
|
||||
fi
|
||||
}
|
||||
|
||||
# Outputs if current branch exists on remote or not
|
||||
function git_prompt_remote() {
|
||||
if [[ -n "$(command git show-ref origin/$(git_current_branch) 2> /dev/null)" ]]; then
|
||||
if [[ -n "$(__git_prompt_git show-ref origin/$(git_current_branch) 2> /dev/null)" ]]; then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_REMOTE_EXISTS"
|
||||
else
|
||||
echo "$ZSH_THEME_GIT_PROMPT_REMOTE_MISSING"
|
||||
|
@ -127,84 +138,130 @@ function git_prompt_remote() {
|
|||
# Formats prompt string for current git commit short SHA
|
||||
function git_prompt_short_sha() {
|
||||
local SHA
|
||||
SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
|
||||
SHA=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
|
||||
}
|
||||
|
||||
# Formats prompt string for current git commit long SHA
|
||||
function git_prompt_long_sha() {
|
||||
local SHA
|
||||
SHA=$(command git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
|
||||
SHA=$(__git_prompt_git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
|
||||
}
|
||||
|
||||
# Get the status of the working tree
|
||||
function git_prompt_status() {
|
||||
local INDEX STATUS
|
||||
INDEX=$(command git status --porcelain -b 2> /dev/null)
|
||||
STATUS=""
|
||||
if $(echo "$INDEX" | command grep -E '^\?\? ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
|
||||
[[ "$(__git_prompt_git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]] && return
|
||||
|
||||
# Maps a git status prefix to an internal constant
|
||||
# This cannot use the prompt constants, as they may be empty
|
||||
local -A prefix_constant_map
|
||||
prefix_constant_map=(
|
||||
'\?\? ' 'UNTRACKED'
|
||||
'A ' 'ADDED'
|
||||
'M ' 'ADDED'
|
||||
'MM ' 'ADDED'
|
||||
' M ' 'MODIFIED'
|
||||
'AM ' 'MODIFIED'
|
||||
' T ' 'MODIFIED'
|
||||
'R ' 'RENAMED'
|
||||
' D ' 'DELETED'
|
||||
'D ' 'DELETED'
|
||||
'UU ' 'UNMERGED'
|
||||
'ahead' 'AHEAD'
|
||||
'behind' 'BEHIND'
|
||||
'diverged' 'DIVERGED'
|
||||
'stashed' 'STASHED'
|
||||
)
|
||||
|
||||
# Maps the internal constant to the prompt theme
|
||||
local -A constant_prompt_map
|
||||
constant_prompt_map=(
|
||||
'UNTRACKED' "$ZSH_THEME_GIT_PROMPT_UNTRACKED"
|
||||
'ADDED' "$ZSH_THEME_GIT_PROMPT_ADDED"
|
||||
'MODIFIED' "$ZSH_THEME_GIT_PROMPT_MODIFIED"
|
||||
'RENAMED' "$ZSH_THEME_GIT_PROMPT_RENAMED"
|
||||
'DELETED' "$ZSH_THEME_GIT_PROMPT_DELETED"
|
||||
'UNMERGED' "$ZSH_THEME_GIT_PROMPT_UNMERGED"
|
||||
'AHEAD' "$ZSH_THEME_GIT_PROMPT_AHEAD"
|
||||
'BEHIND' "$ZSH_THEME_GIT_PROMPT_BEHIND"
|
||||
'DIVERGED' "$ZSH_THEME_GIT_PROMPT_DIVERGED"
|
||||
'STASHED' "$ZSH_THEME_GIT_PROMPT_STASHED"
|
||||
)
|
||||
|
||||
# The order that the prompt displays should be added to the prompt
|
||||
local status_constants
|
||||
status_constants=(
|
||||
UNTRACKED ADDED MODIFIED RENAMED DELETED
|
||||
STASHED UNMERGED AHEAD BEHIND DIVERGED
|
||||
)
|
||||
|
||||
local status_text="$(__git_prompt_git status --porcelain -b 2> /dev/null)"
|
||||
|
||||
# Don't continue on a catastrophic failure
|
||||
if [[ $? -eq 128 ]]; then
|
||||
return 1
|
||||
fi
|
||||
if $(echo "$INDEX" | grep '^A ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS"
|
||||
elif $(echo "$INDEX" | grep '^M ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS"
|
||||
elif $(echo "$INDEX" | grep '^MM ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS"
|
||||
|
||||
# A lookup table of each git status encountered
|
||||
local -A statuses_seen
|
||||
|
||||
if __git_prompt_git rev-parse --verify refs/stash &>/dev/null; then
|
||||
statuses_seen[STASHED]=1
|
||||
fi
|
||||
if $(echo "$INDEX" | grep '^ M ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
|
||||
elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
|
||||
elif $(echo "$INDEX" | grep '^MM ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
|
||||
elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
|
||||
|
||||
local status_lines
|
||||
status_lines=("${(@f)${status_text}}")
|
||||
|
||||
# If the tracking line exists, get and parse it
|
||||
if [[ "$status_lines[1]" =~ "^## [^ ]+ \[(.*)\]" ]]; then
|
||||
local branch_statuses
|
||||
branch_statuses=("${(@s/,/)match}")
|
||||
for branch_status in $branch_statuses; do
|
||||
if [[ ! $branch_status =~ "(behind|diverged|ahead) ([0-9]+)?" ]]; then
|
||||
continue
|
||||
fi
|
||||
local last_parsed_status=$prefix_constant_map[$match[1]]
|
||||
statuses_seen[$last_parsed_status]=$match[2]
|
||||
done
|
||||
fi
|
||||
if $(echo "$INDEX" | grep '^R ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_RENAMED$STATUS"
|
||||
fi
|
||||
if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
|
||||
elif $(echo "$INDEX" | grep '^D ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
|
||||
elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
|
||||
fi
|
||||
if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_STASHED$STATUS"
|
||||
fi
|
||||
if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS"
|
||||
fi
|
||||
if $(echo "$INDEX" | grep '^## [^ ]\+ .*ahead' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_AHEAD$STATUS"
|
||||
fi
|
||||
if $(echo "$INDEX" | grep '^## [^ ]\+ .*behind' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_BEHIND$STATUS"
|
||||
fi
|
||||
if $(echo "$INDEX" | grep '^## [^ ]\+ .*diverged' &> /dev/null); then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_DIVERGED$STATUS"
|
||||
fi
|
||||
echo $STATUS
|
||||
|
||||
# For each status prefix, do a regex comparison
|
||||
for status_prefix in ${(k)prefix_constant_map}; do
|
||||
local status_constant="${prefix_constant_map[$status_prefix]}"
|
||||
local status_regex=$'(^|\n)'"$status_prefix"
|
||||
|
||||
if [[ "$status_text" =~ $status_regex ]]; then
|
||||
statuses_seen[$status_constant]=1
|
||||
fi
|
||||
done
|
||||
|
||||
# Display the seen statuses in the order specified
|
||||
local status_prompt
|
||||
for status_constant in $status_constants; do
|
||||
if (( ${+statuses_seen[$status_constant]} )); then
|
||||
local next_display=$constant_prompt_map[$status_constant]
|
||||
status_prompt="$next_display$status_prompt"
|
||||
fi
|
||||
done
|
||||
|
||||
echo $status_prompt
|
||||
}
|
||||
|
||||
# Outputs the name of the current user
|
||||
# Usage example: $(git_current_user_name)
|
||||
function git_current_user_name() {
|
||||
command git config user.name 2>/dev/null
|
||||
__git_prompt_git config user.name 2>/dev/null
|
||||
}
|
||||
|
||||
# Outputs the email of the current user
|
||||
# Usage example: $(git_current_user_email)
|
||||
function git_current_user_email() {
|
||||
command git config user.email 2>/dev/null
|
||||
__git_prompt_git config user.email 2>/dev/null
|
||||
}
|
||||
|
||||
# Output the name of the root directory of the git repository
|
||||
# Usage example: $(git_repo_name)
|
||||
function git_repo_name() {
|
||||
local repo_path
|
||||
if repo_path="$(git rev-parse --show-toplevel 2>/dev/null)" && [[ -n "$repo_path" ]]; then
|
||||
if repo_path="$(__git_prompt_git rev-parse --show-toplevel 2>/dev/null)" && [[ -n "$repo_path" ]]; then
|
||||
echo ${repo_path:t}
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -6,7 +6,8 @@ function omz_history {
|
|||
if [[ -n "$clear" ]]; then
|
||||
# if -c provided, clobber the history file
|
||||
echo -n >| "$HISTFILE"
|
||||
echo >&2 History file deleted. Reload the session to see its effects.
|
||||
fc -p "$HISTFILE"
|
||||
echo >&2 History file deleted.
|
||||
elif [[ -n "$list" ]]; then
|
||||
# if -l provided, run as if calling `fc' directly
|
||||
builtin fc "$@"
|
||||
|
|
|
@ -15,55 +15,100 @@ if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
|
|||
zle -N zle-line-finish
|
||||
fi
|
||||
|
||||
bindkey -e # Use emacs key bindings
|
||||
# Use emacs key bindings
|
||||
bindkey -e
|
||||
|
||||
# [PageUp] - Up a line of history
|
||||
if [[ -n "${terminfo[kpp]}" ]]; then
|
||||
bindkey -M emacs "${terminfo[kpp]}" up-line-or-history
|
||||
bindkey -M viins "${terminfo[kpp]}" up-line-or-history
|
||||
bindkey -M vicmd "${terminfo[kpp]}" up-line-or-history
|
||||
fi
|
||||
# [PageDown] - Down a line of history
|
||||
if [[ -n "${terminfo[knp]}" ]]; then
|
||||
bindkey -M emacs "${terminfo[knp]}" down-line-or-history
|
||||
bindkey -M viins "${terminfo[knp]}" down-line-or-history
|
||||
bindkey -M vicmd "${terminfo[knp]}" down-line-or-history
|
||||
fi
|
||||
|
||||
# Start typing + [Up-Arrow] - fuzzy find history forward
|
||||
if [[ -n "${terminfo[kcuu1]}" ]]; then
|
||||
autoload -U up-line-or-beginning-search
|
||||
zle -N up-line-or-beginning-search
|
||||
|
||||
bindkey -M emacs "${terminfo[kcuu1]}" up-line-or-beginning-search
|
||||
bindkey -M viins "${terminfo[kcuu1]}" up-line-or-beginning-search
|
||||
bindkey -M vicmd "${terminfo[kcuu1]}" up-line-or-beginning-search
|
||||
fi
|
||||
# Start typing + [Down-Arrow] - fuzzy find history backward
|
||||
if [[ -n "${terminfo[kcud1]}" ]]; then
|
||||
autoload -U down-line-or-beginning-search
|
||||
zle -N down-line-or-beginning-search
|
||||
|
||||
bindkey -M emacs "${terminfo[kcud1]}" down-line-or-beginning-search
|
||||
bindkey -M viins "${terminfo[kcud1]}" down-line-or-beginning-search
|
||||
bindkey -M vicmd "${terminfo[kcud1]}" down-line-or-beginning-search
|
||||
fi
|
||||
|
||||
# [Home] - Go to beginning of line
|
||||
if [[ -n "${terminfo[khome]}" ]]; then
|
||||
bindkey -M emacs "${terminfo[khome]}" beginning-of-line
|
||||
bindkey -M viins "${terminfo[khome]}" beginning-of-line
|
||||
bindkey -M vicmd "${terminfo[khome]}" beginning-of-line
|
||||
fi
|
||||
# [End] - Go to end of line
|
||||
if [[ -n "${terminfo[kend]}" ]]; then
|
||||
bindkey -M emacs "${terminfo[kend]}" end-of-line
|
||||
bindkey -M viins "${terminfo[kend]}" end-of-line
|
||||
bindkey -M vicmd "${terminfo[kend]}" end-of-line
|
||||
fi
|
||||
|
||||
# [Shift-Tab] - move through the completion menu backwards
|
||||
if [[ -n "${terminfo[kcbt]}" ]]; then
|
||||
bindkey -M emacs "${terminfo[kcbt]}" reverse-menu-complete
|
||||
bindkey -M viins "${terminfo[kcbt]}" reverse-menu-complete
|
||||
bindkey -M vicmd "${terminfo[kcbt]}" reverse-menu-complete
|
||||
fi
|
||||
|
||||
# [Backspace] - delete backward
|
||||
bindkey -M emacs '^?' backward-delete-char
|
||||
bindkey -M viins '^?' backward-delete-char
|
||||
bindkey -M vicmd '^?' backward-delete-char
|
||||
# [Delete] - delete forward
|
||||
if [[ -n "${terminfo[kdch1]}" ]]; then
|
||||
bindkey -M emacs "${terminfo[kdch1]}" delete-char
|
||||
bindkey -M viins "${terminfo[kdch1]}" delete-char
|
||||
bindkey -M vicmd "${terminfo[kdch1]}" delete-char
|
||||
else
|
||||
bindkey -M emacs "^[[3~" delete-char
|
||||
bindkey -M viins "^[[3~" delete-char
|
||||
bindkey -M vicmd "^[[3~" delete-char
|
||||
|
||||
bindkey -M emacs "^[3;5~" delete-char
|
||||
bindkey -M viins "^[3;5~" delete-char
|
||||
bindkey -M vicmd "^[3;5~" delete-char
|
||||
fi
|
||||
|
||||
# [Ctrl-Delete] - delete whole forward-word
|
||||
bindkey -M emacs '^[[3;5~' kill-word
|
||||
bindkey -M viins '^[[3;5~' kill-word
|
||||
bindkey -M vicmd '^[[3;5~' kill-word
|
||||
|
||||
# [Ctrl-RightArrow] - move forward one word
|
||||
bindkey -M emacs '^[[1;5C' forward-word
|
||||
bindkey -M viins '^[[1;5C' forward-word
|
||||
bindkey -M vicmd '^[[1;5C' forward-word
|
||||
# [Ctrl-LeftArrow] - move backward one word
|
||||
bindkey -M emacs '^[[1;5D' backward-word
|
||||
bindkey -M viins '^[[1;5D' backward-word
|
||||
bindkey -M vicmd '^[[1;5D' backward-word
|
||||
|
||||
|
||||
bindkey '\ew' kill-region # [Esc-w] - Kill from the cursor to the mark
|
||||
bindkey -s '\el' 'ls\n' # [Esc-l] - run command: ls
|
||||
bindkey '^r' history-incremental-search-backward # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line.
|
||||
if [[ "${terminfo[kpp]}" != "" ]]; then
|
||||
bindkey "${terminfo[kpp]}" up-line-or-history # [PageUp] - Up a line of history
|
||||
fi
|
||||
if [[ "${terminfo[knp]}" != "" ]]; then
|
||||
bindkey "${terminfo[knp]}" down-line-or-history # [PageDown] - Down a line of history
|
||||
fi
|
||||
bindkey ' ' magic-space # [Space] - don't do history expansion
|
||||
|
||||
# start typing + [Up-Arrow] - fuzzy find history forward
|
||||
if [[ "${terminfo[kcuu1]}" != "" ]]; then
|
||||
autoload -U up-line-or-beginning-search
|
||||
zle -N up-line-or-beginning-search
|
||||
bindkey "${terminfo[kcuu1]}" up-line-or-beginning-search
|
||||
fi
|
||||
# start typing + [Down-Arrow] - fuzzy find history backward
|
||||
if [[ "${terminfo[kcud1]}" != "" ]]; then
|
||||
autoload -U down-line-or-beginning-search
|
||||
zle -N down-line-or-beginning-search
|
||||
bindkey "${terminfo[kcud1]}" down-line-or-beginning-search
|
||||
fi
|
||||
|
||||
if [[ "${terminfo[khome]}" != "" ]]; then
|
||||
bindkey "${terminfo[khome]}" beginning-of-line # [Home] - Go to beginning of line
|
||||
fi
|
||||
if [[ "${terminfo[kend]}" != "" ]]; then
|
||||
bindkey "${terminfo[kend]}" end-of-line # [End] - Go to end of line
|
||||
fi
|
||||
|
||||
bindkey ' ' magic-space # [Space] - do history expansion
|
||||
|
||||
bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - move forward one word
|
||||
bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word
|
||||
|
||||
if [[ "${terminfo[kcbt]}" != "" ]]; then
|
||||
bindkey "${terminfo[kcbt]}" reverse-menu-complete # [Shift-Tab] - move through the completion menu backwards
|
||||
fi
|
||||
|
||||
bindkey '^?' backward-delete-char # [Backspace] - delete backward
|
||||
if [[ "${terminfo[kdch1]}" != "" ]]; then
|
||||
bindkey "${terminfo[kdch1]}" delete-char # [Delete] - delete forward
|
||||
else
|
||||
bindkey "^[[3~" delete-char
|
||||
bindkey "^[3;5~" delete-char
|
||||
bindkey "\e[3~" delete-char
|
||||
fi
|
||||
|
||||
# Edit the current command line in $EDITOR
|
||||
autoload -U edit-command-line
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
# get the node.js version
|
||||
# get the nvm-controlled node.js version
|
||||
function nvm_prompt_info() {
|
||||
[[ -f "$NVM_DIR/nvm.sh" ]] || return
|
||||
local nvm_prompt
|
||||
nvm_prompt=$(node -v 2>/dev/null)
|
||||
[[ "${nvm_prompt}x" == "x" ]] && return
|
||||
nvm_prompt=${nvm_prompt:1}
|
||||
which nvm &>/dev/null || return
|
||||
local nvm_prompt=${$(nvm current)#v}
|
||||
echo "${ZSH_THEME_NVM_PROMPT_PREFIX}${nvm_prompt}${ZSH_THEME_NVM_PROMPT_SUFFIX}"
|
||||
}
|
||||
|
|
|
@ -17,17 +17,17 @@ function title {
|
|||
: ${2=$1}
|
||||
|
||||
case "$TERM" in
|
||||
cygwin|xterm*|putty*|rxvt*|konsole*|ansi)
|
||||
print -Pn "\e]2;$2:q\a" # set window name
|
||||
print -Pn "\e]1;$1:q\a" # set tab name
|
||||
cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*)
|
||||
print -Pn "\e]2;${2:q}\a" # set window name
|
||||
print -Pn "\e]1;${1:q}\a" # set tab name
|
||||
;;
|
||||
screen*|tmux*)
|
||||
print -Pn "\ek$1:q\e\\" # set screen hardstatus
|
||||
print -Pn "\ek${1:q}\e\\" # set screen hardstatus
|
||||
;;
|
||||
*)
|
||||
if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
|
||||
print -Pn "\e]2;$2:q\a" # set window name
|
||||
print -Pn "\e]1;$1:q\a" # set tab name
|
||||
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
|
||||
|
@ -42,7 +42,7 @@ function title {
|
|||
}
|
||||
|
||||
ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
|
||||
ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~"
|
||||
ZSH_THEME_TERM_TITLE_IDLE="%n@%m:%~"
|
||||
# Avoid duplication of directory in terminals with independent dir display
|
||||
if [[ "$TERM_PROGRAM" == Apple_Terminal ]]; then
|
||||
ZSH_THEME_TERM_TITLE_IDLE="%n@%m"
|
||||
|
@ -50,13 +50,13 @@ fi
|
|||
|
||||
# Runs before showing the prompt
|
||||
function omz_termsupport_precmd {
|
||||
[[ "$DISABLE_AUTO_TITLE" == true ]] && return
|
||||
[[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return
|
||||
title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
|
||||
}
|
||||
|
||||
# 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
|
||||
|
|
|
@ -39,6 +39,11 @@ if [[ "$DISABLE_LS_COLORS" != "true" ]]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
# enable diff color if possible.
|
||||
if command diff --color . . &>/dev/null; then
|
||||
alias diff='diff --color'
|
||||
fi
|
||||
|
||||
setopt auto_cd
|
||||
setopt multios
|
||||
setopt prompt_subst
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
# If ZSH is not defined, use the current script's directory.
|
||||
[[ -z "$ZSH" ]] && export ZSH="${${(%):-%x}:a:h}"
|
||||
|
||||
# Set ZSH_CACHE_DIR to the path where cache files should be created
|
||||
# or else we will use the default cache/
|
||||
if [[ -z "$ZSH_CACHE_DIR" ]]; then
|
||||
|
@ -6,7 +9,7 @@ fi
|
|||
|
||||
# Check for updates on initial load...
|
||||
if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then
|
||||
env ZSH=$ZSH ZSH_CACHE_DIR=$ZSH_CACHE_DIR DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh
|
||||
source $ZSH/tools/check_for_upgrade.sh
|
||||
fi
|
||||
|
||||
# Initializes Oh My Zsh
|
||||
|
|
|
@ -212,8 +212,8 @@ if (( $+commands[xdg-open] )); then
|
|||
if [[ -z "$infos" ]]; then
|
||||
return
|
||||
fi
|
||||
repo="$(grep '^Repo' <<< "$infos" | grep -oP '[^ ]+$')"
|
||||
arch="$(grep '^Arch' <<< "$infos" | grep -oP '[^ ]+$')"
|
||||
repo="$(grep -m 1 '^Repo' <<< "$infos" | grep -oP '[^ ]+$')"
|
||||
arch="$(grep -m 1 '^Arch' <<< "$infos" | grep -oP '[^ ]+$')"
|
||||
xdg-open "https://www.archlinux.org/packages/$repo/$arch/$pkg/" &>/dev/null
|
||||
}
|
||||
fi
|
||||
|
|
|
@ -15,6 +15,13 @@ plugins=(... aws)
|
|||
It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI.
|
||||
Run `asp` without arguments to clear the profile.
|
||||
|
||||
* `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
|
||||
[official guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html).
|
||||
Run `acp` without arguments to clear the profile.
|
||||
|
||||
* `agp`: gets the current value of `$AWS_PROFILE`.
|
||||
|
||||
* `aws_change_access_key`: changes the AWS access key of a profile.
|
||||
|
@ -33,6 +40,36 @@ plugins=(... aws)
|
|||
The plugin creates an `aws_prompt_info` function that you can use in your theme, which displays
|
||||
the current `$AWS_PROFILE`. It uses two variables to control how that is shown:
|
||||
|
||||
- ZSH_THEME_AWS_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to `<aws:`.
|
||||
* ZSH_THEME_AWS_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to `<aws:`.
|
||||
|
||||
- ZSH_THEME_AWS_SUFFIX: sets the suffix of the AWS_PROFILE. Defaults to `>`.
|
||||
* ZSH_THEME_AWS_SUFFIX: sets the suffix of the AWS_PROFILE. Defaults to `>`.
|
||||
|
||||
## Configuration
|
||||
|
||||
[Configuration and credential file settings](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) by AWS
|
||||
|
||||
### Scenario: IAM roles with a source profile and MFA authentication
|
||||
|
||||
Source profile credentials in `~/.aws/credentials`:
|
||||
|
||||
```
|
||||
[source-profile-name]
|
||||
aws_access_key_id = ...
|
||||
aws_secret_access_key = ...
|
||||
```
|
||||
|
||||
Role configuration in `~/.aws/config`:
|
||||
|
||||
```
|
||||
[profile source-profile-name]
|
||||
mfa_serial = arn:aws:iam::111111111111:mfa/myuser
|
||||
region = us-east-1
|
||||
output = json
|
||||
|
||||
[profile profile-with-role]
|
||||
role_arn = arn:aws:iam::9999999999999:role/myrole
|
||||
mfa_serial = arn:aws:iam::111111111111:mfa/myuser
|
||||
source_profile = source-profile-name
|
||||
region = us-east-1
|
||||
output = json
|
||||
```
|
||||
|
|
|
@ -23,6 +23,99 @@ function asp() {
|
|||
export AWS_EB_PROFILE=$1
|
||||
}
|
||||
|
||||
# AWS profile switch
|
||||
function acp() {
|
||||
if [[ -z "$1" ]]; then
|
||||
unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE
|
||||
unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN
|
||||
echo AWS profile cleared.
|
||||
return
|
||||
fi
|
||||
|
||||
local -a available_profiles
|
||||
available_profiles=($(aws_profiles))
|
||||
if [[ -z "${available_profiles[(r)$1]}" ]]; then
|
||||
echo "${fg[red]}Profile '$1' not found in '${AWS_CONFIG_FILE:-$HOME/.aws/config}'" >&2
|
||||
echo "Available profiles: ${(j:, :)available_profiles:-no profiles found}${reset_color}" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local profile="$1"
|
||||
|
||||
# Get fallback credentials for if the aws command fails or no command is run
|
||||
local aws_access_key_id="$(aws configure get aws_access_key_id --profile $profile)"
|
||||
local aws_secret_access_key="$(aws configure get aws_secret_access_key --profile $profile)"
|
||||
local aws_session_token="$(aws configure get aws_session_token --profile $profile)"
|
||||
|
||||
|
||||
# First, if the profile has MFA configured, lets get the token and session duration
|
||||
local mfa_serial="$(aws configure get mfa_serial --profile $profile)"
|
||||
|
||||
if [[ -n "$mfa_serial" ]]; then
|
||||
local -a mfa_opt
|
||||
local mfa_token sess_duration
|
||||
echo -n "Please enter your MFA token for $mfa_serial: "
|
||||
read -r mfa_token
|
||||
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
|
||||
mfa_opt=(--serial-number "$mfa_serial" --token-code "$mfa_token" --duration-seconds "${sess_duration:-3600}")
|
||||
|
||||
# Now see whether we need to just MFA for the current role, or assume a different one
|
||||
local role_arn="$(aws configure get role_arn --profile $profile)"
|
||||
|
||||
if [[ -n "$role_arn" ]]; then
|
||||
# Means we need to assume a specified role
|
||||
aws_command=(aws sts assume-role --role-arn "$role_arn" "${mfa_opt[@]}")
|
||||
|
||||
# Check whether external_id is configured to use while assuming the role
|
||||
local external_id="$(aws configure get external_id --profile "$profile")"
|
||||
if [[ -n "$external_id" ]]; then
|
||||
aws_command+=(--external-id "$external_id")
|
||||
fi
|
||||
|
||||
# Get source profile to use to assume role
|
||||
local source_profile="$(aws configure get source_profile --profile "$profile")"
|
||||
aws_command+=(--profile="${source_profile:-profile}" --role-session-name "${source_profile:-profile}")
|
||||
|
||||
echo "Assuming role $role_arn using profile ${source_profile:-profile}"
|
||||
else
|
||||
# Means we only need to do MFA
|
||||
aws_command=(aws sts get-session-token --profile="$profile" "${mfa_opt[@]}")
|
||||
echo "Obtaining session token for profile $profile"
|
||||
fi
|
||||
|
||||
# Format output of aws command for easier processing
|
||||
aws_command+=(--query '[Credentials.AccessKeyId,Credentials.SecretAccessKey,Credentials.SessionToken]' --output text)
|
||||
|
||||
# Run the aws command to obtain credentials
|
||||
local -a credentials
|
||||
credentials=(${(ps:\t:)"$(${aws_command[@]})"})
|
||||
|
||||
if [[ -n "$credentials" ]]; then
|
||||
aws_access_key_id="${credentials[1]}"
|
||||
aws_secret_access_key="${credentials[2]}"
|
||||
aws_session_token="${credentials[3]}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Switch to AWS profile
|
||||
if [[ -n "${aws_access_key_id}" && -n "$aws_secret_access_key" ]]; then
|
||||
export AWS_DEFAULT_PROFILE="$profile"
|
||||
export AWS_PROFILE="$profile"
|
||||
export AWS_EB_PROFILE="$profile"
|
||||
export AWS_ACCESS_KEY_ID="$aws_access_key_id"
|
||||
export AWS_SECRET_ACCESS_KEY="$aws_secret_access_key"
|
||||
|
||||
if [[ -n "$aws_session_token" ]]; then
|
||||
export AWS_SESSION_TOKEN="$aws_session_token"
|
||||
else
|
||||
unset AWS_SESSION_TOKEN
|
||||
fi
|
||||
|
||||
echo "Switched to AWS Profile: $profile"
|
||||
fi
|
||||
}
|
||||
|
||||
function aws_change_access_key() {
|
||||
if [[ -z "$1" ]]; then
|
||||
echo "usage: $0 <profile>"
|
||||
|
@ -41,13 +134,13 @@ function aws_change_access_key() {
|
|||
|
||||
function aws_profiles() {
|
||||
[[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1
|
||||
grep '\[profile' "${AWS_CONFIG_FILE:-$HOME/.aws/config}"|sed -e 's/.*profile \([a-zA-Z0-9_\.-]*\).*/\1/'
|
||||
grep --color=never -Eo '\[.*\]' "${AWS_CONFIG_FILE:-$HOME/.aws/config}" | sed -E 's/^[[:space:]]*\[(profile)?[[:space:]]*([-_[:alnum:]\.@]+)\][[:space:]]*$/\2/g'
|
||||
}
|
||||
|
||||
function _aws_profiles() {
|
||||
reply=($(aws_profiles))
|
||||
}
|
||||
compctl -K _aws_profiles asp aws_change_access_key
|
||||
compctl -K _aws_profiles asp acp aws_change_access_key
|
||||
|
||||
# AWS prompt
|
||||
function aws_prompt_info() {
|
||||
|
@ -55,7 +148,7 @@ function aws_prompt_info() {
|
|||
echo "${ZSH_THEME_AWS_PREFIX:=<aws:}${AWS_PROFILE}${ZSH_THEME_AWS_SUFFIX:=>}"
|
||||
}
|
||||
|
||||
if [ "$SHOW_AWS_PROMPT" != false ]; then
|
||||
if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then
|
||||
RPROMPT='$(aws_prompt_info)'"$RPROMPT"
|
||||
fi
|
||||
|
||||
|
@ -63,7 +156,7 @@ fi
|
|||
# Load awscli completions
|
||||
|
||||
# AWS CLI v2 comes with its own autocompletion. Check if that is there, otherwise fall back
|
||||
if [[ -x /usr/local/bin/aws_completer ]]; then
|
||||
if command -v aws_completer &> /dev/null; then
|
||||
autoload -Uz bashcompinit && bashcompinit
|
||||
complete -C aws_completer aws
|
||||
else
|
||||
|
|
|
@ -9,5 +9,14 @@ 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:
|
||||
|
||||
```
|
||||
RPROMPT='$(battery_pct_prompt)'
|
||||
RPROMPT='$(battery_pct_prompt) ...'
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
On Linux, you must have the `acpi` tool installed on your operating system.
|
||||
|
||||
Here's an example of how to install with apt:
|
||||
```
|
||||
sudo apt-get install acpi
|
||||
```
|
||||
|
|
|
@ -18,10 +18,7 @@ if [[ "$OSTYPE" = darwin* ]]; then
|
|||
}
|
||||
|
||||
function battery_pct() {
|
||||
local battery_status="$(ioreg -rc AppleSmartBattery)"
|
||||
local -i capacity=$(sed -n -e '/MaxCapacity/s/^.*"MaxCapacity"\ =\ //p' <<< $battery_status)
|
||||
local -i current=$(sed -n -e '/CurrentCapacity/s/^.*"CurrentCapacity"\ =\ //p' <<< $battery_status)
|
||||
echo $(( current * 100 / capacity ))
|
||||
pmset -g batt | grep -Eo "\d+%" | cut -d% -f1
|
||||
}
|
||||
|
||||
function battery_pct_remaining() {
|
||||
|
|
|
@ -53,7 +53,7 @@ bgnotify () { ## args: (title, subtitle)
|
|||
|
||||
bgnotify_begin() {
|
||||
bgnotify_timestamp=$EPOCHSECONDS
|
||||
bgnotify_lastcmd="$1"
|
||||
bgnotify_lastcmd="${1:-$2}"
|
||||
bgnotify_windowid=$(currentWindowId)
|
||||
}
|
||||
|
||||
|
|
|
@ -10,16 +10,17 @@ plugins=(... brew)
|
|||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
|----------|-------------------------------------------------------------|---------------------------------------------------------------------|
|
||||
| `brewp` | `brew pin` | Pin a specified formula so that it's not upgraded. |
|
||||
| `brews` | `brew list -1` | List installed formulae or the installed files for a given formula. |
|
||||
| `brewsp` | `brew list --pinned` | List pinned formulae, or show the version of a given formula. |
|
||||
| `bubo` | `brew update && brew outdated` | Update Homebrew and all formulae, then list outdated formulae. |
|
||||
| `bubc` | `brew upgrade && brew cleanup` | Upgrade outdated formulae, then run cleanup. |
|
||||
| `bubu` | `bubo && bubc` | Do the last two operations above. |
|
||||
| `bcubo` | `brew update && brew cask outdated` | Update Homebrew and alll formulae, then list outdated casks. |
|
||||
| `bcubc` | `brew cask reinstall $(brew cask outdated) && brew cleanup` | Update outdated casks, then run cleanup. |
|
||||
| Alias | Command | Description |
|
||||
|----------|------------------------------------------------------------- |---------------------------------------------------------------------|
|
||||
| `brewp` | `brew pin` | Pin a specified formula so that it's not upgraded. |
|
||||
| `brews` | `brew list -1` | List installed formulae or the installed files for a given formula. |
|
||||
| `brewsp` | `brew list --pinned` | List pinned formulae, or show the version of a given formula. |
|
||||
| `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. |
|
||||
| `bubc` | `brew upgrade && brew cleanup` | Upgrade outdated formulae and casks, then run cleanup. |
|
||||
| `bubu` | `bubo && bubc` | Do the last two operations above. |
|
||||
| `buf` | `brew upgrade --formula` | Upgrade only formulas (not casks). |
|
||||
| `bcubo` | `brew update && brew outdated --cask` | Update Homebrew data, then list outdated casks. |
|
||||
| `bcubc` | `brew cask reinstall $(brew outdated --cask) && brew cleanup` | Update outdated casks, then run cleanup. |
|
||||
|
||||
## Completion
|
||||
|
||||
|
|
|
@ -4,5 +4,6 @@ alias brewsp='brew list --pinned'
|
|||
alias bubo='brew update && brew outdated'
|
||||
alias bubc='brew upgrade && brew cleanup'
|
||||
alias bubu='bubo && bubc'
|
||||
alias bcubo='brew update && brew cask outdated'
|
||||
alias bcubc='brew cask reinstall $(brew cask outdated) && brew cleanup'
|
||||
alias buf='brew upgrade --formula'
|
||||
alias bcubo='brew update && brew outdated --cask'
|
||||
alias bcubc='brew cask reinstall $(brew outdated --cask) && brew cleanup'
|
||||
|
|
|
@ -1,34 +1,48 @@
|
|||
# Bundler
|
||||
|
||||
- Adds completion for basic bundler commands
|
||||
This plugin adds completion for basic bundler commands, as well as aliases and helper functions for
|
||||
an easier experience with bundler.
|
||||
|
||||
- Adds short aliases for common bundler commands
|
||||
- `ba` aliased to `bundle add`
|
||||
- `be` aliased to `bundle exec`.
|
||||
It also supports aliases (if `rs` is `rails server`, `be rs` will bundle-exec `rails server`).
|
||||
- `bl` aliased to `bundle list`
|
||||
- `bp` aliased to `bundle package`
|
||||
- `bo` aliased to `bundle open`
|
||||
- `bout` aliased to `bundle outdated`
|
||||
- `bu` aliased to `bundle update`
|
||||
- `bi` aliased to `bundle install --jobs=<cpu core count>` (only for bundler `>= 1.4.0`)
|
||||
- `bcn` aliased to `bundle clean`
|
||||
- `bck` aliased to `bundle check`
|
||||
To use it, add `bundler` to the plugins array in your zshrc file:
|
||||
|
||||
- Adds a wrapper for common gems:
|
||||
- Looks for a binstub under `./bin/` and executes it (if present)
|
||||
- Calls `bundle exec <gem executable>` otherwise
|
||||
```zsh
|
||||
plugins=(... bundler)
|
||||
```
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
|--------|--------------------------------------|------------------------------------------------------------------------------------------|
|
||||
| `ba` | `bundle add` | Add gem to the Gemfile and run bundle install |
|
||||
| `bck` | `bundle check` | Verifies if dependencies are satisfied by installed gems |
|
||||
| `bcn` | `bundle clean` | Cleans up unused gems in your bundler directory |
|
||||
| `be` | `bundle exec` | Execute a command in the context of the bundle |
|
||||
| `bi` | `bundle install --jobs=<core_count>` | Install the dependencies specified in your Gemfile (using all cores in bundler >= 1.4.0) |
|
||||
| `bl` | `bundle list` | List all the gems in the bundle |
|
||||
| `bo` | `bundle open` | Opens the source directory for a gem in your bundle |
|
||||
| `bout` | `bundle outdated` | List installed gems with newer versions available |
|
||||
| `bp` | `bundle package` | Package your needed .gem files into your application |
|
||||
| `bu` | `bundle update` | Update your gems to the latest available versions |
|
||||
|
||||
## Gem wrapper
|
||||
|
||||
The plugin adds a wrapper for common gems, which:
|
||||
|
||||
- Looks for a binstub under `./bin/` and executes it if present.
|
||||
- Calls `bundle exec <gem>` otherwise.
|
||||
|
||||
Common gems wrapped by default (by name of the executable):
|
||||
|
||||
`annotate`, `cap`, `capify`, `cucumber`, `foodcritic`, `guard`, `hanami`, `irb`, `jekyll`, `kitchen`, `knife`, `middleman`, `nanoc`, `pry`, `puma`, `rackup`, `rainbows`, `rake`, `rspec`, `rubocop`, `shotgun`, `sidekiq`, `spec`, `spork`, `spring`, `strainer`, `tailor`, `taps`, `thin`, `thor`, `unicorn` and `unicorn_rails`.
|
||||
|
||||
## Configuration
|
||||
### Settings
|
||||
|
||||
Please use the exact name of the executable and not the gem name.
|
||||
You can add or remove gems from the list of wrapped commands.
|
||||
Please **use the exact name of the executable** and not the gem name.
|
||||
|
||||
### Add additional gems to be wrapped
|
||||
#### Include gems to be wrapped (`BUNDLED_COMMANDS`)
|
||||
|
||||
Add this before the plugin-list in your `.zshrc`:
|
||||
Add this before the plugin list in your `.zshrc`:
|
||||
|
||||
```sh
|
||||
BUNDLED_COMMANDS=(rubocop)
|
||||
|
@ -37,10 +51,9 @@ plugins=(... bundler ...)
|
|||
|
||||
This will add the wrapper for the `rubocop` gem (i.e. the executable).
|
||||
|
||||
#### Exclude gems from being wrapped (`UNBUNDLED_COMMANDS`)
|
||||
|
||||
### Exclude gems from being wrapped
|
||||
|
||||
Add this before the plugin-list in your `.zshrc`:
|
||||
Add this before the plugin list in your `.zshrc`:
|
||||
|
||||
```sh
|
||||
UNBUNDLED_COMMANDS=(foreman spin)
|
||||
|
@ -49,13 +62,13 @@ plugins=(... bundler ...)
|
|||
|
||||
This will exclude the `foreman` and `spin` gems (i.e. their executable) from being wrapped.
|
||||
|
||||
## Excluded gems
|
||||
### Excluded gems
|
||||
|
||||
These gems should not be called with `bundle exec`. Please see [issue #2923](https://github.com/ohmyzsh/ohmyzsh/pull/2923) on GitHub for clarification.
|
||||
These gems should not be called with `bundle exec`. Please see [issue #2923](https://github.com/ohmyzsh/ohmyzsh/pull/2923) on GitHub for clarification:
|
||||
|
||||
`berks`
|
||||
`foreman`
|
||||
`mailcatcher`
|
||||
`rails`
|
||||
`ruby`
|
||||
`spin`
|
||||
- `berks`
|
||||
- `foreman`
|
||||
- `mailcatcher`
|
||||
- `rails`
|
||||
- `ruby`
|
||||
- `spin`
|
||||
|
|
|
@ -1,13 +1,49 @@
|
|||
## Aliases
|
||||
|
||||
alias ba="bundle add"
|
||||
alias bck="bundle check"
|
||||
alias bcn="bundle clean"
|
||||
alias be="bundle exec"
|
||||
alias bi="bundle_install"
|
||||
alias bl="bundle list"
|
||||
alias bp="bundle package"
|
||||
alias bo="bundle open"
|
||||
alias bout="bundle outdated"
|
||||
alias bp="bundle package"
|
||||
alias bu="bundle update"
|
||||
alias bi="bundle_install"
|
||||
alias bcn="bundle clean"
|
||||
alias bck="bundle check"
|
||||
|
||||
## Functions
|
||||
|
||||
bundle_install() {
|
||||
# Bail out if bundler is not installed
|
||||
if (( ! $+commands[bundle] )); then
|
||||
echo "Bundler is not installed"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Bail out if not in a bundled project
|
||||
if ! _within-bundled-project; then
|
||||
echo "Can't 'bundle install' outside a bundled project"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Check the bundler version is at least 1.4.0
|
||||
autoload -Uz is-at-least
|
||||
local bundler_version=$(bundle version | cut -d' ' -f3)
|
||||
if ! is-at-least 1.4.0 "$bundler_version"; then
|
||||
bundle install "$@"
|
||||
return $?
|
||||
fi
|
||||
|
||||
# If bundler is at least 1.4.0, use all the CPU cores to bundle install
|
||||
if [[ "$OSTYPE" = (darwin|freebsd)* ]]; then
|
||||
local cores_num="$(sysctl -n hw.ncpu)"
|
||||
else
|
||||
local cores_num="$(nproc)"
|
||||
fi
|
||||
bundle install --jobs="$cores_num" "$@"
|
||||
}
|
||||
|
||||
## Gem wrapper
|
||||
|
||||
bundled_commands=(
|
||||
annotate
|
||||
|
@ -54,65 +90,41 @@ for cmd in $BUNDLED_COMMANDS; do
|
|||
bundled_commands+=($cmd);
|
||||
done
|
||||
|
||||
## Functions
|
||||
|
||||
bundle_install() {
|
||||
if ! _bundler-installed; then
|
||||
echo "Bundler is not installed"
|
||||
elif ! _within-bundled-project; then
|
||||
echo "Can't 'bundle install' outside a bundled project"
|
||||
else
|
||||
local bundler_version=`bundle version | cut -d' ' -f3`
|
||||
if [[ $bundler_version > '1.4.0' || $bundler_version = '1.4.0' ]]; then
|
||||
if [[ "$OSTYPE" = (darwin|freebsd)* ]]
|
||||
then
|
||||
local cores_num="$(sysctl -n hw.ncpu)"
|
||||
else
|
||||
local cores_num="$(nproc)"
|
||||
fi
|
||||
bundle install --jobs=$cores_num $@
|
||||
else
|
||||
bundle install $@
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
_bundler-installed() {
|
||||
which bundle > /dev/null 2>&1
|
||||
}
|
||||
|
||||
# Check if in the root or a subdirectory of a bundled project
|
||||
_within-bundled-project() {
|
||||
local check_dir="$PWD"
|
||||
while [ "$check_dir" != "/" ]; do
|
||||
[ -f "$check_dir/Gemfile" -o -f "$check_dir/gems.rb" ] && return
|
||||
check_dir="$(dirname $check_dir)"
|
||||
while [[ "$check_dir" != "/" ]]; do
|
||||
if [[ -f "$check_dir/Gemfile" || -f "$check_dir/gems.rb" ]]; then
|
||||
return 0
|
||||
fi
|
||||
check_dir="${check_dir:h}"
|
||||
done
|
||||
false
|
||||
}
|
||||
|
||||
_binstubbed() {
|
||||
[ -f "./bin/${1}" ]
|
||||
return 1
|
||||
}
|
||||
|
||||
_run-with-bundler() {
|
||||
if _bundler-installed && _within-bundled-project; then
|
||||
if _binstubbed $1; then
|
||||
./bin/${^^@}
|
||||
else
|
||||
bundle exec $@
|
||||
fi
|
||||
if (( ! $+commands[bundle] )) || ! _within-bundled-project; then
|
||||
"$@"
|
||||
return $?
|
||||
fi
|
||||
|
||||
if [[ -f "./bin/${1}" ]]; then
|
||||
./bin/${^^@}
|
||||
else
|
||||
$@
|
||||
bundle exec "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
## Main program
|
||||
for cmd in $bundled_commands; do
|
||||
eval "function unbundled_$cmd () { $cmd \$@ }"
|
||||
eval "function bundled_$cmd () { _run-with-bundler $cmd \$@}"
|
||||
alias $cmd=bundled_$cmd
|
||||
# Create wrappers for bundled and unbundled execution
|
||||
eval "function unbundled_$cmd () { \"$cmd\" \"\$@\"; }"
|
||||
eval "function bundled_$cmd () { _run-with-bundler \"$cmd\" \"\$@\"; }"
|
||||
alias "$cmd"="bundled_$cmd"
|
||||
|
||||
if which _$cmd > /dev/null 2>&1; then
|
||||
compdef _$cmd bundled_$cmd=$cmd
|
||||
# Bind completion function to wrapped gem if available
|
||||
if (( $+functions[_$cmd] )); then
|
||||
compdef "_$cmd" "bundled_$cmd"="$cmd"
|
||||
fi
|
||||
done
|
||||
|
||||
unset cmd bundled_commands
|
||||
|
|
|
@ -12,8 +12,8 @@ _cargo() {
|
|||
'(-q --quiet)*'{-v,--verbose}'[use verbose output]'
|
||||
'(-q --quiet -v --verbose)'{-q,--quiet}'[no output printed to stdout]'
|
||||
'-Z+[pass unstable (nightly-only) flags to cargo]: :_cargo_unstable_flags'
|
||||
'--frozen[require that Cargo.lock and cache are up-to-date]'
|
||||
'--locked[require that Cargo.lock is up-to-date]'
|
||||
'--frozen[require that Cargo.lock and cache are up to date]'
|
||||
'--locked[require that Cargo.lock is up to date]'
|
||||
'--color=[specify colorization option]:coloring:(auto always never)'
|
||||
'(- 1 *)'{-h,--help}'[show help message]'
|
||||
)
|
||||
|
|
|
@ -20,7 +20,7 @@ Aliens fear that Chuck Norris might abduct them.
|
|||
%
|
||||
An angry glare from Chuck Norris is known to kill on the spot.
|
||||
%
|
||||
Behind every successful man is Chuck Norris
|
||||
Behind every successful man is Chuck Norris.
|
||||
%
|
||||
Beware of dogs... Dogs, beware of Chuck Norris.
|
||||
%
|
||||
|
@ -34,25 +34,25 @@ Chuck Norris - the new standard.
|
|||
%
|
||||
Chuck Norris CAN balance the light-switch between ON and OFF.
|
||||
%
|
||||
Chuck Norris CAN believe it's not butter
|
||||
Chuck Norris CAN believe it's not butter.
|
||||
%
|
||||
Chuck Norris CAN spell with an I before E even after C.
|
||||
%
|
||||
Chuck Norris Can Play the Theme from the Twilight Zone with His Beard
|
||||
Chuck Norris can play the theme from the Twilight Zone with his beard.
|
||||
%
|
||||
Chuck Norris Can Power Solar Panels. At Night.
|
||||
Chuck Norris can power solar panels. At night.
|
||||
%
|
||||
Chuck Norris Watches "the Nat.Geo. Specials" on Discovery Channel
|
||||
Chuck Norris watches "the Nat.Geo. Specials" on Discovery Channel.
|
||||
%
|
||||
Chuck Norris bowled a 301 after constructing another pin out of his beard hair
|
||||
Chuck Norris bowled a 301 after constructing another pin out of his beard hair.
|
||||
%
|
||||
Chuck Norris burnt a fire proof vest, UNDERWATER!
|
||||
%
|
||||
Chuck Norris can French kiss his elbow.
|
||||
%
|
||||
Chuck Norris can bake in a Freezer.
|
||||
Chuck Norris can bake in a freezer.
|
||||
%
|
||||
Chuck Norris can defuse bomb even if he cut the wrong wire
|
||||
Chuck Norris can defuse a bomb by cutting the wrong wire.
|
||||
%
|
||||
Chuck Norris can dig a hole in air.
|
||||
%
|
||||
|
@ -60,19 +60,19 @@ Chuck Norris can divide by zero.
|
|||
%
|
||||
Chuck Norris can do a regime change with a roundhouse kick.
|
||||
%
|
||||
Chuck Norris can fit 10 gallons of water in a 5 gallon water bucket
|
||||
Chuck Norris can fit 10 gallons of water in a 5 gallon bucket.
|
||||
%
|
||||
Chuck Norris can grill a popsicle
|
||||
Chuck Norris can grill a popsicle.
|
||||
%
|
||||
Chuck Norris can lead a horse to water AND make it drink.
|
||||
%
|
||||
Chuck Norris can make his own megazord "The Chuck Norris Roundhouse Kickers Ultimate Super Awesome Megazord"
|
||||
Chuck Norris can make his own megazord "The Chuck Norris Roundhouse Kickers Ultimate Super Awesome Megazord".
|
||||
%
|
||||
Chuck Norris can milk an alligator
|
||||
Chuck Norris can milk an alligator.
|
||||
%
|
||||
Chuck Norris can play the death waltz with his chin.
|
||||
%
|
||||
Chuck Norris can roundhouse kick someone through a window without breaking the glass
|
||||
Chuck Norris can roundhouse kick someone through a window without breaking the glass.
|
||||
%
|
||||
Chuck Norris can roundhouse-kick round houses into squares.
|
||||
%
|
||||
|
@ -80,36 +80,30 @@ Chuck Norris can rub two fires together and make a stick!
|
|||
%
|
||||
Chuck Norris can see in 3D with just one eye.
|
||||
%
|
||||
Chuck Norris can shoot a person 28 times with an unloaded gun.
|
||||
%
|
||||
Chuck Norris can slam a revolving door.
|
||||
%
|
||||
Chuck Norris can terminate a repeating decimal.
|
||||
%
|
||||
Chuck Norris can turn toast back into bread
|
||||
Chuck Norris can turn toast back into bread.
|
||||
%
|
||||
Chuck Norris can win a game of Connect Four in only three moves.
|
||||
%
|
||||
Chuck Norris can win in a top spinning tournament with a cube
|
||||
Chuck Norris can win in a top spinning tournament with a cube.
|
||||
%
|
||||
Chuck Norris can't get fired by Donald Trump
|
||||
%
|
||||
Chuck Norris can't perform Hadoukens, he IS a Hadouken
|
||||
Chuck Norris can't perform Hadoukens, he IS a Hadouken.
|
||||
%
|
||||
Chuck Norris checks under his bed for Fedor Emelianenko because he takes Fedor to the vet regularly.
|
||||
%
|
||||
Chuck Norris counted to infinity - twice.
|
||||
%
|
||||
Chuck Norris created Heavy Metal when he was upset
|
||||
Chuck Norris created Heavy Metal when he was upset.
|
||||
%
|
||||
Chuck Norris does not get frostbite. Chuck Norris bites frost.
|
||||
%
|
||||
Chuck Norris does not have a cell phone because he hears everything
|
||||
Chuck Norris does not have a cell phone because he hears everything.
|
||||
%
|
||||
Chuck Norris does not sleep. He waits.
|
||||
%
|
||||
Chuck Norris does not teabag the ladies. He potato-sacks them.
|
||||
%
|
||||
Chuck Norris doesn't bowl strikes, he just knocks down one pin and the other nine faint.
|
||||
%
|
||||
Chuck Norris doesn't call the wrong number, you just answer the wrong phone.
|
||||
|
@ -118,39 +112,31 @@ Chuck Norris doesn't cheat death, he beats it fair and square.
|
|||
%
|
||||
Chuck Norris doesn't churn butter. He roundhouse kicks the cows and the butter comes straight out.
|
||||
%
|
||||
Chuck Norris doesn't eat, he just sucks the energy out of food by staring at it
|
||||
Chuck Norris doesn't eat, he just sucks the energy out of food by staring at it.
|
||||
%
|
||||
Chuck Norris doesn't exhale. The air runs desperately scared out of his lungs.
|
||||
%
|
||||
Chuck Norris doesn't fight. He gives motivational seminars to die on their own to avoid a roundhouse kick to the face.
|
||||
%
|
||||
Chuck Norris doesn't go hunting.... CHUCK NORRIS GOES KILLING.
|
||||
%
|
||||
Chuck Norris doesn't let it go.
|
||||
%
|
||||
Chuck Norris doesn't like Mudkipz
|
||||
Chuck Norris doesn't like Mudkipz.
|
||||
%
|
||||
Chuck Norris doesn't look for fun. The fun looks for Chuck Norris.
|
||||
%
|
||||
Chuck Norris doesn't need a bulletproof vest to be bulletproof
|
||||
%
|
||||
Chuck Norris doesn't need a bulletproof vest. He catches them with his bare hands.
|
||||
%
|
||||
Chuck Norris doesn't need air, he is air
|
||||
Chuck Norris doesn't need air, he is air.
|
||||
%
|
||||
Chuck Norris doesn't need sunglasses, the sun needs Chuck Norris glasses
|
||||
Chuck Norris doesn't need sunglasses, the sun needs Chuck Norris glasses.
|
||||
%
|
||||
Chuck Norris doesn't need to brush his teeth, his spit acts as a bleach.
|
||||
%
|
||||
Chuck Norris doesn't read books. He stares them down until he gets the information he wants.
|
||||
%
|
||||
Chuck Norris doesn't read. He just stares at the book until he gets the information he wants.
|
||||
%
|
||||
Chuck Norris doesn't throw up if he drinks too much. Chuck Norris throws down!
|
||||
%
|
||||
Chuck Norris doesn't brew up tea. He sucks the bag.
|
||||
%
|
||||
Chuck Norris doesn't eat salad, he eats vegetarians
|
||||
Chuck Norris doesn't eat salad, he eats vegetarians.
|
||||
%
|
||||
Chuck Norris doesn't wash his clothes, he disembowels them.
|
||||
%
|
||||
|
@ -162,26 +148,22 @@ Chuck Norris drives an ice cream truck covered in human skulls.
|
|||
%
|
||||
Chuck Norris drowned a man ON LAND.
|
||||
%
|
||||
Chuck Norris fed the Hunger Games
|
||||
Chuck Norris fed the Hunger Games.
|
||||
%
|
||||
Chuck Norris found the hay in the needle stack.
|
||||
%
|
||||
Chuck Norris found the last digit of pie
|
||||
Chuck Norris found the last digit of pi.
|
||||
%
|
||||
Chuck Norris had a knife thrown at him............ the knife didn't impale him, he impaled the knife
|
||||
Chuck Norris had a knife thrown at him. The knife didn't impale him; he impaled the knife.
|
||||
%
|
||||
Chuck Norris has a battle cruiser AND a car.
|
||||
%
|
||||
Chuck Norris has killed the Dead Sea
|
||||
Chuck Norris has killed the Dead Sea.
|
||||
%
|
||||
Chuck Norris has made a 148 break a snooker.
|
||||
%
|
||||
Chuck Norris has two speeds. Walk, and Kill.
|
||||
Chuck Norris has made a 148 break at snooker.
|
||||
%
|
||||
Chuck Norris invented Kentucky Fried Chicken's famous secret recipe, with eleven herbs and spices. But nobody ever mentions the twelfth ingredient: Fear.
|
||||
%
|
||||
Chuck Norris is Chuck Norris
|
||||
%
|
||||
Chuck Norris is allowed two carry-ons.
|
||||
%
|
||||
Chuck Norris is currently suing NBC, claiming Law and Order are trademarked names for his left and right legs.
|
||||
|
@ -192,13 +174,11 @@ Chuck Norris is entitled to his own facts.
|
|||
%
|
||||
Chuck Norris is my Homeboy.
|
||||
%
|
||||
Chuck Norris is overra...
|
||||
%
|
||||
Chuck Norris is so fast, he can run around the world and punch himself in the back of the head.
|
||||
%
|
||||
Chuck Norris is so hard, he uses diamonds as stress balls.
|
||||
%
|
||||
Chuck Norris is so scary he makes Sharks swim backwards away from him
|
||||
Chuck Norris is so scary, he makes sharks swim backwards away from him.
|
||||
%
|
||||
Chuck Norris is ten feet tall, weighs two-tons, breathes fire, and could eat a hammer and take a shotgun blast standing.
|
||||
%
|
||||
|
@ -212,101 +192,81 @@ Chuck Norris is the only man to ever defeat a brick wall in a game of tennis.
|
|||
%
|
||||
Chuck Norris is the only one who can tear a facebook page!
|
||||
%
|
||||
Chuck Norris is the reason that the world will end in 2012. He was getting bored with the Earth
|
||||
Chuck Norris is the reason that the world will end in 2012. He was getting bored with the Earth.
|
||||
%
|
||||
Chuck Norris is the reason tumbleweeds tumble
|
||||
Chuck Norris is the reason tumbleweeds tumble.
|
||||
%
|
||||
Chuck Norris is the reason why Waldo is hiding.
|
||||
%
|
||||
Chuck Norris is waiting for Mt. St. Helens to erupt again. He's hoping the lava is hot enough to soften his beard so he can shave for the first time.
|
||||
%
|
||||
Chuck Norris isn't allowed at the zoo because when he's there the animals are terriefied to come out their cages
|
||||
%
|
||||
Chuck Norris isn't appropriate...appropriate isn't Chuck Norris
|
||||
%
|
||||
Chuck Norris killed Kemper
|
||||
%
|
||||
Chuck Norris likes everyone on the earth, cause everyone he didn't like... Is dead...
|
||||
Chuck Norris isn't allowed at the zoo, because when he's there the animals are too terrified to come out of their cages.
|
||||
%
|
||||
Chuck Norris made a statue bleed.
|
||||
%
|
||||
Chuck Norris made the big bang just by clicking his fingers
|
||||
Chuck Norris made the big bang just by clicking his fingers.
|
||||
%
|
||||
Chuck Norris never trains, because he's Chuck Norris.
|
||||
%
|
||||
Chuck Norris once asked a man to turn down his music, he refused, that man's baby was born deaf.
|
||||
%
|
||||
Chuck Norris once cried just to see what it was like. The end result was the creation of life.
|
||||
%
|
||||
Chuck Norris once cut a knife with a stick of butter.
|
||||
%
|
||||
Chuck Norris once got a 200 yard punt return
|
||||
Chuck Norris once got a 200 yard punt return.
|
||||
%
|
||||
Chuck Norris once had a pet monkey........his name was KING KONG
|
||||
Chuck Norris once had a pet monkey named KING KONG.
|
||||
%
|
||||
Chuck Norris once had a street named after him. But the name removed at once, because nobody crosses Chuck Norris, and lives
|
||||
Chuck Norris once had a street named after him. The name removed at once, because nobody crosses Chuck Norris, and lives.
|
||||
%
|
||||
Chuck Norris once had a weak moment, just to know what it felt like.
|
||||
%
|
||||
Chuck Norris once played Duck Duck Goose with a group of Kindergarteners. Only one kid made it to first grade
|
||||
Chuck Norris once played Duck Duck Goose with a group of Kindergarteners. Only one kid made it to first grade.
|
||||
%
|
||||
Chuck Norris once proved p^~p by induction on his beard hairs.
|
||||
%
|
||||
Chuck Norris once punched the ground to stop an earthquake. The resulting aftershock caused the BP oil spill
|
||||
Chuck Norris once punched the ground to stop an earthquake. The resulting aftershock caused the BP oil spill.
|
||||
%
|
||||
Chuck Norris once round-house kicked a salesman. Over the phone.
|
||||
%
|
||||
Chuck Norris once roundhouse kicked someone so hard that his foot broke the speed of light, went back in time, and killed Amelia Earhart while she was flying over the Pacific Ocean.
|
||||
%
|
||||
Chuck Norris once rounhouse kicked a football ...... it is now considered as a planet
|
||||
%
|
||||
Chuck Norris once taught a class of martial arts.Unfortunately Chuck had forgiven to take elephant tranquilizers and killed every one just by saluting
|
||||
Chuck Norris once rounhouse kicked a football. The astronomical society now considers it a planet.
|
||||
%
|
||||
Chuck Norris once thought he was wrong. He was, however, mistaken.
|
||||
%
|
||||
Chuck Norris once tried to teach a fat, stupid kid Martial Arts. Unsuccessfully. The kid grew up to be Steven Seagal.
|
||||
%
|
||||
Chuck Norris once walked down a street with his fists in his pockets. He was then arrested for concealing two deadly weapons.
|
||||
%
|
||||
Chuck Norris once won the tour de france riding a " big wheel"
|
||||
Chuck Norris once won the Tour de France riding a "big wheel".
|
||||
%
|
||||
Chuck Norris originally appeared in the "Street Fighter II" video game, but was removed by Beta Testers because every button caused him to do a roundhouse kick. When asked bout this "glitch," Norris replied, "That's no glitch."
|
||||
%
|
||||
Chuck Norris owns all number 1 pencils.
|
||||
%
|
||||
Chuck Norris pees Adamantium
|
||||
Chuck Norris pees Adamantium.
|
||||
%
|
||||
Chuck Norris play's Texas hold em with Zeus, every second Wednesday of the month
|
||||
Chuck Norris plays Texas Hold'Em with Zeus, every second Wednesday of the month.
|
||||
%
|
||||
Chuck Norris played "Got your Nose" with Voldemort and won.
|
||||
%
|
||||
Chuck Norris played the game of thrones and won
|
||||
Chuck Norris played the game of thrones and won.
|
||||
%
|
||||
Chuck Norris protects his body guards.
|
||||
Chuck Norris protects his bodyguards.
|
||||
%
|
||||
Chuck Norris rolled a 20 on a 6 sided die.
|
||||
%
|
||||
Chuck Norris roundhouse kicks people in the face first and asks questions later.
|
||||
%
|
||||
Chuck Norris sent a BBM to an iphone.
|
||||
Chuck Norris sent a BBM to an iPhone.
|
||||
%
|
||||
Chuck Norris shops at Sam's Club, but leaves without having his receipt checked
|
||||
Chuck Norris shops at Sam's Club, but leaves without having his receipt checked.
|
||||
%
|
||||
Chuck Norris shot a man with a knife
|
||||
%
|
||||
Chuck Norris sleeps in Seattle.
|
||||
%
|
||||
Chuck Norris splattered tiger blood and Adonis' dna on Charlie Sheen with 1 roundhouse kick!
|
||||
Chuck Norris splattered tiger blood and Adonis' DNA on Charlie Sheen with 1 roundhouse kick!
|
||||
%
|
||||
Chuck Norris started Chuck Norris.
|
||||
%
|
||||
Chuck Norris starts his day with 6 live chickens two cows, three pigs and a boiling hot cup of pure fury
|
||||
%
|
||||
Chuck Norris thretened to kill Michael Jackson, MJ got so scared to turned white.
|
||||
Chuck Norris starts his day with 6 live chickens, two cows, three pigs, and a boiling hot cup of pure fury.
|
||||
%
|
||||
Chuck Norris told me to put this here.
|
||||
%
|
||||
Chuck Norris uses a real mouse to move the cursor, type on the keyboard, write e-mails, code entire websites, use photoshop, bring coffee.
|
||||
Chuck Norris uses a real mouse to move the cursor, type on the keyboard, write e-mails, code entire websites, and make coffee.
|
||||
%
|
||||
Chuck Norris uses pepper spray to spice up his steaks.
|
||||
%
|
||||
|
@ -322,21 +282,21 @@ Chuck Norris was the reason why the Great Wall of China was constructed. It fail
|
|||
%
|
||||
Chuck Norris was what Willis was talking about.
|
||||
%
|
||||
Chuck Norris wasn't born on his birthday
|
||||
Chuck Norris wasn't born on his birthday.
|
||||
%
|
||||
Chuck Norris watched the first steps on the moon... From his summer home on Mars
|
||||
Chuck Norris watched the first steps on the moon... from his summer home on Mars.
|
||||
%
|
||||
Chuck Norris went up the creek without a paddle... or a canoe
|
||||
Chuck Norris went up the creek without a paddle... or a canoe.
|
||||
%
|
||||
Chuck Norris will attain statehood in 2009. His state flower will be the Magnolia.
|
||||
%
|
||||
Chuck Norris wins NASCAR races with all right turns.
|
||||
%
|
||||
Chuck Norris won a stepdance contest by standing on his hands
|
||||
Chuck Norris won a stepdance contest by standing on his hands.
|
||||
%
|
||||
Chuck Norris yells at Drill Sergeants
|
||||
Chuck Norris yells at drill Sergeants.
|
||||
%
|
||||
Chuck Norris' dog pick up after him.
|
||||
Chuck Norris' dog picks up after him.
|
||||
%
|
||||
Chuck Norris' films are factual documentaries.
|
||||
%
|
||||
|
@ -346,55 +306,47 @@ Chuck Norris' glass is never half full or half empty. It stays full even after h
|
|||
%
|
||||
Chuck Norris' hand is the only hand that can beat a Royal Flush.
|
||||
%
|
||||
Chuck Norris' personal airplane is called Air Force Chuck
|
||||
Chuck Norris' personal airplane is called Air Force Chuck.
|
||||
%
|
||||
Chuck Norris. Enough said.
|
||||
%
|
||||
Chuck Norris: even Naruto can't believe it
|
||||
Chuck Norris: even Naruto can't believe it.
|
||||
%
|
||||
Chunk Norris can make sour milk turn fresh
|
||||
Chunk Norris can make sour milk turn fresh.
|
||||
%
|
||||
Contrary to popular beleif, Rome WAS built in a day, by Chuck Norris.
|
||||
Contrary to popular belief, Rome WAS built in a day, by Chuck Norris.
|
||||
%
|
||||
Contrary to popular belief, America is not a democracy, it is a Chucktatorship.
|
||||
%
|
||||
Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on earth.
|
||||
Contrary to popular belief, Chuck Norris, not the box jellyfish of northern Australia, is the most venomous creature on Earth.
|
||||
%
|
||||
Cops don't need a badges in their wallets but only a picture of Chuck Norris.
|
||||
Cops don't need badges in their wallets, but only a picture of Chuck Norris.
|
||||
%
|
||||
Crop circles are Chuck Norris' way of telling the world that sometimes corn needs to lie down.
|
||||
%
|
||||
Dead bodies were found of people that are still alive. These people will cross Chuck Norris in the future and will be round-house kicked back in time.
|
||||
%
|
||||
Did you here about the boy who cried Chuck Norris?
|
||||
%
|
||||
Do you know why Chuck Norris didn't star in The Expandebles? Because all the others guys would have surrended at the beginning.
|
||||
Did you hear about the boy who cried Chuck Norris?
|
||||
%
|
||||
Dog the Bounty Hunter can't track Chuck Norris down.
|
||||
%
|
||||
Don't get Chuck Norris angry, last time somebody did that Chuck Norris made the Grand Canyon.
|
||||
%
|
||||
During the Civil War Chuck Norris was a slave, his master would often beg him for mercy
|
||||
Don't get Chuck Norris angry. Last time somebody did that, Chuck Norris made the Grand Canyon.
|
||||
%
|
||||
Earth's rotation is purely governed by the direction that Chuck Norris is walking.
|
||||
%
|
||||
Ever wonder what really happened to the dinosaurs? They all dug their own graves when they heard Chuck Norris was coming
|
||||
Ever wonder what really happened to the dinosaurs? They all dug their own graves when they heard Chuck Norris was coming.
|
||||
%
|
||||
Every line in a Chuck Norris haiku is "A roundhouse kick to the face." And they all have the correct number of syllables.
|
||||
Every line in a Chuck Norris haiku is "A roundhouse kick to the face." And they all have the correct number of syllables.
|
||||
%
|
||||
Every phobia known to man has a phobia of Chuck Norris
|
||||
Every phobia known to man has a phobia of Chuck Norris.
|
||||
%
|
||||
Every time there's an earthquake, you know Chuck Norris is hungry. The earthquake is caused by his stomach growling.
|
||||
%
|
||||
Everyone is so scared of Chuck Norris that they kiss his arse by writing these facts, too right they should
|
||||
%
|
||||
Evolution's driving mechanism is nature's desperate attempt to escape Chuck Norris.
|
||||
%
|
||||
Fear of spiders is aracnaphobia, fear of tight spaces is chlaustraphobia, fear of Chuck Norris is called Logic
|
||||
Fear of spiders is arachnaphobia. 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.
|
||||
%
|
||||
Ghosts can see Chuck Norris
|
||||
Ghosts can see Chuck Norris.
|
||||
%
|
||||
Guns don't kill people. Chuck Norris kills people.
|
||||
%
|
||||
|
@ -404,55 +356,47 @@ If Chuck Norris were a calendar, every month would be named Chucktober, and ever
|
|||
%
|
||||
If Chuck Norris were to get into a fight with another Chuck Norris, Chuck Norris would win.
|
||||
%
|
||||
If Chuck was ever captured, he could win a game of Russian Roulette with six bullets in the revolver, he would shoot everyone else!
|
||||
If God doesn't know, Chuck does.
|
||||
%
|
||||
If God doesn't know, Chuck does
|
||||
%
|
||||
If Goliath listened to Chuck Norris he would have won.
|
||||
If Goliath listened to Chuck Norris, he would have won.
|
||||
%
|
||||
If at first you don't succeed, you're not Chuck Norris.
|
||||
%
|
||||
If you ask Chuck Norris what time it is, he always says, "Two seconds 'til." After you ask, "Two seconds 'til what?" he roundhouse kicks you in the face.
|
||||
%
|
||||
If you put in the correct cheat code in Halo 2, you can have Master Cheif play without his helmet; revealing to be Chuck Norris.
|
||||
If you put in the correct cheat code in Halo 2, you can have Master Chief play without his helmet, revealing himself to be Chuck Norris.
|
||||
%
|
||||
If you see a man in the street who looks like Chuck Norris, but isn't, run: you don't want to be caught in the resulting roundhouse kick to his face.
|
||||
%
|
||||
If you spell Chuck Norris in Scrabble, you win. Forever.
|
||||
%
|
||||
In 1945 The US army asked if they could clone Chuck Norris. instead he said he could sort out the Japanese.
|
||||
In 1945 The US army asked if they could clone Chuck Norris. Instead he said he could sort out the Japanese.
|
||||
%
|
||||
In Texas, there are five sizes for fountain drinks: small, medium, large, Texas sized, and Chuck Norris Sized. It is a cup made of a human skull.
|
||||
In Texas, there are five sizes for fountain drinks: small, medium, large, Texas sized, and Chuck Norris sized. It is a cup made of a human skull.
|
||||
%
|
||||
In a rain storm Chuck Norris stays dry. Rain drops are scared to hit him.
|
||||
%
|
||||
In fine print on the last page of the Guinness Book of World Records it notes that all world records are held by Chuck Norris, and those listed in the book are simply the closest anyone else has ever gotten.
|
||||
%
|
||||
In the back of the book of world records, it says "All records are held by Chuck Norris. The ones listed are in second place."
|
||||
%
|
||||
James Bond has a license to kill. He got it from Chuck Norris.
|
||||
%
|
||||
Jedis are now taught to use the "Chuck"
|
||||
Jedis are now taught to use the "Chuck".
|
||||
%
|
||||
MacGyver immediately tried to make a bomb out of some Q-Tips and Gatorade, but Chuck Norris roundhouse-kicked him in the solar plexus. MacGyver promptly threw up his own heart.
|
||||
%
|
||||
Machiavelli said it is better to be feared than loved because he was inspired by Chuck Norris.
|
||||
%
|
||||
May the Force be with Chuck Norris... for it's own good.
|
||||
May the Force be with Chuck Norris... for its own good.
|
||||
%
|
||||
Merlin was Chuck Norris' assistant.
|
||||
%
|
||||
More of a question than a fact: in a fight between Chuck Norris and Gordan Freeman who would win?
|
||||
%
|
||||
Most people have 23 pairs of chromosomes. Chuck Norris has 72... and they're all poisonous.
|
||||
%
|
||||
Note to everyone: Please do not give beans to Chuck Norris or do you want another atombomb on hiroshima?
|
||||
Note to self: Don't be the cashier to tell Chuck Norris his coupons have expired.
|
||||
%
|
||||
Note to self: Don't be the cashier to tell Chuck Norris his coupons have expired.
|
||||
Chuck Norris' keyboard has no control key. Chuck Norris is always in control.
|
||||
%
|
||||
On the keyboard there is no control button because Chuck Norris is always in control.
|
||||
%
|
||||
Once upon a time, Chuck Norris found himself in a town called Shit Creek.....He opened a Paddle Store.
|
||||
Once upon a time, Chuck Norris found himself in a town called Shit Creek. He opened a Paddle Store.
|
||||
%
|
||||
One glance from Chuck Norris and snow turns itself yellow.
|
||||
%
|
||||
|
@ -472,11 +416,9 @@ Police label anyone attacking Chuck Norris as a Code 45-11.... a suicide.
|
|||
%
|
||||
Remember the Soviet Union? They decided to quit after watching a DeltaForce marathon on Satellite TV.
|
||||
%
|
||||
Simon doesn't say...Chuck Norris says.
|
||||
Simon doesn't say... Chuck Norris says.
|
||||
%
|
||||
Since 1940, the year Chuck Norris was born, roundhouse-kick related deaths have increased 13,000 percent.?
|
||||
%
|
||||
Some boots were made for walking. Some boots may walk all over you, but Chuck Norris' boot walk THROUGH you.
|
||||
Some boots were made for walking. Some boots may walk all over you, but Chuck Norris' boots walk THROUGH you.
|
||||
%
|
||||
Some kids pee their name in snow. Chuck Norris pees his name in concrete.
|
||||
%
|
||||
|
@ -486,9 +428,9 @@ Someone once videotaped Chuck Norris getting pissed off. It was called Walker: T
|
|||
%
|
||||
Staring at Chuck Norris for extended periods of time without proper eye protection will cause blindess, and possibly foot sized brusies on the face.
|
||||
%
|
||||
Taking Karate Lessons = $100, Buying MMA DVD's= $150, Subscribing to a UFC event = $50, Getting a Roundhouse Kick from Chuck Norris = PRICELESS
|
||||
Taking Karate Lessons = $100, Buying MMA DVD's = $150, Subscribing to a UFC event = $50, Getting a Roundhouse Kick from Chuck Norris = PRICELESS.
|
||||
%
|
||||
That's not an eclipse....that's the sun hiding from Chuck Norris.
|
||||
That's not an eclipse. That's the sun hiding from Chuck Norris.
|
||||
%
|
||||
The Beatles are on iTunes because Chuck Norris bought a Mac.
|
||||
%
|
||||
|
@ -498,29 +440,25 @@ The Earth was almost destroyed by a 50 km wide asteroid in 1984, but Chuck Norri
|
|||
%
|
||||
The Great Wall of China was originally created to keep Chuck Norris out. It failed miserably.
|
||||
%
|
||||
The Jone's are trying to keep up with Chuck Norris
|
||||
The Joneses are trying to keep up with Chuck Norris.
|
||||
%
|
||||
The Matrix Trilogy would have ended on the first movie if Keanu Reeves said, “I know Chuck Norris.”
|
||||
The Matrix Trilogy would have ended on the first movie had Keanu Reeves said, “I know Chuck Norris.”
|
||||
%
|
||||
The answer to life, the universe and everything isnt 42. It's Chuck Norris.
|
||||
The answer to life, the universe and everything isn't 42. It's Chuck Norris.
|
||||
%
|
||||
The apple falls far from the tree, when a roundhouse kick is taken to the trunk.
|
||||
The apple falls far from the tree, when Chuck's roundhouse kick is taken to the trunk.
|
||||
%
|
||||
The best part of waking up is not Folgers in your cup, it's knowing that Chuck Norris let you live.
|
||||
The best part of waking up is not Folgers in your cup. it's knowing that Chuck Norris let you live.
|
||||
%
|
||||
The chief export of Chuck Norris is Pain.
|
||||
The chief export of Chuck Norris is pain.
|
||||
%
|
||||
The dictionary references Chuck Norris several times, he is metioned under Fear, Law, Order and Chucktatorship.
|
||||
%
|
||||
The kids said when Chuck was eating Trix cereal ´´silly Chuck, Trix are for kids´´...what happened next?..............................Darfur happened.
|
||||
%
|
||||
The leading causes of death in the United States are: 1. Heart Disease 2. Chuck Norris 3. Cancer.
|
||||
%
|
||||
The letters in Chuck Norris cannot be unscrambled.
|
||||
%
|
||||
The meaning of life is Chuck Norris
|
||||
%
|
||||
The only place where the Starship Enterprise refuses to boldly go is Chuck Norris' planet...which is all of them.
|
||||
The only place where the Starship Enterprise refuses to boldly go is Chuck Norris' planet... which is all of them.
|
||||
%
|
||||
The only reason that USA lost the 2011 world cup to Japan is because Chuck Norris wasn't there.
|
||||
%
|
||||
|
@ -528,21 +466,19 @@ The only sure things are Death and Taxes, and when Chuck Norris goes to work for
|
|||
%
|
||||
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 planes in 9/11 were not hijacked. Chuck Norris was just playing with his old radio controller.
|
||||
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 quickest way to a man's heart is with Chuck Norris' fist.
|
||||
%
|
||||
The reason why batman only comes out at night is because he's afraid he might encounter Chuck Norris in the Morning and afternoon.
|
||||
The reason why Batman only comes out at night is because he's afraid he might encounter Chuck Norris in the morning and afternoon.
|
||||
%
|
||||
The red phone in the oval office...Rings directly to Chuck Norris Cell Phone
|
||||
The red phone in the oval office rings directly to Chuck Norris' cell phone.
|
||||
%
|
||||
The show Survivor had the original premise of putting people on an island with Chuck Norris. There were no survivors, and nobody is brave enough to go to the island to retrieve the footage.
|
||||
%
|
||||
The square root of Chuck Norris is pain. Do not try to square Chuck Norris. The result is death
|
||||
The square root of Chuck Norris is pain. Do not try to square Chuck Norris. The result is death.
|
||||
%
|
||||
The sun only rises every morning because Chuck Norris allows it to.
|
||||
%
|
||||
|
@ -550,25 +486,17 @@ The truth hurts, doesn't it? Chuck Norris' truth kills.
|
|||
%
|
||||
There is no chin behind Chuck Norris' beard. There is only another fist.
|
||||
%
|
||||
There is no chin behind Chuck Norris' beard. There is only another fist.
|
||||
%
|
||||
There is no limbo, only a world that doesn't know of Chuck Norris
|
||||
%
|
||||
There is no such thing as being hard its called the Chuck Norris factor.
|
||||
There is no limbo, only a world that doesn't know of Chuck Norris.
|
||||
%
|
||||
There is no such thing as global warming. Chuck Norris was cold, so he turned the sun up.
|
||||
%
|
||||
There is no theory of evolution. Just a list of animals Chuck Norris allows to live.
|
||||
%
|
||||
There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.
|
||||
%
|
||||
They say death by a 1000 lashes was the most painful way to die, that was before they got roundhouse kicked in the face by Chuck Norris
|
||||
There is no theory of evolution, just a list of creatures Chuck Norris has allowed to live.
|
||||
%
|
||||
This one time at band camp... BAM! Chuck Norris.
|
||||
%
|
||||
Those who ignore history, are doomed by Chuck Norris.
|
||||
%
|
||||
Trick me once, shame on you, trick Chuck Norris.....rest in peace.
|
||||
Trick me once, shame on you, trick Chuck Norris.. rest in peace.
|
||||
%
|
||||
Unlike Jack Bauer, Chuck Norris doesn't need bullets. A quick roundhouse to the face kills twice as fast.
|
||||
%
|
||||
|
@ -580,7 +508,7 @@ Whatever Chuck Norris wants, it will instantly appear.
|
|||
%
|
||||
When Betty White gets angry, she turns into the Hulk. When Valerie Bertinelli gets mad, she turns into Chuck Norris.
|
||||
%
|
||||
When Chuck Norris creates a login, it tells him "password not strong enough", he types in his name and it tells him "password too strong."
|
||||
When Chuck Norris creates a login, it tells him "password not strong enough." He types in his name and it tells him "password too strong."
|
||||
%
|
||||
When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.
|
||||
%
|
||||
|
@ -590,7 +518,7 @@ When Chuck Norris goes to Vegas, he doesn't have to gamble. The casinos just giv
|
|||
%
|
||||
When Chuck Norris goes to rodeos, bulls ride him.
|
||||
%
|
||||
When Chuck Norris goes to the library, he looks for the guinness book of records in the comedy section.
|
||||
When Chuck Norris goes to the library, he looks for the Guinness book of records in the comedy section.
|
||||
%
|
||||
When Chuck Norris inhales helium, his voice doesn't change.
|
||||
%
|
||||
|
@ -600,36 +528,32 @@ When Chuck Norris played the card game War with a friend, France surrendered.
|
|||
%
|
||||
When Chuck Norris pokes the Pillsbury Doughboy, it's not a laughing matter.
|
||||
%
|
||||
When Chuck Norris roundhouse-kicks you HE decides when you will feel the impact .
|
||||
When Chuck Norris roundhouse-kicks you, he decides when you will feel the impact.
|
||||
%
|
||||
When Chuck Norris sends in his taxes, he sends blank forms and includes only a picture of himself, crouched and ready to attack. Chuck Norris has not had to pay taxes, ever.
|
||||
%
|
||||
When Chuck Norris tosses a coin, it lands on both head and tail.
|
||||
When Chuck Norris tosses a coin, it lands on both heads and tails.
|
||||
%
|
||||
When God said "Let there be light!", Chuck Norris said "Only for half the day
|
||||
When God said "Let there be light!", Chuck Norris said "Only for half the day."
|
||||
%
|
||||
When President Roosevelt dropped the atomic bomb on Hiroshima, he did so only because it was more human then sending Chuck Norris.
|
||||
%
|
||||
When Presidents speak, their nation listens. When Chuck Norris blinks, the whole World listens.
|
||||
When Presidents speak, their nation listens. When Chuck Norris blinks, the whole world listens.
|
||||
%
|
||||
When Steven Seagal kills a ninja, he only takes its hide. When Chuck Norris kills a ninja, he uses every part.
|
||||
%
|
||||
When chuck Norris was in school, he made his PE teacher run laps.
|
||||
%
|
||||
When does Chuck Norris run out of shotgun bullets?.....whenever he wants to.
|
||||
When does Chuck Norris run out of shotgun bullets? whenever he wants to.
|
||||
%
|
||||
When taking the SAT, write "Chuck Norris" for every answer. You will score over 8000.
|
||||
%
|
||||
When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.
|
||||
%
|
||||
When things go bump in the night.... it's Chuck Norris
|
||||
When things go bump in the night, it's Chuck Norris
|
||||
%
|
||||
While visiting the hexagon, Chuck Norris was asked to demonstrate his famous roundhouse kick. Henceforth, it has been known as the Pentagon.
|
||||
While visiting the Hexagon, Chuck Norris was asked to demonstrate his famous roundhouse kick. Henceforth, it has been known as the Pentagon.
|
||||
%
|
||||
Why didn't the chicken cross the road? Because Chuck Norris got to it first.
|
||||
%
|
||||
World War II began because Chuck Norris took a nap. When he woke up, Hitler found out and killed himself out of fear Chuck Norris would kill him.
|
||||
%
|
||||
You know Chuck Norris' pet lizard, right? Last I heard, he was in the movie "Godzilla". Oh, and his pet turtle starred in "Gamera" as well.
|
||||
%
|
||||
http://chucknorrisfacts.com/ is built in Drupal because Chuck Norris knows a good CMS when he sees one.
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# CloudApp plugin
|
||||
|
||||
## The CloudApp API is deprecated, so the plugin will be removed shortly
|
||||
|
||||
[CloudApp](https://www.getcloudapp.com) brings screen recording, screenshots, and GIF creation to the cloud, in an easy-to-use enterprise-level app. The CloudApp plugin allows you to upload a file to your CloadApp account from the command line.
|
||||
|
||||
To use it, add `cloudapp` to the plugins array of your `~/.zshrc` file:
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
alias cloudapp="${0:a:h}/cloudapp.rb"
|
||||
|
||||
# Ensure only the owner can access the credentials file
|
||||
if [[ -f ~/.cloudapp ]]; then
|
||||
chmod 600 ~/.cloudapp
|
||||
fi
|
||||
print -Pn "%F{yellow}"
|
||||
print "[oh-my-zsh] The CloudApp API no longer works, so the cloudapp plugin will"
|
||||
print "[oh-my-zsh] be removed shortly. Please remove it from your plugins list."
|
||||
print -Pn "%f"
|
||||
|
|
|
@ -16,3 +16,17 @@ You can also try to color other pages by prefixing the respective command with `
|
|||
```zsh
|
||||
colored git help clone
|
||||
```
|
||||
|
||||
## Customization
|
||||
|
||||
The plugin declares global associative array `less_termcap`, which maps termcap capabilities to escape
|
||||
sequences for the `less` pager. This mapping can be further customized by the user after the plugin is
|
||||
loaded. Check out sources for more.
|
||||
|
||||
For example: `less_termcap[md]` maps to `LESS_TERMCAP_md` which is the escape sequence that tells `less`
|
||||
how to print something in bold. It's currently shown in bold red, but if you want to change it, you
|
||||
can redefine `less_termcap[md]` in your zshrc file, after OMZ is sourced:
|
||||
|
||||
```zsh
|
||||
less_termcap[md]="${fg_bold[blue]}" # this tells less to print bold text in bold blue
|
||||
```
|
||||
|
|
|
@ -1,39 +1,48 @@
|
|||
if [[ "$OSTYPE" = solaris* ]]
|
||||
then
|
||||
if [[ ! -x "$HOME/bin/nroff" ]]
|
||||
then
|
||||
mkdir -p "$HOME/bin"
|
||||
cat > "$HOME/bin/nroff" <<EOF
|
||||
#!/bin/sh
|
||||
if [ -n "\$_NROFF_U" -a "\$1,\$2,\$3" = "-u0,-Tlp,-man" ]; then
|
||||
shift
|
||||
exec /usr/bin/nroff -u\$_NROFF_U "\$@"
|
||||
fi
|
||||
#-- Some other invocation of nroff
|
||||
exec /usr/bin/nroff "\$@"
|
||||
EOF
|
||||
chmod +x "$HOME/bin/nroff"
|
||||
fi
|
||||
fi
|
||||
# Requires colors autoload.
|
||||
# See termcap(5).
|
||||
|
||||
# Set up once, and then reuse. This way it supports user overrides after the
|
||||
# plugin is loaded.
|
||||
typeset -AHg less_termcap
|
||||
|
||||
# bold & blinking mode
|
||||
less_termcap[mb]="${fg_bold[red]}"
|
||||
less_termcap[md]="${fg_bold[red]}"
|
||||
less_termcap[me]="${reset_color}"
|
||||
# standout mode
|
||||
less_termcap[so]="${fg_bold[yellow]}${bg[blue]}"
|
||||
less_termcap[se]="${reset_color}"
|
||||
# underlining
|
||||
less_termcap[us]="${fg_bold[green]}"
|
||||
less_termcap[ue]="${reset_color}"
|
||||
|
||||
# Absolute path to this file's directory.
|
||||
typeset __colored_man_pages_dir="${0:A:h}"
|
||||
|
||||
function colored() {
|
||||
command env \
|
||||
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
|
||||
LESS_TERMCAP_md=$(printf "\e[1;31m") \
|
||||
LESS_TERMCAP_me=$(printf "\e[0m") \
|
||||
LESS_TERMCAP_se=$(printf "\e[0m") \
|
||||
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
|
||||
LESS_TERMCAP_ue=$(printf "\e[0m") \
|
||||
LESS_TERMCAP_us=$(printf "\e[1;32m") \
|
||||
PAGER="${commands[less]:-$PAGER}" \
|
||||
_NROFF_U=1 \
|
||||
PATH="$HOME/bin:$PATH" \
|
||||
"$@"
|
||||
local -a environment
|
||||
|
||||
# Convert associative array to plain array of NAME=VALUE items.
|
||||
local k v
|
||||
for k v in "${(@kv)less_termcap}"; do
|
||||
environment+=( "LESS_TERMCAP_${k}=${v}" )
|
||||
done
|
||||
|
||||
# Prefer `less` whenever available, since we specifically configured
|
||||
# environment for it.
|
||||
environment+=( PAGER="${commands[less]:-$PAGER}" )
|
||||
|
||||
# See ./nroff script.
|
||||
if [[ "$OSTYPE" = solaris* ]]; then
|
||||
environment+=( PATH="${__colored_man_pages_dir}:$PATH" )
|
||||
fi
|
||||
|
||||
command env $environment "$@"
|
||||
}
|
||||
|
||||
# Colorize man and dman/debman (from debian-goodies)
|
||||
function man \
|
||||
dman \
|
||||
debman {
|
||||
colored $0 "$@"
|
||||
dman \
|
||||
debman {
|
||||
colored $0 "$@"
|
||||
}
|
||||
|
|
12
dot_oh-my-zsh/plugins/colored-man-pages/executable_nroff
Normal file
12
dot_oh-my-zsh/plugins/colored-man-pages/executable_nroff
Normal file
|
@ -0,0 +1,12 @@
|
|||
#!/bin/sh
|
||||
|
||||
# The whole point of this wrapper is to replace emboldening factor -u0 with
|
||||
# -u1 under certain circumstances on Solaris.
|
||||
|
||||
if [ "$1,$2,$3" = "-u0,-Tlp,-man" ]; then
|
||||
shift
|
||||
exec /usr/bin/nroff -u1 "$@"
|
||||
else
|
||||
# Some other invocation of nroff
|
||||
exec /usr/bin/nroff "$@"
|
||||
fi
|
|
@ -38,6 +38,14 @@ Pygments offers multiple styles. By default, the `default` style is used, but yo
|
|||
ZSH_COLORIZE_STYLE="colorful"
|
||||
```
|
||||
|
||||
### Chroma Formatter Settings
|
||||
|
||||
Chroma supports terminal output in 8 color, 256 color, and true-color. If you need to change the default terminal output style from the standard 8 color output, set the `ZSH_COLORIZE_CHROMA_FORMATTER` environment variable:
|
||||
|
||||
```
|
||||
ZSH_COLORIZE_CHROMA_FORMATTER=terminal256
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
* `ccat <file> [files]`: colorize the contents of the file (or files, if more than one are provided).
|
||||
|
|
|
@ -6,7 +6,8 @@ alias cless="colorize_less"
|
|||
ZSH_COLORIZE_PLUGIN_PATH=$0:A
|
||||
|
||||
colorize_check_requirements() {
|
||||
local available_tools=("chroma" "pygmentize")
|
||||
local -a available_tools
|
||||
available_tools=("chroma" "pygmentize")
|
||||
|
||||
if [ -z "$ZSH_COLORIZE_TOOL" ]; then
|
||||
if (( $+commands[pygmentize] )); then
|
||||
|
@ -46,7 +47,7 @@ colorize_cat() {
|
|||
if [[ "$ZSH_COLORIZE_TOOL" == "pygmentize" ]]; then
|
||||
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g
|
||||
else
|
||||
chroma --style="$ZSH_COLORIZE_STYLE"
|
||||
chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}"
|
||||
fi
|
||||
return $?
|
||||
fi
|
||||
|
@ -62,7 +63,7 @@ colorize_cat() {
|
|||
pygmentize -O style="$ZSH_COLORIZE_STYLE" -g "$FNAME"
|
||||
fi
|
||||
else
|
||||
chroma --style="$ZSH_COLORIZE_STYLE" "$FNAME"
|
||||
chroma --style="$ZSH_COLORIZE_STYLE" --formatter="${ZSH_COLORIZE_CHROMA_FORMATTER:-terminal}" "$FNAME"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
|
|
@ -55,15 +55,15 @@ if is-at-least 4.2.0; then
|
|||
# open browser on urls
|
||||
if [[ -n "$BROWSER" ]]; then
|
||||
_browser_fts=(htm html de org net com at cx nl se dk)
|
||||
for ft in $_browser_fts; do alias -s $ft=$BROWSER; done
|
||||
for ft in $_browser_fts; do alias -s $ft='$BROWSER'; done
|
||||
fi
|
||||
|
||||
_editor_fts=(cpp cxx cc c hh h inl asc txt TXT tex)
|
||||
for ft in $_editor_fts; do alias -s $ft=$EDITOR; done
|
||||
for ft in $_editor_fts; do alias -s $ft='$EDITOR'; done
|
||||
|
||||
if [[ -n "$XIVIEWER" ]]; then
|
||||
_image_fts=(jpg jpeg png gif mng tiff tif xpm)
|
||||
for ft in $_image_fts; do alias -s $ft=$XIVIEWER; done
|
||||
for ft in $_image_fts; do alias -s $ft='$XIVIEWER'; done
|
||||
fi
|
||||
|
||||
_media_fts=(ape avi flv m4a mkv mov mp3 mpeg mpg ogg ogm rm wav webm)
|
||||
|
|
|
@ -51,6 +51,8 @@ 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
|
||||
|
||||
_retrieve_cache composer
|
||||
|
||||
if [[ -z $__composer_bin_dir ]]; then
|
||||
|
|
|
@ -28,3 +28,4 @@ plugins=(... docker-compose)
|
|||
| dclf | `docker-compose logs -f` | Show logs and follow output |
|
||||
| dcpull | `docker-compose pull` | Pull image of a service |
|
||||
| dcstart | `docker-compose start` | Start a container |
|
||||
| dck | `docker-compose kill` | Kills containers |
|
||||
|
|
|
@ -24,3 +24,4 @@ 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'
|
||||
|
|
|
@ -10,3 +10,25 @@ plugins=(... docker)
|
|||
|
||||
A copy of the completion script from the docker/cli git repo:
|
||||
https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker
|
||||
|
||||
## Settings
|
||||
|
||||
By default, the completion doesn't allow option-stacking, meaning if you try to
|
||||
complete `docker run -it <TAB>` it won't work, because you're _stacking_ the
|
||||
`-i` and `-t` options.
|
||||
|
||||
[You can enable it](https://github.com/docker/cli/commit/b10fb43048) by **adding
|
||||
the lines below to your zshrc file**, but be aware of the side effects:
|
||||
|
||||
> This enables Zsh to understand commands like `docker run -it
|
||||
> ubuntu`. However, by enabling this, this also makes Zsh complete
|
||||
> `docker run -u<tab>` with `docker run -uapprox` which is not valid. The
|
||||
> users have to put the space or the equal sign themselves before trying
|
||||
> to complete.
|
||||
>
|
||||
> Therefore, this behavior is disabled by default. To enable it:
|
||||
>
|
||||
> ```
|
||||
> zstyle ':completion:*:*:docker:*' option-stacking yes
|
||||
> zstyle ':completion:*:*:docker-*:*' option-stacking yes
|
||||
> ```
|
||||
|
|
|
@ -53,24 +53,30 @@ Set `ZSH_DOTENV_PROMPT=false` in your zshrc file if you don't want the confirmat
|
|||
You can also choose the `Always` option when prompted to always allow sourcing the .env file
|
||||
in that directory. See the next section for more details.
|
||||
|
||||
### ZSH_DOTENV_ALLOWED_LIST
|
||||
### ZSH_DOTENV_ALLOWED_LIST, ZSH_DOTENV_DISALLOWED_LIST
|
||||
|
||||
The default behavior of the plugin is to always ask whether to source a dotenv file. There's
|
||||
a **Y**es, **N**o, and **A**lways option. If you choose Always, the directory of the .env file
|
||||
will be added to an allowed list. If a directory is found in this list, the plugin won't ask
|
||||
for confirmation and will instead source the .env file directly.
|
||||
a **Y**es, **N**o, **A**lways and N**e**ver option. If you choose Always, the directory of the .env file
|
||||
will be added to an allowed list; if you choose Never, it will be added to a disallowed list.
|
||||
If a directory is found in either of those lists, the plugin won't ask for confirmation and will
|
||||
instead either source the .env file or proceed without action respectively.
|
||||
|
||||
This allowed list is saved by default in `$ZSH_CACHE_DIR/dotenv-allowed.list`. If you want
|
||||
to change that location, change the `$ZSH_DOTENV_ALLOWED_LIST` variable, like so:
|
||||
The allowed and disallowed lists are saved by default in `$ZSH_CACHE_DIR/dotenv-allowed.list` and
|
||||
`$ZSH_CACHE_DIR/dotenv-disallowed.list` respectively. If you want to change that location,
|
||||
change the `$ZSH_DOTENV_ALLOWED_LIST` and `$ZSH_DOTENV_DISALLOWED_LIST` variables, like so:
|
||||
|
||||
```zsh
|
||||
# in ~/.zshrc, before Oh My Zsh is sourced:
|
||||
ZSH_DOTENV_ALLOWED_LIST=/path/to/dotenv/allowed/list
|
||||
ZSH_DOTENV_DISALLOWED_LIST=/path/to/dotenv/disallowed/list
|
||||
```
|
||||
|
||||
This file is just a list of directories allowed, separated by a newline character. If you want
|
||||
to disallow a directory, just edit this file and remove the line for the directory you want to
|
||||
disallow.
|
||||
The file is just a list of directories, separated by a newline character. If you want
|
||||
to change your decision, just edit the file and remove the line for the directory you want to
|
||||
change.
|
||||
|
||||
NOTE: if a directory is found in both the allowed and disallowed lists, the disallowed list
|
||||
takes preference, _i.e._ the .env file will never be sourced.
|
||||
|
||||
## Version Control
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
# Path to the file containing allowed paths
|
||||
: ${ZSH_DOTENV_ALLOWED_LIST:="${ZSH_CACHE_DIR:-$ZSH/cache}/dotenv-allowed.list"}
|
||||
: ${ZSH_DOTENV_DISALLOWED_LIST:="${ZSH_CACHE_DIR:-$ZSH/cache}/dotenv-disallowed.list"}
|
||||
|
||||
|
||||
## Functions
|
||||
|
@ -14,19 +15,26 @@ source_env() {
|
|||
if [[ "$ZSH_DOTENV_PROMPT" != false ]]; then
|
||||
local confirmation dirpath="${PWD:A}"
|
||||
|
||||
# make sure there is an allowed file
|
||||
# make sure there is an (dis-)allowed file
|
||||
touch "$ZSH_DOTENV_ALLOWED_LIST"
|
||||
touch "$ZSH_DOTENV_DISALLOWED_LIST"
|
||||
|
||||
# early return if disallowed
|
||||
if grep -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 ! grep -q "$dirpath" "$ZSH_DOTENV_ALLOWED_LIST" &>/dev/null; then
|
||||
# print same-line prompt and output newline character if necessary
|
||||
echo -n "dotenv: found '$ZSH_DOTENV_FILE' file. Source it? ([Y]es/[n]o/[a]lways) "
|
||||
echo -n "dotenv: found '$ZSH_DOTENV_FILE' file. Source it? ([Y]es/[n]o/[a]lways/n[e]ver) "
|
||||
read -k 1 confirmation; [[ "$confirmation" != $'\n' ]] && echo
|
||||
|
||||
# check input
|
||||
case "$confirmation" in
|
||||
[nN]) return ;;
|
||||
[aA]) echo "$dirpath" >> "$ZSH_DOTENV_ALLOWED_LIST" ;;
|
||||
[eE]) echo "$dirpath" >> "$ZSH_DOTENV_DISALLOWED_LIST"; return ;;
|
||||
*) ;; # interpret anything else as a yes
|
||||
esac
|
||||
fi
|
||||
|
|
|
@ -26,6 +26,16 @@ if "$ZSH/tools/require_tool.sh" emacsclient 24 2>/dev/null ; then
|
|||
# create a new X frame
|
||||
alias eframe='emacsclient --alternate-editor "" --create-frame'
|
||||
|
||||
# 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
|
||||
|
||||
# add chpwd hook
|
||||
autoload -Uz add-zsh-hook
|
||||
add-zsh-hook chpwd chpwd_emacs
|
||||
fi
|
||||
|
||||
# Write to standard output the path to the file
|
||||
# opened in the current buffer.
|
||||
|
|
|
@ -53,6 +53,6 @@ plugins=(... encode64)
|
|||
```console
|
||||
$ echo "b2gtbXktenNoCg==" | decode64
|
||||
oh-my-zsh
|
||||
$ echo "b2gtbXktenNoCg==" | decode64
|
||||
$ echo "b2gtbXktenNoCg==" | d64
|
||||
oh-my-zsh
|
||||
```
|
||||
|
|
|
@ -23,6 +23,7 @@ plugins=(... extract)
|
|||
| `bz2` | Bzip2 file |
|
||||
| `deb` | Debian package |
|
||||
| `gz` | Gzip file |
|
||||
| `ipa` | iOS app package |
|
||||
| `ipsw` | iOS firmware file |
|
||||
| `jar` | Java Archive |
|
||||
| `lrz` | LRZ archive |
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
|
||||
_arguments \
|
||||
'(-r --remove)'{-r,--remove}'[Remove archive.]' \
|
||||
"*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|deb|gz|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst)(-.)'" \
|
||||
"*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|deb|gz|ipa|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst)(-.)'" \
|
||||
&& return 0
|
||||
|
|
|
@ -55,7 +55,7 @@ extract() {
|
|||
(*.lz4) lz4 -d "$1" ;;
|
||||
(*.lzma) unlzma "$1" ;;
|
||||
(*.z) uncompress "$1" ;;
|
||||
(*.zip|*.war|*.jar|*.sublime-package|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d $extract_dir ;;
|
||||
(*.zip|*.war|*.jar|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$1" -d $extract_dir ;;
|
||||
(*.rar) unrar x -ad "$1" ;;
|
||||
(*.rpm) mkdir "$extract_dir" && cd "$extract_dir" && rpm2cpio "../$1" | cpio --quiet -id && cd .. ;;
|
||||
(*.7z) 7za x "$1" ;;
|
||||
|
|
|
@ -1,19 +1,52 @@
|
|||
# fzf
|
||||
|
||||
This plugin enables [junegunn's fzf](https://github.com/junegunn/fzf) fuzzy auto-completion and key bindings
|
||||
This plugin tries to find [junegunn's fzf](https://github.com/junegunn/fzf) based on where
|
||||
it's been installed, and enables its fuzzy auto-completion and key bindings.
|
||||
|
||||
To use it, add `fzf` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
# Set fzf installation directory path
|
||||
export FZF_BASE=/path/to/fzf/install/dir
|
||||
|
||||
# Uncomment the following line to disable fuzzy completion
|
||||
# export DISABLE_FZF_AUTO_COMPLETION="true"
|
||||
|
||||
# Uncomment the following line to disable key bindings (CTRL-T, CTRL-R, ALT-C)
|
||||
# export DISABLE_FZF_KEY_BINDINGS="true"
|
||||
|
||||
plugins=(
|
||||
...
|
||||
fzf
|
||||
)
|
||||
plugins=(... fzf)
|
||||
```
|
||||
|
||||
## Settings
|
||||
|
||||
All these settings should go in your zshrc file, before Oh My Zsh is sourced.
|
||||
|
||||
### `FZF_BASE`
|
||||
|
||||
Set to fzf installation directory path:
|
||||
|
||||
```zsh
|
||||
export FZF_BASE=/path/to/fzf/install/dir
|
||||
```
|
||||
|
||||
### `FZF_DEFAULT_COMMAND`
|
||||
|
||||
Set default command to use when input is tty:
|
||||
|
||||
```zsh
|
||||
export FZF_DEFAULT_COMMAND='<your fzf default commmand>'
|
||||
```
|
||||
|
||||
If not set, the plugin will try to set it to these, in the order in which they're found:
|
||||
|
||||
- [`rg`](https://github.com/BurntSushi/ripgrep)
|
||||
- [`fd`](https://github.com/sharkdp/fd)
|
||||
- [`ag`](https://github.com/ggreer/the_silver_searcher)
|
||||
|
||||
### `DISABLE_FZF_AUTO_COMPLETION`
|
||||
|
||||
Set whether to load fzf auto-completion:
|
||||
|
||||
```zsh
|
||||
DISABLE_FZF_AUTO_COMPLETION="true"
|
||||
```
|
||||
|
||||
### `DISABLE_FZF_KEY_BINDINGS`
|
||||
|
||||
Set whether to disable key bindings (CTRL-T, CTRL-R, ALT-C):
|
||||
|
||||
```zsh
|
||||
DISABLE_FZF_KEY_BINDINGS="true"
|
||||
```
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
function setup_using_base_dir() {
|
||||
# Declare all variables local not no mess with outside env in any way
|
||||
local fzf_base
|
||||
local fzf_shell
|
||||
local fzfdirs
|
||||
local dir
|
||||
local fzf_base fzf_shell fzfdirs dir
|
||||
|
||||
test -d "${FZF_BASE}" && fzf_base="${FZF_BASE}"
|
||||
|
||||
|
@ -31,38 +27,37 @@ function setup_using_base_dir() {
|
|||
fi
|
||||
fi
|
||||
|
||||
if [[ -d "${fzf_base}" ]]; then
|
||||
# Fix fzf shell directory for Arch Linux, NixOS or Void Linux packages
|
||||
if [[ ! -d "${fzf_base}/shell" ]]; then
|
||||
fzf_shell="${fzf_base}"
|
||||
else
|
||||
fzf_shell="${fzf_base}/shell"
|
||||
fi
|
||||
|
||||
# Setup fzf binary path
|
||||
if ! (( ${+commands[fzf]} )) && [[ ! "$PATH" == *$fzf_base/bin* ]]; then
|
||||
export PATH="$PATH:$fzf_base/bin"
|
||||
fi
|
||||
|
||||
# Auto-completion
|
||||
if [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then
|
||||
[[ $- == *i* ]] && source "${fzf_shell}/completion.zsh" 2> /dev/null
|
||||
fi
|
||||
|
||||
# Key bindings
|
||||
if [[ ! "$DISABLE_FZF_KEY_BINDINGS" == "true" ]]; then
|
||||
source "${fzf_shell}/key-bindings.zsh"
|
||||
fi
|
||||
else
|
||||
if [[ ! -d "${fzf_base}" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Fix fzf shell directory for Arch Linux, NixOS or Void Linux packages
|
||||
if [[ ! -d "${fzf_base}/shell" ]]; then
|
||||
fzf_shell="${fzf_base}"
|
||||
else
|
||||
fzf_shell="${fzf_base}/shell"
|
||||
fi
|
||||
|
||||
# Setup fzf binary path
|
||||
if (( ! ${+commands[fzf]} )) && [[ "$PATH" != *$fzf_base/bin* ]]; then
|
||||
export PATH="$PATH:$fzf_base/bin"
|
||||
fi
|
||||
|
||||
# Auto-completion
|
||||
if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then
|
||||
source "${fzf_shell}/completion.zsh" 2> /dev/null
|
||||
fi
|
||||
|
||||
# Key bindings
|
||||
if [[ "$DISABLE_FZF_KEY_BINDINGS" != "true" ]]; then
|
||||
source "${fzf_shell}/key-bindings.zsh"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function setup_using_debian_package() {
|
||||
(( $+commands[dpkg] )) && dpkg -s fzf &> /dev/null
|
||||
if (( $? )); then
|
||||
# Either not a debian based distro, or no fzf installed. In any case skip ahead
|
||||
if (( ! $+commands[dpkg] )) || ! dpkg -s fzf &>/dev/null; then
|
||||
# Either not a debian based distro, or no fzf installed
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
@ -76,8 +71,8 @@ function setup_using_debian_package() {
|
|||
local key_bindings="/usr/share/doc/fzf/examples/key-bindings.zsh"
|
||||
|
||||
# Auto-completion
|
||||
if [[ $- == *i* ]] && [[ ! "$DISABLE_FZF_AUTO_COMPLETION" == "true" ]]; then
|
||||
source $completions 2> /dev/null
|
||||
if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then
|
||||
source $completions 2> /dev/null
|
||||
fi
|
||||
|
||||
# Key bindings
|
||||
|
@ -88,13 +83,81 @@ function setup_using_debian_package() {
|
|||
return 0
|
||||
}
|
||||
|
||||
function indicate_error() {
|
||||
print "[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.\n"\
|
||||
"Please add \`export FZF_BASE=/path/to/fzf/install/dir\` to your .zshrc" >&2
|
||||
function setup_using_opensuse_package() {
|
||||
# OpenSUSE installs fzf in /usr/bin/fzf
|
||||
# If the command is not found, the package isn't installed
|
||||
(( $+commands[fzf] )) || return 1
|
||||
|
||||
# The fzf-zsh-completion package installs the auto-completion in
|
||||
local completions="/usr/share/zsh/site-functions/_fzf"
|
||||
# The fzf-zsh-completion package installs the key-bindings file in
|
||||
local key_bindings="/etc/zsh_completion.d/fzf-key-bindings"
|
||||
|
||||
# If these are not found: (1) maybe we're not on OpenSUSE, or
|
||||
# (2) maybe the fzf-zsh-completion package isn't installed.
|
||||
if [[ ! -f "$completions" || ! -f "$key_bindings" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Auto-completion
|
||||
if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then
|
||||
source "$completions" 2>/dev/null
|
||||
fi
|
||||
|
||||
# Key bindings
|
||||
if [[ "$DISABLE_FZF_KEY_BINDINGS" != "true" ]]; then
|
||||
source "$key_bindings" 2>/dev/null
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Check for debian package first, because it easy to short cut
|
||||
# Indicate to user that fzf installation not found if nothing worked
|
||||
setup_using_debian_package || setup_using_base_dir || indicate_error
|
||||
function setup_using_openbsd_package() {
|
||||
# openBSD installs fzf in /usr/local/bin/fzf
|
||||
if [[ "$OSTYPE" != openbsd* ]] || (( ! $+commands[fzf] )); then
|
||||
return 1
|
||||
fi
|
||||
|
||||
unset -f setup_using_debian_package setup_using_base_dir indicate_error
|
||||
# The fzf package installs the auto-completion in
|
||||
local completions="/usr/local/share/zsh/site-functions/_fzf_completion"
|
||||
# The fzf package installs the key-bindings file in
|
||||
local key_bindings="/usr/local/share/zsh/site-functions/_fzf_key_bindings"
|
||||
|
||||
# Auto-completion
|
||||
if [[ -o interactive && "$DISABLE_FZF_AUTO_COMPLETION" != "true" ]]; then
|
||||
source "$completions" 2>/dev/null
|
||||
fi
|
||||
|
||||
# Key bindings
|
||||
if [[ "$DISABLE_FZF_KEY_BINDINGS" != "true" ]]; then
|
||||
source "$key_bindings" 2>/dev/null
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
function indicate_error() {
|
||||
cat >&2 <<EOF
|
||||
[oh-my-zsh] fzf plugin: Cannot find fzf installation directory.
|
||||
Please add \`export FZF_BASE=/path/to/fzf/install/dir\` to your .zshrc
|
||||
EOF
|
||||
}
|
||||
|
||||
# Indicate to user that fzf installation not found if nothing worked
|
||||
setup_using_openbsd_package \
|
||||
|| setup_using_debian_package \
|
||||
|| setup_using_opensuse_package \
|
||||
|| setup_using_base_dir \
|
||||
|| indicate_error
|
||||
|
||||
unset -f setup_using_opensuse_package setup_using_debian_package setup_using_base_dir indicate_error
|
||||
|
||||
if [[ -z "$FZF_DEFAULT_COMMAND" ]]; then
|
||||
if (( $+commands[rg] )); then
|
||||
export FZF_DEFAULT_COMMAND='rg --files --hidden --glob "!.git/*"'
|
||||
elif (( $+commands[fd] )); then
|
||||
export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude .git'
|
||||
elif (( $+commands[ag] )); then
|
||||
export FZF_DEFAULT_COMMAND='ag -l --hidden -g "" --ignore .git'
|
||||
fi
|
||||
fi
|
||||
|
|
24
dot_oh-my-zsh/plugins/git-lfs/README.md
Normal file
24
dot_oh-my-zsh/plugins/git-lfs/README.md
Normal file
|
@ -0,0 +1,24 @@
|
|||
# git lfs plugin
|
||||
|
||||
The git lfs plugin provides [aliases](#aliases) and [functions](#functions) for [git-lfs](https://github.com/git-lfs/git-lfs).
|
||||
|
||||
To use it, add `git-lfs` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... git-lfs)
|
||||
```
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command |
|
||||
| :------- | :---------------------------------- |
|
||||
| `glfsi` | `git lfs install` |
|
||||
| `glfst` | `git lfs track` |
|
||||
| `glfsls` | `git lfs ls-files` |
|
||||
| `glfsmi` | `git lfs migrate import --include=` |
|
||||
|
||||
## Functions
|
||||
|
||||
| Function | Command |
|
||||
| :------- | :---------------------------------------------- |
|
||||
| `gplfs` | `git lfs push origin "$(current_branch)" --all` |
|
17
dot_oh-my-zsh/plugins/git-lfs/git-lfs.plugin.zsh
Normal file
17
dot_oh-my-zsh/plugins/git-lfs/git-lfs.plugin.zsh
Normal file
|
@ -0,0 +1,17 @@
|
|||
#
|
||||
# Aliases
|
||||
#
|
||||
|
||||
alias glfsi='git lfs install'
|
||||
alias glfst='git lfs track'
|
||||
alias glfsls='git lfs ls-files'
|
||||
alias glfsmi='git lfs migrate import --include='
|
||||
|
||||
#
|
||||
# Functions
|
||||
#
|
||||
|
||||
function gplfs() {
|
||||
local b="$(git_current_branch)"
|
||||
git lfs push origin "$b" --all
|
||||
}
|
|
@ -11,6 +11,9 @@ plugins=(... git-prompt)
|
|||
|
||||
See the [original repository](https://github.com/olivierverdier/zsh-git-prompt).
|
||||
|
||||
## Prerequisites
|
||||
This plugin uses `python`, so your host needs to have it installed
|
||||
|
||||
## Examples
|
||||
|
||||
The prompt may look like the following:
|
||||
|
|
|
@ -23,7 +23,7 @@ plugins=(... git)
|
|||
| gb | git branch |
|
||||
| gba | git branch -a |
|
||||
| gbd | git branch -d |
|
||||
| gbda | git branch --no-color --merged \| command grep -vE "^(\+\|\*\|\s*(master\|development\|develop\|devel\|dev)\s*$)" \| command xargs -n 1 git branch -d |
|
||||
| gbda | git branch --no-color --merged \| command grep -vE "^(\+\|\*\|\s*($(git_main_branch)\|development\|develop\|devel\|dev)\s*$)" \| command xargs -n 1 git branch -d |
|
||||
| gbD | git branch -D |
|
||||
| gbl | git blame -b -w |
|
||||
| gbnm | git branch --no-merged |
|
||||
|
@ -47,7 +47,7 @@ plugins=(... git)
|
|||
| gcl | git clone --recurse-submodules |
|
||||
| gclean | git clean -id |
|
||||
| gpristine | git reset --hard && git clean -dffx |
|
||||
| gcm | git checkout master |
|
||||
| gcm | git checkout $(git_main_branch) |
|
||||
| gcd | git checkout develop |
|
||||
| gcmsg | git commit -m |
|
||||
| gco | git checkout |
|
||||
|
@ -85,7 +85,7 @@ plugins=(... git)
|
|||
| ghh | git help |
|
||||
| gignore | git update-index --assume-unchanged |
|
||||
| gignored | git ls-files -v \| grep "^[[:lower:]]" |
|
||||
| git-svn-dcommit-push | git svn dcommit && git push github master:svntrunk |
|
||||
| git-svn-dcommit-push | git svn dcommit && git push github $(git_main_branch):svntrunk |
|
||||
| gk | gitk --all --branches |
|
||||
| gke | gitk --all $(git log -g --pretty=%h) |
|
||||
| gl | git pull |
|
||||
|
@ -102,12 +102,12 @@ plugins=(... git)
|
|||
| glola | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all |
|
||||
| glog | git log --oneline --decorate --graph |
|
||||
| gloga | git log --oneline --decorate --graph --all |
|
||||
| glp | git log --pretty=\<format\> |
|
||||
| glp | git log --pretty=\<format\> |
|
||||
| gm | git merge |
|
||||
| gmom | git merge origin/master |
|
||||
| gmom | git merge origin/$(git_main_branch) |
|
||||
| gmt | git mergetool --no-prompt |
|
||||
| gmtvim | git mergetool --no-prompt --tool=vimdiff |
|
||||
| gmum | git merge upstream/master |
|
||||
| gmum | git merge upstream/$(git_main_branch) |
|
||||
| gma | git merge --abort |
|
||||
| gp | git push |
|
||||
| gpd | git push --dry-run |
|
||||
|
@ -123,7 +123,7 @@ plugins=(... git)
|
|||
| grbc | git rebase --continue |
|
||||
| grbd | git rebase develop |
|
||||
| grbi | git rebase -i |
|
||||
| grbm | git rebase master |
|
||||
| grbm | git rebase $(git_main_branch) |
|
||||
| grbs | git rebase --skip |
|
||||
| grev | git revert |
|
||||
| grh | git reset |
|
||||
|
@ -170,7 +170,7 @@ plugins=(... git)
|
|||
| gupv | git pull --rebase -v |
|
||||
| gupa | git pull --rebase --autostash |
|
||||
| gupav | git pull --rebase --autostash -v |
|
||||
| glum | git pull upstream master |
|
||||
| glum | git pull upstream $(git_main_branch) |
|
||||
| gwch | git whatchanged -p --abbrev-commit --pretty=medium |
|
||||
| gwip | git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]" |
|
||||
| gam | git am |
|
||||
|
@ -179,6 +179,13 @@ plugins=(... git)
|
|||
| gama | git am --abort |
|
||||
| gamscp | git am --show-current-patch |
|
||||
|
||||
### Main branch preference
|
||||
|
||||
Following the recent push for removing racially-charged words from our technical vocabulary, the git plugin favors using
|
||||
a branch name other than `master`. In this case, we favor the shorter, neutral and descriptive term `main`. This means
|
||||
that any aliases and functions that previously used `master`, will use `main` if that branch exists. We do this via the
|
||||
function `git_main_branch`.
|
||||
|
||||
### Deprecated aliases
|
||||
|
||||
These are aliases that have been removed, renamed, or otherwise modified in a way that may, or may not, receive further support.
|
||||
|
@ -201,12 +208,13 @@ These are aliases that have been removed, renamed, or otherwise modified in a wa
|
|||
|
||||
### Current
|
||||
|
||||
| Command | Description |
|
||||
|:-----------------------|:---------------------------------------------------------|
|
||||
| `grename <old> <new>` | Rename `old` branch to `new`, including in origin remote |
|
||||
| current_branch | Return the name of the current branch |
|
||||
| git_current_user_name | Returns the `user.name` config value |
|
||||
| git_current_user_email | Returns the `user.email` config value |
|
||||
| Command | Description |
|
||||
|:-----------------------|:-----------------------------------------------------------------------------|
|
||||
| `grename <old> <new>` | Rename `old` branch to `new`, including in origin remote |
|
||||
| current_branch | Return the name of the current branch |
|
||||
| git_current_user_name | Returns the `user.name` config value |
|
||||
| git_current_user_email | Returns the `user.email` config value |
|
||||
| git_main_branch | Returns the name of the main branch: `main` if it exists, `master` otherwise |
|
||||
|
||||
### Work in Progress (WIP)
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
# Git version checking
|
||||
autoload -Uz is-at-least
|
||||
git_version="${${(As: :)$(git version 2>/dev/null)}[3]}"
|
||||
|
||||
#
|
||||
# Functions
|
||||
#
|
||||
|
@ -25,6 +29,18 @@ function work_in_progress() {
|
|||
fi
|
||||
}
|
||||
|
||||
# Check if main exists and use instead of master
|
||||
function git_main_branch() {
|
||||
local branch
|
||||
for branch in main trunk; do
|
||||
if command git show-ref -q --verify refs/heads/$branch; then
|
||||
echo $branch
|
||||
return
|
||||
fi
|
||||
done
|
||||
echo master
|
||||
}
|
||||
|
||||
#
|
||||
# Aliases
|
||||
# (sorted alphabetically)
|
||||
|
@ -43,7 +59,7 @@ alias gapt='git apply --3way'
|
|||
alias gb='git branch'
|
||||
alias gba='git branch -a'
|
||||
alias gbd='git branch -d'
|
||||
alias gbda='git branch --no-color --merged | command grep -vE "^(\+|\*|\s*(master|development|develop|devel|dev)\s*$)" | command xargs -n 1 git branch -d'
|
||||
alias gbda='git branch --no-color --merged | command grep -vE "^(\+|\*|\s*($(git_main_branch)|development|develop|devel|dev)\s*$)" | command xargs -n 1 git branch -d'
|
||||
alias gbD='git branch -D'
|
||||
alias gbl='git blame -b -w'
|
||||
alias gbnm='git branch --no-merged'
|
||||
|
@ -68,7 +84,7 @@ alias gcf='git config --list'
|
|||
alias gcl='git clone --recurse-submodules'
|
||||
alias gclean='git clean -id'
|
||||
alias gpristine='git reset --hard && git clean -dffx'
|
||||
alias gcm='git checkout master'
|
||||
alias gcm='git checkout $(git_main_branch)'
|
||||
alias gcd='git checkout develop'
|
||||
alias gcmsg='git commit -m'
|
||||
alias gco='git checkout'
|
||||
|
@ -95,7 +111,10 @@ function gdv() { git diff -w "$@" | view - }
|
|||
compdef _git gdv=git-diff
|
||||
|
||||
alias gf='git fetch'
|
||||
alias gfa='git fetch --all --prune'
|
||||
# --jobs=<n> was added in git 2.8
|
||||
is-at-least 2.8 "$git_version" \
|
||||
&& alias gfa='git fetch --all --prune --jobs=10' \
|
||||
|| alias gfa='git fetch --all --prune'
|
||||
alias gfo='git fetch origin'
|
||||
|
||||
alias gfg='git ls-files | grep'
|
||||
|
@ -160,7 +179,7 @@ alias ghh='git help'
|
|||
|
||||
alias gignore='git update-index --assume-unchanged'
|
||||
alias gignored='git ls-files -v | grep "^[[:lower:]]"'
|
||||
alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
|
||||
alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk'
|
||||
|
||||
alias gk='\gitk --all --branches'
|
||||
alias gke='\gitk --all $(git log -g --pretty=%h)'
|
||||
|
@ -182,10 +201,10 @@ alias gloga='git log --oneline --decorate --graph --all'
|
|||
alias glp="_git_log_prettily"
|
||||
|
||||
alias gm='git merge'
|
||||
alias gmom='git merge origin/master'
|
||||
alias gmom='git merge origin/$(git_main_branch)'
|
||||
alias gmt='git mergetool --no-prompt'
|
||||
alias gmtvim='git mergetool --no-prompt --tool=vimdiff'
|
||||
alias gmum='git merge upstream/master'
|
||||
alias gmum='git merge upstream/$(git_main_branch)'
|
||||
alias gma='git merge --abort'
|
||||
|
||||
alias gp='git push'
|
||||
|
@ -203,7 +222,7 @@ alias grba='git rebase --abort'
|
|||
alias grbc='git rebase --continue'
|
||||
alias grbd='git rebase develop'
|
||||
alias grbi='git rebase -i'
|
||||
alias grbm='git rebase master'
|
||||
alias grbm='git rebase $(git_main_branch)'
|
||||
alias grbs='git rebase --skip'
|
||||
alias grev='git revert'
|
||||
alias grh='git reset'
|
||||
|
@ -231,8 +250,7 @@ alias gss='git status -s'
|
|||
alias gst='git status'
|
||||
|
||||
# use the default stash push on git 2.13 and newer
|
||||
autoload -Uz is-at-least
|
||||
is-at-least 2.13 "$(git --version 2>/dev/null | awk '{print $3}')" \
|
||||
is-at-least 2.13 "$git_version" \
|
||||
&& alias gsta='git stash push' \
|
||||
|| alias gsta='git stash save'
|
||||
|
||||
|
@ -258,7 +276,7 @@ alias gup='git pull --rebase'
|
|||
alias gupv='git pull --rebase -v'
|
||||
alias gupa='git pull --rebase --autostash'
|
||||
alias gupav='git pull --rebase --autostash -v'
|
||||
alias glum='git pull upstream master'
|
||||
alias glum='git pull upstream $(git_main_branch)'
|
||||
|
||||
alias gwch='git whatchanged -p --abbrev-commit --pretty=medium'
|
||||
alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]"'
|
||||
|
@ -282,3 +300,5 @@ function grename() {
|
|||
git push --set-upstream origin "$2"
|
||||
fi
|
||||
}
|
||||
|
||||
unset git_version
|
||||
|
|
|
@ -2,25 +2,24 @@
|
|||
|
||||
# zsh completion wrapper for git
|
||||
#
|
||||
# Copyright (c) 2012-2013 Felipe Contreras <felipe.contreras@gmail.com>
|
||||
# Copyright (c) 2012-2020 Felipe Contreras <felipe.contreras@gmail.com>
|
||||
#
|
||||
# You need git's bash completion script installed somewhere, by default it
|
||||
# would be the location bash-completion uses.
|
||||
# The recommended way to install this script is to make a copy of it as a
|
||||
# file named '_git' inside any directory in your fpath.
|
||||
#
|
||||
# If your script is somewhere else, you can configure it on your ~/.zshrc:
|
||||
#
|
||||
# zstyle ':completion:*:*:git:*' script ~/.git-completion.zsh
|
||||
#
|
||||
# The recommended way to install this script is to copy to '~/.zsh/_git', and
|
||||
# then add the following to your ~/.zshrc file:
|
||||
# For example, create a directory '~/.zsh/', copy this file to '~/.zsh/_git',
|
||||
# and then add the following to your ~/.zshrc file:
|
||||
#
|
||||
# fpath=(~/.zsh $fpath)
|
||||
|
||||
complete ()
|
||||
{
|
||||
# do nothing
|
||||
return 0
|
||||
}
|
||||
#
|
||||
# You need git's bash completion script installed. By default bash-completion's
|
||||
# location will be used (e.g. pkg-config --variable=completionsdir bash-completion).
|
||||
#
|
||||
# If your bash completion script is somewhere else, you can specify the
|
||||
# location in your ~/.zshrc:
|
||||
#
|
||||
# zstyle ':completion:*:*:git:*' script ~/.git-completion.bash
|
||||
#
|
||||
|
||||
zstyle -T ':completion:*:*:git:*' tag-order && \
|
||||
zstyle ':completion:*:*:git:*' tag-order 'common-commands'
|
||||
|
@ -28,18 +27,26 @@ zstyle -T ':completion:*:*:git:*' tag-order && \
|
|||
zstyle -s ":completion:*:*:git:*" script script
|
||||
if [ -z "$script" ]; then
|
||||
local -a locations
|
||||
local e
|
||||
local e bash_completion
|
||||
|
||||
bash_completion=$(pkg-config --variable=completionsdir bash-completion 2>/dev/null) ||
|
||||
bash_completion='/usr/share/bash-completion/completions/'
|
||||
|
||||
locations=(
|
||||
"$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash"
|
||||
'/etc/bash_completion.d/git' # fedora, old debian
|
||||
'/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian
|
||||
'/usr/share/bash-completion/git' # gentoo
|
||||
"$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash
|
||||
"$HOME/.local/share/bash-completion/completions/git"
|
||||
"$bash_completion/git"
|
||||
'/etc/bash_completion.d/git' # old debian
|
||||
)
|
||||
for e in $locations; do
|
||||
test -f $e && script="$e" && break
|
||||
done
|
||||
fi
|
||||
ZSH_VERSION='' . "$script"
|
||||
|
||||
local old_complete="$functions[complete]"
|
||||
functions[complete]=:
|
||||
GIT_SOURCING_ZSH_COMPLETION=y . "$script"
|
||||
functions[complete]="$old_complete"
|
||||
|
||||
__gitcomp ()
|
||||
{
|
||||
|
@ -50,13 +57,35 @@ __gitcomp ()
|
|||
case "$cur_" in
|
||||
--*=)
|
||||
;;
|
||||
--no-*)
|
||||
local c IFS=$' \t\n'
|
||||
local -a array
|
||||
for c in ${=1}; do
|
||||
if [[ $c == "--" ]]; then
|
||||
continue
|
||||
fi
|
||||
c="$c${4-}"
|
||||
case $c in
|
||||
--*=|*.) ;;
|
||||
*) c="$c " ;;
|
||||
esac
|
||||
array+=("$c")
|
||||
done
|
||||
compset -P '*[=:]'
|
||||
compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
|
||||
;;
|
||||
*)
|
||||
local c IFS=$' \t\n'
|
||||
local -a array
|
||||
for c in ${=1}; do
|
||||
if [[ $c == "--" ]]; then
|
||||
c="--no-...${4-}"
|
||||
array+=("$c ")
|
||||
break
|
||||
fi
|
||||
c="$c${4-}"
|
||||
case $c in
|
||||
--*=*|*.) ;;
|
||||
--*=|*.) ;;
|
||||
*) c="$c " ;;
|
||||
esac
|
||||
array+=("$c")
|
||||
|
@ -71,35 +100,57 @@ __gitcomp_direct ()
|
|||
{
|
||||
emulate -L zsh
|
||||
|
||||
local IFS=$'\n'
|
||||
compset -P '*[=:]'
|
||||
compadd -Q -- ${=1} && _ret=0
|
||||
compadd -Q -S '' -- ${(f)1} && _ret=0
|
||||
}
|
||||
|
||||
__gitcomp_nl ()
|
||||
{
|
||||
emulate -L zsh
|
||||
|
||||
local IFS=$'\n'
|
||||
compset -P '*[=:]'
|
||||
compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
|
||||
}
|
||||
|
||||
__gitcomp_nl_append ()
|
||||
{
|
||||
emulate -L zsh
|
||||
|
||||
local IFS=$'\n'
|
||||
compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
|
||||
compadd -Q -S "${4- }" -p "${2-}" -- ${(f)1} && _ret=0
|
||||
}
|
||||
|
||||
__gitcomp_file ()
|
||||
{
|
||||
emulate -L zsh
|
||||
|
||||
local IFS=$'\n'
|
||||
compset -P '*[=:]'
|
||||
compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
|
||||
compadd -f -p "${2-}" -- ${(f)1} && _ret=0
|
||||
}
|
||||
|
||||
__gitcomp_direct_append ()
|
||||
{
|
||||
__gitcomp_direct "$@"
|
||||
}
|
||||
|
||||
__gitcomp_nl_append ()
|
||||
{
|
||||
__gitcomp_nl "$@"
|
||||
}
|
||||
|
||||
__gitcomp_file_direct ()
|
||||
{
|
||||
__gitcomp_file "$1" ""
|
||||
}
|
||||
|
||||
_git_zsh ()
|
||||
{
|
||||
__gitcomp "v1.0"
|
||||
}
|
||||
|
||||
__git_complete_command ()
|
||||
{
|
||||
emulate -L zsh
|
||||
|
||||
local command="$1"
|
||||
local completion_func="_git_${command//-/_}"
|
||||
if (( $+functions[$completion_func] )); then
|
||||
emulate ksh -c $completion_func
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
__git_zsh_bash_func ()
|
||||
|
@ -108,14 +159,12 @@ __git_zsh_bash_func ()
|
|||
|
||||
local command=$1
|
||||
|
||||
local completion_func="_git_${command//-/_}"
|
||||
declare -f $completion_func >/dev/null && $completion_func && return
|
||||
__git_complete_command "$command" && return
|
||||
|
||||
local expansion=$(__git_aliased_command "$command")
|
||||
if [ -n "$expansion" ]; then
|
||||
words[1]=$expansion
|
||||
completion_func="_git_${expansion//-/_}"
|
||||
declare -f $completion_func >/dev/null && $completion_func
|
||||
__git_complete_command "$expansion"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -140,9 +189,11 @@ __git_zsh_cmd_common ()
|
|||
push:'update remote refs along with associated objects'
|
||||
rebase:'forward-port local commits to the updated upstream head'
|
||||
reset:'reset current HEAD to the specified state'
|
||||
restore:'restore working tree files'
|
||||
rm:'remove files from the working tree and from the index'
|
||||
show:'show various types of objects'
|
||||
status:'show the working tree status'
|
||||
switch:'switch branches'
|
||||
tag:'create, list, delete or verify a tag object signed with GPG')
|
||||
_describe -t common-commands 'common commands' list && _ret=0
|
||||
}
|
||||
|
@ -150,8 +201,9 @@ __git_zsh_cmd_common ()
|
|||
__git_zsh_cmd_alias ()
|
||||
{
|
||||
local -a list
|
||||
list=(${${${(0)"$(git config -z --get-regexp '^alias\.')"}#alias.}%$'\n'*})
|
||||
_describe -t alias-commands 'aliases' list $* && _ret=0
|
||||
list=(${${(0)"$(git config -z --get-regexp '^alias\.*')"}#alias.})
|
||||
list=(${(f)"$(printf "%s:alias for '%s'\n" ${(f@)list})"})
|
||||
_describe -t alias-commands 'aliases' list && _ret=0
|
||||
}
|
||||
|
||||
__git_zsh_cmd_all ()
|
||||
|
@ -189,10 +241,13 @@ __git_zsh_main ()
|
|||
|
||||
case $state in
|
||||
(command)
|
||||
_alternative \
|
||||
'alias-commands:alias:__git_zsh_cmd_alias' \
|
||||
'common-commands:common:__git_zsh_cmd_common' \
|
||||
'all-commands:all:__git_zsh_cmd_all' && _ret=0
|
||||
_tags common-commands alias-commands all-commands
|
||||
while _tags; do
|
||||
_requested common-commands && __git_zsh_cmd_common
|
||||
_requested alias-commands && __git_zsh_cmd_alias
|
||||
_requested all-commands && __git_zsh_cmd_all
|
||||
let _ret || break
|
||||
done
|
||||
;;
|
||||
(arg)
|
||||
local command="${words[1]}" __git_dir
|
||||
|
@ -227,6 +282,8 @@ _git ()
|
|||
emulate ksh -c __${service}_main
|
||||
elif (( $+functions[_${service}] )); then
|
||||
emulate ksh -c _${service}
|
||||
elif (( $+functions[_${service//-/_}] )); then
|
||||
emulate ksh -c _${service//-/_}
|
||||
fi
|
||||
|
||||
let _ret && _default && _ret=0
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
url="https://git.kernel.org/pub/scm/git/git.git/plain/contrib/completion"
|
||||
version="2.16.0"
|
||||
url="https://raw.githubusercontent.com/felipec/git-completion"
|
||||
version="1.0"
|
||||
|
||||
curl -s -o _git "${url}/git-completion.zsh?h=v${version}" &&
|
||||
curl -s -o git-completion.bash "${url}/git-completion.bash?h=v${version}" &&
|
||||
curl -s -o git-prompt.sh "${url}/git-prompt.sh?h=v${version}" &&
|
||||
git apply updates.patch
|
||||
curl -s -o _git "${url}/v${version}/git-completion.zsh" &&
|
||||
curl -s -o git-completion.bash "${url}/v${version}/git-completion.bash" &&
|
||||
curl -s -o git-prompt.sh "${url}/v${version}/git-prompt.sh"
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -70,6 +70,15 @@
|
|||
# state symbols by setting GIT_PS1_STATESEPARATOR. The default separator
|
||||
# is SP.
|
||||
#
|
||||
# When there is an in-progress operation such as a merge, rebase,
|
||||
# revert, cherry-pick, or bisect, the prompt will include information
|
||||
# related to the operation, often in the form "|<OPERATION-NAME>".
|
||||
#
|
||||
# When the repository has a sparse-checkout, a notification of the form
|
||||
# "|SPARSE" will be included in the prompt. This can be shortened to a
|
||||
# single '?' character by setting GIT_PS1_COMPRESSSPARSESTATE, or omitted
|
||||
# by setting GIT_PS1_OMITSPARSESTATE.
|
||||
#
|
||||
# By default, __git_ps1 will compare HEAD to your SVN upstream if it can
|
||||
# find one, or @{upstream} otherwise. Once you have set
|
||||
# GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by
|
||||
|
@ -88,7 +97,8 @@
|
|||
# If you would like a colored hint about the current dirty state, set
|
||||
# GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on
|
||||
# the colored output of "git status -sb" and are available only when
|
||||
# using __git_ps1 for PROMPT_COMMAND or precmd.
|
||||
# using __git_ps1 for PROMPT_COMMAND or precmd in Bash,
|
||||
# but always available in Zsh.
|
||||
#
|
||||
# If you would like __git_ps1 to do nothing in the case when the current
|
||||
# directory is set up to be ignored by git, then set
|
||||
|
@ -286,6 +296,37 @@ __git_eread ()
|
|||
test -r "$1" && IFS=$'\r\n' read "$2" <"$1"
|
||||
}
|
||||
|
||||
# see if a cherry-pick or revert is in progress, if the user has committed a
|
||||
# conflict resolution with 'git commit' in the middle of a sequence of picks or
|
||||
# reverts then CHERRY_PICK_HEAD/REVERT_HEAD will not exist so we have to read
|
||||
# the todo file.
|
||||
__git_sequencer_status ()
|
||||
{
|
||||
local todo
|
||||
if test -f "$g/CHERRY_PICK_HEAD"
|
||||
then
|
||||
r="|CHERRY-PICKING"
|
||||
return 0;
|
||||
elif test -f "$g/REVERT_HEAD"
|
||||
then
|
||||
r="|REVERTING"
|
||||
return 0;
|
||||
elif __git_eread "$g/sequencer/todo" todo
|
||||
then
|
||||
case "$todo" in
|
||||
p[\ \ ]|pick[\ \ ]*)
|
||||
r="|CHERRY-PICKING"
|
||||
return 0
|
||||
;;
|
||||
revert[\ \ ]*)
|
||||
r="|REVERTING"
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# __git_ps1 accepts 0 or 1 arguments (i.e., format string)
|
||||
# when called from PS1 using command substitution
|
||||
# in this mode it prints text to add to bash PS1 prompt (includes branch name)
|
||||
|
@ -390,6 +431,13 @@ __git_ps1 ()
|
|||
return $exit
|
||||
fi
|
||||
|
||||
local sparse=""
|
||||
if [ -z "${GIT_PS1_COMPRESSSPARSESTATE}" ] &&
|
||||
[ -z "${GIT_PS1_OMITSPARSESTATE}" ] &&
|
||||
[ "$(git config --bool core.sparseCheckout)" = "true" ]; then
|
||||
sparse="|SPARSE"
|
||||
fi
|
||||
|
||||
local r=""
|
||||
local b=""
|
||||
local step=""
|
||||
|
@ -398,11 +446,7 @@ __git_ps1 ()
|
|||
__git_eread "$g/rebase-merge/head-name" b
|
||||
__git_eread "$g/rebase-merge/msgnum" step
|
||||
__git_eread "$g/rebase-merge/end" total
|
||||
if [ -f "$g/rebase-merge/interactive" ]; then
|
||||
r="|REBASE-i"
|
||||
else
|
||||
r="|REBASE-m"
|
||||
fi
|
||||
r="|REBASE"
|
||||
else
|
||||
if [ -d "$g/rebase-apply" ]; then
|
||||
__git_eread "$g/rebase-apply/next" step
|
||||
|
@ -417,10 +461,8 @@ __git_ps1 ()
|
|||
fi
|
||||
elif [ -f "$g/MERGE_HEAD" ]; then
|
||||
r="|MERGING"
|
||||
elif [ -f "$g/CHERRY_PICK_HEAD" ]; then
|
||||
r="|CHERRY-PICKING"
|
||||
elif [ -f "$g/REVERT_HEAD" ]; then
|
||||
r="|REVERTING"
|
||||
elif __git_sequencer_status; then
|
||||
:
|
||||
elif [ -f "$g/BISECT_LOG" ]; then
|
||||
r="|BISECTING"
|
||||
fi
|
||||
|
@ -467,6 +509,7 @@ __git_ps1 ()
|
|||
local i=""
|
||||
local s=""
|
||||
local u=""
|
||||
local h=""
|
||||
local c=""
|
||||
local p=""
|
||||
|
||||
|
@ -499,6 +542,11 @@ __git_ps1 ()
|
|||
u="%${ZSH_VERSION+%}"
|
||||
fi
|
||||
|
||||
if [ -n "${GIT_PS1_COMPRESSSPARSESTATE}" ] &&
|
||||
[ "$(git config --bool core.sparseCheckout)" = "true" ]; then
|
||||
h="?"
|
||||
fi
|
||||
|
||||
if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
|
||||
__git_ps1_show_upstream
|
||||
fi
|
||||
|
@ -519,8 +567,8 @@ __git_ps1 ()
|
|||
b="\${__git_ps1_branch_name}"
|
||||
fi
|
||||
|
||||
local f="$w$i$s$u"
|
||||
local gitstring="$c$b${f:+$z$f}$r$p"
|
||||
local f="$h$w$i$s$u"
|
||||
local gitstring="$c$b${f:+$z$f}${sparse}$r$p"
|
||||
|
||||
if [ $pcmode = yes ]; then
|
||||
if [ "${__git_printf_supports_v-}" != yes ]; then
|
||||
|
|
|
@ -17,6 +17,9 @@ Then just press `SPACE` to trigger the expansion of a command you've written.
|
|||
If you only want to insert a space without expanding the command line, press
|
||||
`CTRL`+`SPACE`.
|
||||
|
||||
if you would like to filter out any values from expanding set `GLOBALIAS_FILTER_VALUES` to
|
||||
an array of said values. See [Filtered values](#filtered-values).
|
||||
|
||||
## Examples
|
||||
|
||||
#### Glob expressions
|
||||
|
@ -37,7 +40,6 @@ $ ls folder/file.json anotherfolder/another.json
|
|||
$ mkdir "`date -R`"
|
||||
# expands to
|
||||
$ mkdir Tue,\ 04\ Oct\ 2016\ 13:54:03\ +0300
|
||||
|
||||
```
|
||||
|
||||
#### Aliases
|
||||
|
@ -60,3 +62,18 @@ $ S<space>
|
|||
# expands to:
|
||||
$ sudo systemctl
|
||||
```
|
||||
|
||||
#### Filtered values
|
||||
|
||||
```
|
||||
# .zshrc
|
||||
alias l='ls -lh'
|
||||
alias la='ls --color=auto -lah'
|
||||
GLOBALIAS_FILTER_VALUES=(l)
|
||||
|
||||
$ l<space>
|
||||
# does not expand
|
||||
$ la<space>
|
||||
# expands to:
|
||||
$ ls --color=auto -lah
|
||||
```
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
globalias() {
|
||||
zle _expand_alias
|
||||
zle expand-word
|
||||
# Get last word to the left of the cursor:
|
||||
# (z) splits into words using shell parsing
|
||||
# (A) makes it an array even if there's only one element
|
||||
local word=${${(Az)LBUFFER}[-1]}
|
||||
if [[ $GLOBALIAS_FILTER_VALUES[(Ie)$word] -eq 0 ]]; then
|
||||
zle _expand_alias
|
||||
zle expand-word
|
||||
fi
|
||||
zle self-insert
|
||||
}
|
||||
zle -N globalias
|
||||
|
|
|
@ -41,7 +41,7 @@ __go_tool_complete() {
|
|||
return
|
||||
fi
|
||||
build_flags=(
|
||||
'-a[force reinstallation of packages that are already up-to-date]'
|
||||
'-a[force reinstallation of packages that are already up to date]'
|
||||
'-n[print the commands but do not run them]'
|
||||
'-p[number of parallel builds]:number'
|
||||
'-race[enable data race detection]'
|
||||
|
|
|
@ -116,9 +116,9 @@ __gradle-generate-tasks-cache() {
|
|||
# Reuse Gradle Daemon if IDLE but don't start a new one.
|
||||
local gradle_tasks_output
|
||||
if [[ ! -z "$($gradle_cmd --status 2>/dev/null | grep IDLE)" ]]; then
|
||||
gradle_tasks_output="$($gradle_cmd --daemon --build-file $gradle_build_file -q tasks --all 2>/dev/null)"
|
||||
gradle_tasks_output="$($gradle_cmd --daemon --build-file $gradle_build_file --console plain -q tasks --all 2>/dev/null)"
|
||||
else
|
||||
gradle_tasks_output="$($gradle_cmd --no-daemon --build-file $gradle_build_file -q tasks --all 2>/dev/null)"
|
||||
gradle_tasks_output="$($gradle_cmd --no-daemon --build-file $gradle_build_file --console plain -q tasks --all 2>/dev/null)"
|
||||
fi
|
||||
local gradle_all_tasks="" root_tasks="" subproject_tasks="" output_line
|
||||
local -a match
|
||||
|
|
|
@ -11,4 +11,10 @@ plugins=(... httpie)
|
|||
|
||||
It uses completion from [zsh-completions](https://github.com/zsh-users/zsh-completions).
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command |
|
||||
| ------------ | ---------------------------------------------------------------- |
|
||||
| `https` | `http --default-scheme=https` |
|
||||
|
||||
**Maintainer:** [lululau](https://github.com/lululau)
|
||||
|
|
7
dot_oh-my-zsh/plugins/httpie/httpie.plugin.zsh
Normal file
7
dot_oh-my-zsh/plugins/httpie/httpie.plugin.zsh
Normal file
|
@ -0,0 +1,7 @@
|
|||
#
|
||||
# Aliases
|
||||
# (sorted alphabetically)
|
||||
#
|
||||
|
||||
alias https='http --default-scheme=https'
|
||||
|
22
dot_oh-my-zsh/plugins/ipfs/LICENSE
Normal file
22
dot_oh-my-zsh/plugins/ipfs/LICENSE
Normal file
|
@ -0,0 +1,22 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Angel Ramboi
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
17
dot_oh-my-zsh/plugins/ipfs/README.md
Normal file
17
dot_oh-my-zsh/plugins/ipfs/README.md
Normal file
|
@ -0,0 +1,17 @@
|
|||
# zsh-ipfs
|
||||
|
||||
zsh completion plugin for [The InterPlanetary File System (IPFS)][1]
|
||||
|
||||
Please submit issues and pull requests to the [main zsh-ipfs repo][2].
|
||||
|
||||
### About
|
||||
|
||||
[IPFS (InterPlanetary File System)][1] is a peer-to-peer hypermedia protocol
|
||||
designed to make the web faster, safer, and more open.
|
||||
|
||||
### License
|
||||
|
||||
See: https://github.com/hellounicorn/zsh-ipfs/blob/master/LICENSE
|
||||
|
||||
[1]: http://ipfs.io/
|
||||
[2]: https://github.com/hellounicorn/zsh-ipfs
|
717
dot_oh-my-zsh/plugins/ipfs/_ipfs
Normal file
717
dot_oh-my-zsh/plugins/ipfs/_ipfs
Normal file
|
@ -0,0 +1,717 @@
|
|||
#compdef ipfs
|
||||
#autoload
|
||||
|
||||
local -a _1st_arguments
|
||||
_1st_arguments=(
|
||||
'add:Add a file or directory to ipfs.'
|
||||
'bitswap:Interact with the bitswap agent.'
|
||||
'block:Interact with raw IPFS blocks.'
|
||||
'bootstrap:Show or edit the list of bootstrap peers.'
|
||||
'cat:Show IPFS object data.'
|
||||
'cid:Convert and discover properties of CIDs'
|
||||
'commands:List all available commands.'
|
||||
'config:Get and set ipfs config values.'
|
||||
'daemon:Run a network-connected IPFS node.'
|
||||
'dag:Interact with ipld dag objects. (experimental)'
|
||||
'dht:Issue commands directly through the DHT.'
|
||||
'diag:Generate diagnostic reports.'
|
||||
'dns:Resolve DNS links.'
|
||||
'files:Interact with unixfs files.'
|
||||
'filestore:Interact with filestore objects. (experimental)'
|
||||
'get:Download IPFS objects.'
|
||||
'id:Show ipfs node id info.'
|
||||
'init:Initializes ipfs config file.'
|
||||
'key:Create and list IPNS name keypairs.'
|
||||
'log:Interact with the daemon log output.'
|
||||
'ls:List directory contents for Unix filesystem objects.'
|
||||
'mount:Mounts IPFS to the filesystem (read-only).'
|
||||
'name:Publish and resolve IPNS names.'
|
||||
'object:Interact with IPFS objects.'
|
||||
'p2p:Libp2p stream mounting.'
|
||||
'pin:Pin (and unpin) objects to local storage.'
|
||||
'ping:Send echo request packets to IPFS hosts.'
|
||||
'refs:List links (references) from an object.'
|
||||
'repo:Manipulate the IPFS repo.'
|
||||
'resolve:Resolve the value of names to IPFS.'
|
||||
'stats:Query IPFS statistics.'
|
||||
'swarm:Interact with the swarm.'
|
||||
'tar:Utility functions for tar files in ipfs.'
|
||||
'update:Download and apply go-ipfs updates'
|
||||
'version:Show ipfs version information.'
|
||||
)
|
||||
|
||||
_ipfs_subcommand(){
|
||||
local curcontext="$curcontext" state line
|
||||
typeset -A opt_args
|
||||
_arguments -C ':command:->command' '*::options:->options'
|
||||
case $state in
|
||||
(command)
|
||||
_describe -t commands "ipfs subcommand" $1
|
||||
return
|
||||
;;
|
||||
(options)
|
||||
case $line[1] in
|
||||
(wantlist)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(bitswap)
|
||||
_arguments '(-p --peer)'{-p,--peer}'[Specify which peer to show wantlist for. Default: self.]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(add)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(pin)
|
||||
_arguments \
|
||||
'(-r --recursive)'{-r,--recursive}'[Recursively pin the object linked to by the specified object(s). Default: true.]' \
|
||||
'--progress[Show progress.]'
|
||||
;;
|
||||
(bootstrap)
|
||||
local -a _bootstrap_rm_arguments
|
||||
_bootstrap_rm_arguments=(
|
||||
'default:Add default peers to the bootstrap list.'
|
||||
)
|
||||
_ipfs_subcommand _bootstrap_rm_arguments
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(rm)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(pin)
|
||||
_arguments '(-r --recursive)'{-r,--recursive}'[Recursively unpin the object linked to by the specified object(s). Default: true.]'
|
||||
;;
|
||||
(bootstrap)
|
||||
local -a _bootstrap_rm_arguments
|
||||
_bootstrap_rm_arguments=(
|
||||
'all:Remove all peers from the bootstrap list.'
|
||||
)
|
||||
_ipfs_subcommand _bootstrap_rm_arguments
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(ls)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(pin)
|
||||
_arguments \
|
||||
'(-t --type)'{-t,--type}'[The type of pinned keys to list. Can be "direct", "indirect", "recursive", or "all". Default: all.]' \
|
||||
'(-q --quiet)'{-q,--quiet}'[Write just hashes of objects.]'
|
||||
;;
|
||||
(p2p)
|
||||
_arguments '(-v --headers)'{-v,--headers}'[Print table headers (Protocol, Listen, Target).]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(update)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(pin)
|
||||
_arguments '--unpin[Remove the old pin. Default: true.]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(verify)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(pin)
|
||||
_arguments \
|
||||
'--verbose[Also write the hashes of non-broken pins.]' \
|
||||
'(-q --quiet)'{-q,--quiet}'[Write just hashes of broken pins.]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(get|query|findpeer)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(dht)
|
||||
_arguments '(-v --verbose)'{-v,--verbose}'[Print extra information.]'
|
||||
;;
|
||||
(object)
|
||||
_arguments '--data-encoding[Encoding type of the data field, either "text" or "base64". Default: text.]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(put)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(dht)
|
||||
_arguments '(-v --verbose)'{-v,--verbose}'[Print extra information.]'
|
||||
;;
|
||||
(object)
|
||||
_arguments \
|
||||
'--inputenc[Encoding type of input data. One of: {"protobuf", "json"}. Default: json.]' \
|
||||
'--datafieldenc[Encoding type of the data field, either "text" or "base64". Default: text.]' \
|
||||
'--pin[Pin this object when adding.]' \
|
||||
'(-q --quiet)'{-q,--quiet}'[Write minimal output]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(findprovs)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(dht)
|
||||
_arguments \
|
||||
'(-v --verbose)'{-v,--verbose}'[Print extra information.]' \
|
||||
'(-n --num-providers)'{-n,--num-providers}'[The number of providers to find. Default: 20.]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(provide)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(dht)
|
||||
_arguments \
|
||||
'(-v --verbose)'{-v,--verbose}'[Print extra information.]' \
|
||||
'(-r --recursive)'{-r,--recursive}'[Recursively provide entire graph.]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(cmds|diff)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(diag|object)
|
||||
_arguments '(-v --verbose)'{-v,--verbose}'[Print extra information.]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(stat)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(object)
|
||||
_arguments '--human[Print sizes in human readable format (e.g., 1K 234M 2G).]'
|
||||
;;
|
||||
(repo)
|
||||
_arguments \
|
||||
'--size-only[Only report RepoSize and StorageMax.]' \
|
||||
'--human[Print sizes in human readable format (e.g., 1K 234M 2G).]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(publish)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(name)
|
||||
_arguments \
|
||||
'--resolve[Check if the given path can be resolved before publishing. Default: true.]' \
|
||||
'(-t --lifetime)'{-t,--lifetime}'[Time duration that the record will be valid for. Default: 24h.]' \
|
||||
'--allow-offline[When offline, save the IPNS record to the the local datastore without broadcasting to the network instead of simply failing.]' \
|
||||
'--ttl[Time duration this record should be cached for. Uses the same syntax as the lifetime option. (caution: experimental).]' \
|
||||
'(-k --key)'{-k,--key}"[Name of the key to be used or a valid PeerID, as listed by 'ipfs key list -l'. Default: self.]" \
|
||||
'(-Q --quieter)'{-Q,--quieter}'[Write only final hash.]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(pubsub)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(name)
|
||||
local -a _name_pubsub_arguments
|
||||
_name_pubsub_arguments=(
|
||||
'cancel:Cancel a name subscription'
|
||||
'state:Query the state of IPNS pubsub'
|
||||
'subs:Show current name subscriptions'
|
||||
)
|
||||
_ipfs_subcommand _name_pubsub_arguments
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(resolve)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(name)
|
||||
_arguments \
|
||||
'(-r --recursive)'{-r,--recursive}'[Resolve until the result is not an IPNS name. Default: true.]' \
|
||||
'(-n --nocache)'{-n,--nocache}'[Do not use cached entries.]' \
|
||||
'(--dhtrc --dht-record-count)'{--dhtrc,--dht-record-count}'[Number of records to request for DHT resolution.]' \
|
||||
'(--dhtt --dht-timeout)'{--dhtt,--dht-timeout}'[Max time to collect values during DHT resolution eg "30s". Pass 0 for no timeout.]' \
|
||||
'(-s --stream)'{-s,--stream}'[Stream entries as they are found.]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(patch)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(object)
|
||||
local -a _object_patch_arguments
|
||||
_object_patch_arguments=(
|
||||
'add-link:Add a link to a given object.'
|
||||
'append-data:Append data to the data segment of a dag node.'
|
||||
'rm-link:Remove a link from a given object.'
|
||||
'set-data:Set the data field of an IPFS object.'
|
||||
)
|
||||
_ipfs_subcommand _object_patch_arguments
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(gc)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(repo)
|
||||
_arguments \
|
||||
'--stream-errors[Stream errors.]' \
|
||||
'(-q --quiet)'{-q,--quiet}'[Write minimal output.]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(bitswap)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(stats)
|
||||
_arguments \
|
||||
'(-v --verbose)'{-v,--verbose}'[Print extra information.]' \
|
||||
'--human[Print sizes in human readable format (e.g., 1K 234M 2G).]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(bw)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(stats)
|
||||
_arguments \
|
||||
'(-p --peer)'{-p,--peer}'[Specify a peer to print bandwidth for.]' \
|
||||
'(-t --proto)'{-t,--proto}'[Specify a protocol to print bandwidth for.]' \
|
||||
'--poll[Print bandwidth at an interval.]' \
|
||||
'(-i --interval)'{-i,--interval}'[Time interval to wait between updating output, if 'poll' is true.]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(repo)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(stats)
|
||||
_arguments \
|
||||
'--size-only[Only report RepoSize and StorageMax.]' \
|
||||
'--human[Print sizes in human readable format (e.g., 1K 234M 2G).]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(bases)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(cid)
|
||||
_arguments \
|
||||
'--prefix[also include the single leter prefixes in addition to the code.]' \
|
||||
'--numeric[also include numeric codes.]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(codecs|hashes)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(cid)
|
||||
_arguments '--numeric[also include numeric codes.]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(format)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(cid)
|
||||
_arguments \
|
||||
'-f[Printf style format string. Default: %s.]' \
|
||||
'-v[CID version to convert to.]' \
|
||||
'-b[Multibase to display CID in.]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(close)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(p2p)
|
||||
_arguments \
|
||||
'(-a --all)'{-a,--all}'[Close all listeners.]' \
|
||||
'(-p --protocol)'{-p,--protocol}'[Match protocol name.]' \
|
||||
'(-l --listen-address)'{-l,--listen-address}'[Match listen address.]' \
|
||||
'(-t --target-address)'{-t,--target-address}'[Match target address.]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(forward)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(p2p)
|
||||
_arguments "--allow-custom-protocol[Don't require /x/ prefix.]"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(listen)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(p2p)
|
||||
_arguments \
|
||||
"--allow-custom-protocol[Don't require /x/ prefix.]" \
|
||||
'(-r --report-peer-id)'{-r,--report-peer-id}'[Send remote base58 peerid to target when a new connection is established.]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(stream)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(p2p)
|
||||
local -a _p2p_stream_arguments
|
||||
_p2p_stream_arguments=(
|
||||
'close:Close active p2p stream.'
|
||||
'ls:List active p2p streams.'
|
||||
)
|
||||
_ipfs_subcommand _p2p_stream_arguments
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(addrs)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(swarm)
|
||||
local -a _swarm_addrs_arguments
|
||||
_swarm_addrs_arguments=(
|
||||
'listen:List interface listening addresses.'
|
||||
'local:List local addresses.'
|
||||
)
|
||||
_ipfs_subcommand _swarm_addrs_arguments
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(filters)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(swarm)
|
||||
local -a _swarm_filters_arguments
|
||||
_swarm_filters_arguments=(
|
||||
'add:Add an address filter.'
|
||||
'rm:Remove an address filter.'
|
||||
)
|
||||
_ipfs_subcommand _swarm_filters_arguments
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(peers)
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(swarm)
|
||||
_arguments \
|
||||
'(-v --verbose)'{-v,--verbose}'[display all extra information.]' \
|
||||
'--streams[Also list information about open streams for each peer.]' \
|
||||
'--latency[Also list information about latency to each peer.]' \
|
||||
'--direction[Also list information about the direction of connection.]'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
local expl
|
||||
|
||||
_arguments \
|
||||
'(-c --config)'{-c,--config}'[Path to the configuration file to use.]' \
|
||||
'(-D --debug)'{-D,--debug}'[Operate in debug mode.]' \
|
||||
'(--help)--help[Show the full command help text.]' \
|
||||
'(--h)-h[Show a short version of the command help text.]' \
|
||||
'(-L --local)'{-L,--local}'[Run the command locally, instead of using the daemon. DEPRECATED: use --offline.]' \
|
||||
'(--offline)--offline[Run the command offline.]' \
|
||||
'(--api)--api[Use a specific API instance (defaults to /ip4/127.0.0.1/tcp/5001).]' \
|
||||
'(--cid-base)--cid-base[Multibase encoding used for version 1 CIDs in output.]' \
|
||||
'(--upgrade-cidv0-in-output)--upgrade-cidv0-in-output[Upgrade version 0 to version 1 CIDs in output.]' \
|
||||
'(--enc --encoding)'{--enc,--encoding}'[The encoding type the output should be encoded with (json, xml, or text). Default: text.]' \
|
||||
'(--stream-channels)--stream-channels[Stream channel output.]' \
|
||||
'(--timeout)--timeout[Set a global timeout on the command.]' \
|
||||
'*:: :->subcmds' && return 0
|
||||
|
||||
if (( CURRENT == 1 )); then
|
||||
_describe -t commands "ipfs subcommand" _1st_arguments
|
||||
return
|
||||
fi
|
||||
|
||||
MAIN_SUBCOMMAND="$words[1]"
|
||||
case $MAIN_SUBCOMMAND in
|
||||
(add)
|
||||
_arguments \
|
||||
'(-r --recursive)'{-r,--recursive}'[Add directory paths recursively.]' \
|
||||
'(--dereference-args)--dereference-args[Symlinks supplied in arguments are dereferenced.]' \
|
||||
'(--stdin-name)--stdin-name[Assign a name if the file source is stdin.]' \
|
||||
'(-H --hidden)'{-H,--hidden}'[Include files that are hidden. Only takes effect on recursive add.]' \
|
||||
'(-q --quiet)'{-q,--quiet}'[Write minimal output.]' \
|
||||
'(-Q --quieter)'{-Q,--quieter}'[Write only final hash.]' \
|
||||
'(--silent)--silent[Write no output.]' \
|
||||
'(-p --progress)'{-p,--progress}'[Stream progress data.]' \
|
||||
'(-t --trickle)'{-t,--trickle}'[Use trickle-dag format for dag generation.]' \
|
||||
'(-n --only-hash)'{-n,--only-hash}'[Only chunk and hash - do not write to disk.]' \
|
||||
'(-w --wrap-with-directory)'{-w,--wrap-with-directory}'[Wrap files with a directory object.]' \
|
||||
'(-s --chunker)'{-s,--chunker}'[Chunking algorithm, size-(bytes) or rabin-(min)-(avg)-(max). Default: size-262144.]' \
|
||||
'(--pin)--pin[Pin this object when adding. Default: true.]' \
|
||||
'(--raw-leaves)--raw-leaves[Use raw blocks for leaf nodes. (experimental).]' \
|
||||
'(--nocopy)--nocopy[Add the file using filestore. Implies raw-leaves. (experimental).]' \
|
||||
'(--fscache)--fscache[Check the filestore for pre-existing blocks. (experimental).]' \
|
||||
'(--cid-version)--cid-version[CID version. Defaults to 0 unless an option that depends on CIDv1 is passed. (experimental).]' \
|
||||
'(--hash)--hash[Hash function to use. Implies CIDv1 if not sha2-256. (experimental). Default: sha2-256.]' \
|
||||
'(--inline)--inline[Inline small blocks into CIDs. (experimental).]' \
|
||||
'(--inline-limit)--inline-limit[Maximum block size to inline. (experimental). Default: 32.]'
|
||||
;;
|
||||
(bitswap)
|
||||
local -a _bitswap_arguments
|
||||
_bitswap_arguments=(
|
||||
'ledger:Show the current ledger for a peer.'
|
||||
'reprovide:Trigger reprovider.'
|
||||
'stat:Show some diagnostic information on the bitswap agent.'
|
||||
'wantlist:Show blocks currently on the wantlist.'
|
||||
)
|
||||
_ipfs_subcommand _bitswap_arguments
|
||||
;;
|
||||
(block)
|
||||
local -a _block_arguments
|
||||
_block_arguments=(
|
||||
'get:Get a raw IPFS block.'
|
||||
'put:Store input as an IPFS block.'
|
||||
'rm:Remove IPFS block(s).'
|
||||
'stat:Print information of a raw IPFS block.'
|
||||
)
|
||||
_ipfs_subcommand _block_arguments
|
||||
;;
|
||||
(bootstrap)
|
||||
local -a _bootstrap_arguments
|
||||
_bootstrap_arguments=(
|
||||
'add:Add peers to the bootstrap list.'
|
||||
'list:Show peers in the bootstrap list.'
|
||||
'rm:Remove peers from the bootstrap list.'
|
||||
)
|
||||
_ipfs_subcommand _bootstrap_arguments
|
||||
;;
|
||||
(cat)
|
||||
_arguments \
|
||||
'(-o --offset)'{-o,--offset}'[Byte offset to begin reading from.]' \
|
||||
'(-l --length)'{-l,--length}'[Maximum number of bytes to read.]'
|
||||
;;
|
||||
(cid)
|
||||
local -a _cid_arguments
|
||||
_cid_arguments=(
|
||||
'base32:Convert CIDs to Base32 CID version 1.'
|
||||
'bases:List available multibase encodings.'
|
||||
'codecs:List available CID codecs.'
|
||||
'format:Format and convert a CID in various useful ways.'
|
||||
'hashes:List available multihashes.'
|
||||
)
|
||||
_ipfs_subcommand _cid_arguments
|
||||
;;
|
||||
(commands)
|
||||
_arguments '(-f --flags)'{-f,--flags}'[Show command flags.]'
|
||||
;;
|
||||
(config)
|
||||
_arguments \
|
||||
'--bool[Set a boolean value.]' \
|
||||
'--json[Parse stringified JSON.]'
|
||||
local -a _config_arguments
|
||||
_config_arguments=(
|
||||
'edit:Open the config file for editing in $EDITOR.'
|
||||
'profile:Apply profiles to config.'
|
||||
'replace:Replace the config with <file>.'
|
||||
'show:Output config file contents.'
|
||||
)
|
||||
_ipfs_subcommand _config_arguments
|
||||
;;
|
||||
(daemon)
|
||||
_arguments \
|
||||
'--init[Initialize ipfs with default settings if not already initialized.]' \
|
||||
'--init-profile[Configuration profiles to apply for --init. See ipfs init --help for more.]' \
|
||||
'--routing[Overrides the routing option. Default: default.]' \
|
||||
'--mount[Mounts IPFS to the filesystem.]' \
|
||||
'--writable[Enable writing objects (with POST, PUT and DELETE).]' \
|
||||
'--mount-ipfs[Path to the mountpoint for IPFS (if using --mount). Defaults to config setting.]' \
|
||||
'--mount-ipns[Path to the mountpoint for IPNS (if using --mount). Defaults to config setting.]' \
|
||||
'--unrestricted-api[Allow API access to unlisted hashes.]' \
|
||||
'--disable-transport-encryption[Disable transport encryption (for debugging protocols).]' \
|
||||
'--enable-gc[Enable automatic periodic repo garbage collection.]' \
|
||||
'--manage-fdlimit[Check and raise file descriptor limits if needed. Default: true.]' \
|
||||
'--migrate[If true, assume yes at the migrate prompt. If false, assume no.]' \
|
||||
'--enable-pubsub-experiment[Instantiate the ipfs daemon with the experimental pubsub feature enabled.]' \
|
||||
'--enable-namesys-pubsub[Enable IPNS record distribution through pubsub; enables pubsub.]' \
|
||||
'--enable-mplex-experiment[Add the experimental 'go-multiplex' stream muxer to libp2p on construction. Default: true.]'
|
||||
;;
|
||||
(dag)
|
||||
local -a _dag_arguments
|
||||
_dag_arguments=(
|
||||
'get:Get a dag node from ipfs.'
|
||||
'put:Add a dag node to ipfs.'
|
||||
'resolve:Resolve ipld block.'
|
||||
)
|
||||
_ipfs_subcommand _dag_arguments
|
||||
;;
|
||||
(dht)
|
||||
local -a _dht_arguments
|
||||
_dht_arguments=(
|
||||
'findpeer:Find the multiaddresses associated with a Peer ID.'
|
||||
'findprovs:Find peers that can provide a specific value, given a key.'
|
||||
'get:Given a key, query the routing system for its best value.'
|
||||
'provide:Announce to the network that you are providing given values.'
|
||||
'put:Write a key/value pair to the routing system.'
|
||||
'query:Find the closest Peer IDs to a given Peer ID by querying the DHT.'
|
||||
)
|
||||
_ipfs_subcommand _dht_arguments
|
||||
;;
|
||||
(diag)
|
||||
local -a _diag_arguments
|
||||
_diag_arguments=(
|
||||
'cmds:List commands run on this IPFS node.'
|
||||
'sys:Print system diagnostic information.'
|
||||
)
|
||||
_ipfs_subcommand _diag_arguments
|
||||
;;
|
||||
(dns)
|
||||
_arguments '(-r --recursive)'{-r,--recursive}'[Resolve until the result is not a DNS link. Default: true.]'
|
||||
;;
|
||||
(files)
|
||||
_arguments '(-f --flush)'{-f,--flush}'[Flush target and ancestors after write. Default: true.]'
|
||||
local -a _files_arguments
|
||||
_files_arguments=(
|
||||
'chcid:Change the cid version or hash function of the root node of a given path.'
|
||||
'cp:Copy files into mfs.'
|
||||
"flush:Flush a given path's data to disk."
|
||||
'ls:List directories in the local mutable namespace.'
|
||||
'mkdir:Make directories.'
|
||||
'mv:Move files.'
|
||||
'read:Read a file in a given mfs.'
|
||||
'rm:Remove a file.'
|
||||
'stat:Display file status.'
|
||||
'write:Write to a mutable file in a given filesystem.'
|
||||
)
|
||||
_ipfs_subcommand _files_arguments
|
||||
;;
|
||||
(filestore)
|
||||
local -a _filestore_arguments
|
||||
_filestore_arguments=(
|
||||
'dups:List blocks that are both in the filestore and standard block storage.'
|
||||
'ls:List objects in filestore.'
|
||||
'verify:Verify objects in filestore.'
|
||||
)
|
||||
_ipfs_subcommand _filestore_arguments
|
||||
;;
|
||||
(get)
|
||||
_arguments \
|
||||
'(-o --output)'{-o,--output}'[The path where the output should be stored.]'\
|
||||
'(-a --archive)'{-a,--archive}'[Output a TAR archive.]' \
|
||||
'(-C --compress)'{-C,--compress}'[Compress the output with GZIP compression.]' \
|
||||
'(-l --compression-level)'{-l,--compression-level}'[The level of compression (1-9).]'
|
||||
;;
|
||||
(id)
|
||||
_arguments '(-f --format)'{-f,--format}'[Optional output format.]'
|
||||
;;
|
||||
(init)
|
||||
_arguments \
|
||||
'(-b --bits)'{-b,--bits}'[Number of bits to use in the generated RSA private key. Default: 2048.]' \
|
||||
'(-e --empty-repo)'{-e,--empty-repo}"[Don't add and pin help files to the local storage.]" \
|
||||
'(-p --profile)'{-p,--profile}"[Apply profile settings to config. Multiple profiles can be separated by ','.]"
|
||||
;;
|
||||
(key)
|
||||
local -a _key_arguments
|
||||
_key_arguments=(
|
||||
'gen:Create a new keypair'
|
||||
'list:List all local keypairs'
|
||||
'rename:Rename a keypair'
|
||||
'rm:Remove a keypair'
|
||||
)
|
||||
_ipfs_subcommand _key_arguments
|
||||
;;
|
||||
(log)
|
||||
local -a _log_arguments
|
||||
_log_arguments=(
|
||||
'level:Change the logging level.'
|
||||
'ls:List the logging subsystems.'
|
||||
'tail:Read the event log.'
|
||||
)
|
||||
_ipfs_subcommand _log_arguments
|
||||
;;
|
||||
(ls)
|
||||
_arguments \
|
||||
'(-v --headers)'{-v,--headers}'[Print table headers (Hash, Size, Name).]' \
|
||||
'--resolve-type[Resolve linked objects to find out their types. Default: true.]' \
|
||||
'--size[Resolve linked objects to find out their file size. Default: true.]' \
|
||||
'(-s --stream)'{-s,--stream}'[Enable exprimental streaming of directory entries as they are traversed.]' \
|
||||
;;
|
||||
(mount)
|
||||
_arguments \
|
||||
'(-f --ipfs-path)'{-f,--ipfs-path}'[The path where IPFS should be mounted.]' \
|
||||
'(-n --ipns-path)'{-n,--ipns-path}'[The path where IPNS should be mounted.]'
|
||||
;;
|
||||
(name)
|
||||
local -a _name_arguments
|
||||
_name_arguments=(
|
||||
'publish:Publish IPNS names.'
|
||||
'pubsub:IPNS pubsub management.'
|
||||
'resolve:Resolve IPNS names.'
|
||||
)
|
||||
_ipfs_subcommand _name_arguments
|
||||
;;
|
||||
(object)
|
||||
local -a _object_arguments
|
||||
_object_arguments=(
|
||||
'data:Output the raw bytes of an IPFS object.'
|
||||
'diff:Display the diff between two ipfs objects.'
|
||||
'get:Get and serialize the DAG node named by <key>.'
|
||||
'links:Output the links pointed to by the specified object.'
|
||||
'new:Create a new object from an ipfs template.'
|
||||
'patch:Create a new merkledag object based on an existing one.'
|
||||
'put:Store input as a DAG object, print its key.'
|
||||
'stat:Get stats for the DAG node named by <key>.'
|
||||
)
|
||||
_ipfs_subcommand _object_arguments
|
||||
;;
|
||||
(p2p)
|
||||
local -a _p2p_arguments
|
||||
_p2p_arguments=(
|
||||
'close:Stop listening for new connections to forward.'
|
||||
'forward:Forward connections to libp2p service'
|
||||
'listen:Create libp2p service'
|
||||
'ls:List active p2p listeners.'
|
||||
'stream:P2P stream management.'
|
||||
)
|
||||
_ipfs_subcommand _p2p_arguments
|
||||
;;
|
||||
(pin)
|
||||
local -a _pin_arguments
|
||||
_pin_arguments=(
|
||||
'add:Pin objects to local storage.'
|
||||
'ls:List objects pinned to local storage.'
|
||||
'rm:Remove pinned objects from local storage.'
|
||||
'update:Update a recursive pin'
|
||||
'verify:Verify that recursive pins are complete.'
|
||||
)
|
||||
_ipfs_subcommand _pin_arguments
|
||||
;;
|
||||
(ping)
|
||||
_arguments '(-n --count)'{-n,--count}'[Number of ping messages to send. Default: 10.]'
|
||||
;;
|
||||
(refs)
|
||||
_arguments \
|
||||
'--format[Emit edges with given format. Available tokens: <src> <dst> <linkname>. Default: <dst>.]' \
|
||||
'(-e --edges)'{-e,--edges}'[Emit edge format: `<from> -> <to>`.]' \
|
||||
'(-u --unique)'{-u,--unique}'[Omit duplicate refs from output.]' \
|
||||
'(-r --recursive)'{-r,--recursive}'[Recursively list links of child nodes.]' \
|
||||
'--max-depth[Only for recursive refs, limits fetch and listing to the given depth. Default: -1.]'
|
||||
local -a _refs_arguments
|
||||
_refs_arguments='local:List all local references.'
|
||||
_ipfs_subcommand _refs_arguments
|
||||
;;
|
||||
(repo)
|
||||
local -a _repo_arguments
|
||||
_repo_arguments=(
|
||||
'fsck:Remove repo lockfiles.'
|
||||
'gc:Perform a garbage collection sweep on the repo.'
|
||||
'stat:Get stats for the currently used repo.'
|
||||
'verify:Verify all blocks in repo are not corrupted.'
|
||||
'version:Show the repo version.'
|
||||
)
|
||||
_ipfs_subcommand _repo_arguments
|
||||
;;
|
||||
(resolve)
|
||||
_arguments \
|
||||
'(-r --recursive)'{-r,--recursive}'[Resolve until the result is an IPFS name. Default: true.]' \
|
||||
'(--dhtrc --dht-record-count)'{--dhtrc,--dht-record-count}'[Number of records to request for DHT resolution.]' \
|
||||
'(--dhtt --dht-timeout)'{--dhtt,--dht-timeout}'[Max time to collect values during DHT resolution eg "30s". Pass 0 for no timeout.]'
|
||||
;;
|
||||
(stats)
|
||||
local -a _stats_arguments
|
||||
_stats_arguments=(
|
||||
'bitswap:Show some diagnostic information on the bitswap agent.'
|
||||
'bw:Print ipfs bandwidth information.'
|
||||
'repo:Get stats for the currently used repo.'
|
||||
)
|
||||
_ipfs_subcommand _stats_arguments
|
||||
;;
|
||||
(swarm)
|
||||
local -a _swarm_arguments
|
||||
_swarm_arguments=(
|
||||
'addrs:List known addresses. Useful for debugging.'
|
||||
'connect:Open connection to a given address.'
|
||||
'disconnect:Close connection to a given address.'
|
||||
'filters:Manipulate address filters.'
|
||||
'peers:List peers with open connections.'
|
||||
)
|
||||
_ipfs_subcommand _swarm_arguments
|
||||
;;
|
||||
(tar)
|
||||
local -a _tar_arguments
|
||||
_tar_arguments=(
|
||||
'add:Import a tar file into ipfs.'
|
||||
'cat:Export a tar file from IPFS.'
|
||||
)
|
||||
_ipfs_subcommand _tar_arguments
|
||||
;;
|
||||
(version)
|
||||
_arguments \
|
||||
'(-n --number)'{-n,--number}'[Only show the version number.]' \
|
||||
'--commit[Show the commit hash.]' \
|
||||
'--repo[Show repo version.]' \
|
||||
'--all[Show all version information.]'
|
||||
;;
|
||||
esac
|
|
@ -6,14 +6,6 @@ configured on `kubectl` to your Bash/Zsh prompt strings (i.e. the `$PS1`).
|
|||
|
||||
Inspired by several tools used to simplify usage of `kubectl`.
|
||||
|
||||
![prompt](img/screenshot2.png)
|
||||
|
||||
![prompt_sol_light](img/screenshot-sol-light.png)
|
||||
|
||||
![prompt_img](img/screenshot-img.png)
|
||||
|
||||
![prompt demo](img/kube-ps1.gif)
|
||||
|
||||
## Installing
|
||||
|
||||
### MacOS
|
||||
|
|
|
@ -22,7 +22,7 @@ plugins=(... kubectl)
|
|||
| kcsc | `kubectl config set-context` | Set a context entry in kubeconfig |
|
||||
| kcdc | `kubectl config delete-context` | Delete the specified context from the kubeconfig |
|
||||
| kccc | `kubectl config current-context` | Display the current-context |
|
||||
| kcgc | `kubectl config get-contexts` | List of contexts available
|
||||
| kcgc | `kubectl config get-contexts` | List of contexts available
|
||||
| | | **General aliases** |
|
||||
| kdel | `kubectl delete` | Delete resources by filenames, stdin, resources and names, or by resources and label selector |
|
||||
| kdelf | `kubectl delete -f` | Delete a pod using the type and name specified in -f argument |
|
||||
|
@ -33,7 +33,8 @@ plugins=(... kubectl)
|
|||
| kep | `kubectl edit pods` | Edit pods from the default editor |
|
||||
| kdp | `kubectl describe pods` | Describe all pods |
|
||||
| kdelp | `kubectl delete pods` | Delete all pods matching passed arguments |
|
||||
| kgpl | `kgp -l` | Get pod by label. Example: `kgpl "app=myapp" -n myns` |
|
||||
| kgpl | `kgp -l` | Get pods by label. Example: `kgpl "app=myapp" -n myns` |
|
||||
| kgpn | `kgp -n` | Get pods by namespace. Example: `kgpn kube-system` |
|
||||
| | | **Service management** |
|
||||
| kgs | `kubectl get svc` | List all services in ps output format |
|
||||
| kgsw | `kgs --watch` | After listing all services, watch for changes |
|
||||
|
@ -90,13 +91,13 @@ plugins=(... kubectl)
|
|||
| keno | `kubectl edit node` | Edit nodes resource from the default editor |
|
||||
| kdno | `kubectl describe node` | Describe node resource in detail |
|
||||
| kdelno | `kubectl delete node` | Delete the node |
|
||||
| | | **Persistent Volume Claim management** |
|
||||
| | | **Persistent Volume Claim management** |
|
||||
| kgpvc | `kubectl get pvc` | List all PVCs |
|
||||
| kgpvcw | `kgpvc --watch` | After listing/getting the requested object, watch for changes |
|
||||
| kepvc | `kubectl edit pvc` | Edit pvcs from the default editor |
|
||||
| kdpvc | `kubectl describe pvc` | Descirbe all pvcs |
|
||||
| kdpvc | `kubectl describe pvc` | Describe all pvcs |
|
||||
| kdelpvc | `kubectl delete pvc` | Delete all pvcs matching passed arguments |
|
||||
| | | |
|
||||
| | | **StatefulSets management** |
|
||||
| kgss | `kubectl get statefulset` | List the statefulsets in ps format |
|
||||
| kgssw | `kgss --watch` | After getting the list of statefulsets, watch for changes |
|
||||
| kgsswide| `kgss -o wide` | After getting the statefulsets, output in plain-text format with any additional information |
|
||||
|
@ -105,3 +106,26 @@ plugins=(... kubectl)
|
|||
| kdelss | `kubectl delete statefulset` | Delete the statefulset |
|
||||
| ksss | `kubectl scale statefulset` | Scale a statefulset |
|
||||
| krsss | `kubectl rollout status statefulset`| Check the rollout status of a deployment |
|
||||
| | | **Service Accounts management** |
|
||||
| kgsa | `kubectl get sa` | List all service accounts |
|
||||
| kdsa | `kubectl describe sa` | Describe a service account in details |
|
||||
| kdelsa | `kubectl delete sa` | Delete the service account |
|
||||
| | | **DaemonSet management** |
|
||||
| kgds | `kubectl get daemonset` | List all DaemonSets in ps output format |
|
||||
| kgdsw | `kgds --watch` | After listing all DaemonSets, watch for changes |
|
||||
| keds | `kubectl edit daemonset` | Edit DaemonSets from the default editor |
|
||||
| kdds | `kubectl describe daemonset` | Describe all DaemonSets in detail |
|
||||
| kdelds | `kubectl delete daemonset` | Delete all DaemonSets matching passed argument |
|
||||
| | | **CronJob management** |
|
||||
| kgcj | `kubectl get cronjob` | List all CronJobs in ps output format |
|
||||
| kecj | `kubectl edit cronjob` | Edit CronJob from the default editor |
|
||||
| kdcj | `kubectl describe cronjob` | Describe a CronJob in details |
|
||||
| kdelcj | `kubectl delete cronjob` | Delete the CronJob |
|
||||
|
||||
## Wrappers
|
||||
|
||||
This plugin provides 3 wrappers to colorize kubectl output in JSON and YAML using various tools (which must be installed):
|
||||
|
||||
- `kj`: JSON, colorized with [`jq`](https://stedolan.github.io/jq/).
|
||||
- `kjx`: JSON, colorized with [`fx`](https://github.com/antonmedv/fx).
|
||||
- `ky`: YAML, colorized with [`yh`](https://github.com/andreazorzetto/yh).
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
if (( $+commands[kubectl] )); then
|
||||
__KUBECTL_COMPLETION_FILE="${ZSH_CACHE_DIR}/kubectl_completion"
|
||||
|
||||
if [[ ! -f $__KUBECTL_COMPLETION_FILE ]]; then
|
||||
if [[ ! -f $__KUBECTL_COMPLETION_FILE || ! -s $__KUBECTL_COMPLETION_FILE ]]; then
|
||||
kubectl completion zsh >! $__KUBECTL_COMPLETION_FILE
|
||||
fi
|
||||
|
||||
|
@ -47,6 +47,9 @@ alias kdelp='kubectl delete pods'
|
|||
# get pod by label: kgpl "app=myapp" -n myns
|
||||
alias kgpl='kgp -l'
|
||||
|
||||
# get pod by namespace: kgpn kube-system"
|
||||
alias kgpn='kgp -n'
|
||||
|
||||
# Service management.
|
||||
alias kgs='kubectl get svc'
|
||||
alias kgsa='kubectl get svc --all-namespaces'
|
||||
|
@ -147,3 +150,31 @@ alias kepvc='kubectl edit pvc'
|
|||
alias kdpvc='kubectl describe pvc'
|
||||
alias kdelpvc='kubectl delete pvc'
|
||||
|
||||
# Service account management.
|
||||
alias kgsa="kubectl get sa"
|
||||
alias kdsa="kubectl describe sa"
|
||||
alias kdelsa="kubectl delete sa"
|
||||
|
||||
# DaemonSet management.
|
||||
alias kgds='kubectl get daemonset'
|
||||
alias kgdsw='kgds --watch'
|
||||
alias keds='kubectl edit daemonset'
|
||||
alias kdds='kubectl describe daemonset'
|
||||
alias kdelds='kubectl delete daemonset'
|
||||
|
||||
# CronJob management.
|
||||
alias kgcj='kubectl get cronjob'
|
||||
alias kecj='kubectl edit cronjob'
|
||||
alias kdcj='kubectl describe cronjob'
|
||||
alias kdelcj='kubectl delete cronjob'
|
||||
|
||||
# Only run if the user actually has kubectl installed
|
||||
if (( ${+_comps[kubectl]} )); then
|
||||
kj() { kubectl "$@" -o json | jq; }
|
||||
kjx() { kubectl "$@" -o json | fx; }
|
||||
ky() { kubectl "$@" -o yaml | yh; }
|
||||
|
||||
compdef kj=kubectl
|
||||
compdef kjx=kubectl
|
||||
compdef ky=kubectl
|
||||
fi
|
||||
|
|
21
dot_oh-my-zsh/plugins/lando/LICENSE
Normal file
21
dot_oh-my-zsh/plugins/lando/LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2019 Joshua Bedford
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
37
dot_oh-my-zsh/plugins/lando/README.md
Normal file
37
dot_oh-my-zsh/plugins/lando/README.md
Normal file
|
@ -0,0 +1,37 @@
|
|||
# Lando ZSH (lando-zsh)
|
||||
|
||||
This plugin adds aliases for using various languages and frameworks with [Lando](https://docs.lando.dev/basics/) for Docker. It will only run within lando-driven project directories.
|
||||
|
||||
To use it, add `lando` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... lando)
|
||||
```
|
||||
|
||||
## ALIASES:
|
||||
|
||||
| Alias | Description |
|
||||
|:----------:|:----------------:|
|
||||
| `artisan` | `lando artisan` |
|
||||
| `composer` | `lando composer` |
|
||||
| `drush` | `lando drush` |
|
||||
| `gulp` | `lando gulp` |
|
||||
| `npm` | `lando npm` |
|
||||
| `wp` | `lando wp` |
|
||||
| `yarn` | `lando yarn` |
|
||||
|
||||
## How It Works:
|
||||
|
||||
This plugin removes the requirement to type `lando` before a command. It utilizes the lando version of supported commands run within directories with the following criteria:
|
||||
- The `.lando.yml` file is found in the current directory or any parent directory within `$LANDO_ZSH_SITES_DIRECTORY`.
|
||||
- The current directory is within `$LANDO_ZSH_SITES_DIRECTORY` but is not `$LANDO_ZSH_SITES_DIRECTORY` itself.
|
||||
|
||||
## Settings:
|
||||
|
||||
- `LANDO_ZSH_SITES_DIRECTORY`: The plugin will stop searching through parents for `CONFIG_FILE` once it hits this directory.
|
||||
- `LANDO_ZSH_CONFIG_FILE`: The plugin will check to see if this provided file exists to check for presence of Lando.
|
||||
|
||||
## Author:
|
||||
|
||||
- Author: Joshua Bedford
|
||||
- URL: [https://github.com/joshuabedford/lando-zsh](https://github.com/joshuabedford/lando-zsh)
|
40
dot_oh-my-zsh/plugins/lando/lando.plugin.zsh
Normal file
40
dot_oh-my-zsh/plugins/lando/lando.plugin.zsh
Normal file
|
@ -0,0 +1,40 @@
|
|||
# Settings
|
||||
: ${LANDO_ZSH_SITES_DIRECTORY:="$HOME/Sites"}
|
||||
: ${LANDO_ZSH_CONFIG_FILE:=.lando.yml}
|
||||
|
||||
# Enable multiple commands with lando.
|
||||
function artisan \
|
||||
composer \
|
||||
drush \
|
||||
gulp \
|
||||
npm \
|
||||
wp \
|
||||
yarn {
|
||||
if checkForLandoFile; then
|
||||
lando "$0" "$@"
|
||||
else
|
||||
command "$0" "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
# Check for the file in the current and parent directories.
|
||||
checkForLandoFile() {
|
||||
# Only bother checking for lando within the Sites directory.
|
||||
if [[ "$PWD/" != "$LANDO_ZSH_SITES_DIRECTORY"/* ]]; then
|
||||
# Not within $LANDO_ZSH_SITES_DIRECTORY
|
||||
return 1
|
||||
fi
|
||||
|
||||
local curr_dir="$PWD"
|
||||
# Checking for file: $LANDO_ZSH_CONFIG_FILE within $LANDO_ZSH_SITES_DIRECTORY...
|
||||
while [[ "$curr_dir" != "$LANDO_ZSH_SITES_DIRECTORY" ]]; do
|
||||
if [[ -f "$curr_dir/$LANDO_ZSH_CONFIG_FILE" ]]; then
|
||||
return 0
|
||||
fi
|
||||
curr_dir="${curr_dir:h}"
|
||||
done
|
||||
|
||||
# Could not find $LANDO_ZSH_CONFIG_FILE in the current directory
|
||||
# or in any of its parents up to $LANDO_ZSH_SITES_DIRECTORY.
|
||||
return 1
|
||||
}
|
|
@ -1,20 +1,19 @@
|
|||
# Alias
|
||||
alias la5='php artisan'
|
||||
alias la5cache='php artisan cache:clear'
|
||||
alias la5routes='php artisan route:list'
|
||||
alias la5vendor='php artisan vendor:publish'
|
||||
|
||||
# Laravel5 basic command completion
|
||||
_laravel5_get_command_list () {
|
||||
php artisan --raw --no-ansi list | sed "s/[[:space:]].*//g"
|
||||
php artisan --raw --no-ansi list | sed "s/[[:space:]].*//g"
|
||||
}
|
||||
|
||||
_laravel5 () {
|
||||
if [ -f artisan ]; then
|
||||
compadd `_laravel5_get_command_list`
|
||||
if [[ -f artisan ]]; then
|
||||
compadd $(_laravel5_get_command_list)
|
||||
fi
|
||||
}
|
||||
|
||||
compdef _laravel5 artisan
|
||||
compdef _laravel5 la5
|
||||
|
||||
#Alias
|
||||
alias la5='php artisan'
|
||||
|
||||
alias la5cache='php artisan cache:clear'
|
||||
alias la5routes='php artisan route:list'
|
||||
alias la5vendor='php artisan vendor:publish'
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
# Autocompletion for Minikube.
|
||||
#
|
||||
if (( $+commands[minikube] )); then
|
||||
__MINICUBE_COMPLETION_FILE="${ZSH_CACHE_DIR}/minicube_completion"
|
||||
__MINIKUBE_COMPLETION_FILE="${ZSH_CACHE_DIR}/minikube_completion"
|
||||
|
||||
if [[ ! -f $__MINICUBE_COMPLETION_FILE ]]; then
|
||||
minikube completion zsh >! $__MINICUBE_COMPLETION_FILE
|
||||
if [[ ! -f $__MINIKUBE_COMPLETION_FILE ]]; then
|
||||
minikube completion zsh >! $__MINIKUBE_COMPLETION_FILE
|
||||
fi
|
||||
|
||||
[[ -f $__MINICUBE_COMPLETION_FILE ]] && source $__MINICUBE_COMPLETION_FILE
|
||||
[[ -f $__MINIKUBE_COMPLETION_FILE ]] && source $__MINIKUBE_COMPLETION_FILE
|
||||
|
||||
unset __MINICUBE_COMPLETION_FILE
|
||||
unset __MINIKUBE_COMPLETION_FILE
|
||||
fi
|
||||
|
|
|
@ -12,7 +12,7 @@ _mix_does_task_list_need_generating () {
|
|||
}
|
||||
|
||||
_mix_generate () {
|
||||
mix help | grep -v 'iex -S' | tail -n +2 | cut -d " " -f 2 > .mix_tasks
|
||||
mix help | grep '^mix [^ ]' | sed -E "s/mix ([^ ]*) *# (.*)/\1:\2/" > .mix_tasks
|
||||
}
|
||||
|
||||
_mix () {
|
||||
|
@ -21,7 +21,8 @@ _mix () {
|
|||
echo "\nGenerating .mix_tasks..." > /dev/stderr
|
||||
_mix_generate
|
||||
fi
|
||||
compadd `cat .mix_tasks`
|
||||
local tasks=(${(f)"$(cat .mix_tasks)"})
|
||||
_describe 'tasks' tasks
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ if it's found, or the mvn command otherwise.
|
|||
| `mvn!` | `mvn -f <root>/pom.xml` |
|
||||
| `mvnag` | `mvn archetype:generate` |
|
||||
| `mvnboot` | `mvn spring-boot:run` |
|
||||
| `mvnqdev` | `mvn quarkus:dev` |
|
||||
| `mvnc` | `mvn clean` |
|
||||
| `mvncd` | `mvn clean deploy` |
|
||||
| `mvnce` | `mvn clean eclipse:clean eclipse:eclipse` |
|
||||
|
@ -36,6 +37,7 @@ if it's found, or the mvn command otherwise.
|
|||
| `mvndocs` | `mvn dependency:resolve -Dclassifier=javadoc` |
|
||||
| `mvndt` | `mvn dependency:tree` |
|
||||
| `mvne` | `mvn eclipse:eclipse` |
|
||||
| `mvnfmt` | `mvn fmt:format` |
|
||||
| `mvnjetty` | `mvn jetty:run` |
|
||||
| `mvnp` | `mvn package` |
|
||||
| `mvns` | `mvn site` |
|
||||
|
|
|
@ -59,8 +59,10 @@ alias mvnd='mvn deploy'
|
|||
alias mvndocs='mvn dependency:resolve -Dclassifier=javadoc'
|
||||
alias mvndt='mvn dependency:tree'
|
||||
alias mvne='mvn eclipse:eclipse'
|
||||
alias mvnfmt='mvn fmt:format'
|
||||
alias mvnjetty='mvn jetty:run'
|
||||
alias mvnp='mvn package'
|
||||
alias mvnqdev='mvn quarkus:dev'
|
||||
alias mvns='mvn site'
|
||||
alias mvnsrc='mvn dependency:sources'
|
||||
alias mvnt='mvn test'
|
||||
|
@ -71,7 +73,7 @@ alias mvn-updates='mvn versions:display-dependency-updates'
|
|||
|
||||
function listMavenCompletions {
|
||||
local file new_file
|
||||
local -a profiles POM_FILES
|
||||
local -a profiles POM_FILES modules
|
||||
|
||||
# Root POM
|
||||
POM_FILES=(~/.m2/settings.xml)
|
||||
|
@ -107,6 +109,9 @@ function listMavenCompletions {
|
|||
profiles+=($(sed 's/<!--.*-->//' "$file" | sed '/<!--/,/-->/d' | grep -e "<profile>" -A 1 | grep -e "<id>.*</id>" | sed 's?.*<id>\(.*\)<\/id>.*?-P\1?'))
|
||||
done
|
||||
|
||||
# List modules
|
||||
modules=($(find **/pom.xml -type f | grep -v '/target/classes/META-INF/' | grep '/pom.xml' |sed 's|\(.*\)/pom\.xml|\1|'))
|
||||
|
||||
reply=(
|
||||
# common lifecycle
|
||||
clean initialize process-resources compile process-test-resources test-compile test package verify install deploy site
|
||||
|
@ -183,6 +188,8 @@ function listMavenCompletions {
|
|||
tomee:run tomee:run-war tomee:run-war-only tomee:stop tomee:deploy tomee:undeploy
|
||||
# spring-boot
|
||||
spring-boot:run spring-boot:repackage
|
||||
# quarkus
|
||||
quarkus:dev quarkus:list-extensions quarkus:add-extension quarkus:add-extensions quarkus:generate-config quarkus:help
|
||||
# exec
|
||||
exec:exec exec:java
|
||||
# versions
|
||||
|
@ -267,8 +274,8 @@ function listMavenCompletions {
|
|||
stage:copy
|
||||
# toolchain
|
||||
toolchain:toolchain
|
||||
#liberty
|
||||
liberty:clean-server liberty:compile-jsp liberty:configure-arquillian liberty:create-server liberty:debug liberty:debug-server liberty:deploy liberty:dev liberty:display-url liberty:dump-server liberty:install-apps liberty:install-feature liberty:install-server liberty:java-dump-server liberty:package-server liberty:run liberty:run-server liberty:server-status liberty:start liberty:start-server liberty:status liberty:stop liberty:stop-server liberty:test-start-server liberty:test-stop-server liberty:undeploy liberty:uninstall-feature
|
||||
#liberty
|
||||
liberty:clean-server liberty:compile-jsp liberty:configure-arquillian liberty:create-server liberty:debug liberty:debug-server liberty:deploy liberty:dev liberty:display-url liberty:dump-server liberty:install-apps liberty:install-feature liberty:install-server liberty:java-dump-server liberty:package-server liberty:run liberty:run-server liberty:server-status liberty:start liberty:start-server liberty:status liberty:stop liberty:stop-server liberty:test-start-server liberty:test-stop-server liberty:undeploy liberty:uninstall-feature
|
||||
|
||||
# options
|
||||
"-Dmaven.test.skip=true" -DskipTests -DskipITs -Dmaven.surefire.debug -DenableCiProfile "-Dpmd.skip=true" "-Dcheckstyle.skip=true" "-Dtycho.mode=maven" "-Dmaven.test.failure.ignore=true" "-DgroupId=" "-DartifactId=" "-Dversion=" "-Dpackaging=jar" "-Dfile="
|
||||
|
@ -319,6 +326,7 @@ function listMavenCompletions {
|
|||
-Dit.test=$(if [ -d ./src/test/java ] ; then find ./src/test/java -type f -name '*.java' | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dit.test=\1?' ; fi)
|
||||
|
||||
$profiles
|
||||
$modules
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,21 +1,15 @@
|
|||
# NPX Plugin
|
||||
> npx(1) -- execute npm package binaries. ([more info](https://github.com/zkat/npx))
|
||||
|
||||
> npx(1) -- execute npm package binaries. ([more info](https://github.com/npm/npx))
|
||||
|
||||
This plugin automatically registers npx command-not-found handler if `npx` exists in your `$PATH`.
|
||||
|
||||
## Setup
|
||||
To use it, add `npx` to the plugins array in your zshrc file:
|
||||
|
||||
- Add plugin to `~/.zshrc`
|
||||
|
||||
```bash
|
||||
```zsh
|
||||
plugins=(.... npx)
|
||||
```
|
||||
|
||||
- Globally install npx binary (npx will be auto installed with recent versions of Node.js)
|
||||
```bash
|
||||
sudo npm install -g npx
|
||||
```
|
||||
|
||||
## Note
|
||||
|
||||
The shell auto-fallback doesn't auto-install plain packages. In order to get it to install something, you need to add `@`:
|
||||
|
@ -29,3 +23,17 @@ Started
|
|||
|
||||
It does it this way so folks using the fallback don't accidentally try to install regular typoes.
|
||||
|
||||
## Deprecation
|
||||
|
||||
Since npm v7, `npx` has been moved to `npm exec`. With the move, [the `--shell-auto-fallback` argument
|
||||
for `npx` has been removed](https://github.com/npm/cli/blob/v7.0.0/docs/content/cli-commands/npm-exec.md#compatibility-with-older-npx-versions):
|
||||
|
||||
> Shell fallback functionality is removed, as it is not advisable.
|
||||
|
||||
When using npm v7, you'll get this error:
|
||||
|
||||
> npx: the --shell-auto-fallback argument has been removed
|
||||
|
||||
If you get this error, just disable the plugin by removing it from the plugins array in your zshrc file.
|
||||
This plugin will no longer be maintained and will be removed in the future, when the older `npx` versions
|
||||
are no longer available.
|
||||
|
|
|
@ -1,9 +1,26 @@
|
|||
# nvm plugin
|
||||
|
||||
This plugin adds autocompletions for [nvm](https://github.com/creationix/nvm) — a Node.js version manager.
|
||||
This plugin adds autocompletions for [nvm](https://github.com/nvm-sh/nvm) — a Node.js version manager.
|
||||
It also automatically sources nvm, so you don't need to do it manually in your `.zshrc`.
|
||||
|
||||
To use it, add `nvm` to the plugins array of your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... nvm)
|
||||
```
|
||||
|
||||
## Settings
|
||||
|
||||
- **`NVM_DIR`**: if you have installed nvm in a directory other than `$HOME/.nvm`, set and export `NVM_DIR`
|
||||
to be the directory where you installed nvm.
|
||||
|
||||
- **`NVM_HOMEBREW`**: if you installed nvm via Homebrew, in a directory other than `/usr/local/opt/nvm`, you
|
||||
can set `NVM_HOMEBREW` to be the directory where you installed it.
|
||||
|
||||
- **`NVM_LAZY`**: if you want the plugin to defer the load of nvm to speed-up the start of your zsh session,
|
||||
set `NVM_LAZY` to `1`. This will use the `--no-use` parameter when loading nvm, and will create a function
|
||||
for `node`, `npm` and `yarn`, so when you call either of these three, nvm will load with `nvm use default`.
|
||||
|
||||
- **`NVM_AUTOLOAD`**: if `NVM_AUTOLOAD` is set to `1`, the plugin will automatically load a node version when
|
||||
if finds a [`.nvmrc` file](https://github.com/nvm-sh/nvm#nvmrc) in the current working directory indicating
|
||||
which node version to load.
|
||||
|
|
|
@ -1,8 +1,77 @@
|
|||
# Set NVM_DIR if it isn't already defined
|
||||
[[ -z "$NVM_DIR" ]] && export NVM_DIR="$HOME/.nvm"
|
||||
|
||||
# Try to load nvm only if command not already available
|
||||
if ! type "nvm" &> /dev/null; then
|
||||
# Load nvm if it exists
|
||||
[[ -f "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh"
|
||||
# See https://github.com/nvm-sh/nvm#installation-and-update
|
||||
if [[ -z "$NVM_DIR" ]]; then
|
||||
if [[ -d "$HOME/.nvm" ]]; then
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
elif [[ -d "${XDG_CONFIG_HOME:-$HOME/.config}/nvm" ]]; then
|
||||
export NVM_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/nvm"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Don't try to load nvm if command already available
|
||||
which nvm &> /dev/null && return
|
||||
|
||||
if [[ -f "$NVM_DIR/nvm.sh" ]]; then
|
||||
# Load nvm if it exists in $NVM_DIR
|
||||
source "$NVM_DIR/nvm.sh" ${NVM_LAZY+"--no-use"}
|
||||
else
|
||||
# Otherwise try to load nvm installed via Homebrew
|
||||
# User can set this if they have an unusual Homebrew setup
|
||||
NVM_HOMEBREW="${NVM_HOMEBREW:-/usr/local/opt/nvm}"
|
||||
# Load nvm from Homebrew location if it exists
|
||||
if [[ -f "$NVM_HOMEBREW/nvm.sh" ]]; then
|
||||
source "$NVM_HOMEBREW/nvm.sh" ${NVM_LAZY+"--no-use"}
|
||||
else
|
||||
# Exit the plugin if we couldn't find nvm
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
# Call nvm when first using node, npm or yarn
|
||||
if (( $+NVM_LAZY )); then
|
||||
function node npm yarn {
|
||||
unfunction node npm yarn
|
||||
nvm use default
|
||||
command "$0" "$@"
|
||||
}
|
||||
fi
|
||||
|
||||
# Autoload nvm when finding a .nvmrc file in the current directory
|
||||
# Adapted from: https://github.com/nvm-sh/nvm#zsh
|
||||
if (( $+NVM_AUTOLOAD )); then
|
||||
load-nvmrc() {
|
||||
local node_version="$(nvm version)"
|
||||
local nvmrc_path="$(nvm_find_nvmrc)"
|
||||
|
||||
if [[ -n "$nvmrc_path" ]]; then
|
||||
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
|
||||
|
||||
if [[ "$nvmrc_node_version" = "N/A" ]]; then
|
||||
nvm install
|
||||
elif [[ "$nvmrc_node_version" != "$node_version" ]]; then
|
||||
nvm use
|
||||
fi
|
||||
elif [[ "$node_version" != "$(nvm version default)" ]]; then
|
||||
echo "Reverting to nvm default version"
|
||||
nvm use default
|
||||
fi
|
||||
}
|
||||
|
||||
autoload -U add-zsh-hook
|
||||
add-zsh-hook chpwd load-nvmrc
|
||||
|
||||
load-nvmrc
|
||||
fi
|
||||
|
||||
# Load nvm bash completion
|
||||
for nvm_completion in "$NVM_DIR/bash_completion" "$NVM_HOMEBREW/etc/bash_completion.d/nvm"; do
|
||||
if [[ -f "$nvm_completion" ]]; then
|
||||
# Load bashcompinit
|
||||
autoload -U +X bashcompinit && bashcompinit
|
||||
# Bypass compinit call in nvm bash completion script. See:
|
||||
# https://github.com/nvm-sh/nvm/blob/4436638/bash_completion#L86-L93
|
||||
ZSH_VERSION= source "$nvm_completion"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
unset NVM_HOMEBREW NVM_LAZY NVM_AUTOLOAD nvm_completion
|
||||
|
|
|
@ -22,14 +22,17 @@ Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
|
|||
| `pfs` | Return the current Finder selection |
|
||||
| `cdf` | `cd` to the current Finder directory |
|
||||
| `pushdf` | `pushd` to the current Finder directory |
|
||||
| `pxd` | Return the current Xcode project directory |
|
||||
| `cdx` | `cd` to the current Xcode project directory |
|
||||
| `quick-look` | Quick-Look a specified file |
|
||||
| `man-preview` | Open a specified man page in Preview app |
|
||||
| `showfiles` | Show hidden files |
|
||||
| `hidefiles` | Hide the hidden files |
|
||||
| `itunes` | DEPRECATED. Use `music` from macOS Catalina on |
|
||||
| `showfiles` | Show hidden files in Finder |
|
||||
| `hidefiles` | Hide the hidden files in Finder |
|
||||
| `itunes` | _DEPRECATED_. Use `music` from macOS Catalina on |
|
||||
| `music` | Control Apple Music. Use `music -h` for usage details |
|
||||
| `spotify` | Control Spotify and search by artist, album, track… |
|
||||
| `rmdsstore` | Remove .DS\_Store files recursively in a directory |
|
||||
| `btrestart` | Restart the Bluetooth daemon |
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
|
|
90
dot_oh-my-zsh/plugins/osx/_security
Normal file
90
dot_oh-my-zsh/plugins/osx/_security
Normal file
|
@ -0,0 +1,90 @@
|
|||
#compdef security
|
||||
|
||||
local -a _1st_arguments
|
||||
_1st_arguments=(
|
||||
'help:Show all commands, or show usage for a command'
|
||||
'list-keychains:Display or manipulate the keychain search list'
|
||||
'default-keychain:Display or set the default keychain'
|
||||
'login-keychain:Display or set the login keychain'
|
||||
'create-keychain:Create keychains and add them to the search list'
|
||||
'delete-keychain:Delete keychains and remove them from the search list'
|
||||
'lock-keychain:Lock the specified keychain'
|
||||
'lock-keychain:Unlock the specified keychain'
|
||||
'set-keychain-settings:Set settings for a keychain'
|
||||
'set-keychain-password:Set password for a keychain'
|
||||
'show-keychain-info:Show the settings for keychain'
|
||||
'dump-keychain:Dump the contents of one or more keychains'
|
||||
'create-keypair:Create an asymmetric key pair'
|
||||
'add-generic-password:Add a generic password item'
|
||||
'add-internet-password:Add an internet password item'
|
||||
'add-certificates:Add certificates to a keychain'
|
||||
'find-generic-password:Find a generic password item'
|
||||
'delete-generic-password:Delete a generic password item'
|
||||
'find-internet-password:Find an internet password item'
|
||||
'delete-internet-password:Delete an internet password item'
|
||||
'find-certificate:Find a certificate item'
|
||||
'find-identity:Find an identity certificate + private key'
|
||||
'delete-certificate:Delete a certificate from a keychain'
|
||||
'set-identity-preference:Set the preferred identity to use for a service'
|
||||
'get-identity-preference:Get the preferred identity to use for a service'
|
||||
'create-db:Create a db using the DL'
|
||||
'export:Export items from a keychain'
|
||||
'import:Import items into a keychain'
|
||||
'cms:Encode or decode CMS messages'
|
||||
'install-mds:MDS database'
|
||||
'add-trusted-cert:Add trusted certificates:'
|
||||
'remove-trusted-cert:Remove trusted certificates:'
|
||||
'dump-trust-settings:Display contents of trust settings'
|
||||
'user-trust-settings-enable:Display or manipulate user-level trust settings'
|
||||
'trust-settings-export:Export trust settings'
|
||||
'trust-settings-import:Import trust settings'
|
||||
'verify-cert:Verify certificates:'
|
||||
'authorize:Perform authorization operations'
|
||||
'authorizationdb:Make changes to the authorization policy database'
|
||||
'execute-with-privileges:Execute tool with privileges'
|
||||
'leaks:Run /usr/bin/leaks on this process'
|
||||
'error:Display a descriptive message for the given error codes:'
|
||||
'create-filevaultmaster-keychain:"Create a keychain containing a key pair for FileVault recovery use'
|
||||
)
|
||||
_arguments '*:: :->command'
|
||||
|
||||
if (( CURRENT == 1 )); then
|
||||
_describe -t commands "security command" _1st_arguments
|
||||
return
|
||||
fi
|
||||
|
||||
case "$words[1]" in
|
||||
find-(generic|internet)-password)
|
||||
_values \
|
||||
'Usage: find-[internet/generic]-password [-a account] [-s server] [options...] [-g] [keychain...]' \
|
||||
'-a[Match "account" string]' \
|
||||
'-c[Match "creator" (four-character code)]' \
|
||||
'-C[Match "type" (four-character code)]' \
|
||||
'-D[Match "kind" string]' \
|
||||
'-G[Match "value" string (generic attribute)]' \
|
||||
'-j[Match "comment" string]' \
|
||||
'-l[Match "label" string]' \
|
||||
'-s[Match "service" string]' \
|
||||
'-g[Display the password for the item found]' \
|
||||
'-w[Display only the password on stdout]' ;;
|
||||
add-(generic|internet)-password)
|
||||
_values \
|
||||
'Usage: add-[internet/generic]-password [-a account] [-s server] [-w password] [options...] [-A|-T appPath] [keychain]]' \
|
||||
'-a[Specify account name (required)]' \
|
||||
'-c[Specify item creator (optional four-character code)]' \
|
||||
'-C[Specify item type (optional four-character code)]' \
|
||||
'-d[Specify security domain string (optional)]' \
|
||||
'-D[Specify kind (default is "Internet password")]' \
|
||||
'-j[Specify comment string (optional)]' \
|
||||
'-l[Specify label (if omitted, server name is used as default label)]' \
|
||||
'-p[Specify path string (optional)]' \
|
||||
'-P[Specify port number (optional)]' \
|
||||
'-r[Specify protocol (optional four-character SecProtocolType, e.g. "http", "ftp ")]' \
|
||||
'-s[Specify server name (required)]' \
|
||||
'-t[Specify authentication type (as a four-character SecAuthenticationType, default is "dflt")]' \
|
||||
'-w[Specify password to be added]' \
|
||||
'-A[Allow any application to access this item without warning (insecure, not recommended!)]' \
|
||||
'-T[Specify an application which may access this item (multiple -T options are allowed)]' \
|
||||
'-U[Update item if it already exists (if omitted, the item cannot already exist) ]' \
|
||||
'utils)]' ;;
|
||||
esac
|
170
dot_oh-my-zsh/plugins/osx/music
Normal file
170
dot_oh-my-zsh/plugins/osx/music
Normal file
|
@ -0,0 +1,170 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
function music itunes() {
|
||||
local APP_NAME=Music sw_vers=$(sw_vers -productVersion 2>/dev/null)
|
||||
|
||||
autoload is-at-least
|
||||
if [[ -z "$sw_vers" ]] || is-at-least 10.15 $sw_vers; then
|
||||
if [[ $0 = itunes ]]; then
|
||||
echo >&2 The itunes function name is deprecated. Use \'music\' instead.
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
APP_NAME=iTunes
|
||||
fi
|
||||
|
||||
local opt=$1 playlist=$2
|
||||
(( $# > 0 )) && shift
|
||||
case "$opt" in
|
||||
launch|play|pause|stop|rewind|resume|quit)
|
||||
;;
|
||||
mute)
|
||||
opt="set mute to true"
|
||||
;;
|
||||
unmute)
|
||||
opt="set mute to false"
|
||||
;;
|
||||
next|previous)
|
||||
opt="$opt track"
|
||||
;;
|
||||
vol)
|
||||
local new_volume volume=$(osascript -e "tell application \"$APP_NAME\" to get sound volume")
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "Current volume is ${volume}."
|
||||
return 0
|
||||
fi
|
||||
case $1 in
|
||||
up) new_volume=$((volume + 10 < 100 ? volume + 10 : 100)) ;;
|
||||
down) new_volume=$((volume - 10 > 0 ? volume - 10 : 0)) ;;
|
||||
<0-100>) new_volume=$1 ;;
|
||||
*) echo "'$1' is not valid. Expected <0-100>, up or down."
|
||||
return 1 ;;
|
||||
esac
|
||||
opt="set sound volume to ${new_volume}"
|
||||
;;
|
||||
playlist)
|
||||
# Inspired by: https://gist.github.com/nakajijapan/ac8b45371064ae98ea7f
|
||||
if [[ -n "$playlist" ]]; then
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "$APP_NAME"
|
||||
set new_playlist to "$playlist" as string
|
||||
play playlist new_playlist
|
||||
end tell
|
||||
EOF
|
||||
if [[ $? -eq 0 ]]; then
|
||||
opt="play"
|
||||
else
|
||||
opt="stop"
|
||||
fi
|
||||
else
|
||||
opt="set allPlaylists to (get name of every playlist)"
|
||||
fi
|
||||
;;
|
||||
playing|status)
|
||||
local currenttrack currentartist state=$(osascript -e "tell application \"$APP_NAME\" to player state as string")
|
||||
if [[ "$state" = "playing" ]]; then
|
||||
currenttrack=$(osascript -e "tell application \"$APP_NAME\" to name of current track as string")
|
||||
currentartist=$(osascript -e "tell application \"$APP_NAME\" to artist of current track as string")
|
||||
echo -E "Listening to ${fg[yellow]}${currenttrack}${reset_color} by ${fg[yellow]}${currentartist}${reset_color}"
|
||||
else
|
||||
echo "$APP_NAME is $state"
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
shuf|shuff|shuffle)
|
||||
# The shuffle property of current playlist can't be changed in iTunes 12,
|
||||
# so this workaround uses AppleScript to simulate user input instead.
|
||||
# Defaults to toggling when no options are given.
|
||||
# The toggle option depends on the shuffle button being visible in the Now playing area.
|
||||
# On and off use the menu bar items.
|
||||
local state=$1
|
||||
|
||||
if [[ -n "$state" && "$state" != (on|off|toggle) ]]; then
|
||||
print "Usage: $0 shuffle [on|off|toggle]. Invalid option."
|
||||
return 1
|
||||
fi
|
||||
|
||||
case "$state" in
|
||||
on|off)
|
||||
# Inspired by: https://stackoverflow.com/a/14675583
|
||||
osascript >/dev/null 2>&1 <<EOF
|
||||
tell application "System Events" to perform action "AXPress" of (menu item "${state}" of menu "Shuffle" of menu item "Shuffle" of menu "Controls" of menu bar item "Controls" of menu bar 1 of application process "iTunes" )
|
||||
EOF
|
||||
return 0
|
||||
;;
|
||||
toggle|*)
|
||||
osascript >/dev/null 2>&1 <<EOF
|
||||
tell application "System Events" to perform action "AXPress" of (button 2 of process "iTunes"'s window "iTunes"'s scroll area 1)
|
||||
EOF
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
""|-h|--help)
|
||||
echo "Usage: $0 <option>"
|
||||
echo "option:"
|
||||
echo "\t-h|--help\tShow this message and exit"
|
||||
echo "\tlaunch|play|pause|stop|rewind|resume|quit"
|
||||
echo "\tmute|unmute\tMute or unmute $APP_NAME"
|
||||
echo "\tnext|previous\tPlay next or previous track"
|
||||
echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer."
|
||||
echo "\tvol [0-100|up|down]\tGet or set the volume. 0 to 100 sets the volume. 'up' / 'down' increases / decreases by 10 points. No argument displays current volume."
|
||||
echo "\tplaying|status\tShow what song is currently playing in Music."
|
||||
echo "\tplaylist [playlist name]\t Play specific playlist"
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
print "Unknown option: $opt"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
osascript -e "tell application \"$APP_NAME\" to $opt"
|
||||
}
|
||||
|
||||
function _music() {
|
||||
local app_name
|
||||
case "$words[1]" in
|
||||
itunes) app_name="iTunes" ;;
|
||||
music|*) app_name="Music" ;;
|
||||
esac
|
||||
|
||||
local -a cmds subcmds
|
||||
cmds=(
|
||||
"launch:Launch the ${app_name} app"
|
||||
"play:Play ${app_name}"
|
||||
"pause:Pause ${app_name}"
|
||||
"stop:Stop ${app_name}"
|
||||
"rewind:Rewind ${app_name}"
|
||||
"resume:Resume ${app_name}"
|
||||
"quit:Quit ${app_name}"
|
||||
"mute:Mute the ${app_name} app"
|
||||
"unmute:Unmute the ${app_name} app"
|
||||
"next:Skip to the next song"
|
||||
"previous:Skip to the previous song"
|
||||
"vol:Change the volume"
|
||||
"playlist:Play a specific playlist"
|
||||
{playing,status}":Show what song is currently playing"
|
||||
{shuf,shuff,shuffle}":Set shuffle mode"
|
||||
{-h,--help}":Show usage"
|
||||
)
|
||||
|
||||
if (( CURRENT == 2 )); then
|
||||
_describe 'command' cmds
|
||||
elif (( CURRENT == 3 )); then
|
||||
case "$words[2]" in
|
||||
vol) subcmds=( 'up:Raise the volume' 'down:Lower the volume' )
|
||||
_describe 'command' subcmds ;;
|
||||
shuf|shuff|shuffle) subcmds=('on:Switch on shuffle mode' 'off:Switch off shuffle mode' 'toggle:Toggle shuffle mode (default)')
|
||||
_describe 'command' subcmds ;;
|
||||
esac
|
||||
elif (( CURRENT == 4 )); then
|
||||
case "$words[2]" in
|
||||
playlist) subcmds=('play:Play the playlist (default)' 'stop:Stop the playlist')
|
||||
_describe 'command' subcmds ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
compdef _music music itunes
|
|
@ -1,15 +1,22 @@
|
|||
# Open the current directory in a Finder window
|
||||
alias ofd='open_command $PWD'
|
||||
|
||||
# Show/hide hidden files in the Finder
|
||||
alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
|
||||
alias hidefiles="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
|
||||
|
||||
# Bluetooth restart
|
||||
function btrestart() {
|
||||
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
|
||||
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
|
||||
}
|
||||
|
||||
function _omz_osx_get_frontmost_app() {
|
||||
local the_app=$(
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "System Events"
|
||||
name of first item of (every process whose frontmost is true)
|
||||
end tell
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "System Events"
|
||||
name of first item of (every process whose frontmost is true)
|
||||
end tell
|
||||
EOF
|
||||
)
|
||||
echo "$the_app"
|
||||
}
|
||||
|
||||
function tab() {
|
||||
|
@ -27,7 +34,6 @@ function tab() {
|
|||
end tell
|
||||
tell application "Terminal" to do script "${command}" in front window
|
||||
EOF
|
||||
|
||||
elif [[ "$the_app" == 'iTerm' ]]; then
|
||||
osascript <<EOF
|
||||
tell application "iTerm"
|
||||
|
@ -41,32 +47,29 @@ EOF
|
|||
end tell
|
||||
end tell
|
||||
EOF
|
||||
|
||||
elif [[ "$the_app" == 'iTerm2' ]]; then
|
||||
osascript <<EOF
|
||||
tell application "iTerm2"
|
||||
tell current window
|
||||
create tab with default profile
|
||||
tell current session to write text "${command}"
|
||||
end tell
|
||||
osascript <<EOF
|
||||
tell application "iTerm2"
|
||||
tell current window
|
||||
create tab with default profile
|
||||
tell current session to write text "${command}"
|
||||
end tell
|
||||
end tell
|
||||
EOF
|
||||
elif [[ "$the_app" == 'Hyper' ]]; then
|
||||
osascript >/dev/null <<EOF
|
||||
tell application "System Events"
|
||||
tell process "Hyper" to keystroke "t" using command down
|
||||
end tell
|
||||
delay 1
|
||||
tell application "System Events"
|
||||
keystroke "${command}"
|
||||
key code 36 #(presses enter)
|
||||
end tell
|
||||
tell application "System Events"
|
||||
tell process "Hyper" to keystroke "t" using command down
|
||||
end tell
|
||||
delay 1
|
||||
tell application "System Events"
|
||||
keystroke "${command}"
|
||||
key code 36 #(presses enter)
|
||||
end tell
|
||||
EOF
|
||||
|
||||
else
|
||||
echo "tab: unsupported terminal app: $the_app"
|
||||
false
|
||||
|
||||
echo "$0: unsupported terminal app: $the_app" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -79,7 +82,6 @@ function vsplit_tab() {
|
|||
if [[ "$the_app" == 'iTerm' ]]; then
|
||||
osascript <<EOF
|
||||
-- tell application "iTerm" to activate
|
||||
|
||||
tell application "System Events"
|
||||
tell process "iTerm"
|
||||
tell menu item "Split Vertically With Current Profile" of menu "Shell" of menu bar item "Shell" of menu bar 1
|
||||
|
@ -89,37 +91,33 @@ function vsplit_tab() {
|
|||
keystroke "${command} \n"
|
||||
end tell
|
||||
EOF
|
||||
|
||||
elif [[ "$the_app" == 'iTerm2' ]]; then
|
||||
osascript <<EOF
|
||||
tell application "iTerm2"
|
||||
tell current session of first window
|
||||
set newSession to (split vertically with same profile)
|
||||
tell newSession
|
||||
write text "${command}"
|
||||
select
|
||||
end tell
|
||||
osascript <<EOF
|
||||
tell application "iTerm2"
|
||||
tell current session of first window
|
||||
set newSession to (split vertically with same profile)
|
||||
tell newSession
|
||||
write text "${command}"
|
||||
select
|
||||
end tell
|
||||
end tell
|
||||
EOF
|
||||
|
||||
elif [[ "$the_app" == 'Hyper' ]]; then
|
||||
osascript >/dev/null <<EOF
|
||||
tell application "System Events"
|
||||
tell process "Hyper"
|
||||
tell menu item "Split Vertically" of menu "Shell" of menu bar 1
|
||||
click
|
||||
end tell
|
||||
end tell
|
||||
delay 1
|
||||
keystroke "${command} \n"
|
||||
end tell
|
||||
EOF
|
||||
|
||||
elif [[ "$the_app" == 'Hyper' ]]; then
|
||||
osascript >/dev/null <<EOF
|
||||
tell application "System Events"
|
||||
tell process "Hyper"
|
||||
tell menu item "Split Vertically" of menu "Shell" of menu bar 1
|
||||
click
|
||||
end tell
|
||||
end tell
|
||||
delay 1
|
||||
keystroke "${command} \n"
|
||||
end tell
|
||||
EOF
|
||||
else
|
||||
echo "$0: unsupported terminal app: $the_app" >&2
|
||||
false
|
||||
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -142,44 +140,40 @@ function split_tab() {
|
|||
keystroke "${command} \n"
|
||||
end tell
|
||||
EOF
|
||||
|
||||
elif [[ "$the_app" == 'iTerm2' ]]; then
|
||||
osascript <<EOF
|
||||
tell application "iTerm2"
|
||||
tell current session of first window
|
||||
set newSession to (split horizontally with same profile)
|
||||
tell newSession
|
||||
write text "${command}"
|
||||
select
|
||||
end tell
|
||||
osascript <<EOF
|
||||
tell application "iTerm2"
|
||||
tell current session of first window
|
||||
set newSession to (split horizontally with same profile)
|
||||
tell newSession
|
||||
write text "${command}"
|
||||
select
|
||||
end tell
|
||||
end tell
|
||||
EOF
|
||||
|
||||
elif [[ "$the_app" == 'Hyper' ]]; then
|
||||
osascript >/dev/null <<EOF
|
||||
tell application "System Events"
|
||||
tell process "Hyper"
|
||||
tell menu item "Split Horizontally" of menu "Shell" of menu bar 1
|
||||
click
|
||||
end tell
|
||||
end tell
|
||||
delay 1
|
||||
keystroke "${command} \n"
|
||||
end tell
|
||||
EOF
|
||||
|
||||
elif [[ "$the_app" == 'Hyper' ]]; then
|
||||
osascript >/dev/null <<EOF
|
||||
tell application "System Events"
|
||||
tell process "Hyper"
|
||||
tell menu item "Split Horizontally" of menu "Shell" of menu bar 1
|
||||
click
|
||||
end tell
|
||||
end tell
|
||||
delay 1
|
||||
keystroke "${command} \n"
|
||||
end tell
|
||||
EOF
|
||||
else
|
||||
echo "$0: unsupported terminal app: $the_app" >&2
|
||||
false
|
||||
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function pfd() {
|
||||
osascript 2>/dev/null <<EOF
|
||||
tell application "Finder"
|
||||
return POSIX path of (target of window 1 as alias)
|
||||
return POSIX path of (insertion location as alias)
|
||||
end tell
|
||||
EOF
|
||||
}
|
||||
|
@ -205,6 +199,21 @@ function pushdf() {
|
|||
pushd "$(pfd)"
|
||||
}
|
||||
|
||||
function pxd() {
|
||||
dirname $(osascript 2>/dev/null <<EOF
|
||||
if application "Xcode" is running then
|
||||
tell application "Xcode"
|
||||
return path of active workspace document
|
||||
end tell
|
||||
end if
|
||||
EOF
|
||||
)
|
||||
}
|
||||
|
||||
function cdx() {
|
||||
cd "$(pxd)"
|
||||
}
|
||||
|
||||
function quick-look() {
|
||||
(( $# > 0 )) && qlmanage -p $* &>/dev/null &
|
||||
}
|
||||
|
@ -218,133 +227,13 @@ function vncviewer() {
|
|||
open vnc://$@
|
||||
}
|
||||
|
||||
# iTunes control function
|
||||
function itunes music() {
|
||||
local APP_NAME=Music
|
||||
|
||||
autoload is-at-least
|
||||
if is-at-least 10.15 $(sw_vers -productVersion); then
|
||||
if [[ $0 = itunes ]]; then
|
||||
echo >&2 The itunes function name is deprecated. Use \`music\' instead.
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
APP_NAME=iTunes
|
||||
fi
|
||||
|
||||
local opt=$1
|
||||
local playlist=$2
|
||||
shift
|
||||
case "$opt" in
|
||||
launch|play|pause|stop|rewind|resume|quit)
|
||||
;;
|
||||
mute)
|
||||
opt="set mute to true"
|
||||
;;
|
||||
unmute)
|
||||
opt="set mute to false"
|
||||
;;
|
||||
next|previous)
|
||||
opt="$opt track"
|
||||
;;
|
||||
vol)
|
||||
local new_volume volume=$(osascript -e "tell application \"$APP_NAME\" to get sound volume")
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "Current volume is ${volume}."
|
||||
return 0
|
||||
fi
|
||||
case $1 in
|
||||
up) new_volume=$((volume + 10 < 100 ? volume + 10 : 100)) ;;
|
||||
down) new_volume=$((volume - 10 > 0 ? volume - 10 : 0)) ;;
|
||||
<0-100>) new_volume=$1 ;;
|
||||
*) echo "'$1' is not valid. Expected <0-100>, up or down."
|
||||
return 1 ;;
|
||||
esac
|
||||
opt="set sound volume to ${new_volume}"
|
||||
;;
|
||||
playlist)
|
||||
# Inspired by: https://gist.github.com/nakajijapan/ac8b45371064ae98ea7f
|
||||
if [[ ! -z "$playlist" ]]; then
|
||||
osascript -e "tell application \"$APP_NAME\"" -e "set new_playlist to \"$playlist\" as string" -e "play playlist new_playlist" -e "end tell" 2>/dev/null;
|
||||
if [[ $? -eq 0 ]]; then
|
||||
opt="play"
|
||||
else
|
||||
opt="stop"
|
||||
fi
|
||||
else
|
||||
opt="set allPlaylists to (get name of every playlist)"
|
||||
fi
|
||||
;;
|
||||
playing|status)
|
||||
local state=`osascript -e "tell application \"$APP_NAME\" to player state as string"`
|
||||
if [[ "$state" = "playing" ]]; then
|
||||
currenttrack=`osascript -e "tell application \"$APP_NAME\" to name of current track as string"`
|
||||
currentartist=`osascript -e "tell application \"$APP_NAME\" to artist of current track as string"`
|
||||
echo -E "Listening to $fg[yellow]$currenttrack$reset_color by $fg[yellow]$currentartist$reset_color";
|
||||
else
|
||||
echo "$APP_NAME is" $state;
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
shuf|shuff|shuffle)
|
||||
# The shuffle property of current playlist can't be changed in iTunes 12,
|
||||
# so this workaround uses AppleScript to simulate user input instead.
|
||||
# Defaults to toggling when no options are given.
|
||||
# The toggle option depends on the shuffle button being visible in the Now playing area.
|
||||
# On and off use the menu bar items.
|
||||
local state=$1
|
||||
|
||||
if [[ -n "$state" && ! "$state" =~ "^(on|off|toggle)$" ]]
|
||||
then
|
||||
print "Usage: $0 shuffle [on|off|toggle]. Invalid option."
|
||||
return 1
|
||||
fi
|
||||
|
||||
case "$state" in
|
||||
on|off)
|
||||
# Inspired by: https://stackoverflow.com/a/14675583
|
||||
osascript 1>/dev/null 2>&1 <<-EOF
|
||||
tell application "System Events" to perform action "AXPress" of (menu item "${state}" of menu "Shuffle" of menu item "Shuffle" of menu "Controls" of menu bar item "Controls" of menu bar 1 of application process "iTunes" )
|
||||
EOF
|
||||
return 0
|
||||
;;
|
||||
toggle|*)
|
||||
osascript 1>/dev/null 2>&1 <<-EOF
|
||||
tell application "System Events" to perform action "AXPress" of (button 2 of process "iTunes"'s window "iTunes"'s scroll area 1)
|
||||
EOF
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
""|-h|--help)
|
||||
echo "Usage: $0 <option>"
|
||||
echo "option:"
|
||||
echo "\tlaunch|play|pause|stop|rewind|resume|quit"
|
||||
echo "\tmute|unmute\tcontrol volume set"
|
||||
echo "\tnext|previous\tplay next or previous track"
|
||||
echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer."
|
||||
echo "\tvol [0-100|up|down]\tGet or set the volume. 0 to 100 sets the volume. 'up' / 'down' increases / decreases by 10 points. No argument displays current volume."
|
||||
echo "\tplaying|status\tShow what song is currently playing in Music."
|
||||
echo "\tplaylist [playlist name]\t Play specific playlist"
|
||||
echo "\thelp\tshow this message and exit"
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
print "Unknown option: $opt"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
osascript -e "tell application \"$APP_NAME\" to $opt"
|
||||
}
|
||||
|
||||
# Spotify control function
|
||||
source ${ZSH}/plugins/osx/spotify
|
||||
|
||||
# Show/hide hidden files in the Finder
|
||||
alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
|
||||
alias hidefiles="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
|
||||
|
||||
# Remove .DS_Store files recursively in a directory, default .
|
||||
function rmdsstore() {
|
||||
find "${@:-.}" -type f -name .DS_Store -delete
|
||||
find "${@:-.}" -type f -name .DS_Store -delete
|
||||
}
|
||||
|
||||
# Music / iTunes control function
|
||||
source "${0:h:A}/music"
|
||||
|
||||
# Spotify control function
|
||||
source "${0:h:A}/spotify"
|
||||
|
|
|
@ -9,7 +9,11 @@
|
|||
# If you would like to clear your cache, go ahead and do a
|
||||
# "zsh-pip-clear-cache".
|
||||
|
||||
ZSH_PIP_CACHE_FILE=~/.pip/zsh-cache
|
||||
if [[ -d "${XDG_CACHE_HOME:-$HOME/.cache}/pip" ]]; then
|
||||
ZSH_PIP_CACHE_FILE="${XDG_CACHE_HOME:-$HOME/.cache}/pip/zsh-cache"
|
||||
else
|
||||
ZSH_PIP_CACHE_FILE=~/.pip/zsh-cache
|
||||
fi
|
||||
ZSH_PIP_INDEXES=(https://pypi.org/simple/)
|
||||
|
||||
zsh-pip-clear-cache() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Pipenv completion
|
||||
_pipenv() {
|
||||
eval $(env COMMANDLINE="${words[1,$CURRENT]}" _PIPENV_COMPLETE=complete-zsh pipenv)
|
||||
eval $(env COMMANDLINE="${words[1,$CURRENT]}" _PIPENV_COMPLETE=complete-zsh pipenv)
|
||||
}
|
||||
compdef _pipenv pipenv
|
||||
|
||||
|
@ -25,6 +25,7 @@ _togglePipenvShell() {
|
|||
}
|
||||
autoload -U add-zsh-hook
|
||||
add-zsh-hook chpwd _togglePipenvShell
|
||||
_togglePipenvShell
|
||||
|
||||
# Aliases
|
||||
alias pch="pipenv check"
|
||||
|
|
|
@ -2,7 +2,11 @@
|
|||
# the 'pyenv_prompt_info' function. Also loads pyenv-virtualenv if available.
|
||||
|
||||
# Load pyenv only if command not already available
|
||||
command -v pyenv &> /dev/null && FOUND_PYENV=1 || FOUND_PYENV=0
|
||||
if command -v pyenv &> /dev/null && [[ "$(uname -r)" != *icrosoft* ]]; then
|
||||
FOUND_PYENV=1
|
||||
else
|
||||
FOUND_PYENV=0
|
||||
fi
|
||||
|
||||
if [[ $FOUND_PYENV -ne 1 ]]; then
|
||||
pyenvdirs=("$HOME/.pyenv" "/usr/local/pyenv" "/opt/pyenv" "/usr/local/opt/pyenv")
|
||||
|
@ -25,7 +29,7 @@ if [[ $FOUND_PYENV -ne 1 ]]; then
|
|||
fi
|
||||
|
||||
if [[ $FOUND_PYENV -eq 1 ]]; then
|
||||
eval "$(pyenv init - zsh)"
|
||||
eval "$(pyenv init - --no-rehash zsh)"
|
||||
if (( $+commands[pyenv-virtualenv-init] )); then
|
||||
eval "$(pyenv virtualenv-init - zsh)"
|
||||
fi
|
||||
|
|
|
@ -34,7 +34,7 @@ if [[ $FOUND_RBENV -eq 1 ]]; then
|
|||
}
|
||||
|
||||
function current_gemset() {
|
||||
echo "$(rbenv gemset active 2>/dev/null | sed -e ":a" -e '$ s/\n/+/gp;N;b a' | head -n1)"
|
||||
echo "$(rbenv gemset active 2>/dev/null)" | tr ' ' '+'
|
||||
}
|
||||
|
||||
function gems() {
|
||||
|
|
|
@ -1,54 +1,100 @@
|
|||
# A good summary of the zsh 5.1 Bracketed Paste Mode changes is at:
|
||||
# https://archive.zhimingwang.org/blog/2015-09-21-zsh-51-and-bracketed-paste.html
|
||||
|
||||
# zsh 5.1 (September 2015) introduced built-in support for Bracketed Paste Mode
|
||||
# https://github.com/zsh-users/zsh/blob/68405f31a043bdd5bf338eb06688ed3e1f740937/README#L38-L45
|
||||
#
|
||||
# zsh 5.1 breaks url-quote-magic and other widgets replacing self-insert
|
||||
# zsh-users' bracketed-paste-magic resolves these issues:
|
||||
# https://github.com/zsh-users/zsh/blob/f702e17b14d75aa21bff014168fa9048124db286/Functions/Zle/bracketed-paste-magic#L9-L12
|
||||
|
||||
# Load bracketed-paste-magic if zsh version is >= 5.1
|
||||
if [[ ${ZSH_VERSION:0:3} -ge 5.1 ]]; then
|
||||
set zle_bracketed_paste # Explicitly restore this zsh default
|
||||
autoload -Uz bracketed-paste-magic
|
||||
zle -N bracketed-paste bracketed-paste-magic
|
||||
return ### The rest of this file is NOT executed on zsh version >= 5.1 ###
|
||||
fi
|
||||
|
||||
######################################################################
|
||||
# The rest of this file is ONLY executed if zsh version < 5.1
|
||||
######################################################################
|
||||
|
||||
# Code from Mikael Magnusson: https://www.zsh.org/mla/users/2011/msg00367.html
|
||||
#
|
||||
# Requires xterm, urxvt, iTerm2 or any other terminal that supports bracketed
|
||||
# paste mode as documented: https://www.xfree86.org/current/ctlseqs.html
|
||||
# Requires xterm, urxvt, iTerm2 or any other terminal that supports
|
||||
# Bracketed Paste Mode as documented:
|
||||
# https://www.xfree86.org/current/ctlseqs.html#Bracketed%20Paste%20Mode
|
||||
#
|
||||
# For tmux, use: bind ] paste-buffer -p
|
||||
#
|
||||
# Additional technical details: https://cirw.in/blog/bracketed-paste
|
||||
|
||||
# create a new keymap to use while pasting
|
||||
bindkey -N paste
|
||||
# make everything in this keymap call our custom widget
|
||||
bindkey -R -M paste "^@"-"\M-^?" paste-insert
|
||||
# these are the codes sent around the pasted text in bracketed
|
||||
# paste mode.
|
||||
# do the first one with both -M viins and -M vicmd in vi mode
|
||||
bindkey '^[[200~' _start_paste
|
||||
bindkey -M paste '^[[201~' _end_paste
|
||||
# insert newlines rather than carriage returns when pasting newlines
|
||||
bindkey -M paste -s '^M' '^J'
|
||||
# Create a new keymap to use while pasting
|
||||
bindkey -N bracketed-paste
|
||||
# Make everything in this new keymap enqueue characters for pasting
|
||||
bindkey -RM bracketed-paste '\x00-\xFF' bracketed-paste-enqueue
|
||||
# These are the codes sent around the pasted text in bracketed paste mode
|
||||
bindkey -M main '^[[200~' _bracketed_paste_begin
|
||||
bindkey -M bracketed-paste '^[[201~' _bracketed_paste_end
|
||||
# Insert newlines rather than carriage returns when pasting newlines
|
||||
bindkey -M bracketed-paste -s '^M' '^J'
|
||||
|
||||
zle -N _start_paste
|
||||
zle -N _end_paste
|
||||
zle -N zle-line-init _zle_line_init
|
||||
zle -N zle-line-finish _zle_line_finish
|
||||
zle -N paste-insert _paste_insert
|
||||
zle -N _bracketed_paste_begin
|
||||
zle -N _bracketed_paste_end
|
||||
zle -N bracketed-paste-enqueue _bracketed_paste_enqueue
|
||||
|
||||
# switch the active keymap to paste mode
|
||||
function _start_paste() {
|
||||
bindkey -A paste main
|
||||
# Attempt to not clobber zle_line_{init,finish}
|
||||
# Use https://github.com/willghatch/zsh-hooks if available
|
||||
if typeset -f hooks-add-hook > /dev/null; then
|
||||
hooks-add-hook zle_line_init_hook _bracketed_paste_zle_init
|
||||
hooks-add-hook zle_line_finish_hook _bracketed_paste_zle_finish
|
||||
else
|
||||
zle -N zle-line-init _bracketed_paste_zle_init
|
||||
zle -N zle-line-finish _bracketed_paste_zle_finish
|
||||
fi
|
||||
|
||||
# Switch the active keymap to paste mode
|
||||
_bracketed_paste_begin() {
|
||||
# Save the bindkey command to restore the active ("main") keymap
|
||||
# Tokenise the restorative bindkey command into an array
|
||||
_bracketed_paste_restore_keymap=( ${(z)"$(bindkey -lL main)"} )
|
||||
bindkey -A bracketed-paste main
|
||||
}
|
||||
|
||||
# go back to our normal keymap, and insert all the pasted text in the
|
||||
# command line. this has the nice effect of making the whole paste be
|
||||
# Go back to our normal keymap, and insert all the pasted text in the
|
||||
# command line. This has the nice effect of making the whole paste be
|
||||
# a single undo/redo event.
|
||||
function _end_paste() {
|
||||
#use bindkey -v here with vi mode probably. maybe you want to track
|
||||
#if you were in ins or cmd mode and restore the right one.
|
||||
bindkey -e
|
||||
LBUFFER+=$_paste_content
|
||||
unset _paste_content
|
||||
_bracketed_paste_end() {
|
||||
# Only execute the restore command if it starts with 'bindkey'
|
||||
# Allow for option KSH_ARRAYS being set (indexing starts at 0)
|
||||
if [ ${_bracketed_paste_restore_keymap[@]:0:1} = 'bindkey' ]; then
|
||||
$_bracketed_paste_restore_keymap
|
||||
fi
|
||||
LBUFFER+=$_bracketed_paste_content
|
||||
unset _bracketed_paste_content _bracketed_paste_restore_keymap
|
||||
}
|
||||
|
||||
function _paste_insert() {
|
||||
_paste_content+=$KEYS
|
||||
# Append a pasted character to the content which is later inserted as a whole
|
||||
_bracketed_paste_enqueue() {
|
||||
_bracketed_paste_content+=$KEYS
|
||||
}
|
||||
|
||||
function _zle_line_init() {
|
||||
# Tell terminal to send escape codes around pastes.
|
||||
[[ $TERM == rxvt-unicode || $TERM == xterm || $TERM = xterm-256color || $TERM = screen || $TERM = screen-256color ]] && printf '\e[?2004h'
|
||||
# Run at zle-line-init
|
||||
_bracketed_paste_zle_init() {
|
||||
_bracketed_paste_content=''
|
||||
# Tell terminal to send escape codes around pastes
|
||||
if [[ $TERM =~ '^(rxvt-unicode|xterm(-256color)?|screen(-256color)?)$' ]]; then
|
||||
printf '\e[?2004h'
|
||||
fi
|
||||
}
|
||||
|
||||
function _zle_line_finish() {
|
||||
# Tell it to stop when we leave zle, so pasting in other programs
|
||||
# doesn't get the ^[[200~ codes around the pasted text.
|
||||
[[ $TERM == rxvt-unicode || $TERM == xterm || $TERM = xterm-256color || $TERM = screen || $TERM = screen-256color ]] && printf '\e[?2004l'
|
||||
# Run at zle-line-finish
|
||||
_bracketed_paste_zle_finish() {
|
||||
# Turn off bracketed paste when we leave ZLE, so pasting in other programs
|
||||
# doesn't get the ^[[200~ codes around the pasted text
|
||||
if [[ $TERM =~ '^(rxvt-unicode|xterm(-256color)?|screen(-256color)?)$' ]]; then
|
||||
printf '\e[?2004l'
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,9 @@ directory aliases, which appear as named directories in zsh session.
|
|||
## INSTALLATION NOTES
|
||||
|
||||
Besides oh-my-zsh, `scd` can be used with *bash*, *dash* or *tcsh*
|
||||
shells and is also available as [Vim](https://www.vim.org/) plugin and
|
||||
[IPython](https://ipython.org/) extension. For installation details, see
|
||||
shells and is also available as Vim plugin
|
||||
[scd.vim](https://github.com/pavoljuhas/scd.vim) and
|
||||
[IPython](https://ipython.org) extension. For installation details, see
|
||||
https://github.com/pavoljuhas/smart-change-directory.
|
||||
|
||||
## SYNOPSIS
|
||||
|
@ -24,11 +25,31 @@ https://github.com/pavoljuhas/smart-change-directory.
|
|||
scd [options] [pattern1 pattern2 ...]
|
||||
```
|
||||
|
||||
## PATTERNS
|
||||
|
||||
Patterns may use all zsh [glob operators](
|
||||
http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Operators)
|
||||
available with *extendedglob* option. Specified patterns must match
|
||||
the absolute path and at least one of them must match in the tail.
|
||||
Several special patterns are also recognized as follows:
|
||||
|
||||
<dl><dt>
|
||||
^PAT</dt><dd>
|
||||
PAT must match at the beginning of the path, for example, "^/home"</dd><dt>
|
||||
PAT$</dt><dd>
|
||||
require PAT to match the end of the path, "man$"</dd><dt>
|
||||
./</dt><dd>
|
||||
match only subdirectories of the current directory</dd><dt>
|
||||
:PAT</dt><dd>
|
||||
require PAT to match over the tail component, ":doc", ":re/doc"</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
## OPTIONS
|
||||
|
||||
<dl><dt>
|
||||
-a, --add</dt><dd>
|
||||
add specified directories to the directory index.</dd><dt>
|
||||
add current or specified directories to the directory index.</dd><dt>
|
||||
|
||||
--unindex</dt><dd>
|
||||
remove current or specified directories from the index.</dd><dt>
|
||||
|
@ -42,11 +63,16 @@ scd [options] [pattern1 pattern2 ...]
|
|||
|
||||
--unalias</dt><dd>
|
||||
remove ALIAS definition for the current or specified directory from
|
||||
<em>~/.scdalias.zsh</em>.</dd><dt>
|
||||
<em>~/.scdalias.zsh</em>. Use "OLD" to purge aliases to non-existent
|
||||
directories.</dd><dt>
|
||||
|
||||
-A, --all</dt><dd>
|
||||
include all matching directories. Disregard matching by directory
|
||||
alias and filtering of less likely paths.</dd><dt>
|
||||
display all directories even those excluded by patterns in
|
||||
<em>~/.scdignore</em>. Disregard the unique matching for a
|
||||
directory alias and filtering of less likely paths.</dd><dt>
|
||||
|
||||
-p, --push</dt><dd>
|
||||
use "pushd" to change to the target directory.</dd><dt>
|
||||
|
||||
--list</dt><dd>
|
||||
show matching directories and exit.</dd><dt>
|
||||
|
@ -58,6 +84,7 @@ scd [options] [pattern1 pattern2 ...]
|
|||
display this options summary and exit.</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
```sh
|
||||
|
@ -83,17 +110,26 @@ scd --alias=xray
|
|||
scd xray
|
||||
```
|
||||
|
||||
# FILES
|
||||
## FILES
|
||||
|
||||
<dl><dt>
|
||||
~/.scdhistory</dt><dd>
|
||||
time-stamped index of visited directories.</dd><dt>
|
||||
|
||||
~/.scdalias.zsh</dt><dd>
|
||||
scd-generated definitions of directory aliases.</dd>
|
||||
scd-generated definitions of directory aliases.</dd><dt>
|
||||
|
||||
~/.scdignore</dt><dd>
|
||||
<a href="http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Operators">
|
||||
glob patterns</a> for paths to be ignored in the scd search, for example,
|
||||
<code>/mnt/backup/*</code>. The patterns are specified one per line
|
||||
and are matched assuming the <em>extendedglob</em> zsh option. Lines
|
||||
starting with "#" are skipped as comments. The .scdignore patterns
|
||||
are not applied in the <em>--all</em> mode.</dd>
|
||||
</dl>
|
||||
|
||||
# ENVIRONMENT
|
||||
|
||||
## ENVIRONMENT
|
||||
|
||||
<dl><dt>
|
||||
SCD_HISTFILE</dt><dd>
|
||||
|
|
60
dot_oh-my-zsh/plugins/scd/_scd
Normal file
60
dot_oh-my-zsh/plugins/scd/_scd
Normal file
|
@ -0,0 +1,60 @@
|
|||
#compdef scd
|
||||
#description smart change directory
|
||||
|
||||
local curcontext="$curcontext" state line expl ret=1
|
||||
typeset -A opt_args
|
||||
|
||||
local -a indexopts myargs
|
||||
indexopts=( --add -a --unindex )
|
||||
|
||||
myargs=(
|
||||
# common options
|
||||
"(--help -h)"{--help,-h}"[print help and exit]"
|
||||
|
||||
# options for manipulating directory index
|
||||
- index
|
||||
"(--recursive -r)"{--recursive,-r}"[use recursive --add or --unindex]"
|
||||
"($indexopts)"{--add,-a}"[add specified directories to the index]"
|
||||
"($indexopts)--unindex[remove specified directories from the index]"
|
||||
"*:directory:{ (( ${words[(I)-a|--add|--unindex]} )) && _path_files -/ }"
|
||||
|
||||
# define new directory alias
|
||||
- alias
|
||||
"--alias=[create alias for this or given directory]:directory-alias:()"
|
||||
'1:directory:{ (( words[(I)--alias*] )) && _path_files -/ }'
|
||||
|
||||
# remove definition of directory alias
|
||||
- unalias
|
||||
"--unalias[remove definition of directory alias]"
|
||||
"*::directory alias:->scd-alias-target"
|
||||
|
||||
# act on the directory change
|
||||
- scd
|
||||
"(--all -A)"{--all,-A}"[include less likely and ignored paths]"
|
||||
"--list[print matching directories and exit]"
|
||||
"(--verbose -v)"{--verbose,-v}"[show directory ranking and full paths]"
|
||||
"(--push -p)"{--push,-p}"[change directory with 'pushd']"
|
||||
"1::directory alias:->scd-alias-target"
|
||||
"*:patterns:()"
|
||||
)
|
||||
|
||||
_arguments -S -C $myargs && ret=0
|
||||
|
||||
|
||||
if [[ "$state" == scd-alias-target && -s ~/.scdalias.zsh ]]; then
|
||||
local -a scdaliases
|
||||
scdaliases=( )
|
||||
eval "$(setopt extendedglob
|
||||
phome="(#b)(#s)${HOME}(/*)#(#e)"
|
||||
builtin hash -dr
|
||||
source ~/.scdalias.zsh &&
|
||||
for k v in ${(kv)nameddirs}; do
|
||||
scdaliases+=( $k:${v/${~phome}/"~"${match[1]}} )
|
||||
done
|
||||
complete_unalias=${+opt_args[unalias---unalias]}
|
||||
if (( complete_unalias && ! ${+nameddirs[OLD]} )); then
|
||||
scdaliases+=( 'OLD:all aliases to non-existent paths' )
|
||||
fi
|
||||
typeset -p scdaliases )"
|
||||
_describe -t scdaliases scdalias scdaliases
|
||||
fi
|
533
dot_oh-my-zsh/plugins/scd/executable_scd
Normal file
533
dot_oh-my-zsh/plugins/scd/executable_scd
Normal file
|
@ -0,0 +1,533 @@
|
|||
#!/bin/zsh -f
|
||||
|
||||
emulate -L zsh
|
||||
|
||||
local RUNNING_AS_COMMAND=
|
||||
local EXIT=return
|
||||
if [[ $(whence -w $0) == *:' 'command ]]; then
|
||||
RUNNING_AS_COMMAND=1
|
||||
EXIT=exit
|
||||
fi
|
||||
|
||||
local DOC='scd -- smart change to a recently used directory
|
||||
usage: scd [options] [pattern1 pattern2 ...]
|
||||
Go to a directory path that matches all patterns. Prefer recent or
|
||||
frequently visited directories as found in the directory index.
|
||||
Display a selection menu in case of multiple matches.
|
||||
|
||||
Special patterns:
|
||||
^PAT match at the path root, "^/home"
|
||||
PAT$ match paths ending with PAT, "man$"
|
||||
./ match paths under the current directory
|
||||
:PAT require PAT to span the tail, ":doc", ":re/doc"
|
||||
|
||||
Options:
|
||||
-a, --add add current or specified directories to the index.
|
||||
--unindex remove current or specified directories from the index.
|
||||
-r, --recursive apply options --add or --unindex recursively.
|
||||
--alias=ALIAS create alias for the current or specified directory and
|
||||
store it in ~/.scdalias.zsh.
|
||||
--unalias remove ALIAS definition for the current or specified
|
||||
directory from ~/.scdalias.zsh.
|
||||
Use "OLD" to purge aliases to non-existent directories.
|
||||
-A, --all display all directories even those excluded by patterns
|
||||
in ~/.scdignore. Disregard unique match for a directory
|
||||
alias and filtering of less likely paths.
|
||||
-p, --push use "pushd" to change to the target directory.
|
||||
--list show matching directories and exit.
|
||||
-v, --verbose display directory rank in the selection menu.
|
||||
-h, --help display this message and exit.
|
||||
'
|
||||
|
||||
local SCD_HISTFILE=${SCD_HISTFILE:-${HOME}/.scdhistory}
|
||||
local SCD_HISTSIZE=${SCD_HISTSIZE:-5000}
|
||||
local SCD_MENUSIZE=${SCD_MENUSIZE:-20}
|
||||
local SCD_MEANLIFE=${SCD_MEANLIFE:-86400}
|
||||
local SCD_THRESHOLD=${SCD_THRESHOLD:-0.005}
|
||||
local SCD_SCRIPT=${RUNNING_AS_COMMAND:+$SCD_SCRIPT}
|
||||
local SCD_ALIAS=~/.scdalias.zsh
|
||||
local SCD_IGNORE=~/.scdignore
|
||||
|
||||
# Minimum logarithm of probability. Avoids out of range warning in exp().
|
||||
local -r MINLOGPROB=-15
|
||||
|
||||
# When false, use case-insensitive globbing to fix PWD capitalization.
|
||||
local PWDCASECORRECT=true
|
||||
if [[ ${OSTYPE} == darwin* ]]; then
|
||||
PWDCASECORRECT=false
|
||||
fi
|
||||
|
||||
local a d m p i maxrank threshold
|
||||
local opt_help opt_add opt_unindex opt_recursive opt_verbose
|
||||
local opt_alias opt_unalias opt_all opt_push opt_list
|
||||
local -A drank dalias scdignore
|
||||
local dmatching
|
||||
local last_directory
|
||||
|
||||
setopt extendedglob noautonamedirs brace_ccl
|
||||
|
||||
# If SCD_SCRIPT is defined make sure that that file exists and is empty.
|
||||
# This removes any old previous commands from the SCD_SCRIPT file.
|
||||
[[ -n "$SCD_SCRIPT" ]] && [[ -s $SCD_SCRIPT || ! -f $SCD_SCRIPT ]] && (
|
||||
umask 077
|
||||
: >| $SCD_SCRIPT
|
||||
)
|
||||
|
||||
# process command line options
|
||||
zmodload -i zsh/zutil
|
||||
zmodload -i zsh/datetime
|
||||
zmodload -i zsh/parameter
|
||||
zparseopts -D -E -- a=opt_add -add=opt_add -unindex=opt_unindex \
|
||||
r=opt_recursive -recursive=opt_recursive \
|
||||
-alias:=opt_alias -unalias=opt_unalias \
|
||||
A=opt_all -all=opt_all p=opt_push -push=opt_push -list=opt_list \
|
||||
v=opt_verbose -verbose=opt_verbose h=opt_help -help=opt_help \
|
||||
|| $EXIT $?
|
||||
|
||||
# remove the first instance of "--" from positional arguments
|
||||
argv[(i)--]=( )
|
||||
|
||||
if [[ -n $opt_help ]]; then
|
||||
print $DOC
|
||||
$EXIT
|
||||
fi
|
||||
|
||||
# load directory aliases if they exist
|
||||
[[ -r $SCD_ALIAS ]] && source $SCD_ALIAS
|
||||
|
||||
# load scd-ignore patterns if available
|
||||
if [[ -s $SCD_IGNORE ]]; then
|
||||
setopt noglob
|
||||
<$SCD_IGNORE \
|
||||
while read p; do
|
||||
[[ $p != [\#]* ]] || continue
|
||||
[[ -n $p ]] || continue
|
||||
# expand leading tilde if it has valid expansion
|
||||
if [[ $p == [~]* ]] && ( : ${~p} ) 2>/dev/null; then
|
||||
p=${~p}
|
||||
fi
|
||||
scdignore[$p]=1
|
||||
done
|
||||
setopt glob
|
||||
fi
|
||||
|
||||
# Private internal functions are prefixed with _scd_Y19oug_.
|
||||
# Clean them up when the scd function returns.
|
||||
setopt localtraps
|
||||
trap 'unfunction -m "_scd_Y19oug_*"' EXIT
|
||||
|
||||
# works faster than the (:a) modifier and is compatible with zsh 4.2.6
|
||||
_scd_Y19oug_abspath() {
|
||||
set -A $1 ${(ps:\0:)"$(
|
||||
setopt pushdsilent
|
||||
unfunction -m "*"
|
||||
unalias -m "*"
|
||||
unset CDPATH
|
||||
shift
|
||||
for d; do
|
||||
pushd $d || continue
|
||||
$PWDCASECORRECT &&
|
||||
print -Nr -- $PWD ||
|
||||
print -Nr -- (#i)$PWD
|
||||
popd 2>/dev/null
|
||||
done
|
||||
)"}
|
||||
}
|
||||
|
||||
# define directory alias
|
||||
if [[ -n $opt_alias ]]; then
|
||||
if [[ -n $1 && ! -d $1 ]]; then
|
||||
print -u2 "'$1' is not a directory."
|
||||
$EXIT 1
|
||||
fi
|
||||
a=${opt_alias[-1]#=}
|
||||
_scd_Y19oug_abspath d ${1:-$PWD}
|
||||
# alias in the current shell, update alias file if successful
|
||||
hash -d -- $a=$d &&
|
||||
(
|
||||
umask 077
|
||||
hash -dr
|
||||
[[ -r $SCD_ALIAS ]] && source $SCD_ALIAS
|
||||
hash -d -- $a=$d
|
||||
hash -dL >| $SCD_ALIAS
|
||||
)
|
||||
$EXIT $?
|
||||
fi
|
||||
|
||||
# undefine one or more directory aliases
|
||||
if [[ -n $opt_unalias ]]; then
|
||||
local -U uu
|
||||
local ec=0
|
||||
uu=( ${*:-${PWD}} )
|
||||
if (( ${uu[(I)OLD]} && ${+nameddirs[OLD]} == 0 )); then
|
||||
uu=( ${uu:#OLD} ${(ps:\0:)"$(
|
||||
hash -dr
|
||||
if [[ -r $SCD_ALIAS ]]; then
|
||||
source $SCD_ALIAS
|
||||
fi
|
||||
for a d in ${(kv)nameddirs}; do
|
||||
[[ -d $d ]] || print -Nr -- $a
|
||||
done
|
||||
)"}
|
||||
)
|
||||
fi
|
||||
m=( )
|
||||
for p in $uu; do
|
||||
d=$p
|
||||
if [[ ${+nameddirs[$d]} == 0 && -d $d ]]; then
|
||||
_scd_Y19oug_abspath d $d
|
||||
fi
|
||||
a=${(k)nameddirs[$d]:-${(k)nameddirs[(r)$d]}}
|
||||
if [[ -z $a ]]; then
|
||||
ec=1
|
||||
print -u2 "'$p' is neither a directory alias nor an aliased path."
|
||||
continue
|
||||
fi
|
||||
# unalias in the current shell and remember to update the alias file
|
||||
if unhash -d -- $a 2>/dev/null; then
|
||||
m+=( $a )
|
||||
fi
|
||||
done
|
||||
if [[ $#m != 0 && -r $SCD_ALIAS ]]; then
|
||||
(
|
||||
umask 077
|
||||
hash -dr
|
||||
source $SCD_ALIAS
|
||||
for a in $m; do
|
||||
unhash -d -- $a 2>/dev/null
|
||||
done
|
||||
hash -dL >| $SCD_ALIAS
|
||||
) || ec=$?
|
||||
fi
|
||||
$EXIT $ec
|
||||
fi
|
||||
|
||||
# The "compress" function collapses repeated directories into
|
||||
# a single entry with a time-stamp yielding an equivalent probability.
|
||||
_scd_Y19oug_compress() {
|
||||
awk -v epochseconds=$EPOCHSECONDS \
|
||||
-v meanlife=$SCD_MEANLIFE \
|
||||
-v minlogprob=$MINLOGPROB \
|
||||
'
|
||||
BEGIN {
|
||||
FS = "[:;]";
|
||||
pmin = exp(minlogprob);
|
||||
}
|
||||
/^: deleted:0;/ { next; }
|
||||
length($0) < 4096 && $2 > 1000 {
|
||||
df = $0;
|
||||
sub("^[^;]*;", "", df);
|
||||
if (!df) next;
|
||||
tau = 1.0 * ($2 - epochseconds) / meanlife;
|
||||
prob = (tau < minlogprob) ? pmin : exp(tau);
|
||||
dlist[last[df]] = "";
|
||||
dlist[NR] = df;
|
||||
last[df] = NR;
|
||||
ptot[df] += prob;
|
||||
}
|
||||
END {
|
||||
for (i = 1; i <= NR; ++i) {
|
||||
d = dlist[i];
|
||||
if (d) {
|
||||
ts = log(ptot[d]) * meanlife + epochseconds;
|
||||
printf(": %.0f:0;%s\n", ts, d);
|
||||
}
|
||||
}
|
||||
}
|
||||
' $*
|
||||
}
|
||||
|
||||
# Rewrite directory index if it is at least 20% oversized.
|
||||
local curhistsize
|
||||
if [[ -z $opt_unindex && -s $SCD_HISTFILE ]] && \
|
||||
curhistsize=$(wc -l <$SCD_HISTFILE) && \
|
||||
(( $curhistsize > 1.2 * $SCD_HISTSIZE )); then
|
||||
# Compress repeated entries in a background process.
|
||||
(
|
||||
m=( ${(f)"$(_scd_Y19oug_compress $SCD_HISTFILE)"} )
|
||||
# purge non-existent and ignored directories
|
||||
m=( ${(f)"$(
|
||||
for a in $m; do
|
||||
d=${a#*;}
|
||||
[[ -z ${scdignore[(k)$d]} ]] || continue
|
||||
[[ -d $d ]] || continue
|
||||
$PWDCASECORRECT || d=( (#i)${d} )
|
||||
t=${a%%;*}
|
||||
print -r -- "${t};${d}"
|
||||
done
|
||||
)"}
|
||||
)
|
||||
# cut old entries if still oversized
|
||||
if [[ $#m -gt $SCD_HISTSIZE ]]; then
|
||||
m=( ${m[-$SCD_HISTSIZE,-1]} )
|
||||
fi
|
||||
# Checking existence of many directories could have taken a while.
|
||||
# Append any index entries added in meantime.
|
||||
m+=( ${(f)"$(sed "1,${curhistsize}d" $SCD_HISTFILE)"} )
|
||||
print -lr -- $m >| ${SCD_HISTFILE}
|
||||
) &|
|
||||
fi
|
||||
|
||||
# Determine the last recorded directory
|
||||
if [[ -s ${SCD_HISTFILE} ]]; then
|
||||
last_directory=${"$(tail -1 ${SCD_HISTFILE})"#*;}
|
||||
fi
|
||||
|
||||
# The "record" function adds its arguments to the directory index.
|
||||
_scd_Y19oug_record() {
|
||||
while [[ -n $last_directory && $1 == $last_directory ]]; do
|
||||
shift
|
||||
done
|
||||
if [[ $# -gt 0 ]]; then
|
||||
( umask 077
|
||||
p=": ${EPOCHSECONDS}:0;"
|
||||
print -lr -- ${p}${^*} >>| $SCD_HISTFILE )
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ -n $opt_add ]]; then
|
||||
m=( ${^${argv:-$PWD}}(N-/) )
|
||||
_scd_Y19oug_abspath m ${m}
|
||||
_scd_Y19oug_record $m
|
||||
if [[ -n $opt_recursive ]]; then
|
||||
for d in $m; do
|
||||
print -n "scanning ${d} ... "
|
||||
_scd_Y19oug_record ${d}/**/*(-/N)
|
||||
print "[done]"
|
||||
done
|
||||
fi
|
||||
$EXIT
|
||||
fi
|
||||
|
||||
# take care of removing entries from the directory index
|
||||
if [[ -n $opt_unindex ]]; then
|
||||
if [[ ! -s $SCD_HISTFILE ]]; then
|
||||
$EXIT
|
||||
fi
|
||||
argv=( ${argv:-$PWD} )
|
||||
# expand existing directories in the argument list
|
||||
for i in {1..$#}; do
|
||||
if [[ -d ${argv[i]} ]]; then
|
||||
_scd_Y19oug_abspath d ${argv[i]}
|
||||
argv[i]=${d}
|
||||
fi
|
||||
done
|
||||
# strip trailing slashes, but preserve the root path
|
||||
argv=( ${argv/(#m)?\/##(#e)/${MATCH[1]}} )
|
||||
m="$(awk -v recursive=${opt_recursive} '
|
||||
BEGIN {
|
||||
for (i = 2; i < ARGC; ++i) {
|
||||
argset[ARGV[i]] = 1;
|
||||
delete ARGV[i];
|
||||
}
|
||||
unindex_root = ("/" in argset);
|
||||
}
|
||||
1 {
|
||||
d = $0; sub(/^[^;]*;/, "", d);
|
||||
if (d in argset) next;
|
||||
}
|
||||
recursive {
|
||||
if (unindex_root) exit;
|
||||
for (a in argset) {
|
||||
if (substr(d, 1, length(a) + 1) == a"/") next;
|
||||
}
|
||||
}
|
||||
{ print $0 }
|
||||
' $SCD_HISTFILE $* )" || $EXIT $?
|
||||
: >| ${SCD_HISTFILE}
|
||||
[[ ${#m} == 0 ]] || print -r -- $m >> ${SCD_HISTFILE}
|
||||
$EXIT
|
||||
fi
|
||||
|
||||
# The "action" function is called when there is just one target directory.
|
||||
_scd_Y19oug_action() {
|
||||
local cdcmd=cd
|
||||
[[ -z ${opt_push} ]] || cdcmd=pushd
|
||||
builtin $cdcmd $1 || return $?
|
||||
if [[ -z $SCD_SCRIPT && -n $RUNNING_AS_COMMAND ]]; then
|
||||
print -u2 "Warning: running as command with SCD_SCRIPT undefined."
|
||||
fi
|
||||
if [[ -n $SCD_SCRIPT ]]; then
|
||||
local d=$1
|
||||
if [[ $OSTYPE == cygwin && ${(L)SCD_SCRIPT} == *.bat ]]; then
|
||||
d=$(cygpath -aw .)
|
||||
fi
|
||||
print -r "${cdcmd} ${(qqq)d}" >| $SCD_SCRIPT
|
||||
fi
|
||||
}
|
||||
|
||||
# Select and order indexed directories by matching command-line patterns.
|
||||
# Set global arrays dmatching and drank.
|
||||
_scd_Y19oug_match() {
|
||||
## single argument that is an existing directory or directory alias
|
||||
if [[ -z $opt_all && $# == 1 ]] && \
|
||||
[[ -d ${d::=${nameddirs[$1]}} || -d ${d::=$1} ]] && [[ -x $d ]];
|
||||
then
|
||||
_scd_Y19oug_abspath dmatching $d
|
||||
drank[${dmatching[1]}]=1
|
||||
return
|
||||
fi
|
||||
|
||||
# quote brackets when PWD is /Volumes/[C]/
|
||||
local qpwd=${PWD//(#m)[][]/\\${MATCH}}
|
||||
|
||||
# support "./" as an alias for $PWD to match only subdirectories.
|
||||
argv=( ${argv/(#s).\/(#e)/(#s)${qpwd}(|/*)(#e)} )
|
||||
|
||||
# support "./pat" as an alias for $PWD/pat.
|
||||
argv=( ${argv/(#m)(#s).\/?*/(#s)${qpwd}${MATCH#.}} )
|
||||
|
||||
# support "^" as an anchor for the root directory, e.g., "^$HOME".
|
||||
argv=( ${argv/(#m)(#s)\^?*/(#s)${${~MATCH[2,-1]}}} )
|
||||
|
||||
# support "$" as an anchor at the end of directory name.
|
||||
argv=( ${argv/(#m)?[$](#e)/${MATCH[1]}(#e)} )
|
||||
|
||||
# support prefix ":" to match over the tail component.
|
||||
argv=( ${argv/(#m)(#s):?*/${MATCH[2,-1]}[^/]#(#e)} )
|
||||
|
||||
# calculate rank of all directories in SCD_HISTFILE and store it in drank.
|
||||
# include a dummy entry to avoid issues with splitting an empty string.
|
||||
[[ -s $SCD_HISTFILE ]] && drank=( ${(f)"$(
|
||||
print -l /dev/null -10
|
||||
<$SCD_HISTFILE \
|
||||
awk -v epochseconds=$EPOCHSECONDS \
|
||||
-v meanlife=$SCD_MEANLIFE \
|
||||
-v minlogprob=$MINLOGPROB \
|
||||
'
|
||||
BEGIN {
|
||||
FS = "[:;]";
|
||||
pmin = exp(minlogprob);
|
||||
}
|
||||
/^: deleted:0;/ {
|
||||
df = $0;
|
||||
sub("^[^;]*;", "", df);
|
||||
delete ptot[df];
|
||||
next;
|
||||
}
|
||||
length($0) < 4096 && $2 > 0 {
|
||||
df = $0;
|
||||
sub("^[^;]*;", "", df);
|
||||
if (!df) next;
|
||||
dp = df;
|
||||
while (!(dp in ptot)) {
|
||||
ptot[dp] = pmin;
|
||||
sub("//*[^/]*$", "", dp);
|
||||
if (!dp) break;
|
||||
}
|
||||
if ($2 <= 1000) next;
|
||||
tau = 1.0 * ($2 - epochseconds) / meanlife;
|
||||
prob = (tau < minlogprob) ? pmin : exp(tau);
|
||||
ptot[df] += prob;
|
||||
}
|
||||
END { for (di in ptot) { print di; print ptot[di]; } }
|
||||
'
|
||||
)"}
|
||||
)
|
||||
unset "drank[/dev/null]"
|
||||
|
||||
# filter drank to the entries that match all arguments
|
||||
for a; do
|
||||
p="(#l)*(${a})*"
|
||||
drank=( ${(kv)drank[(I)${~p}]} )
|
||||
done
|
||||
# require that at least one argument matches in directory tail name.
|
||||
p="(#l)*(${(j:|:)argv})[^/]#"
|
||||
drank=( ${(kv)drank[(I)${~p}]} )
|
||||
|
||||
# discard ignored directories
|
||||
if [[ -z ${opt_all} ]]; then
|
||||
for d in ${(k)drank}; do
|
||||
[[ -z ${scdignore[(k)$d]} ]] || unset "drank[$d]"
|
||||
done
|
||||
fi
|
||||
|
||||
# build a list of matching directories reverse-sorted by their probabilities
|
||||
dmatching=( ${(f)"$(
|
||||
builtin printf "%s %s\n" ${(Oakv)drank} |
|
||||
/usr/bin/sort -grk1 )"}
|
||||
)
|
||||
dmatching=( ${dmatching#*[[:blank:]]} )
|
||||
|
||||
# do not match $HOME or $PWD when run without arguments
|
||||
if [[ $# == 0 ]]; then
|
||||
dmatching=( ${dmatching:#(${HOME}|${PWD})} )
|
||||
fi
|
||||
|
||||
# keep at most SCD_MENUSIZE of matching and valid directories
|
||||
# mark up any deleted entries in the index
|
||||
local -A isdeleted
|
||||
m=( )
|
||||
isdeleted=( )
|
||||
for d in $dmatching; do
|
||||
[[ ${#m} == $SCD_MENUSIZE ]] && break
|
||||
(( ${+isdeleted[$d]} == 0 )) || continue
|
||||
[[ -d $d ]] || { isdeleted[$d]=1; continue }
|
||||
[[ -x $d ]] && m+=$d
|
||||
done
|
||||
dmatching=( $m )
|
||||
if [[ -n ${isdeleted} ]]; then
|
||||
print -lr -- ": deleted:0;"${^${(k)isdeleted}} >> $SCD_HISTFILE
|
||||
fi
|
||||
|
||||
# find the maximum rank
|
||||
maxrank=0.0
|
||||
for d in $dmatching; do
|
||||
[[ ${drank[$d]} -lt maxrank ]] || maxrank=${drank[$d]}
|
||||
done
|
||||
|
||||
# discard all directories below the rank threshold
|
||||
threshold=$(( maxrank * SCD_THRESHOLD ))
|
||||
if [[ -n ${opt_all} ]]; then
|
||||
threshold=0
|
||||
fi
|
||||
dmatching=( ${^dmatching}(Ne:'(( ${drank[$REPLY]} >= threshold ))':) )
|
||||
}
|
||||
|
||||
_scd_Y19oug_match $*
|
||||
|
||||
## process matching directories.
|
||||
if [[ ${#dmatching} == 0 ]]; then
|
||||
print -u2 "No matching directory."
|
||||
$EXIT 1
|
||||
fi
|
||||
|
||||
## build formatted directory aliases for selection menu or list display
|
||||
for d in $dmatching; do
|
||||
if [[ -n ${opt_verbose} ]]; then
|
||||
dalias[$d]=$(printf "%.3g %s" ${drank[$d]} $d)
|
||||
else
|
||||
dalias[$d]=$(print -Dr -- $d)
|
||||
fi
|
||||
done
|
||||
|
||||
## process the --list option
|
||||
if [[ -n $opt_list ]]; then
|
||||
for d in $dmatching; do
|
||||
print -r -- "# ${dalias[$d]}"
|
||||
print -r -- $d
|
||||
done
|
||||
$EXIT
|
||||
fi
|
||||
|
||||
## handle a single matching directory here.
|
||||
if [[ ${#dmatching} == 1 ]]; then
|
||||
_scd_Y19oug_action $dmatching
|
||||
$EXIT $?
|
||||
fi
|
||||
|
||||
## Here we have multiple matches. Let's use the selection menu.
|
||||
a=( {a-z} {A-Z} )
|
||||
a=( ${a[1,${#dmatching}]} )
|
||||
p=( )
|
||||
for i in {1..${#dmatching}}; do
|
||||
[[ -n ${a[i]} ]] || break
|
||||
p+="${a[i]}) ${dalias[${dmatching[i]}]}"
|
||||
done
|
||||
|
||||
print -c -r -- $p
|
||||
|
||||
if read -s -k 1 d && [[ ${i::=${a[(I)$d]}} -gt 0 ]]; then
|
||||
_scd_Y19oug_action ${dmatching[i]}
|
||||
$EXIT $?
|
||||
fi
|
|
@ -1,390 +0,0 @@
|
|||
#!/bin/zsh -f
|
||||
|
||||
emulate -L zsh
|
||||
local EXIT=return
|
||||
if [[ $(whence -w $0) == *:' 'command ]]; then
|
||||
emulate -R zsh
|
||||
local RUNNING_AS_COMMAND=1
|
||||
EXIT=exit
|
||||
fi
|
||||
|
||||
local DOC='scd -- smart change to a recently used directory
|
||||
usage: scd [options] [pattern1 pattern2 ...]
|
||||
Go to a directory path that contains all fixed string patterns. Prefer
|
||||
recent or frequently visited directories as found in the directory index.
|
||||
Display a selection menu in case of multiple matches.
|
||||
|
||||
Options:
|
||||
-a, --add add specified directories to the directory index.
|
||||
--unindex remove current or specified directories from the index.
|
||||
-r, --recursive apply options --add or --unindex recursively.
|
||||
--alias=ALIAS create alias for the current or specified directory and
|
||||
store it in ~/.scdalias.zsh.
|
||||
--unalias remove ALIAS definition for the current or specified
|
||||
directory from ~/.scdalias.zsh.
|
||||
-A, --all include all matching directories. Disregard matching by
|
||||
directory alias and filtering of less likely paths.
|
||||
--list show matching directories and exit.
|
||||
-v, --verbose display directory rank in the selection menu.
|
||||
-h, --help display this message and exit.
|
||||
'
|
||||
|
||||
local SCD_HISTFILE=${SCD_HISTFILE:-${HOME}/.scdhistory}
|
||||
local SCD_HISTSIZE=${SCD_HISTSIZE:-5000}
|
||||
local SCD_MENUSIZE=${SCD_MENUSIZE:-20}
|
||||
local SCD_MEANLIFE=${SCD_MEANLIFE:-86400}
|
||||
local SCD_THRESHOLD=${SCD_THRESHOLD:-0.005}
|
||||
local SCD_SCRIPT=${RUNNING_AS_COMMAND:+$SCD_SCRIPT}
|
||||
local SCD_ALIAS=~/.scdalias.zsh
|
||||
|
||||
local ICASE a d m p i maxrank threshold
|
||||
local opt_help opt_add opt_unindex opt_recursive opt_verbose
|
||||
local opt_alias opt_unalias opt_all opt_list
|
||||
local -A drank dalias
|
||||
local dmatching
|
||||
local last_directory
|
||||
|
||||
setopt extendedhistory extendedglob noautonamedirs brace_ccl
|
||||
|
||||
# If SCD_SCRIPT is defined make sure the file exists and is empty.
|
||||
# This removes any previous old commands.
|
||||
[[ -n "$SCD_SCRIPT" ]] && [[ -s $SCD_SCRIPT || ! -f $SCD_SCRIPT ]] && (
|
||||
umask 077
|
||||
: >| $SCD_SCRIPT
|
||||
)
|
||||
|
||||
# process command line options
|
||||
zmodload -i zsh/zutil
|
||||
zmodload -i zsh/datetime
|
||||
zparseopts -D -- a=opt_add -add=opt_add -unindex=opt_unindex \
|
||||
r=opt_recursive -recursive=opt_recursive \
|
||||
-alias:=opt_alias -unalias=opt_unalias \
|
||||
A=opt_all -all=opt_all -list=opt_list \
|
||||
v=opt_verbose -verbose=opt_verbose h=opt_help -help=opt_help \
|
||||
|| $EXIT $?
|
||||
|
||||
if [[ -n $opt_help ]]; then
|
||||
print $DOC
|
||||
$EXIT
|
||||
fi
|
||||
|
||||
# load directory aliases if they exist
|
||||
[[ -r $SCD_ALIAS ]] && source $SCD_ALIAS
|
||||
|
||||
# Private internal functions are prefixed with _scd_Y19oug_.
|
||||
# Clean them up when the scd function returns.
|
||||
setopt localtraps
|
||||
trap 'unfunction -m "_scd_Y19oug_*"' EXIT
|
||||
|
||||
# works faster than the (:a) modifier and is compatible with zsh 4.2.6
|
||||
_scd_Y19oug_abspath() {
|
||||
set -A $1 ${(ps:\0:)"$(
|
||||
unfunction -m "*"; shift
|
||||
for d; do
|
||||
cd $d && print -Nr -- $PWD && cd $OLDPWD
|
||||
done
|
||||
)"}
|
||||
}
|
||||
|
||||
# define directory alias
|
||||
if [[ -n $opt_alias ]]; then
|
||||
if [[ -n $1 && ! -d $1 ]]; then
|
||||
print -u2 "'$1' is not a directory."
|
||||
$EXIT 1
|
||||
fi
|
||||
a=${opt_alias[-1]#=}
|
||||
_scd_Y19oug_abspath d ${1:-$PWD}
|
||||
# alias in the current shell, update alias file if successful
|
||||
hash -d -- $a=$d &&
|
||||
(
|
||||
umask 077
|
||||
hash -dr
|
||||
[[ -r $SCD_ALIAS ]] && source $SCD_ALIAS
|
||||
hash -d -- $a=$d
|
||||
hash -dL >| $SCD_ALIAS
|
||||
)
|
||||
$EXIT $?
|
||||
fi
|
||||
|
||||
# undefine directory alias
|
||||
if [[ -n $opt_unalias ]]; then
|
||||
if [[ -n $1 && ! -d $1 ]]; then
|
||||
print -u2 "'$1' is not a directory."
|
||||
$EXIT 1
|
||||
fi
|
||||
_scd_Y19oug_abspath a ${1:-$PWD}
|
||||
a=$(print -rD ${a})
|
||||
if [[ $a != [~][^/]## ]]; then
|
||||
$EXIT
|
||||
fi
|
||||
a=${a#[~]}
|
||||
# unalias in the current shell, update alias file if successful
|
||||
if unhash -d -- $a 2>/dev/null && [[ -r $SCD_ALIAS ]]; then
|
||||
(
|
||||
umask 077
|
||||
hash -dr
|
||||
source $SCD_ALIAS
|
||||
unhash -d -- $a 2>/dev/null &&
|
||||
hash -dL >| $SCD_ALIAS
|
||||
)
|
||||
fi
|
||||
$EXIT $?
|
||||
fi
|
||||
|
||||
# The "compress" function collapses repeated directories to
|
||||
# one entry with a time stamp that gives equivalent-probability.
|
||||
_scd_Y19oug_compress() {
|
||||
awk -v epochseconds=$EPOCHSECONDS -v meanlife=$SCD_MEANLIFE '
|
||||
BEGIN { FS = "[:;]"; }
|
||||
length($0) < 4096 && $2 > 0 {
|
||||
tau = 1.0 * ($2 - epochseconds) / meanlife;
|
||||
if (tau < -6.9078) tau = -6.9078;
|
||||
prob = exp(tau);
|
||||
sub(/^[^;]*;/, "");
|
||||
if (NF) {
|
||||
dlist[last[$0]] = "";
|
||||
dlist[NR] = $0;
|
||||
last[$0] = NR;
|
||||
ptot[$0] += prob;
|
||||
}
|
||||
}
|
||||
END {
|
||||
for (i = 1; i <= NR; ++i) {
|
||||
d = dlist[i];
|
||||
if (d) {
|
||||
ts = log(ptot[d]) * meanlife + epochseconds;
|
||||
printf(": %.0f:0;%s\n", ts, d);
|
||||
}
|
||||
}
|
||||
}
|
||||
' $*
|
||||
}
|
||||
|
||||
# Rewrite directory index if it is at least 20% oversized
|
||||
if [[ -s $SCD_HISTFILE ]] && \
|
||||
(( $(wc -l <$SCD_HISTFILE) > 1.2 * $SCD_HISTSIZE )); then
|
||||
# compress repeated entries
|
||||
m=( ${(f)"$(_scd_Y19oug_compress $SCD_HISTFILE)"} )
|
||||
# purge non-existent directories
|
||||
m=( ${(f)"$(
|
||||
for a in $m; do
|
||||
if [[ -d ${a#*;} ]]; then print -r -- $a; fi
|
||||
done
|
||||
)"}
|
||||
)
|
||||
# cut old entries if still oversized
|
||||
if [[ $#m -gt $SCD_HISTSIZE ]]; then
|
||||
m=( ${m[-$SCD_HISTSIZE,-1]} )
|
||||
fi
|
||||
print -lr -- $m >| ${SCD_HISTFILE}
|
||||
fi
|
||||
|
||||
# Determine the last recorded directory
|
||||
if [[ -s ${SCD_HISTFILE} ]]; then
|
||||
last_directory=${"$(tail -1 ${SCD_HISTFILE})"#*;}
|
||||
fi
|
||||
|
||||
# The "record" function adds its arguments to the directory index.
|
||||
_scd_Y19oug_record() {
|
||||
while [[ -n $last_directory && $1 == $last_directory ]]; do
|
||||
shift
|
||||
done
|
||||
if [[ $# -gt 0 ]]; then
|
||||
( umask 077
|
||||
p=": ${EPOCHSECONDS}:0;"
|
||||
print -lr -- ${p}${^*} >>| $SCD_HISTFILE )
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ -n $opt_add ]]; then
|
||||
for d; do
|
||||
if [[ ! -d $d ]]; then
|
||||
print -u2 "Directory '$d' does not exist."
|
||||
$EXIT 2
|
||||
fi
|
||||
done
|
||||
_scd_Y19oug_abspath m ${*:-$PWD}
|
||||
_scd_Y19oug_record $m
|
||||
if [[ -n $opt_recursive ]]; then
|
||||
for d in $m; do
|
||||
print -n "scanning ${d} ... "
|
||||
_scd_Y19oug_record ${d}/**/*(-/N)
|
||||
print "[done]"
|
||||
done
|
||||
fi
|
||||
$EXIT
|
||||
fi
|
||||
|
||||
# take care of removing entries from the directory index
|
||||
if [[ -n $opt_unindex ]]; then
|
||||
if [[ ! -s $SCD_HISTFILE ]]; then
|
||||
$EXIT
|
||||
fi
|
||||
# expand existing directories in the argument list
|
||||
for i in {1..$#}; do
|
||||
if [[ -d ${argv[i]} ]]; then
|
||||
_scd_Y19oug_abspath d ${argv[i]}
|
||||
argv[i]=${d}
|
||||
fi
|
||||
done
|
||||
m="$(awk -v recursive=${opt_recursive} '
|
||||
BEGIN {
|
||||
for (i = 2; i < ARGC; ++i) {
|
||||
argset[ARGV[i]] = 1;
|
||||
delete ARGV[i];
|
||||
}
|
||||
}
|
||||
1 {
|
||||
d = $0; sub(/^[^;]*;/, "", d);
|
||||
if (d in argset) next;
|
||||
}
|
||||
recursive {
|
||||
for (a in argset) {
|
||||
if (substr(d, 1, length(a) + 1) == a"/") next;
|
||||
}
|
||||
}
|
||||
{ print $0 }
|
||||
' $SCD_HISTFILE ${*:-$PWD} )" || $EXIT $?
|
||||
: >| ${SCD_HISTFILE}
|
||||
[[ ${#m} == 0 ]] || print -r -- $m >> ${SCD_HISTFILE}
|
||||
$EXIT
|
||||
fi
|
||||
|
||||
# The "action" function is called when there is just one target directory.
|
||||
_scd_Y19oug_action() {
|
||||
cd $1 || return $?
|
||||
if [[ -z $SCD_SCRIPT && -n $RUNNING_AS_COMMAND ]]; then
|
||||
print -u2 "Warning: running as command with SCD_SCRIPT undefined."
|
||||
fi
|
||||
if [[ -n $SCD_SCRIPT ]]; then
|
||||
print -r "cd ${(q)1}" >| $SCD_SCRIPT
|
||||
fi
|
||||
}
|
||||
|
||||
# Match and rank patterns to the index file
|
||||
# set global arrays dmatching and drank
|
||||
_scd_Y19oug_match() {
|
||||
## single argument that is an existing directory or directory alias
|
||||
if [[ -z $opt_all && $# == 1 ]] && \
|
||||
[[ -d ${d::=$1} || -d ${d::=${nameddirs[$1]}} ]] && [[ -x $d ]];
|
||||
then
|
||||
_scd_Y19oug_abspath dmatching $d
|
||||
drank[${dmatching[1]}]=1
|
||||
return
|
||||
fi
|
||||
|
||||
# ignore case unless there is an argument with an uppercase letter
|
||||
[[ "$*" == *[[:upper:]]* ]] || ICASE='(#i)'
|
||||
# support "$" as an anchor for the directory name ending
|
||||
argv=( ${argv/(#m)?[$](#e)/${MATCH[1]}(#e)} )
|
||||
|
||||
# calculate rank of all directories in the SCD_HISTFILE and keep it as drank
|
||||
# include a dummy entry for splitting of an empty string is buggy
|
||||
[[ -s $SCD_HISTFILE ]] && drank=( ${(f)"$(
|
||||
print -l /dev/null -10
|
||||
<$SCD_HISTFILE \
|
||||
awk -v epochseconds=$EPOCHSECONDS -v meanlife=$SCD_MEANLIFE '
|
||||
BEGIN { FS = "[:;]"; }
|
||||
length($0) < 4096 && $2 > 0 {
|
||||
tau = 1.0 * ($2 - epochseconds) / meanlife;
|
||||
if (tau < -6.9078) tau = -6.9078;
|
||||
prob = exp(tau);
|
||||
sub(/^[^;]*;/, "");
|
||||
if (NF) ptot[$0] += prob;
|
||||
}
|
||||
END { for (di in ptot) { print di; print ptot[di]; } }'
|
||||
)"}
|
||||
)
|
||||
unset "drank[/dev/null]"
|
||||
|
||||
# filter drank to the entries that match all arguments
|
||||
for a; do
|
||||
p=${ICASE}"*(${a})*"
|
||||
drank=( ${(kv)drank[(I)${~p}]} )
|
||||
done
|
||||
# require at least one argument matches the directory name
|
||||
p=${ICASE}"*(${(j:|:)argv})[^/]#"
|
||||
drank=( ${(kv)drank[(I)${~p}]} )
|
||||
|
||||
# build a list of matching directories reverse-sorted by their probabilities
|
||||
dmatching=( ${(f)"$(
|
||||
for d p in ${(kv)drank}; do
|
||||
print -r -- "$p $d";
|
||||
done | sort -grk1 | cut -d ' ' -f 2-
|
||||
)"}
|
||||
)
|
||||
|
||||
# do not match $HOME or $PWD when run without arguments
|
||||
if [[ $# == 0 ]]; then
|
||||
dmatching=( ${dmatching:#(${HOME}|${PWD})} )
|
||||
fi
|
||||
|
||||
# keep at most SCD_MENUSIZE of matching and valid directories
|
||||
m=( )
|
||||
for d in $dmatching; do
|
||||
[[ ${#m} == $SCD_MENUSIZE ]] && break
|
||||
[[ -d $d && -x $d ]] && m+=$d
|
||||
done
|
||||
dmatching=( $m )
|
||||
|
||||
# find the maximum rank
|
||||
maxrank=0.0
|
||||
for d in $dmatching; do
|
||||
[[ ${drank[$d]} -lt maxrank ]] || maxrank=${drank[$d]}
|
||||
done
|
||||
|
||||
# discard all directories below the rank threshold
|
||||
threshold=$(( maxrank * SCD_THRESHOLD ))
|
||||
if [[ -n ${opt_all} ]]; then
|
||||
threshold=0
|
||||
fi
|
||||
dmatching=( ${^dmatching}(Ne:'(( ${drank[$REPLY]} >= threshold ))':) )
|
||||
}
|
||||
|
||||
_scd_Y19oug_match $*
|
||||
|
||||
## process whatever directories that remained
|
||||
if [[ ${#dmatching} == 0 ]]; then
|
||||
print -u2 "No matching directory."
|
||||
$EXIT 1
|
||||
fi
|
||||
|
||||
## build formatted directory aliases for selection menu or list display
|
||||
for d in $dmatching; do
|
||||
if [[ -n ${opt_verbose} ]]; then
|
||||
dalias[$d]=$(printf "%.3g %s" ${drank[$d]} $d)
|
||||
else
|
||||
dalias[$d]=$(print -Dr -- $d)
|
||||
fi
|
||||
done
|
||||
|
||||
## process the --list option
|
||||
if [[ -n $opt_list ]]; then
|
||||
for d in $dmatching; do
|
||||
print -r -- "# ${dalias[$d]}"
|
||||
print -r -- $d
|
||||
done
|
||||
$EXIT
|
||||
fi
|
||||
|
||||
## process single directory match
|
||||
if [[ ${#dmatching} == 1 ]]; then
|
||||
_scd_Y19oug_action $dmatching
|
||||
$EXIT $?
|
||||
fi
|
||||
|
||||
## here we have multiple matches - display selection menu
|
||||
a=( {a-z} {A-Z} )
|
||||
a=( ${a[1,${#dmatching}]} )
|
||||
p=( )
|
||||
for i in {1..${#dmatching}}; do
|
||||
[[ -n ${a[i]} ]] || break
|
||||
p+="${a[i]}) ${dalias[${dmatching[i]}]}"
|
||||
done
|
||||
|
||||
print -c -r -- $p
|
||||
|
||||
if read -s -k 1 d && [[ ${i::=${a[(I)$d]}} -gt 0 ]]; then
|
||||
_scd_Y19oug_action ${dmatching[i]}
|
||||
$EXIT $?
|
||||
fi
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue