mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-26 21:51:05 +01:00
Merge branch 'ohmyzsh:master' into master
This commit is contained in:
commit
1d11c6eef6
78 changed files with 1459 additions and 876 deletions
|
@ -202,7 +202,7 @@ type(scope)!: subject
|
||||||
feat(archlinux): add support for aura AUR helper (#9467)
|
feat(archlinux): add support for aura AUR helper (#9467)
|
||||||
```
|
```
|
||||||
|
|
||||||
- Formatted inline code by using backticks: the text inbetween backticks will also be highlighted by
|
- Formatted inline code by using backticks: the text between backticks will also be highlighted by
|
||||||
the changelog tool:
|
the changelog tool:
|
||||||
```
|
```
|
||||||
feat(shell-proxy): enable unexported `DEFAULT_PROXY` setting (#9774)
|
feat(shell-proxy): enable unexported `DEFAULT_PROXY` setting (#9774)
|
||||||
|
|
67
README.md
67
README.md
|
@ -42,7 +42,7 @@ It's a good idea to inspect the install script from projects you don't yet know.
|
||||||
that by downloading the install script first, looking through it so everything looks normal,
|
that by downloading the install script first, looking through it so everything looks normal,
|
||||||
then running it:
|
then running it:
|
||||||
|
|
||||||
```shell
|
```sh
|
||||||
wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
|
wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
|
||||||
sh install.sh
|
sh install.sh
|
||||||
```
|
```
|
||||||
|
@ -57,18 +57,18 @@ Oh My Zsh comes with a shitload of plugins for you to take advantage of. You can
|
||||||
|
|
||||||
Once you spot a plugin (or several) that you'd like to use with Oh My Zsh, you'll need to enable them in the `.zshrc` file. You'll find the zshrc file in your `$HOME` directory. Open it with your favorite text editor and you'll see a spot to list all the plugins you want to load.
|
Once you spot a plugin (or several) that you'd like to use with Oh My Zsh, you'll need to enable them in the `.zshrc` file. You'll find the zshrc file in your `$HOME` directory. Open it with your favorite text editor and you'll see a spot to list all the plugins you want to load.
|
||||||
|
|
||||||
```shell
|
```sh
|
||||||
vi ~/.zshrc
|
vi ~/.zshrc
|
||||||
```
|
```
|
||||||
|
|
||||||
For example, this might begin to look like this:
|
For example, this might begin to look like this:
|
||||||
|
|
||||||
```shell
|
```sh
|
||||||
plugins=(
|
plugins=(
|
||||||
git
|
git
|
||||||
bundler
|
bundler
|
||||||
dotenv
|
dotenv
|
||||||
osx
|
macos
|
||||||
rake
|
rake
|
||||||
rbenv
|
rbenv
|
||||||
ruby
|
ruby
|
||||||
|
@ -91,13 +91,13 @@ _Robby's theme is the default one. It's not the fanciest one. It's not the simpl
|
||||||
|
|
||||||
Once you find a theme that you'd like to use, you will need to edit the `~/.zshrc` file. You'll see an environment variable (all caps) in there that looks like:
|
Once you find a theme that you'd like to use, you will need to edit the `~/.zshrc` file. You'll see an environment variable (all caps) in there that looks like:
|
||||||
|
|
||||||
```shell
|
```sh
|
||||||
ZSH_THEME="robbyrussell"
|
ZSH_THEME="robbyrussell"
|
||||||
```
|
```
|
||||||
|
|
||||||
To use a different theme, simply change the value to match the name of your desired theme. For example:
|
To use a different theme, simply change the value to match the name of your desired theme. For example:
|
||||||
|
|
||||||
```shell
|
```sh
|
||||||
ZSH_THEME="agnoster" # (this is one of the fancy ones)
|
ZSH_THEME="agnoster" # (this is one of the fancy ones)
|
||||||
# see https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#agnoster
|
# see https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#agnoster
|
||||||
```
|
```
|
||||||
|
@ -112,13 +112,13 @@ In case you did not find a suitable theme for your needs, please have a look at
|
||||||
|
|
||||||
If you're feeling feisty, you can let the computer select one randomly for you each time you open a new terminal window.
|
If you're feeling feisty, you can let the computer select one randomly for you each time you open a new terminal window.
|
||||||
|
|
||||||
```shell
|
```sh
|
||||||
ZSH_THEME="random" # (...please let it be pie... please be some pie..)
|
ZSH_THEME="random" # (...please let it be pie... please be some pie..)
|
||||||
```
|
```
|
||||||
|
|
||||||
And if you want to pick random theme from a list of your favorite themes:
|
And if you want to pick random theme from a list of your favorite themes:
|
||||||
|
|
||||||
```shell
|
```sh
|
||||||
ZSH_THEME_RANDOM_CANDIDATES=(
|
ZSH_THEME_RANDOM_CANDIDATES=(
|
||||||
"robbyrussell"
|
"robbyrussell"
|
||||||
"agnoster"
|
"agnoster"
|
||||||
|
@ -127,7 +127,7 @@ ZSH_THEME_RANDOM_CANDIDATES=(
|
||||||
|
|
||||||
If you only know which themes you don't like, you can add them similarly to an ignored list:
|
If you only know which themes you don't like, you can add them similarly to an ignored list:
|
||||||
|
|
||||||
```shell
|
```sh
|
||||||
ZSH_THEME_RANDOM_IGNORED=(pygmalion tjkirch_mod)
|
ZSH_THEME_RANDOM_IGNORED=(pygmalion tjkirch_mod)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ If you'd like to change the install directory with the `ZSH` environment variabl
|
||||||
`export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline
|
`export ZSH=/your/path` before installing, or by setting it before the end of the install pipeline
|
||||||
like this:
|
like this:
|
||||||
|
|
||||||
```shell
|
```sh
|
||||||
ZSH="$HOME/.dotfiles/oh-my-zsh" sh install.sh
|
ZSH="$HOME/.dotfiles/oh-my-zsh" sh install.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ If you're running the Oh My Zsh install script as part of an automated install,
|
||||||
flag `--unattended` to the `install.sh` script. This will have the effect of not trying to change
|
flag `--unattended` to the `install.sh` script. This will have the effect of not trying to change
|
||||||
the default shell, and also won't run `zsh` when the installation has finished.
|
the default shell, and also won't run `zsh` when the installation has finished.
|
||||||
|
|
||||||
```shell
|
```sh
|
||||||
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
|
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ The install script also accepts these variables to allow installation of a diffe
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
```shell
|
```sh
|
||||||
REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh
|
REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -193,13 +193,13 @@ REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh
|
||||||
|
|
||||||
##### 1. Clone the repository
|
##### 1. Clone the repository
|
||||||
|
|
||||||
```shell
|
```sh
|
||||||
git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
|
git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
|
||||||
```
|
```
|
||||||
|
|
||||||
##### 2. *Optionally*, backup your existing `~/.zshrc` file
|
##### 2. *Optionally*, backup your existing `~/.zshrc` file
|
||||||
|
|
||||||
```shell
|
```sh
|
||||||
cp ~/.zshrc ~/.zshrc.orig
|
cp ~/.zshrc ~/.zshrc.orig
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -207,13 +207,13 @@ cp ~/.zshrc ~/.zshrc.orig
|
||||||
|
|
||||||
You can create a new zsh config file by copying the template that we have included for you.
|
You can create a new zsh config file by copying the template that we have included for you.
|
||||||
|
|
||||||
```shell
|
```sh
|
||||||
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
|
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
|
||||||
```
|
```
|
||||||
|
|
||||||
##### 4. Change your default shell
|
##### 4. Change your default shell
|
||||||
|
|
||||||
```shell
|
```sh
|
||||||
chsh -s $(which zsh)
|
chsh -s $(which zsh)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -242,23 +242,40 @@ If you would like to override the functionality of a plugin distributed with Oh
|
||||||
|
|
||||||
## Getting Updates
|
## Getting Updates
|
||||||
|
|
||||||
By default, you will be prompted to check for upgrades every few weeks. If you would like `oh-my-zsh` to automatically upgrade itself without prompting you, set the following in your `~/.zshrc`:
|
By default, you will be prompted to check for updates every 2 weeks. You can choose other update modes by adding a line to your `~/.zshrc` file, **before Oh My Zsh is loaded**:
|
||||||
|
|
||||||
```shell
|
1. Automatic update without confirmation prompt:
|
||||||
DISABLE_UPDATE_PROMPT=true
|
|
||||||
```
|
|
||||||
|
|
||||||
To disable automatic upgrades, set the following in your `~/.zshrc`:
|
```sh
|
||||||
|
zstyle ':omz:update' mode auto
|
||||||
|
```
|
||||||
|
|
||||||
```shell
|
2. Just offer a reminder every few days, if there are updates available:
|
||||||
DISABLE_AUTO_UPDATE=true
|
|
||||||
|
```sh
|
||||||
|
zstyle ':omz:update' mode reminder
|
||||||
|
```
|
||||||
|
|
||||||
|
3. To disable automatic updates entirely:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
zstyle ':omz:update' mode disabled
|
||||||
|
```
|
||||||
|
|
||||||
|
NOTE: you can control how often Oh My Zsh checks for updates with the following setting:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# This will check for updates every 7 days
|
||||||
|
zstyle ':omz:update' frequency 7
|
||||||
|
# This will check for updates every time you open the terminal (not recommended)
|
||||||
|
zstyle ':omz:update' frequency 0
|
||||||
```
|
```
|
||||||
|
|
||||||
### Manual Updates
|
### Manual Updates
|
||||||
|
|
||||||
If you'd like to upgrade at any point in time (maybe someone just released a new plugin and you don't want to wait a week?) you just need to run:
|
If you'd like to update at any point in time (maybe someone just released a new plugin and you don't want to wait a week?) you just need to run:
|
||||||
|
|
||||||
```shell
|
```sh
|
||||||
omz update
|
omz update
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
22
SECURITY.md
Normal file
22
SECURITY.md
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
# Security Policy
|
||||||
|
|
||||||
|
## Supported Versions
|
||||||
|
|
||||||
|
At the moment Oh My Zsh only considers the very latest commit to be supported.
|
||||||
|
We combine that with our fast response to incidents, so risk is minimized.
|
||||||
|
|
||||||
|
| Version | Supported |
|
||||||
|
|:-------------- |:------------------ |
|
||||||
|
| master | :white_check_mark: |
|
||||||
|
| other commits | :x: |
|
||||||
|
|
||||||
|
In the near future we will introduce versioning, so expect this section to change.
|
||||||
|
|
||||||
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
|
If you find a vulnerability, email all the maintainers directly at:
|
||||||
|
|
||||||
|
- Robby: robby [at] planetargon.com
|
||||||
|
- Marc: hello [at] mcornella.com
|
||||||
|
|
||||||
|
**Do not open an issue or Pull Request directly**, because it might reveal the vulnerability.
|
44
lib/cli.zsh
44
lib/cli.zsh
|
@ -26,6 +26,7 @@ function _omz {
|
||||||
'help:Usage information'
|
'help:Usage information'
|
||||||
'plugin:Manage plugins'
|
'plugin:Manage plugins'
|
||||||
'pr:Manage Oh My Zsh Pull Requests'
|
'pr:Manage Oh My Zsh Pull Requests'
|
||||||
|
'reload:Reload the current zsh session'
|
||||||
'theme:Manage themes'
|
'theme:Manage themes'
|
||||||
'update:Update Oh My Zsh'
|
'update:Update Oh My Zsh'
|
||||||
)
|
)
|
||||||
|
@ -35,7 +36,7 @@ function _omz {
|
||||||
elif (( CURRENT == 3 )); then
|
elif (( CURRENT == 3 )); then
|
||||||
case "$words[2]" in
|
case "$words[2]" in
|
||||||
changelog) local -a refs
|
changelog) local -a refs
|
||||||
refs=("${(@f)$(command git -C "$ZSH" for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}")
|
refs=("${(@f)$(cd "$ZSH"; command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}")
|
||||||
_describe 'command' refs ;;
|
_describe 'command' refs ;;
|
||||||
plugin) subcmds=(
|
plugin) subcmds=(
|
||||||
'disable:Disable plugin(s)'
|
'disable:Disable plugin(s)'
|
||||||
|
@ -90,7 +91,8 @@ function _omz {
|
||||||
# NOTE: $(( CURRENT - 1 )) is the last plugin argument completely passed, i.e. that which
|
# NOTE: $(( CURRENT - 1 )) is the last plugin argument completely passed, i.e. that which
|
||||||
# has a space after them. This is to avoid removing plugins partially passed, which makes
|
# has a space after them. This is to avoid removing plugins partially passed, which makes
|
||||||
# the completion not add a space after the completed plugin.
|
# the completion not add a space after the completed plugin.
|
||||||
local -a args=(${words[4,$(( CURRENT - 1))]})
|
local -a args
|
||||||
|
args=(${words[4,$(( CURRENT - 1))]})
|
||||||
valid_plugins=(${valid_plugins:|args})
|
valid_plugins=(${valid_plugins:|args})
|
||||||
|
|
||||||
_describe 'plugin' valid_plugins ;;
|
_describe 'plugin' valid_plugins ;;
|
||||||
|
@ -159,6 +161,7 @@ Available commands:
|
||||||
changelog Print the changelog
|
changelog Print the changelog
|
||||||
plugin <command> Manage plugins
|
plugin <command> Manage plugins
|
||||||
pr <command> Manage Oh My Zsh Pull Requests
|
pr <command> Manage Oh My Zsh Pull Requests
|
||||||
|
reload Reload the current zsh session
|
||||||
theme <command> Manage themes
|
theme <command> Manage themes
|
||||||
update Update Oh My Zsh
|
update Update Oh My Zsh
|
||||||
|
|
||||||
|
@ -168,9 +171,12 @@ EOF
|
||||||
function _omz::changelog {
|
function _omz::changelog {
|
||||||
local version=${1:-HEAD} format=${3:-"--text"}
|
local version=${1:-HEAD} format=${3:-"--text"}
|
||||||
|
|
||||||
if ! command git -C "$ZSH" show-ref --verify refs/heads/$version &>/dev/null && \
|
if (
|
||||||
! command git -C "$ZSH" show-ref --verify refs/tags/$version &>/dev/null && \
|
cd "$ZSH"
|
||||||
! command git -C "$ZSH" rev-parse --verify "${version}^{commit}" &>/dev/null; then
|
! command git show-ref --verify refs/heads/$version && \
|
||||||
|
! command git show-ref --verify refs/tags/$version && \
|
||||||
|
! command git rev-parse --verify "${version}^{commit}"
|
||||||
|
) &>/dev/null; then
|
||||||
cat >&2 <<EOF
|
cat >&2 <<EOF
|
||||||
Usage: omz changelog [version]
|
Usage: omz changelog [version]
|
||||||
|
|
||||||
|
@ -212,7 +218,7 @@ function _omz::plugin::disable {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check that plugin is in $plugins
|
# Check that plugin is in $plugins
|
||||||
local -a dis_plugins=()
|
local -a dis_plugins
|
||||||
for plugin in "$@"; do
|
for plugin in "$@"; do
|
||||||
if [[ ${plugins[(Ie)$plugin]} -eq 0 ]]; then
|
if [[ ${plugins[(Ie)$plugin]} -eq 0 ]]; then
|
||||||
_omz::log warn "plugin '$plugin' is not enabled."
|
_omz::log warn "plugin '$plugin' is not enabled."
|
||||||
|
@ -301,7 +307,7 @@ function _omz::plugin::enable {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check that plugin is not in $plugins
|
# Check that plugin is not in $plugins
|
||||||
local -a add_plugins=()
|
local -a add_plugins
|
||||||
for plugin in "$@"; do
|
for plugin in "$@"; do
|
||||||
if [[ ${plugins[(Ie)$plugin]} -ne 0 ]]; then
|
if [[ ${plugins[(Ie)$plugin]} -ne 0 ]]; then
|
||||||
_omz::log warn "plugin '$plugin' is already enabled."
|
_omz::log warn "plugin '$plugin' is already enabled."
|
||||||
|
@ -422,10 +428,8 @@ function _omz::plugin::load {
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local plugins=("$@")
|
|
||||||
local plugin base has_completion=0
|
local plugin base has_completion=0
|
||||||
|
for plugin in "$@"; do
|
||||||
for plugin in $plugins; do
|
|
||||||
if [[ -d "$ZSH_CUSTOM/plugins/$plugin" ]]; then
|
if [[ -d "$ZSH_CUSTOM/plugins/$plugin" ]]; then
|
||||||
base="$ZSH_CUSTOM/plugins/$plugin"
|
base="$ZSH_CUSTOM/plugins/$plugin"
|
||||||
elif [[ -d "$ZSH/plugins/$plugin" ]]; then
|
elif [[ -d "$ZSH/plugins/$plugin" ]]; then
|
||||||
|
@ -445,9 +449,9 @@ function _omz::plugin::load {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if it has completion to reload compinit
|
# Check if it has completion to reload compinit
|
||||||
if [[ -f "$base/_$plugin" ]]; then
|
local -a comp_files
|
||||||
has_completion=1
|
comp_files=($base/_*(N))
|
||||||
fi
|
has_completion=$(( $#comp_files > 0 ))
|
||||||
|
|
||||||
# Load the plugin
|
# Load the plugin
|
||||||
if [[ -f "$base/$plugin.plugin.zsh" ]]; then
|
if [[ -f "$base/$plugin.plugin.zsh" ]]; then
|
||||||
|
@ -598,6 +602,16 @@ function _omz::pr::test {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _omz::reload {
|
||||||
|
# Delete current completion cache
|
||||||
|
command rm -f $_comp_dumpfile $ZSH_COMPDUMP
|
||||||
|
|
||||||
|
# Old zsh versions don't have ZSH_ARGZERO
|
||||||
|
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
|
||||||
|
# Check whether to run a login shell
|
||||||
|
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
|
||||||
|
}
|
||||||
|
|
||||||
function _omz::theme {
|
function _omz::theme {
|
||||||
(( $# > 0 && $+functions[_omz::theme::$1] )) || {
|
(( $# > 0 && $+functions[_omz::theme::$1] )) || {
|
||||||
cat >&2 <<EOF
|
cat >&2 <<EOF
|
||||||
|
@ -744,9 +758,9 @@ function _omz::update {
|
||||||
|
|
||||||
# Run update script
|
# Run update script
|
||||||
if [[ "$1" != --unattended ]]; then
|
if [[ "$1" != --unattended ]]; then
|
||||||
ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" --interactive
|
ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" --interactive || return $?
|
||||||
else
|
else
|
||||||
ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh"
|
ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" || return $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update last updated file
|
# Update last updated file
|
||||||
|
|
|
@ -335,7 +335,7 @@ function _omz_diag_dump_os_specific_version() {
|
||||||
builtin echo "OS Version: $osname $osver build $(sw_vers -buildVersion)"
|
builtin echo "OS Version: $osname $osver build $(sw_vers -buildVersion)"
|
||||||
;;
|
;;
|
||||||
cygwin)
|
cygwin)
|
||||||
command systeminfo | command head -4 | command tail -2
|
command systeminfo | command head -n 4 | command tail -n 2
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ alias -g .....='../../../..'
|
||||||
alias -g ......='../../../../..'
|
alias -g ......='../../../../..'
|
||||||
|
|
||||||
alias -- -='cd -'
|
alias -- -='cd -'
|
||||||
alias 1='cd -'
|
alias 1='cd -1'
|
||||||
alias 2='cd -2'
|
alias 2='cd -2'
|
||||||
alias 3='cd -3'
|
alias 3='cd -3'
|
||||||
alias 4='cd -4'
|
alias 4='cd -4'
|
||||||
|
@ -26,7 +26,7 @@ function d () {
|
||||||
if [[ -n $1 ]]; then
|
if [[ -n $1 ]]; then
|
||||||
dirs "$@"
|
dirs "$@"
|
||||||
else
|
else
|
||||||
dirs -v | head -10
|
dirs -v | head -n 10
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
compdef _dirs d
|
compdef _dirs d
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
function zsh_stats() {
|
function zsh_stats() {
|
||||||
fc -l 1 \
|
fc -l 1 \
|
||||||
| awk '{ CMD[$2]++; count++; } END { for (a in CMD) print CMD[a] " " CMD[a]*100/count "% " a }' \
|
| awk '{ CMD[$2]++; count++; } END { for (a in CMD) print CMD[a] " " CMD[a]*100/count "% " a }' \
|
||||||
| grep -v "./" | sort -nr | head -20 | column -c3 -s " " -t | nl
|
| grep -v "./" | sort -nr | head -n 20 | column -c3 -s " " -t | nl
|
||||||
}
|
}
|
||||||
|
|
||||||
function uninstall_oh_my_zsh() {
|
function uninstall_oh_my_zsh() {
|
||||||
|
@ -45,7 +45,7 @@ function takeurl() {
|
||||||
data="$(mktemp)"
|
data="$(mktemp)"
|
||||||
curl -L "$1" > "$data"
|
curl -L "$1" > "$data"
|
||||||
tar xf "$data"
|
tar xf "$data"
|
||||||
thedir="$(tar tf "$data" | head -1)"
|
thedir="$(tar tf "$data" | head -n 1)"
|
||||||
rm "$data"
|
rm "$data"
|
||||||
cd "$thedir"
|
cd "$thedir"
|
||||||
}
|
}
|
||||||
|
@ -237,12 +237,11 @@ function omz_urldecode {
|
||||||
tmp=${tmp:gs/\\/\\\\/}
|
tmp=${tmp:gs/\\/\\\\/}
|
||||||
# Handle %-escapes by turning them into `\xXX` printf escapes
|
# Handle %-escapes by turning them into `\xXX` printf escapes
|
||||||
tmp=${tmp:gs/%/\\x/}
|
tmp=${tmp:gs/%/\\x/}
|
||||||
local decoded
|
local decoded="$(printf -- "$tmp")"
|
||||||
eval "decoded=\$'$tmp'"
|
|
||||||
|
|
||||||
# Now we have a UTF-8 encoded string in the variable. We need to re-encode
|
# Now we have a UTF-8 encoded string in the variable. We need to re-encode
|
||||||
# it if caller is in a non-UTF-8 locale.
|
# it if caller is in a non-UTF-8 locale.
|
||||||
local safe_encodings
|
local -a safe_encodings
|
||||||
safe_encodings=(UTF-8 utf8 US-ASCII)
|
safe_encodings=(UTF-8 utf8 US-ASCII)
|
||||||
if [[ -z ${safe_encodings[(r)$caller_encoding]} ]]; then
|
if [[ -z ${safe_encodings[(r)$caller_encoding]} ]]; then
|
||||||
decoded=$(echo -E "$decoded" | iconv -f UTF-8 -t $caller_encoding)
|
decoded=$(echo -E "$decoded" | iconv -f UTF-8 -t $caller_encoding)
|
||||||
|
|
|
@ -51,7 +51,7 @@ function parse_git_dirty() {
|
||||||
FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}"
|
FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -1)
|
STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n 1)
|
||||||
fi
|
fi
|
||||||
if [[ -n $STATUS ]]; then
|
if [[ -n $STATUS ]]; then
|
||||||
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
|
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
|
||||||
|
@ -206,7 +206,8 @@ function git_prompt_status() {
|
||||||
STASHED UNMERGED AHEAD BEHIND DIVERGED
|
STASHED UNMERGED AHEAD BEHIND DIVERGED
|
||||||
)
|
)
|
||||||
|
|
||||||
local status_text="$(__git_prompt_git status --porcelain -b 2> /dev/null)"
|
local status_text
|
||||||
|
status_text="$(__git_prompt_git status --porcelain -b 2> /dev/null)"
|
||||||
|
|
||||||
# Don't continue on a catastrophic failure
|
# Don't continue on a catastrophic failure
|
||||||
if [[ $? -eq 128 ]]; then
|
if [[ $? -eq 128 ]]; then
|
||||||
|
|
|
@ -20,16 +20,18 @@ done
|
||||||
|
|
||||||
# Show all 256 colors with color number
|
# Show all 256 colors with color number
|
||||||
function spectrum_ls() {
|
function spectrum_ls() {
|
||||||
|
setopt localoptions nopromptsubst
|
||||||
local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
|
local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
|
||||||
for code in {000..255}; do
|
for code in {000..255}; do
|
||||||
print -P -- "$code: $FG[$code]$ZSH_SPECTRUM_TEXT%{$reset_color%}"
|
print -P -- "$code: ${FG[$code]}${ZSH_SPECTRUM_TEXT}%{$reset_color%}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Show all 256 colors where the background is set to specific color
|
# Show all 256 colors where the background is set to specific color
|
||||||
function spectrum_bls() {
|
function spectrum_bls() {
|
||||||
|
setopt localoptions nopromptsubst
|
||||||
local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
|
local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
|
||||||
for code in {000..255}; do
|
for code in {000..255}; do
|
||||||
print -P -- "$code: $BG[$code]$ZSH_SPECTRUM_TEXT%{$reset_color%}"
|
print -P -- "$code: ${BG[$code]}${ZSH_SPECTRUM_TEXT}%{$reset_color%}"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
# (In screen, only short_tab_title is used)
|
# (In screen, only short_tab_title is used)
|
||||||
# Limited support for Apple Terminal (Terminal can't set window and tab separately)
|
# Limited support for Apple Terminal (Terminal can't set window and tab separately)
|
||||||
function title {
|
function title {
|
||||||
emulate -L zsh
|
setopt localoptions nopromptsubst
|
||||||
setopt prompt_subst
|
|
||||||
|
|
||||||
# Don't set the title if inside emacs, unless using vterm
|
# Don't set the title if inside emacs, unless using vterm
|
||||||
[[ -n "$INSIDE_EMACS" && "$INSIDE_EMACS" != vterm ]] && return
|
[[ -n "$INSIDE_EMACS" && "$INSIDE_EMACS" != vterm ]] && return
|
||||||
|
@ -48,13 +47,13 @@ fi
|
||||||
|
|
||||||
# Runs before showing the prompt
|
# Runs before showing the prompt
|
||||||
function omz_termsupport_precmd {
|
function omz_termsupport_precmd {
|
||||||
[[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return
|
[[ "${DISABLE_AUTO_TITLE:-}" != true ]] || return
|
||||||
title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
|
title "$ZSH_THEME_TERM_TAB_TITLE_IDLE" "$ZSH_THEME_TERM_TITLE_IDLE"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Runs before executing the command
|
# Runs before executing the command
|
||||||
function omz_termsupport_preexec {
|
function omz_termsupport_preexec {
|
||||||
[[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return
|
[[ "${DISABLE_AUTO_TITLE:-}" != true ]] || return
|
||||||
|
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
setopt extended_glob
|
setopt extended_glob
|
||||||
|
@ -97,10 +96,10 @@ function omz_termsupport_preexec {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# cmd name only, or if this is sudo or ssh, the next cmd
|
# cmd name only, or if this is sudo or ssh, the next cmd
|
||||||
local CMD=${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%}
|
local CMD="${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%}"
|
||||||
local LINE="${2:gs/%/%%}"
|
local LINE="${2:gs/%/%%}"
|
||||||
|
|
||||||
title '$CMD' '%100>...>$LINE%<<'
|
title "$CMD" "%100>...>${LINE}%<<"
|
||||||
}
|
}
|
||||||
|
|
||||||
autoload -Uz add-zsh-hook
|
autoload -Uz add-zsh-hook
|
||||||
|
|
|
@ -40,7 +40,7 @@ if [[ "$DISABLE_LS_COLORS" != "true" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# enable diff color if possible.
|
# enable diff color if possible.
|
||||||
if command diff --color . . &>/dev/null; then
|
if command diff --color /dev/null /dev/null &>/dev/null; then
|
||||||
alias diff='diff --color'
|
alias diff='diff --color'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
38
oh-my-zsh.sh
38
oh-my-zsh.sh
|
@ -1,8 +1,40 @@
|
||||||
# Protect against non-zsh execution of Oh My Zsh (use POSIX syntax here)
|
# Protect against non-zsh execution of Oh My Zsh (use POSIX syntax here)
|
||||||
[ -n "$ZSH_VERSION" ] || {
|
[ -n "$ZSH_VERSION" ] || {
|
||||||
# ANSI (\033[<code>m): 0: reset, 1: bold, 4: underline, 22: no bold, 24: no underline, 31: red
|
# ANSI formatting function (\033[<code>m)
|
||||||
printf "\033[1;31mERROR:\033[22m Oh My Zsh can't be loaded from: \033[1m${0#-}\033[22m. " >&2
|
# 0: reset, 1: bold, 4: underline, 22: no bold, 24: no underline, 31: red, 33: yellow
|
||||||
printf "You need to run \033[1;4mzsh\033[22;24m instead.\033[0m\n" >&2
|
omz_f() {
|
||||||
|
[ $# -gt 0 ] || return
|
||||||
|
IFS=";" printf "\033[%sm" $*
|
||||||
|
}
|
||||||
|
# If stdout is not a terminal ignore all formatting
|
||||||
|
[ -t 1 ] || omz_f() { :; }
|
||||||
|
|
||||||
|
omz_ptree() {
|
||||||
|
# Get process tree of the current process
|
||||||
|
pid=$$; pids="$pid"
|
||||||
|
while [ ${pid-0} -ne 1 ] && ppid=$(ps -e -o pid,ppid | awk "\$1 == $pid { print \$2 }"); do
|
||||||
|
pids="$pids $pid"; pid=$ppid
|
||||||
|
done
|
||||||
|
|
||||||
|
# Show process tree
|
||||||
|
case "$(uname)" in
|
||||||
|
Linux) ps -o ppid,pid,command -f -p $pids 2>/dev/null ;;
|
||||||
|
Darwin|*) ps -o ppid,pid,command -p $pids 2>/dev/null ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# If ps command failed, try Busybox ps
|
||||||
|
[ $? -eq 0 ] || ps -o ppid,pid,comm | awk "NR == 1 || index(\"$pids\", \$2) != 0"
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
shell=$(ps -o pid,comm | awk "\$1 == $$ { print \$2 }")
|
||||||
|
printf "$(omz_f 1 31)Error:$(omz_f 22) Oh My Zsh can't be loaded from: $(omz_f 1)${shell}$(omz_f 22). "
|
||||||
|
printf "You need to run $(omz_f 1)zsh$(omz_f 22) instead.$(omz_f 0)\n"
|
||||||
|
printf "$(omz_f 33)Here's the process tree:$(omz_f 22)\n\n"
|
||||||
|
omz_ptree
|
||||||
|
printf "$(omz_f 0)\n"
|
||||||
|
} >&2
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,15 +8,22 @@ To use, add `battery` to the list of plugins in your `.zshrc` file:
|
||||||
|
|
||||||
Then, add the `battery_pct_prompt` function to your custom theme. For example:
|
Then, add the `battery_pct_prompt` function to your custom theme. For example:
|
||||||
|
|
||||||
```
|
```zsh
|
||||||
RPROMPT='$(battery_pct_prompt) ...'
|
RPROMPT='$(battery_pct_prompt) ...'
|
||||||
```
|
```
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
On Linux, you must have the `acpi` tool installed on your operating system.
|
- On Linux, you must have the `acpi` or `acpitool` commands installed on your operating system.
|
||||||
|
On Debian/Ubuntu, you can do that with `sudo apt install acpi` or `sudo apt install acpitool`.
|
||||||
|
|
||||||
Here's an example of how to install with apt:
|
- On Android (via [Termux](https://play.google.com/store/apps/details?id=com.termux)), you must have:
|
||||||
```
|
|
||||||
sudo apt-get install acpi
|
1. The `Termux:API` addon app installed:
|
||||||
```
|
[Google Play](https://play.google.com/store/apps/details?id=com.termux.api) | [F-Droid](https://f-droid.org/packages/com.termux.api/)
|
||||||
|
|
||||||
|
2. The `termux-api` package installed within termux:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pkg install termux-api
|
||||||
|
```
|
||||||
|
|
|
@ -10,17 +10,17 @@
|
||||||
# Author: J (927589452) #
|
# Author: J (927589452) #
|
||||||
# Modified to add support for FreeBSD #
|
# Modified to add support for FreeBSD #
|
||||||
###########################################
|
###########################################
|
||||||
|
# Author: Avneet Singh (kalsi-avneet) #
|
||||||
|
# Modified to add support for Android #
|
||||||
|
###########################################
|
||||||
|
|
||||||
if [[ "$OSTYPE" = darwin* ]]; then
|
if [[ "$OSTYPE" = darwin* ]]; then
|
||||||
|
|
||||||
function battery_is_charging() {
|
function battery_is_charging() {
|
||||||
ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ Yes'
|
ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ Yes'
|
||||||
}
|
}
|
||||||
|
|
||||||
function battery_pct() {
|
function battery_pct() {
|
||||||
pmset -g batt | grep -Eo "\d+%" | cut -d% -f1
|
pmset -g batt | grep -Eo "\d+%" | cut -d% -f1
|
||||||
}
|
}
|
||||||
|
|
||||||
function battery_pct_remaining() {
|
function battery_pct_remaining() {
|
||||||
if battery_is_charging; then
|
if battery_is_charging; then
|
||||||
echo "External Power"
|
echo "External Power"
|
||||||
|
@ -28,7 +28,6 @@ if [[ "$OSTYPE" = darwin* ]]; then
|
||||||
battery_pct
|
battery_pct
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function battery_time_remaining() {
|
function battery_time_remaining() {
|
||||||
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
|
local smart_battery_status="$(ioreg -rc "AppleSmartBattery")"
|
||||||
if [[ $(echo $smart_battery_status | command grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]]; then
|
if [[ $(echo $smart_battery_status | command grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]]; then
|
||||||
|
@ -42,7 +41,6 @@ if [[ "$OSTYPE" = darwin* ]]; then
|
||||||
echo "∞"
|
echo "∞"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function battery_pct_prompt () {
|
function battery_pct_prompt () {
|
||||||
local battery_pct color
|
local battery_pct color
|
||||||
if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then
|
if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then
|
||||||
|
@ -61,17 +59,14 @@ if [[ "$OSTYPE" = darwin* ]]; then
|
||||||
}
|
}
|
||||||
|
|
||||||
elif [[ "$OSTYPE" = freebsd* ]]; then
|
elif [[ "$OSTYPE" = freebsd* ]]; then
|
||||||
|
|
||||||
function battery_is_charging() {
|
function battery_is_charging() {
|
||||||
[[ $(sysctl -n hw.acpi.battery.state) -eq 2 ]]
|
[[ $(sysctl -n hw.acpi.battery.state) -eq 2 ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
function battery_pct() {
|
function battery_pct() {
|
||||||
if (( $+commands[sysctl] )); then
|
if (( $+commands[sysctl] )); then
|
||||||
sysctl -n hw.acpi.battery.life
|
sysctl -n hw.acpi.battery.life
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function battery_pct_remaining() {
|
function battery_pct_remaining() {
|
||||||
if ! battery_is_charging; then
|
if ! battery_is_charging; then
|
||||||
battery_pct
|
battery_pct
|
||||||
|
@ -79,7 +74,6 @@ elif [[ "$OSTYPE" = freebsd* ]]; then
|
||||||
echo "External Power"
|
echo "External Power"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function battery_time_remaining() {
|
function battery_time_remaining() {
|
||||||
local remaining_time
|
local remaining_time
|
||||||
remaining_time=$(sysctl -n hw.acpi.battery.time)
|
remaining_time=$(sysctl -n hw.acpi.battery.time)
|
||||||
|
@ -89,7 +83,6 @@ elif [[ "$OSTYPE" = freebsd* ]]; then
|
||||||
printf %02d:%02d $hour $minute
|
printf %02d:%02d $hour $minute
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function battery_pct_prompt() {
|
function battery_pct_prompt() {
|
||||||
local battery_pct color
|
local battery_pct color
|
||||||
battery_pct=$(battery_pct_remaining)
|
battery_pct=$(battery_pct_remaining)
|
||||||
|
@ -106,19 +99,22 @@ elif [[ "$OSTYPE" = freebsd* ]]; then
|
||||||
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
|
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
elif [[ "$OSTYPE" = linux-android ]] && (( ${+commands[termux-battery-status]} )); then
|
||||||
elif [[ "$OSTYPE" = linux* ]]; then
|
|
||||||
|
|
||||||
function battery_is_charging() {
|
function battery_is_charging() {
|
||||||
! acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -q '^Battery.*Discharging'
|
termux-battery-status 2>/dev/null | command awk '/status/ { exit ($0 ~ /DISCHARGING/) }'
|
||||||
}
|
}
|
||||||
|
|
||||||
function battery_pct() {
|
function battery_pct() {
|
||||||
if (( $+commands[acpi] )); then
|
# Sample output:
|
||||||
acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -E '^Battery.*(Full|(Disc|C)harging)' | cut -f2 -d ',' | tr -cd '[:digit:]'
|
# {
|
||||||
fi
|
# "health": "GOOD",
|
||||||
|
# "percentage": 93,
|
||||||
|
# "plugged": "UNPLUGGED",
|
||||||
|
# "status": "DISCHARGING",
|
||||||
|
# "temperature": 29.0,
|
||||||
|
# "current": 361816
|
||||||
|
# }
|
||||||
|
termux-battery-status 2>/dev/null | command awk '/percentage/ { gsub(/[,]/,""); print $2}'
|
||||||
}
|
}
|
||||||
|
|
||||||
function battery_pct_remaining() {
|
function battery_pct_remaining() {
|
||||||
if ! battery_is_charging; then
|
if ! battery_is_charging; then
|
||||||
battery_pct
|
battery_pct
|
||||||
|
@ -126,13 +122,72 @@ elif [[ "$OSTYPE" = linux* ]]; then
|
||||||
echo "External Power"
|
echo "External Power"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
function battery_time_remaining() { } # Not available on android
|
||||||
function battery_time_remaining() {
|
function battery_pct_prompt() {
|
||||||
if ! battery_is_charging; then
|
local battery_pct color
|
||||||
acpi 2>/dev/null | command grep -v "rate information unavailable" | cut -f3 -d ','
|
battery_pct=$(battery_pct_remaining)
|
||||||
fi
|
if battery_is_charging; then
|
||||||
}
|
echo "∞"
|
||||||
|
else
|
||||||
|
if [[ $battery_pct -gt 50 ]]; then
|
||||||
|
color='green'
|
||||||
|
elif [[ $battery_pct -gt 20 ]]; then
|
||||||
|
color='yellow'
|
||||||
|
else
|
||||||
|
color='red'
|
||||||
|
fi
|
||||||
|
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
elif [[ "$OSTYPE" = linux* ]]; then
|
||||||
|
function battery_is_charging() {
|
||||||
|
if (( $+commands[acpitool] )); then
|
||||||
|
! acpitool 2>/dev/null | command grep -qE '^\s+Battery.*Discharging'
|
||||||
|
elif (( $+commands[acpi] )); then
|
||||||
|
! acpi 2>/dev/null | command grep -v "rate information unavailable" | command grep -q '^Battery.*Discharging'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
function battery_pct() {
|
||||||
|
if (( $+commands[acpitool] )); then
|
||||||
|
# Sample output:
|
||||||
|
# Battery #1 : Unknown, 99.55%
|
||||||
|
# Battery #2 : Discharging, 49.58%, 01:12:05
|
||||||
|
# All batteries : 62.60%, 02:03:03
|
||||||
|
local -i pct=$(acpitool 2>/dev/null | command awk -F, '
|
||||||
|
/^\s+All batteries/ {
|
||||||
|
gsub(/[^0-9.]/, "", $1)
|
||||||
|
pct=$1
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
!pct && /^\s+Battery/ {
|
||||||
|
gsub(/[^0-9.]/, "", $2)
|
||||||
|
pct=$2
|
||||||
|
}
|
||||||
|
END { print pct }
|
||||||
|
')
|
||||||
|
echo $pct
|
||||||
|
elif (( $+commands[acpi] )); then
|
||||||
|
# Sample output:
|
||||||
|
# Battery 0: Discharging, 0%, rate information unavailable
|
||||||
|
# Battery 1: Full, 100%
|
||||||
|
acpi 2>/dev/null | command awk -F, '
|
||||||
|
/rate information unavailable/ { next }
|
||||||
|
/^Battery.*: /{ gsub(/[^0-9]/, "", $2); print $2; exit }
|
||||||
|
'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
function battery_pct_remaining() {
|
||||||
|
if ! battery_is_charging; then
|
||||||
|
battery_pct
|
||||||
|
else
|
||||||
|
echo "External Power"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
function battery_time_remaining() {
|
||||||
|
if ! battery_is_charging; then
|
||||||
|
acpi 2>/dev/null | command grep -v "rate information unavailable" | cut -f3 -d ','
|
||||||
|
fi
|
||||||
|
}
|
||||||
function battery_pct_prompt() {
|
function battery_pct_prompt() {
|
||||||
local battery_pct color
|
local battery_pct color
|
||||||
battery_pct=$(battery_pct_remaining)
|
battery_pct=$(battery_pct_remaining)
|
||||||
|
@ -149,7 +204,6 @@ elif [[ "$OSTYPE" = linux* ]]; then
|
||||||
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
|
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
# Empty functions so we don't cause errors in prompts
|
# Empty functions so we don't cause errors in prompts
|
||||||
function battery_is_charging { false }
|
function battery_is_charging { false }
|
||||||
|
@ -174,7 +228,7 @@ function battery_level_gauge() {
|
||||||
local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow}
|
local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow}
|
||||||
local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'}
|
local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'}
|
||||||
|
|
||||||
local battery_remaining_percentage=$(battery_pct)
|
local -i battery_remaining_percentage=$(battery_pct)
|
||||||
local filled empty gauge_color
|
local filled empty gauge_color
|
||||||
|
|
||||||
if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then
|
if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
# chucknorris
|
# chucknorris
|
||||||
|
|
||||||
Chuck Norris fortunes plugin for oh-my-zsh. Perfectly suitable as MOTD.
|
Chuck Norris fortunes plugin for Oh My Zsh. Perfectly suitable as MOTD.
|
||||||
|
|
||||||
**Maintainers**: [apjanke](https://github.com/apjanke) [maff](https://github.com/maff)
|
|
||||||
|
|
||||||
To use it add `chucknorris` to the plugins array in you zshrc file.
|
To use it add `chucknorris` to the plugins array in you zshrc file.
|
||||||
|
|
||||||
|
|
|
@ -1,28 +1,24 @@
|
||||||
# chucknorris: Chuck Norris fortunes
|
|
||||||
|
|
||||||
# Automatically generate or update Chuck's compiled fortune data file
|
|
||||||
# $0 must be used outside a local function. This variable name is unlikly to collide.
|
|
||||||
CHUCKNORRIS_PLUGIN_DIR=${0:h}
|
|
||||||
|
|
||||||
() {
|
() {
|
||||||
local DIR=$CHUCKNORRIS_PLUGIN_DIR/fortunes
|
# %x: name of file containing code being executed
|
||||||
if [[ ! -f $DIR/chucknorris.dat ]] || [[ $DIR/chucknorris.dat -ot $DIR/chucknorris ]]; then
|
local fortunes_dir="${${(%):-%x}:h}/fortunes"
|
||||||
# For some reason, Cygwin puts strfile in /usr/sbin, which is not on the path by default
|
|
||||||
local strfile=strfile
|
# Aliases
|
||||||
if ! which strfile &>/dev/null && [[ -f /usr/sbin/strfile ]]; then
|
alias chuck="fortune -a $fortunes_dir"
|
||||||
strfile=/usr/sbin/strfile
|
alias chuck_cow="chuck | cowthink"
|
||||||
|
|
||||||
|
# Automatically generate or update Chuck's compiled fortune data file
|
||||||
|
if [[ "$fortunes_dir/chucknorris" -ot "$fortunes_dir/chucknorris.dat" ]]; then
|
||||||
|
return
|
||||||
fi
|
fi
|
||||||
if which $strfile &> /dev/null; then
|
|
||||||
$strfile $DIR/chucknorris $DIR/chucknorris.dat >/dev/null
|
# For some reason, Cygwin puts strfile in /usr/sbin, which is not on the path by default
|
||||||
else
|
local strfile="${commands[strfile]:-/usr/sbin/strfile}"
|
||||||
|
if [[ ! -x "$strfile" ]]; then
|
||||||
echo "[oh-my-zsh] chucknorris depends on strfile, which is not installed" >&2
|
echo "[oh-my-zsh] chucknorris depends on strfile, which is not installed" >&2
|
||||||
echo "[oh-my-zsh] strfile is often provided as part of the 'fortune' package" >&2
|
echo "[oh-my-zsh] strfile is often provided as part of the 'fortune' package" >&2
|
||||||
|
return
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# Aliases
|
# Generate the compiled fortune data file
|
||||||
alias chuck="fortune -a $DIR"
|
$strfile "$fortunes_dir/chucknorris" "$fortunes_dir/chucknorris.dat" >/dev/null
|
||||||
alias chuck_cow="chuck | cowthink"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unset CHUCKNORRIS_PLUGIN_DIR
|
|
||||||
|
|
|
@ -558,3 +558,11 @@ You know Chuck Norris' pet lizard, right? Last I heard, he was in the movie "God
|
||||||
%
|
%
|
||||||
http://chucknorrisfacts.com/ is built in Drupal because Chuck Norris knows a good CMS when he sees one.
|
http://chucknorrisfacts.com/ is built in Drupal because Chuck Norris knows a good CMS when he sees one.
|
||||||
%
|
%
|
||||||
|
Chuck Norris made the first Giraffe by uppercutting a horse.
|
||||||
|
%
|
||||||
|
Chuck Norris can hear sign language.
|
||||||
|
%
|
||||||
|
Chuck Norris make onions cry.
|
||||||
|
%
|
||||||
|
Chuck Norris doesn't shake hands, he makes them tremble.
|
||||||
|
%
|
||||||
|
|
|
@ -50,13 +50,13 @@ fi
|
||||||
# NixOS: https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/command-not-found
|
# NixOS: https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/command-not-found
|
||||||
if [[ -x /run/current-system/sw/bin/command-not-found ]]; then
|
if [[ -x /run/current-system/sw/bin/command-not-found ]]; then
|
||||||
command_not_found_handler() {
|
command_not_found_handler() {
|
||||||
/run/current-system/sw/bin/command-not-found -- "$@"
|
/run/current-system/sw/bin/command-not-found "$@"
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Termux: https://github.com/termux/command-not-found
|
# Termux: https://github.com/termux/command-not-found
|
||||||
if [[ -x /data/data/com.termux/files/usr/libexec/termux/command-not-found ]]; then
|
if [[ -x /data/data/com.termux/files/usr/libexec/termux/command-not-found ]]; then
|
||||||
command_not_found_handler() {
|
command_not_found_handler() {
|
||||||
/data/data/com.termux/files/usr/libexec/termux/command-not-found -- "$1"
|
/data/data/com.termux/files/usr/libexec/termux/command-not-found "$1"
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -12,19 +12,27 @@ plugins=(... dirhistory)
|
||||||
|
|
||||||
| Shortcut | Description |
|
| Shortcut | Description |
|
||||||
|-----------------------------------|-----------------------------------------------------------|
|
|-----------------------------------|-----------------------------------------------------------|
|
||||||
| <kbd>alt</kbd> + <kbd>left</kbd> | Go to previous directory |
|
| <kbd>Alt</kbd> + <kbd>Left</kbd> | Go to previous directory |
|
||||||
| <kbd>alt</kbd> + <kbd>right</kbd> | Undo <kbd>alt</kbd> + <kbd>left</kbd> |
|
| <kbd>Alt</kbd> + <kbd>Right</kbd> | Go to next directory |
|
||||||
| <kbd>alt</kbd> + <kbd>up</kbd> | Move into the parent directory |
|
| <kbd>Alt</kbd> + <kbd>Up</kbd> | Move into the parent directory |
|
||||||
| <kbd>alt</kbd> + <kbd>down</kbd> | Move into the first child directory by alphabetical order |
|
| <kbd>Alt</kbd> + <kbd>Down</kbd> | Move into the first child directory by alphabetical order |
|
||||||
|
|
||||||
NOTE: some terminals might override the ALT+Arrows key bindings (Windows Terminal, for example).
|
**For macOS: use the Option key (<kbd>⌥</kbd>) instead of <kbd>Alt</kbd>**.
|
||||||
If these don't work check your terminal settings and change them to a different keyboard shortcut.
|
|
||||||
|
> NOTE: some terminals might override the <kbd>Alt</kbd> + Arrows key bindings (e.g. Windows Terminal).
|
||||||
|
> If these don't work check your terminal settings and change them to a different keyboard shortcut.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
This plugin allows you to navigate the history of previous current-working-directories using ALT-LEFT and ALT-RIGHT. ALT-LEFT moves back to directories that the user has changed to in the past, and ALT-RIGHT undoes ALT-LEFT. MAC users may alternately use OPT-LEFT and OPT-RIGHT.
|
This plugin allows you to navigate the history of previous working directories using <kbd>Alt</kbd> + <kbd>Left</kbd>
|
||||||
|
and <kbd>Alt</kbd> + <kbd>Right</kbd>. <kbd>Alt</kbd> + <kbd>Left</kbd> moves to past directories, and
|
||||||
|
<kbd>Alt</kbd> + <kbd>Right</kbd> goes back to recent directories.
|
||||||
|
|
||||||
Also, navigate directory **hierarchy** using ALT-UP and ALT-DOWN. (mac keybindings not yet implemented). ALT-UP moves to higher hierarchy (shortcut for 'cd ..'). ALT-DOWN moves into the first directory found in alphabetical order (useful to navigate long empty directories e.g. java packages)
|
**NOTE: the maximum directory history size is 30.**
|
||||||
|
|
||||||
|
You can also navigate **directory hierarchies** using <kbd>Alt</kbd> + <kbd>Up</kbd> and <kbd>Alt</kbd> + <kbd>Down</kbd>.
|
||||||
|
<kbd>Alt</kbd> + <kbd>Up</kbd> moves to the parent directory, while <kbd>Alt</kbd> + <kbd>Down</kbd> moves into the first
|
||||||
|
child directory found in alphabetical order (useful to navigate long empty directories, e.g. Java packages).
|
||||||
|
|
||||||
For example, if the shell was started, and the following commands were entered:
|
For example, if the shell was started, and the following commands were entered:
|
||||||
|
|
||||||
|
@ -35,8 +43,20 @@ cd share
|
||||||
cd doc
|
cd doc
|
||||||
```
|
```
|
||||||
|
|
||||||
Then entering ALT-LEFT at the prompt would change directory from /usr/share/doc to /usr/share, then if pressed again to /usr/, then ~. If ALT-RIGHT were pressed the directory would be changed to /usr/ again.
|
the directory stack (`dirs -v`) would look like this:
|
||||||
|
|
||||||
After that, ALT-DOWN will probably go to /usr/bin (depends on your /usr structure), ALT-UP will return to /usr, then ALT-UP will get you to /
|
```console
|
||||||
|
$ dirs -v
|
||||||
|
0 /usr/share/doc
|
||||||
|
1 /usr/share
|
||||||
|
2 /usr
|
||||||
|
3 ~
|
||||||
|
```
|
||||||
|
|
||||||
**Currently the max history size is 30**. The navigation should work for xterm, PuTTY xterm mode, GNU screen, and on MAC with alternate keys as mentioned above.
|
then entering <kbd>Alt</kbd> + <kbd>Left</kbd> at the prompt would change directory from `/usr/share/doc` to `/usr/share`,
|
||||||
|
then if pressed again to `/usr`, then `~`. If <kbd>Alt</kbd> + <kbd>Right</kbd> were pressed the directory would be changed
|
||||||
|
to `/usr` again.
|
||||||
|
|
||||||
|
After that, <kbd>Alt</kbd> + <kbd>Down</kbd> will probably go to `/usr/bin` if `bin` is the first directory in alphabetical
|
||||||
|
order (depends on your `/usr` folder structure). <kbd>Alt</kbd> + <kbd>Up</kbd> will return to `/usr`, and once more will get
|
||||||
|
you to the root folder (`/`).
|
||||||
|
|
|
@ -19,14 +19,14 @@ export DIRHISTORY_SIZE=30
|
||||||
# Returns the element if the array was not empty,
|
# Returns the element if the array was not empty,
|
||||||
# otherwise returns empty string.
|
# otherwise returns empty string.
|
||||||
function pop_past() {
|
function pop_past() {
|
||||||
eval "$1='$dirhistory_past[$#dirhistory_past]'"
|
eval "$1=${(q)dirhistory_past[$#dirhistory_past]}"
|
||||||
if [[ $#dirhistory_past -gt 0 ]]; then
|
if [[ $#dirhistory_past -gt 0 ]]; then
|
||||||
dirhistory_past[$#dirhistory_past]=()
|
dirhistory_past[$#dirhistory_past]=()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function pop_future() {
|
function pop_future() {
|
||||||
eval "$1='$dirhistory_future[$#dirhistory_future]'"
|
eval "$1=${(q)dirhistory_future[$#dirhistory_future]}"
|
||||||
if [[ $#dirhistory_future -gt 0 ]]; then
|
if [[ $#dirhistory_future -gt 0 ]]; then
|
||||||
dirhistory_future[$#dirhistory_future]=()
|
dirhistory_future[$#dirhistory_future]=()
|
||||||
fi
|
fi
|
||||||
|
@ -121,35 +121,30 @@ function dirhistory_zle_dirhistory_future() {
|
||||||
}
|
}
|
||||||
|
|
||||||
zle -N dirhistory_zle_dirhistory_back
|
zle -N dirhistory_zle_dirhistory_back
|
||||||
# xterm in normal mode
|
bindkey "\e[3D" dirhistory_zle_dirhistory_back # xterm in normal mode
|
||||||
bindkey "\e[3D" dirhistory_zle_dirhistory_back
|
bindkey "\e[1;3D" dirhistory_zle_dirhistory_back # xterm in normal mode
|
||||||
bindkey "\e[1;3D" dirhistory_zle_dirhistory_back
|
bindkey "\e\e[D" dirhistory_zle_dirhistory_back # Putty
|
||||||
# Terminal.app
|
bindkey "\eO3D" dirhistory_zle_dirhistory_back # GNU screen
|
||||||
if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then
|
case "$TERM_PROGRAM" in
|
||||||
bindkey "^[b" dirhistory_zle_dirhistory_back
|
iTerm.app) bindkey "^[^[[D" dirhistory_zle_dirhistory_back ;; # iTerm2
|
||||||
|
Apple_Terminal) bindkey "^[b" dirhistory_zle_dirhistory_back ;; # Terminal.app
|
||||||
|
esac
|
||||||
|
if (( ${+terminfo[kcub1]} )); then
|
||||||
|
bindkey "^[${terminfo[kcub1]}" dirhistory_zle_dirhistory_back # urxvt
|
||||||
fi
|
fi
|
||||||
# iTerm2
|
|
||||||
if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
|
|
||||||
bindkey "^[^[[D" dirhistory_zle_dirhistory_back
|
|
||||||
fi
|
|
||||||
# Putty:
|
|
||||||
bindkey "\e\e[D" dirhistory_zle_dirhistory_back
|
|
||||||
# GNU screen:
|
|
||||||
bindkey "\eO3D" dirhistory_zle_dirhistory_back
|
|
||||||
|
|
||||||
zle -N dirhistory_zle_dirhistory_future
|
zle -N dirhistory_zle_dirhistory_future
|
||||||
bindkey "\e[3C" dirhistory_zle_dirhistory_future
|
bindkey "\e[3C" dirhistory_zle_dirhistory_future # xterm in normal mode
|
||||||
bindkey "\e[1;3C" dirhistory_zle_dirhistory_future
|
bindkey "\e[1;3C" dirhistory_zle_dirhistory_future # xterm in normal mode
|
||||||
# Terminal.app
|
bindkey "\e\e[C" dirhistory_zle_dirhistory_future # Putty
|
||||||
if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then
|
bindkey "\eO3C" dirhistory_zle_dirhistory_future # GNU screen
|
||||||
bindkey "^[f" dirhistory_zle_dirhistory_future
|
case "$TERM_PROGRAM" in
|
||||||
|
iTerm.app) bindkey "^[^[[C" dirhistory_zle_dirhistory_future ;; # iTerm2
|
||||||
|
Apple_Terminal) bindkey "^[f" dirhistory_zle_dirhistory_future ;; # Terminal.app
|
||||||
|
esac
|
||||||
|
if (( ${+terminfo[kcuf1]} )); then
|
||||||
|
bindkey "^[${terminfo[kcuf1]}" dirhistory_zle_dirhistory_future # urxvt
|
||||||
fi
|
fi
|
||||||
# iTerm2
|
|
||||||
if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
|
|
||||||
bindkey "^[^[[C" dirhistory_zle_dirhistory_future
|
|
||||||
fi
|
|
||||||
bindkey "\e\e[C" dirhistory_zle_dirhistory_future
|
|
||||||
bindkey "\eO3C" dirhistory_zle_dirhistory_future
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -181,22 +176,27 @@ function dirhistory_zle_dirhistory_down() {
|
||||||
}
|
}
|
||||||
|
|
||||||
zle -N dirhistory_zle_dirhistory_up
|
zle -N dirhistory_zle_dirhistory_up
|
||||||
# xterm in normal mode
|
bindkey "\e[3A" dirhistory_zle_dirhistory_up # xterm in normal mode
|
||||||
bindkey "\e[3A" dirhistory_zle_dirhistory_up
|
bindkey "\e[1;3A" dirhistory_zle_dirhistory_up # xterm in normal mode
|
||||||
bindkey "\e[1;3A" dirhistory_zle_dirhistory_up
|
bindkey "\e\e[A" dirhistory_zle_dirhistory_up # Putty
|
||||||
if [[ "$TERM_PROGRAM" == "Apple_Terminal" || "$TERM_PROGRAM" == "iTerm.app" ]]; then
|
bindkey "\eO3A" dirhistory_zle_dirhistory_up # GNU screen
|
||||||
bindkey "^[[A" dirhistory_zle_dirhistory_up
|
case "$TERM_PROGRAM" in
|
||||||
|
iTerm.app) bindkey "^[^[[A" dirhistory_zle_dirhistory_up ;; # iTerm2
|
||||||
|
Apple_Terminal) bindkey "^[[A" dirhistory_zle_dirhistory_up ;; # Terminal.app
|
||||||
|
esac
|
||||||
|
if (( ${+terminfo[kcuu1]} )); then
|
||||||
|
bindkey "^[${terminfo[kcuu1]}" dirhistory_zle_dirhistory_up # urxvt
|
||||||
fi
|
fi
|
||||||
# Putty:
|
|
||||||
bindkey "\e\e[A" dirhistory_zle_dirhistory_up
|
|
||||||
# GNU screen:
|
|
||||||
bindkey "\eO3A" dirhistory_zle_dirhistory_up
|
|
||||||
|
|
||||||
zle -N dirhistory_zle_dirhistory_down
|
zle -N dirhistory_zle_dirhistory_down
|
||||||
bindkey "\e[3B" dirhistory_zle_dirhistory_down
|
bindkey "\e[3B" dirhistory_zle_dirhistory_down # xterm in normal mode
|
||||||
bindkey "\e[1;3B" dirhistory_zle_dirhistory_down
|
bindkey "\e[1;3B" dirhistory_zle_dirhistory_down # xterm in normal mode
|
||||||
if [[ "$TERM_PROGRAM" == "Apple_Terminal" || "$TERM_PROGRAM" == "iTerm.app" ]]; then
|
bindkey "\e\e[B" dirhistory_zle_dirhistory_down # Putty
|
||||||
bindkey "^[[B" dirhistory_zle_dirhistory_down
|
bindkey "\eO3B" dirhistory_zle_dirhistory_down # GNU screen
|
||||||
|
case "$TERM_PROGRAM" in
|
||||||
|
iTerm.app) bindkey "^[^[[B" dirhistory_zle_dirhistory_down ;; # iTerm2
|
||||||
|
Apple_Terminal) bindkey "^[[B" dirhistory_zle_dirhistory_down ;; # Terminal.app
|
||||||
|
esac
|
||||||
|
if (( ${+terminfo[kcud1]} )); then
|
||||||
|
bindkey "^[${terminfo[kcud1]}" dirhistory_zle_dirhistory_down # urxvt
|
||||||
fi
|
fi
|
||||||
bindkey "\e\e[B" dirhistory_zle_dirhistory_down
|
|
||||||
bindkey "\eO3B" dirhistory_zle_dirhistory_down
|
|
||||||
|
|
|
@ -121,12 +121,6 @@ __docker-compose_subcommand() {
|
||||||
'--parallel[Build images in parallel.]' \
|
'--parallel[Build images in parallel.]' \
|
||||||
'*:services:__docker-compose_services_from_build' && ret=0
|
'*:services:__docker-compose_services_from_build' && ret=0
|
||||||
;;
|
;;
|
||||||
(bundle)
|
|
||||||
_arguments \
|
|
||||||
$opts_help \
|
|
||||||
'--push-images[Automatically push images for any services which have a `build` option specified.]' \
|
|
||||||
'(--output -o)'{--output,-o}'[Path to write the bundle file to. Defaults to "<project name>.dab".]:file:_files' && ret=0
|
|
||||||
;;
|
|
||||||
(config)
|
(config)
|
||||||
_arguments \
|
_arguments \
|
||||||
$opts_help \
|
$opts_help \
|
||||||
|
@ -290,7 +284,7 @@ __docker-compose_subcommand() {
|
||||||
(up)
|
(up)
|
||||||
_arguments \
|
_arguments \
|
||||||
$opts_help \
|
$opts_help \
|
||||||
'(--abort-on-container-exit)-d[Detached mode: Run containers in the background, print new container names. Incompatible with --abort-on-container-exit.]' \
|
'(--abort-on-container-exit)-d[Detached mode: Run containers in the background, print new container names. Incompatible with --abort-on-container-exit and --attach-dependencies.]' \
|
||||||
$opts_no_color \
|
$opts_no_color \
|
||||||
$opts_no_deps \
|
$opts_no_deps \
|
||||||
$opts_force_recreate \
|
$opts_force_recreate \
|
||||||
|
@ -298,6 +292,7 @@ __docker-compose_subcommand() {
|
||||||
$opts_no_build \
|
$opts_no_build \
|
||||||
"(--no-build)--build[Build images before starting containers.]" \
|
"(--no-build)--build[Build images before starting containers.]" \
|
||||||
"(-d)--abort-on-container-exit[Stops all containers if any container was stopped. Incompatible with -d.]" \
|
"(-d)--abort-on-container-exit[Stops all containers if any container was stopped. Incompatible with -d.]" \
|
||||||
|
"(-d)--attach-dependencies[Attach to dependent containers. Incompatible with -d.]" \
|
||||||
'(-t --timeout)'{-t,--timeout}"[Use this timeout in seconds for container shutdown when attached or when containers are already running. (default: 10)]:seconds: " \
|
'(-t --timeout)'{-t,--timeout}"[Use this timeout in seconds for container shutdown when attached or when containers are already running. (default: 10)]:seconds: " \
|
||||||
'--scale[SERVICE=NUM Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present.]:service scale SERVICE=NUM: ' \
|
'--scale[SERVICE=NUM Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present.]:service scale SERVICE=NUM: ' \
|
||||||
'--exit-code-from=[Return the exit code of the selected service container. Implies --abort-on-container-exit]:service:__docker-compose_services' \
|
'--exit-code-from=[Return the exit code of the selected service container. Implies --abort-on-container-exit]:service:__docker-compose_services' \
|
||||||
|
@ -341,11 +336,13 @@ _docker-compose() {
|
||||||
'(- :)'{-h,--help}'[Get help]' \
|
'(- :)'{-h,--help}'[Get help]' \
|
||||||
'*'{-f,--file}"[${file_description}]:file:_files -g '*.yml'" \
|
'*'{-f,--file}"[${file_description}]:file:_files -g '*.yml'" \
|
||||||
'(-p --project-name)'{-p,--project-name}'[Specify an alternate project name (default: directory name)]:project name:' \
|
'(-p --project-name)'{-p,--project-name}'[Specify an alternate project name (default: directory name)]:project name:' \
|
||||||
|
'--env-file[Specify an alternate environment file (default: .env)]:env-file:_files' \
|
||||||
"--compatibility[If set, Compose will attempt to convert keys in v3 files to their non-Swarm equivalent]" \
|
"--compatibility[If set, Compose will attempt to convert keys in v3 files to their non-Swarm equivalent]" \
|
||||||
'(- :)'{-v,--version}'[Print version and exit]' \
|
'(- :)'{-v,--version}'[Print version and exit]' \
|
||||||
'--verbose[Show more output]' \
|
'--verbose[Show more output]' \
|
||||||
'--log-level=[Set log level]:level:(DEBUG INFO WARNING ERROR CRITICAL)' \
|
'--log-level=[Set log level]:level:(DEBUG INFO WARNING ERROR CRITICAL)' \
|
||||||
'--no-ansi[Do not print ANSI control characters]' \
|
'--no-ansi[Do not print ANSI control characters]' \
|
||||||
|
'--ansi=[Control when to print ANSI control characters]:when:(never always auto)' \
|
||||||
'(-H --host)'{-H,--host}'[Daemon socket to connect to]:host:' \
|
'(-H --host)'{-H,--host}'[Daemon socket to connect to]:host:' \
|
||||||
'--tls[Use TLS; implied by --tlsverify]' \
|
'--tls[Use TLS; implied by --tlsverify]' \
|
||||||
'--tlscacert=[Trust certs signed only by this CA]:ca path:' \
|
'--tlscacert=[Trust certs signed only by this CA]:ca path:' \
|
||||||
|
@ -359,6 +356,7 @@ _docker-compose() {
|
||||||
local -a relevant_compose_flags relevant_compose_repeatable_flags relevant_docker_flags compose_options docker_options
|
local -a relevant_compose_flags relevant_compose_repeatable_flags relevant_docker_flags compose_options docker_options
|
||||||
|
|
||||||
relevant_compose_flags=(
|
relevant_compose_flags=(
|
||||||
|
"--env-file"
|
||||||
"--file" "-f"
|
"--file" "-f"
|
||||||
"--host" "-H"
|
"--host" "-H"
|
||||||
"--project-name" "-p"
|
"--project-name" "-p"
|
||||||
|
|
|
@ -1,28 +1,24 @@
|
||||||
# Authors:
|
# support Compose v2 as docker CLI plugin
|
||||||
# https://github.com/tristola
|
DOCKER_CONTEXT=default command docker compose &>/dev/null \
|
||||||
#
|
&& dccmd='docker compose' \
|
||||||
# Docker-compose related zsh aliases
|
|| dccmd='docker-compose'
|
||||||
|
|
||||||
# Aliases ###################################################################
|
alias dco="$dccmd"
|
||||||
|
alias dcb="$dccmd build"
|
||||||
|
alias dce="$dccmd exec"
|
||||||
|
alias dcps="$dccmd ps"
|
||||||
|
alias dcrestart="$dccmd restart"
|
||||||
|
alias dcrm="$dccmd rm"
|
||||||
|
alias dcr="$dccmd run"
|
||||||
|
alias dcstop="$dccmd stop"
|
||||||
|
alias dcup="$dccmd up"
|
||||||
|
alias dcupb="$dccmd up --build"
|
||||||
|
alias dcupd="$dccmd up -d"
|
||||||
|
alias dcdn="$dccmd down"
|
||||||
|
alias dcl="$dccmd logs"
|
||||||
|
alias dclf="$dccmd logs -f"
|
||||||
|
alias dcpull="$dccmd pull"
|
||||||
|
alias dcstart="$dccmd start"
|
||||||
|
alias dck="$dccmd kill"
|
||||||
|
|
||||||
# Use dco as alias for docker-compose, since dc on *nix is 'dc - an arbitrary precision calculator'
|
unset dccmd
|
||||||
# https://www.gnu.org/software/bc/manual/dc-1.05/html_mono/dc.html
|
|
||||||
|
|
||||||
alias dco='docker-compose'
|
|
||||||
|
|
||||||
alias dcb='docker-compose build'
|
|
||||||
alias dce='docker-compose exec'
|
|
||||||
alias dcps='docker-compose ps'
|
|
||||||
alias dcrestart='docker-compose restart'
|
|
||||||
alias dcrm='docker-compose rm'
|
|
||||||
alias dcr='docker-compose run'
|
|
||||||
alias dcstop='docker-compose stop'
|
|
||||||
alias dcup='docker-compose up'
|
|
||||||
alias dcupb='docker-compose up --build'
|
|
||||||
alias dcupd='docker-compose up -d'
|
|
||||||
alias dcdn='docker-compose down'
|
|
||||||
alias dcl='docker-compose logs'
|
|
||||||
alias dclf='docker-compose logs -f'
|
|
||||||
alias dcpull='docker-compose pull'
|
|
||||||
alias dcstart='docker-compose start'
|
|
||||||
alias dck='docker-compose kill'
|
|
||||||
|
|
|
@ -20,7 +20,9 @@ function setup_using_base_dir() {
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ -z "${fzf_base}" ]]; then
|
if [[ -z "${fzf_base}" ]]; then
|
||||||
if (( ${+commands[brew]} )) && dir="$(brew --prefix fzf 2>/dev/null)"; then
|
if (( ${+commands[fzf-share]} )) && dir="$(fzf-share)" && [[ -d "${dir}" ]]; then
|
||||||
|
fzf_base="${dir}"
|
||||||
|
elif (( ${+commands[brew]} )) && dir="$(brew --prefix fzf 2>/dev/null)"; then
|
||||||
if [[ -d "${dir}" ]]; then
|
if [[ -d "${dir}" ]]; then
|
||||||
fzf_base="${dir}"
|
fzf_base="${dir}"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -47,6 +47,7 @@ plugins=(... git)
|
||||||
| gcb | git checkout -b |
|
| gcb | git checkout -b |
|
||||||
| gcf | git config --list |
|
| gcf | git config --list |
|
||||||
| gcl | git clone --recurse-submodules |
|
| gcl | git clone --recurse-submodules |
|
||||||
|
| gccd | git clone --recurse-submodules "$@" && cd "$(basename $_ .git)" |
|
||||||
| gclean | git clean -id |
|
| gclean | git clean -id |
|
||||||
| gpristine | git reset --hard && git clean -dffx |
|
| gpristine | git reset --hard && git clean -dffx |
|
||||||
| gcm | git checkout $(git_main_branch) |
|
| gcm | git checkout $(git_main_branch) |
|
||||||
|
@ -66,7 +67,7 @@ plugins=(... git)
|
||||||
| gds | git diff --staged |
|
| gds | git diff --staged |
|
||||||
| gdt | git diff-tree --no-commit-id --name-only -r |
|
| gdt | git diff-tree --no-commit-id --name-only -r |
|
||||||
| gdnolock | git diff $@ ":(exclude)package-lock.json" ":(exclude)*.lock" |
|
| gdnolock | git diff $@ ":(exclude)package-lock.json" ":(exclude)*.lock" |
|
||||||
| gdu | git diff @{u} |
|
| gdup | git diff @{upstream} |
|
||||||
| gdv | git diff -w $@ \| view - |
|
| gdv | git diff -w $@ \| view - |
|
||||||
| gdw | git diff --word-diff |
|
| gdw | git diff --word-diff |
|
||||||
| gf | git fetch |
|
| gf | git fetch |
|
||||||
|
@ -90,8 +91,8 @@ plugins=(... git)
|
||||||
| gignore | git update-index --assume-unchanged |
|
| gignore | git update-index --assume-unchanged |
|
||||||
| gignored | git ls-files -v \| grep "^[[:lower:]]" |
|
| gignored | git ls-files -v \| grep "^[[:lower:]]" |
|
||||||
| git-svn-dcommit-push | git svn dcommit && git push github $(git_main_branch):svntrunk |
|
| git-svn-dcommit-push | git svn dcommit && git push github $(git_main_branch):svntrunk |
|
||||||
| gk | gitk --all --branches |
|
| gk | gitk --all --branches &! |
|
||||||
| gke | gitk --all $(git log -g --pretty=%h) |
|
| gke | gitk --all $(git log -g --pretty=%h) &! |
|
||||||
| gl | git pull |
|
| gl | git pull |
|
||||||
| glg | git log --stat |
|
| glg | git log --stat |
|
||||||
| glgp | git log --stat -p |
|
| glgp | git log --stat -p |
|
||||||
|
@ -168,6 +169,8 @@ plugins=(... git)
|
||||||
| gsu | git submodule update |
|
| gsu | git submodule update |
|
||||||
| gsw | git switch |
|
| gsw | git switch |
|
||||||
| gswc | git switch -c |
|
| gswc | git switch -c |
|
||||||
|
| gswm | git switch $(git_main_branch) |
|
||||||
|
| gswd | git switch $(git_develop_branch) |
|
||||||
| gts | git tag -s |
|
| gts | git tag -s |
|
||||||
| gtv | git tag \| sort -V |
|
| gtv | git tag \| sort -V |
|
||||||
| gtl | gtl(){ git tag --sort=-v:refname -n -l ${1}* }; noglob gtl |
|
| gtl | gtl(){ git tag --sort=-v:refname -n -l ${1}* }; noglob gtl |
|
||||||
|
|
|
@ -97,6 +97,13 @@ alias gcas='git commit -a -s'
|
||||||
alias gcasm='git commit -a -s -m'
|
alias gcasm='git commit -a -s -m'
|
||||||
alias gcb='git checkout -b'
|
alias gcb='git checkout -b'
|
||||||
alias gcf='git config --list'
|
alias gcf='git config --list'
|
||||||
|
|
||||||
|
function gccd() {
|
||||||
|
command git clone --recurse-submodules "$@"
|
||||||
|
[[ -d "$_" ]] && cd "$_" || cd "${${_:t}%.git}"
|
||||||
|
}
|
||||||
|
compdef _git gccd=git-clone
|
||||||
|
|
||||||
alias gcl='git clone --recurse-submodules'
|
alias gcl='git clone --recurse-submodules'
|
||||||
alias gclean='git clean -id'
|
alias gclean='git clean -id'
|
||||||
alias gpristine='git reset --hard && git clean -dffx'
|
alias gpristine='git reset --hard && git clean -dffx'
|
||||||
|
@ -119,7 +126,7 @@ alias gdcw='git diff --cached --word-diff'
|
||||||
alias gdct='git describe --tags $(git rev-list --tags --max-count=1)'
|
alias gdct='git describe --tags $(git rev-list --tags --max-count=1)'
|
||||||
alias gds='git diff --staged'
|
alias gds='git diff --staged'
|
||||||
alias gdt='git diff-tree --no-commit-id --name-only -r'
|
alias gdt='git diff-tree --no-commit-id --name-only -r'
|
||||||
alias gdu='git diff @{u}'
|
alias gdup='git diff @{upstream}'
|
||||||
alias gdw='git diff --word-diff'
|
alias gdw='git diff --word-diff'
|
||||||
|
|
||||||
function gdnolock() {
|
function gdnolock() {
|
||||||
|
@ -201,8 +208,8 @@ alias gignore='git update-index --assume-unchanged'
|
||||||
alias gignored='git ls-files -v | grep "^[[:lower:]]"'
|
alias gignored='git ls-files -v | grep "^[[:lower:]]"'
|
||||||
alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk'
|
alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk'
|
||||||
|
|
||||||
alias gk='\gitk --all --branches'
|
alias gk='\gitk --all --branches &!'
|
||||||
alias gke='\gitk --all $(git log -g --pretty=%h)'
|
alias gke='\gitk --all $(git log -g --pretty=%h) &!'
|
||||||
|
|
||||||
alias gl='git pull'
|
alias gl='git pull'
|
||||||
alias glg='git log --stat'
|
alias glg='git log --stat'
|
||||||
|
@ -288,6 +295,8 @@ alias gstall='git stash --all'
|
||||||
alias gsu='git submodule update'
|
alias gsu='git submodule update'
|
||||||
alias gsw='git switch'
|
alias gsw='git switch'
|
||||||
alias gswc='git switch -c'
|
alias gswc='git switch -c'
|
||||||
|
alias gswm='git switch $(git_main_branch)'
|
||||||
|
alias gswd='git switch $(git_develop_branch)'
|
||||||
|
|
||||||
alias gts='git tag -s'
|
alias gts='git tag -s'
|
||||||
alias gtv='git tag | sort -V'
|
alias gtv='git tag | sort -V'
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
Enables [GPG's gpg-agent](https://www.gnupg.org/documentation/manuals/gnupg/) if it is not running.
|
Enables [GPG's gpg-agent](https://www.gnupg.org/documentation/manuals/gnupg/) if it is not running.
|
||||||
|
|
||||||
To use it, add gpg-agent to the plugins array of your zshrc file:
|
To use it, add `gpg-agent` to the plugins array of your zshrc file:
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
plugins=(... gpg-agent)
|
plugins=(... gpg-agent)
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
# Enable gpg-agent if it is not running-
|
|
||||||
# --use-standard-socket will work from version 2 upwards
|
|
||||||
|
|
||||||
AGENT_SOCK=$(gpgconf --list-dirs | grep agent-socket | cut -d : -f 2)
|
|
||||||
|
|
||||||
if [[ ! -S $AGENT_SOCK ]]; then
|
|
||||||
gpg-agent --daemon --use-standard-socket &>/dev/null
|
|
||||||
fi
|
|
||||||
export GPG_TTY=$TTY
|
export GPG_TTY=$TTY
|
||||||
|
|
||||||
# Set SSH to use gpg-agent if it's enabled
|
# Fix for passphrase prompt on the correct tty
|
||||||
GNUPGCONFIG="${GNUPGHOME:-"$HOME/.gnupg"}/gpg-agent.conf"
|
# See https://www.gnupg.org/documentation/manuals/gnupg/Agent-Options.html#option-_002d_002denable_002dssh_002dsupport
|
||||||
if [[ -r $GNUPGCONFIG ]] && command grep -q enable-ssh-support "$GNUPGCONFIG"; then
|
function _gpg-agent_update-tty_preexec {
|
||||||
export SSH_AUTH_SOCK="$AGENT_SOCK.ssh"
|
gpg-connect-agent updatestartuptty /bye &>/dev/null
|
||||||
|
}
|
||||||
|
autoload -U add-zsh-hook
|
||||||
|
add-zsh-hook preexec _gpg-agent_update-tty_preexec
|
||||||
|
|
||||||
|
# If enable-ssh-support is set, fix ssh agent integration
|
||||||
|
if [[ $(gpgconf --list-options gpg-agent | awk -F: '$1=="enable-ssh-support" {print $10}') = 1 ]]; then
|
||||||
unset SSH_AGENT_PID
|
unset SSH_AGENT_PID
|
||||||
|
if [[ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]]; then
|
||||||
|
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -4,11 +4,15 @@ if ! (( $+commands[curl] )); then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function hitokoto {
|
function hitokoto {
|
||||||
emulate -L zsh
|
setopt localoptions nopromptsubst
|
||||||
Q=$(curl -s --connect-timeout 2 "https://v1.hitokoto.cn" | jq -j '.hitokoto+"\t"+.from')
|
|
||||||
|
|
||||||
TXT=$(echo "$Q" | awk -F '\t' '{print $1}')
|
# Get hitokoto data
|
||||||
WHO=$(echo "$Q" | awk -F '\t' '{print $2}')
|
local -a data
|
||||||
|
data=("${(ps:\n:)"$(command curl -s --connect-timeout 2 "https://v1.hitokoto.cn" | command jq -j '.hitokoto+"\n"+.from')"}")
|
||||||
|
|
||||||
[[ -n "$WHO" && -n "$TXT" ]] && print -P "%F{3}${WHO}%f: “%F{5}${TXT}%f”"
|
# Exit if could not fetch hitokoto
|
||||||
|
[[ -n "$data" ]] || return 0
|
||||||
|
|
||||||
|
local quote="${data[1]}" author="${data[2]}"
|
||||||
|
print -P "%F{3}${author}%f: “%F{5}${quote}%f”"
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ if [[ -n "$JSONTOOLS_METHOD" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If method undefined, find the first one that is installed
|
# If method undefined, find the first one that is installed
|
||||||
if [[ ! -v JSONTOOLS_METHOD ]]; then
|
if [[ -z "$JSONTOOLS_METHOD" ]]; then
|
||||||
for JSONTOOLS_METHOD in node python ruby; do
|
for JSONTOOLS_METHOD in node python ruby; do
|
||||||
# If method found, break out of loop
|
# If method found, break out of loop
|
||||||
(( $+commands[$JSONTOOLS_METHOD] )) && break
|
(( $+commands[$JSONTOOLS_METHOD] )) && break
|
||||||
|
@ -16,7 +16,7 @@ if [[ ! -v JSONTOOLS_METHOD ]]; then
|
||||||
done
|
done
|
||||||
|
|
||||||
# If no methods were found, exit the plugin
|
# If no methods were found, exit the plugin
|
||||||
[[ -v JSONTOOLS_METHOD ]] || return 1
|
[[ -n "$JSONTOOLS_METHOD" ]] || return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Define json tools for each method
|
# Define json tools for each method
|
||||||
|
|
63
plugins/macos/README.md
Normal file
63
plugins/macos/README.md
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
# MacOS plugin
|
||||||
|
|
||||||
|
This plugin provides a few utilities to make it more enjoyable on macOS (previously named OSX).
|
||||||
|
|
||||||
|
To start using it, add the `macos` plugin to your plugins array in `~/.zshrc`:
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
plugins=(... macos)
|
||||||
|
```
|
||||||
|
|
||||||
|
Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
|
||||||
|
|
||||||
|
## Commands
|
||||||
|
|
||||||
|
| Command | Description |
|
||||||
|
| :------------ | :------------------------------------------------------- |
|
||||||
|
| `tab` | Open the current directory in a new tab |
|
||||||
|
| `split_tab` | Split the current terminal tab horizontally |
|
||||||
|
| `vsplit_tab` | Split the current terminal tab vertically |
|
||||||
|
| `ofd` | Open the current directory in a Finder window |
|
||||||
|
| `pfd` | Return the path of the frontmost Finder window |
|
||||||
|
| `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 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 |
|
||||||
|
| `freespace` | Erases purgeable disk space with 0s on the selected disk |
|
||||||
|
|
||||||
|
## Acknowledgements
|
||||||
|
|
||||||
|
This application makes use of the following third party scripts:
|
||||||
|
|
||||||
|
[shpotify](https://github.com/hnarayanan/shpotify)
|
||||||
|
|
||||||
|
Copyright (c) 2012–2019 [Harish Narayanan](https://harishnarayanan.org/).
|
||||||
|
|
||||||
|
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.
|
|
@ -1,3 +1,9 @@
|
||||||
|
# Check if 'osx' is still in the plugins list and prompt to change to 'macos'
|
||||||
|
if [[ -n "${plugins[(r)osx]}" ]]; then
|
||||||
|
print ${(%):-"%F{yellow}The \`osx\` plugin is deprecated and has been renamed to \`macos\`."}
|
||||||
|
print ${(%):-"Please update your .zshrc to use the \`%Bmacos%b\` plugin instead.%f"}
|
||||||
|
fi
|
||||||
|
|
||||||
# Open the current directory in a Finder window
|
# Open the current directory in a Finder window
|
||||||
alias ofd='open_command $PWD'
|
alias ofd='open_command $PWD'
|
||||||
|
|
||||||
|
@ -11,7 +17,7 @@ function btrestart() {
|
||||||
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
|
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
|
||||||
}
|
}
|
||||||
|
|
||||||
function _omz_osx_get_frontmost_app() {
|
function _omz_macos_get_frontmost_app() {
|
||||||
osascript 2>/dev/null <<EOF
|
osascript 2>/dev/null <<EOF
|
||||||
tell application "System Events"
|
tell application "System Events"
|
||||||
name of first item of (every process whose frontmost is true)
|
name of first item of (every process whose frontmost is true)
|
||||||
|
@ -24,7 +30,7 @@ function tab() {
|
||||||
local command="cd \\\"$PWD\\\"; clear"
|
local command="cd \\\"$PWD\\\"; clear"
|
||||||
(( $# > 0 )) && command="${command}; $*"
|
(( $# > 0 )) && command="${command}; $*"
|
||||||
|
|
||||||
local the_app=$(_omz_osx_get_frontmost_app)
|
local the_app=$(_omz_macos_get_frontmost_app)
|
||||||
|
|
||||||
if [[ "$the_app" == 'Terminal' ]]; then
|
if [[ "$the_app" == 'Terminal' ]]; then
|
||||||
# Discarding stdout to quash "tab N of window id XXX" output
|
# Discarding stdout to quash "tab N of window id XXX" output
|
||||||
|
@ -77,7 +83,7 @@ function vsplit_tab() {
|
||||||
local command="cd \\\"$PWD\\\"; clear"
|
local command="cd \\\"$PWD\\\"; clear"
|
||||||
(( $# > 0 )) && command="${command}; $*"
|
(( $# > 0 )) && command="${command}; $*"
|
||||||
|
|
||||||
local the_app=$(_omz_osx_get_frontmost_app)
|
local the_app=$(_omz_macos_get_frontmost_app)
|
||||||
|
|
||||||
if [[ "$the_app" == 'iTerm' ]]; then
|
if [[ "$the_app" == 'iTerm' ]]; then
|
||||||
osascript <<EOF
|
osascript <<EOF
|
||||||
|
@ -125,7 +131,7 @@ function split_tab() {
|
||||||
local command="cd \\\"$PWD\\\"; clear"
|
local command="cd \\\"$PWD\\\"; clear"
|
||||||
(( $# > 0 )) && command="${command}; $*"
|
(( $# > 0 )) && command="${command}; $*"
|
||||||
|
|
||||||
local the_app=$(_omz_osx_get_frontmost_app)
|
local the_app=$(_omz_macos_get_frontmost_app)
|
||||||
|
|
||||||
if [[ "$the_app" == 'iTerm' ]]; then
|
if [[ "$the_app" == 'iTerm' ]]; then
|
||||||
osascript 2>/dev/null <<EOF
|
osascript 2>/dev/null <<EOF
|
||||||
|
@ -233,6 +239,29 @@ function rmdsstore() {
|
||||||
find "${@:-.}" -type f -name .DS_Store -delete
|
find "${@:-.}" -type f -name .DS_Store -delete
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Erases purgeable disk space with 0s on the selected disk
|
||||||
|
function freespace(){
|
||||||
|
if [[ -z "$1" ]]; then
|
||||||
|
echo "Usage: $0 <disk>"
|
||||||
|
echo "Example: $0 /dev/disk1s1"
|
||||||
|
echo
|
||||||
|
echo "Possible disks:"
|
||||||
|
df -h | awk 'NR == 1 || /^\/dev\/disk/'
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Cleaning purgeable files from disk: $1 ...."
|
||||||
|
diskutil secureErase freespace 0 $1
|
||||||
|
}
|
||||||
|
|
||||||
|
_freespace() {
|
||||||
|
local -a disks
|
||||||
|
disks=("${(@f)"$(df | awk '/^\/dev\/disk/{ printf $1 ":"; for (i=9; i<=NF; i++) printf $i FS; print "" }')"}")
|
||||||
|
_describe disks disks
|
||||||
|
}
|
||||||
|
|
||||||
|
compdef _freespace freespace
|
||||||
|
|
||||||
# Music / iTunes control function
|
# Music / iTunes control function
|
||||||
source "${0:h:A}/music"
|
source "${0:h:A}/music"
|
||||||
|
|
1
plugins/macos/osx.plugin.zsh
Symbolic link
1
plugins/macos/osx.plugin.zsh
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
macos.plugin.zsh
|
|
@ -30,7 +30,8 @@ plugins=(... mercurial)
|
||||||
| `hgl` | `hg pull -u` |
|
| `hgl` | `hg pull -u` |
|
||||||
| `hglr` | `hg pull --rebase` |
|
| `hglr` | `hg pull --rebase` |
|
||||||
| `hgo` | `hg outgoing` |
|
| `hgo` | `hg outgoing` |
|
||||||
|
| `hglg` | `hg log --stat -v` |
|
||||||
|
| `hglgp`| `hg log --stat -p -v` |
|
||||||
## Prompt usage
|
## Prompt usage
|
||||||
|
|
||||||
- Switch to a theme which uses `hg_prompt_info`
|
- Switch to a theme which uses `hg_prompt_info`
|
||||||
|
|
|
@ -17,6 +17,8 @@ alias hgi='hg incoming'
|
||||||
alias hgl='hg pull -u'
|
alias hgl='hg pull -u'
|
||||||
alias hglr='hg pull --rebase'
|
alias hglr='hg pull --rebase'
|
||||||
alias hgo='hg outgoing'
|
alias hgo='hg outgoing'
|
||||||
|
alias hglg='hg log --stat -v'
|
||||||
|
alias hglgp='hg log --stat -p -v'
|
||||||
|
|
||||||
function in_hg() {
|
function in_hg() {
|
||||||
if $(hg branch > /dev/null 2>&1); then
|
if $(hg branch > /dev/null 2>&1); then
|
||||||
|
|
|
@ -10,10 +10,10 @@ plugins=(... mix)
|
||||||
## Supported Task Types
|
## Supported Task Types
|
||||||
|
|
||||||
| Task Type | Documentation |
|
| Task Type | Documentation |
|
||||||
|-------------------------|----------------------------------------------------------|
|
|--------------------------|----------------------------------------------------------|
|
||||||
| Elixir | [Elixir Lang](https://elixir-lang.org/) |
|
| Elixir | [Elixir Lang](https://elixir-lang.org/) |
|
||||||
| Phoenix v1.2.1 and below| [Phoenix](https://hexdocs.pm/phoenix/1.2.1/Phoenix.html) |
|
| Phoenix v1.2.1 and below | [Phoenix](https://hexdocs.pm/phoenix/1.2.1/Phoenix.html) |
|
||||||
| Phoenix v1.3.0 and above| [Phoenix](https://hexdocs.pm/phoenix/Phoenix.html) |
|
| Phoenix v1.3.0 and above | [Phoenix](https://hexdocs.pm/phoenix/Phoenix.html) |
|
||||||
| Ecto | [Ecto](https://hexdocs.pm/ecto/Ecto.html) |
|
| Ecto | [Ecto](https://hexdocs.pm/ecto/Ecto.html) |
|
||||||
| Hex | [Hex](https://hex.pm/) |
|
| Hex | [Hex](https://hex.pm/) |
|
||||||
| Nerves | [Nerves](https://nerves-project.org/) |
|
| Nerves | [Nerves](https://nerves-project.org/) |
|
||||||
|
|
|
@ -5,8 +5,10 @@
|
||||||
|
|
||||||
local -a _1st_arguments
|
local -a _1st_arguments
|
||||||
_1st_arguments=(
|
_1st_arguments=(
|
||||||
|
'app.config:Configures all registered apps'
|
||||||
'app.start:Start all registered apps'
|
'app.start:Start all registered apps'
|
||||||
'archive:List all archives'
|
'app.tree:Prints the application tree'
|
||||||
|
'archive:Lists installed archives'
|
||||||
'archive.build:Archive this project into a .ez file'
|
'archive.build:Archive this project into a .ez file'
|
||||||
'archive.install:Install an archive locally'
|
'archive.install:Install an archive locally'
|
||||||
'archive.uninstall:Uninstall archives'
|
'archive.uninstall:Uninstall archives'
|
||||||
|
@ -18,6 +20,7 @@ _1st_arguments=(
|
||||||
"deps.clean:Remove the given dependencies' files"
|
"deps.clean:Remove the given dependencies' files"
|
||||||
'deps.compile:Compile dependencies'
|
'deps.compile:Compile dependencies'
|
||||||
'deps.get:Get all out of date dependencies'
|
'deps.get:Get all out of date dependencies'
|
||||||
|
'deps.tree:Prints the dependency tree'
|
||||||
'deps.unlock:Unlock the given dependencies'
|
'deps.unlock:Unlock the given dependencies'
|
||||||
'deps.update:Update the given dependencies'
|
'deps.update:Update the given dependencies'
|
||||||
'do:Executes the tasks separated by comma'
|
'do:Executes the tasks separated by comma'
|
||||||
|
@ -30,27 +33,39 @@ _1st_arguments=(
|
||||||
'ecto.migrate:Runs Ecto migration'
|
'ecto.migrate:Runs Ecto migration'
|
||||||
'ecto.migrations:Displays the up / down migration status'
|
'ecto.migrations:Displays the up / down migration status'
|
||||||
'ecto.rollback:Reverts applied migrations'
|
'ecto.rollback:Reverts applied migrations'
|
||||||
|
'escript:Lists installed escripts'
|
||||||
'escript.build:Builds an escript for the project'
|
'escript.build:Builds an escript for the project'
|
||||||
|
'escript.install:Installs an escript locally'
|
||||||
|
'escript.uninstall:Uninstalls escripts'
|
||||||
'firmware:Nerves - Build a firmware image for the selected target platform'
|
'firmware:Nerves - Build a firmware image for the selected target platform'
|
||||||
'firmware.burn:Nerves - Writes the generated firmware image to an attached SDCard or file'
|
'firmware.burn:Nerves - Writes the generated firmware image to an attached SDCard or file'
|
||||||
'firmware.image:Nerves - Create a firmware image file that can be copied byte-for-byte'
|
'firmware.image:Nerves - Create a firmware image file that can be copied byte-for-byte'
|
||||||
'format:Formats the given files and patterns'
|
'format:Formats the given files and patterns'
|
||||||
'help:Print help information for tasks'
|
'help:Print help information for tasks'
|
||||||
'hex:Print hex help information'
|
'hex:Print hex help information'
|
||||||
'hex.config:Read or update hex config'
|
'hex.audit:Shows retired Hex deps for the current project'
|
||||||
'hex.docs:Publish docs for package'
|
'hex.build:Builds a new package version locally'
|
||||||
|
'hex.config:Reads, updates or deletes local Hex config'
|
||||||
|
'hex.docs:Fetches or opens documentation of a package'
|
||||||
'hex.info:Print hex information'
|
'hex.info:Print hex information'
|
||||||
|
'hex.organization:Manages Hex.pm organizations'
|
||||||
'hex.key:Hex API key tasks'
|
'hex.key:Hex API key tasks'
|
||||||
'hex.outdated:Shows outdated hex deps for the current project'
|
'hex.outdated:Shows outdated Hex deps for the current project'
|
||||||
'hex.owner:Hex package ownership tasks'
|
'hex.owner:Manages Hex package ownership'
|
||||||
|
'hex.package:Fetches or diffs packages'
|
||||||
'hex.publish:Publish a new package version'
|
'hex.publish:Publish a new package version'
|
||||||
|
'hex.registry:Manages local Hex registries'
|
||||||
|
'hex.repo:Manages Hex repositories'
|
||||||
|
'hex.retire:Retires a package version'
|
||||||
'hex.search:Search for package names'
|
'hex.search:Search for package names'
|
||||||
'hex.user:Hex user tasks'
|
'hex.sponsor:Show Hex packages accepting sponsorships'
|
||||||
|
'hex.user:Manages your Hex user account'
|
||||||
'loadconfig:Loads and persists the given configuration'
|
'loadconfig:Loads and persists the given configuration'
|
||||||
'local:List local tasks'
|
'local:List local tasks'
|
||||||
'local.hex:Install hex locally'
|
'local.hex:Install hex locally'
|
||||||
'local.phoenix:Updates Phoenix locally'
|
'local.phoenix:Updates Phoenix locally'
|
||||||
'local.phx:Updates the Phoenix project generator locally'
|
'local.phx:Updates the Phoenix project generator locally'
|
||||||
|
'local.public_keys:Manages public keys'
|
||||||
'local.rebar:Install rebar locally'
|
'local.rebar:Install rebar locally'
|
||||||
'nerves.artifact:Create an artifact for a specified Nerves package'
|
'nerves.artifact:Create an artifact for a specified Nerves package'
|
||||||
'nerves.artifact.get:Nerves get artifacts'
|
'nerves.artifact.get:Nerves get artifacts'
|
||||||
|
@ -69,21 +84,33 @@ _1st_arguments=(
|
||||||
'phoenix.server:Starts applications and their servers'
|
'phoenix.server:Starts applications and their servers'
|
||||||
'phx.digest:Digests and compresses static files'
|
'phx.digest:Digests and compresses static files'
|
||||||
'phx.digest.clean:Removes old versions of static assets.'
|
'phx.digest.clean:Removes old versions of static assets.'
|
||||||
|
'phx.gen.auth:Generates authentication logic for a resource'
|
||||||
|
'phx.gen.cert:Generates a self-signed certificate for HTTPS testing'
|
||||||
'phx.gen.channel:Generates a Phoenix channel'
|
'phx.gen.channel:Generates a Phoenix channel'
|
||||||
'phx.gen.context:Generates a context with functions around an Ecto schema'
|
'phx.gen.context:Generates a context with functions around an Ecto schema'
|
||||||
'phx.gen.embedded:Generates an embedded Ecto schema file'
|
'phx.gen.embedded:Generates an embedded Ecto schema file'
|
||||||
'phx.gen.html:Generates controller, views, and context for an HTML resource'
|
'phx.gen.html:Generates controller, views, and context for an HTML resource'
|
||||||
'phx.gen.json:Generates controller, views, and context for a JSON resource'
|
'phx.gen.json:Generates controller, views, and context for a JSON resource'
|
||||||
|
'phx.gen.live:Generates LiveView, templates, and context for a resource'
|
||||||
|
'phx.gen.notifier:Generates a notifier that delivers emails by default'
|
||||||
'phx.gen.presence:Generates a Presence tracker'
|
'phx.gen.presence:Generates a Presence tracker'
|
||||||
'phx.gen.schema:Generates an Ecto schema and migration file'
|
'phx.gen.schema:Generates an Ecto schema and migration file'
|
||||||
'phx.gen.secret:Generates a secret'
|
'phx.gen.secret:Generates a secret'
|
||||||
'phx.new:Creates a new Phoenix v1.3.0 application'
|
'phx.gen.socket:Generates a Phoenix socket handler'
|
||||||
|
'phx.new:Creates a new Phoenix application'
|
||||||
'phx.new.ecto:Creates a new Ecto project within an umbrella project'
|
'phx.new.ecto:Creates a new Ecto project within an umbrella project'
|
||||||
'phx.new.web:Creates a new Phoenix web project within an umbrella project'
|
'phx.new.web:Creates a new Phoenix web project within an umbrella project'
|
||||||
'phx.routes:Prints all routes'
|
'phx.routes:Prints all routes'
|
||||||
'phx.server:Starts applications and their servers'
|
'phx.server:Starts applications and their servers'
|
||||||
|
'profile.cprof:Profiles the given file or expression with cprof'
|
||||||
|
'profile.eprof:Profiles the given file or expression with eprof'
|
||||||
|
'profile.fprof:Profiles the given file or expression with fprof'
|
||||||
|
'release:Assembles a self-contained release'
|
||||||
|
'release.init:Generates sample files for releases'
|
||||||
'run:Run the given file or expression'
|
'run:Run the given file or expression'
|
||||||
"test:Run a project's tests"
|
"test:Run a project's tests"
|
||||||
|
'test.coverage:Build report from exported test coverage'
|
||||||
|
'xref:Prints cross reference information'
|
||||||
'--help:Describe available tasks'
|
'--help:Describe available tasks'
|
||||||
'--version:Prints the Elixir version information'
|
'--version:Prints the Elixir version information'
|
||||||
)
|
)
|
||||||
|
@ -93,7 +120,7 @@ __task_list ()
|
||||||
local expl
|
local expl
|
||||||
declare -a tasks
|
declare -a tasks
|
||||||
|
|
||||||
tasks=(app.start archive archive.build archive.install archive.uninstall clean cmd compile compile.protocols deps deps.clean deps.compile deps.get deps.unlock deps.update do escript.build format help hex hex.config hex.docs hex.info hex.key hex.outdated hex.owner hex.publish hex.search hex.user loadconfig local local.hex local.rebar new phoenix.digest phoenix.gen.channel phoenix.gen.html phoenix.gen.json phoenix.gen.model phoenix.gen.secret phoenix.new phoenix.routes phoenix.server phx.digest phx.digest.clean phx.gen.channel phx.gen.context phx.gen.embedded phx.gen.html phx.gen.json phx.gen.presence phx.gen.schema phx.gen.secret phx.new phx.new.ecto phx.new.web phx.routes phx.server run test)
|
tasks=(app.config app.start app.tree archive archive.build archive.install archive.uninstall clean cmd compile compile.protocols deps deps.clean deps.compile deps.get deps.tree deps.unlock deps.update do ecto.create ecto.drop ecto.dump ecto.gen.migration ecto.gen.repo ecto.load ecto.migrate ecto.migrations ecto.rollback escript escript.build escript.install escript.uninstall firmware firmware.burn firmware.image format help hex hex.audit hex.build hex.config hex.docs hex.info hex.organization hex.key hex.outdated hex.owner hex.package hex.publish hex.registry hex.repo hex.retire hex.search hex.sponsor hex.user loadconfig local local.hex local.phoenix local.phx local.public_keys local.rebar nerves.artifact nerves.artifact.get nerves.info nerves.new nerves.release.init new phoenix.digest phoenix.gen.channel phoenix.gen.html phoenix.gen.json phoenix.gen.model phoenix.gen.secret phoenix.new phoenix.routes phoenix.server phx.digest phx.digest.clean phx.gen.auth phx.gen.cert phx.gen.channel phx.gen.context phx.gen.embedded phx.gen.html phx.gen.json phx.gen.live phx.gen.notifier phx.gen.presence phx.gen.schema phx.gen.secret phx.gen.socket phx.new phx.new.ecto phx.new.web phx.routes phx.server profile.cprof profile.eprof profile.fprof release release.init run test test.coverage xref)
|
||||||
|
|
||||||
_wanted tasks expl 'help' compadd $tasks
|
_wanted tasks expl 'help' compadd $tasks
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,17 @@
|
||||||
# Calls ./mvnw if found, otherwise execute the original mvn
|
# Calls mvnw if found in the current project, otherwise execute the original mvn
|
||||||
mvn-or-mvnw() {
|
mvn-or-mvnw() {
|
||||||
if [ -x ./mvnw ]; then
|
local dir="$PWD"
|
||||||
echo "executing mvnw instead of mvn"
|
while [[ ! -x "$dir/mvnw" && "$dir" != / ]]; do
|
||||||
./mvnw "$@"
|
dir="${dir:h}"
|
||||||
else
|
done
|
||||||
command mvn "$@"
|
|
||||||
|
if [[ -x "$dir/mvnw" ]]; then
|
||||||
|
echo "Running \`$dir/mvnw\`..." >&2
|
||||||
|
"$dir/mvnw" "$@"
|
||||||
|
return $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
command mvn "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Wrapper function for Maven's mvn command. Based on https://gist.github.com/1027800
|
# Wrapper function for Maven's mvn command. Based on https://gist.github.com/1027800
|
||||||
|
@ -17,6 +23,7 @@ mvn-color() {
|
||||||
local TEXT_BLUE=$(echoti setaf 4)
|
local TEXT_BLUE=$(echoti setaf 4)
|
||||||
local TEXT_WHITE=$(echoti setaf 7)
|
local TEXT_WHITE=$(echoti setaf 7)
|
||||||
local RESET_FORMATTING=$(echoti sgr0)
|
local RESET_FORMATTING=$(echoti sgr0)
|
||||||
|
|
||||||
(
|
(
|
||||||
# Filter mvn output using sed. Before filtering set the locale to C, so invalid characters won't break some sed implementations
|
# Filter mvn output using sed. Before filtering set the locale to C, so invalid characters won't break some sed implementations
|
||||||
unset LANG
|
unset LANG
|
||||||
|
@ -33,7 +40,7 @@ mvn-color() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
# either use orignal mvn or the mvn wrapper
|
# either use original mvn or the mvn wrapper
|
||||||
alias mvn="mvn-or-mvnw"
|
alias mvn="mvn-or-mvnw"
|
||||||
|
|
||||||
# Run mvn against the pom found in a project's root directory (assumes a git repo)
|
# Run mvn against the pom found in a project's root directory (assumes a git repo)
|
||||||
|
|
1
plugins/osx
Symbolic link
1
plugins/osx
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
macos
|
|
@ -1,62 +0,0 @@
|
||||||
# OSX plugin
|
|
||||||
|
|
||||||
This plugin provides a few utilities to make it more enjoyable on macOS (previously named OSX).
|
|
||||||
|
|
||||||
To start using it, add the `osx` plugin to your plugins array in `~/.zshrc`:
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
plugins=(... osx)
|
|
||||||
```
|
|
||||||
|
|
||||||
Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
|
|
||||||
|
|
||||||
## Commands
|
|
||||||
|
|
||||||
| Command | Description |
|
|
||||||
| :-------------- | :---------------------------------------------------- |
|
|
||||||
| `tab` | Open the current directory in a new tab |
|
|
||||||
| `split_tab` | Split the current terminal tab horizontally |
|
|
||||||
| `vsplit_tab` | Split the current terminal tab vertically |
|
|
||||||
| `ofd` | Open the current directory in a Finder window |
|
|
||||||
| `pfd` | Return the path of the frontmost Finder window |
|
|
||||||
| `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 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
|
|
||||||
|
|
||||||
This application makes use of the following third party scripts:
|
|
||||||
|
|
||||||
[shpotify](https://github.com/hnarayanan/shpotify)
|
|
||||||
|
|
||||||
Copyright (c) 2012–2019 [Harish Narayanan](https://harishnarayanan.org/).
|
|
||||||
|
|
||||||
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.
|
|
|
@ -57,6 +57,7 @@
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
|
||||||
[[ -z $HISTORY_BASE ]] && HISTORY_BASE="$HOME/.directory_history"
|
[[ -z $HISTORY_BASE ]] && HISTORY_BASE="$HOME/.directory_history"
|
||||||
|
[[ -z $HISTORY_START_WITH_GLOBAL ]] && HISTORY_START_WITH_GLOBAL=false
|
||||||
[[ -z $PER_DIRECTORY_HISTORY_TOGGLE ]] && PER_DIRECTORY_HISTORY_TOGGLE='^G'
|
[[ -z $PER_DIRECTORY_HISTORY_TOGGLE ]] && PER_DIRECTORY_HISTORY_TOGGLE='^G'
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
|
@ -66,9 +67,11 @@
|
||||||
function per-directory-history-toggle-history() {
|
function per-directory-history-toggle-history() {
|
||||||
if [[ $_per_directory_history_is_global == true ]]; then
|
if [[ $_per_directory_history_is_global == true ]]; then
|
||||||
_per-directory-history-set-directory-history
|
_per-directory-history-set-directory-history
|
||||||
|
_per_directory_history_is_global=false
|
||||||
print -n "\nusing local history"
|
print -n "\nusing local history"
|
||||||
else
|
else
|
||||||
_per-directory-history-set-global-history
|
_per-directory-history-set-global-history
|
||||||
|
_per_directory_history_is_global=true
|
||||||
print -n "\nusing global history"
|
print -n "\nusing global history"
|
||||||
fi
|
fi
|
||||||
zle .push-line
|
zle .push-line
|
||||||
|
@ -114,13 +117,32 @@ function _per-directory-history-addhistory() {
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
print -Sr -- "${1%%$'\n'}"
|
print -Sr -- "${1%%$'\n'}"
|
||||||
|
# instantly write history if set options require it.
|
||||||
|
if [[ -o share_history ]] || \
|
||||||
|
[[ -o inc_append_history ]] || \
|
||||||
|
[[ -o inc_append_history_time ]]; then
|
||||||
|
fc -AI $HISTFILE
|
||||||
|
fc -AI $_per_directory_history_directory
|
||||||
|
fi
|
||||||
fc -p $_per_directory_history_directory
|
fc -p $_per_directory_history_directory
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _per-directory-history-precmd() {
|
||||||
|
if [[ $_per_directory_history_initialized == false ]]; then
|
||||||
|
_per_directory_history_initialized=true
|
||||||
|
|
||||||
|
if [[ $HISTORY_START_WITH_GLOBAL == true ]]; then
|
||||||
|
_per-directory-history-set-global-history
|
||||||
|
_per_directory_history_is_global=true
|
||||||
|
else
|
||||||
|
_per-directory-history-set-directory-history
|
||||||
|
_per_directory_history_is_global=false
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function _per-directory-history-set-directory-history() {
|
function _per-directory-history-set-directory-history() {
|
||||||
if [[ $_per_directory_history_is_global == true ]]; then
|
|
||||||
fc -AI $HISTFILE
|
fc -AI $HISTFILE
|
||||||
local original_histsize=$HISTSIZE
|
local original_histsize=$HISTSIZE
|
||||||
HISTSIZE=0
|
HISTSIZE=0
|
||||||
|
@ -128,11 +150,9 @@ function _per-directory-history-set-directory-history() {
|
||||||
if [[ -e "$_per_directory_history_directory" ]]; then
|
if [[ -e "$_per_directory_history_directory" ]]; then
|
||||||
fc -R "$_per_directory_history_directory"
|
fc -R "$_per_directory_history_directory"
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
_per_directory_history_is_global=false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _per-directory-history-set-global-history() {
|
function _per-directory-history-set-global-history() {
|
||||||
if [[ $_per_directory_history_is_global == false ]]; then
|
|
||||||
fc -AI $_per_directory_history_directory
|
fc -AI $_per_directory_history_directory
|
||||||
local original_histsize=$HISTSIZE
|
local original_histsize=$HISTSIZE
|
||||||
HISTSIZE=0
|
HISTSIZE=0
|
||||||
|
@ -140,17 +160,15 @@ function _per-directory-history-set-global-history() {
|
||||||
if [[ -e "$HISTFILE" ]]; then
|
if [[ -e "$HISTFILE" ]]; then
|
||||||
fc -R "$HISTFILE"
|
fc -R "$HISTFILE"
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
_per_directory_history_is_global=true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mkdir -p ${_per_directory_history_directory:h}
|
||||||
|
|
||||||
#add functions to the exec list for chpwd and zshaddhistory
|
#add functions to the exec list for chpwd and zshaddhistory
|
||||||
autoload -U add-zsh-hook
|
autoload -U add-zsh-hook
|
||||||
add-zsh-hook chpwd _per-directory-history-change-directory
|
add-zsh-hook chpwd _per-directory-history-change-directory
|
||||||
add-zsh-hook zshaddhistory _per-directory-history-addhistory
|
add-zsh-hook zshaddhistory _per-directory-history-addhistory
|
||||||
|
add-zsh-hook precmd _per-directory-history-precmd
|
||||||
|
|
||||||
#start in directory mode
|
# set initialized flag to false
|
||||||
mkdir -p ${_per_directory_history_directory:h}
|
_per_directory_history_initialized=false
|
||||||
_per_directory_history_is_global=true
|
|
||||||
_per-directory-history-set-directory-history
|
|
||||||
|
|
|
@ -1,20 +1,23 @@
|
||||||
## percol
|
# percol
|
||||||
|
|
||||||
Provides some useful function to make [percol](https://github.com/mooz/percol) work with zsh history and [jump plugin](https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/jump/jump.plugin.zsh)
|
Provides some useful function to make [percol](https://github.com/mooz/percol) work with zsh history and
|
||||||
|
the [jump plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/jump), optionally.
|
||||||
|
|
||||||
### Requirements
|
To use it, add `percol` to the plugins array in your zshrc:
|
||||||
|
|
||||||
```shell
|
```zsh
|
||||||
pip install percol
|
plugins=(... percol)
|
||||||
```
|
```
|
||||||
|
|
||||||
And [jump](https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/jump/jump.plugin.zsh) for `oh-my-zsh` is a optional requirement.
|
## Requirements
|
||||||
|
|
||||||
### Usage
|
- `percol`: install with `pip install percol`.
|
||||||
|
|
||||||
For default
|
- (_Optional_) [`jump`](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/jump) plugin: needs to be
|
||||||
|
enabled before the `percol` plugin.
|
||||||
|
|
||||||
- `^-r` bind to `percol_select_history`.You can use it to grep your history with percol.
|
## Usage
|
||||||
|
|
||||||
- `^-b` bind to `percol_select_marks`.You can use it to grep your bookmarks with percol.
|
- <kbd>CTRL-R</kbd> (bound to `percol_select_history`): you can use it to grep your history with percol.
|
||||||
|
|
||||||
|
- <kbd>CTRL-B</kbd> (bound to `percol_select_marks`): you can use it to grep your jump bookmarks with percol.
|
||||||
|
|
|
@ -1,22 +1,25 @@
|
||||||
if which percol &> /dev/null; then
|
(( ${+commands[percol]} )) || return
|
||||||
function percol_select_history() {
|
|
||||||
local tac
|
function percol_select_history() {
|
||||||
which gtac &> /dev/null && tac="gtac" || { which tac &> /dev/null && tac="tac" || { tac="tail -r" } }
|
# print history in reverse order (from -1 (latest) to 1 (oldest))
|
||||||
BUFFER=$(fc -l -n 1 | eval $tac | percol --query "$LBUFFER")
|
BUFFER=$(fc -l -n -1 1 | percol --query "$LBUFFER")
|
||||||
|
CURSOR=$#BUFFER
|
||||||
|
zle -R -c
|
||||||
|
}
|
||||||
|
zle -N percol_select_history
|
||||||
|
bindkey -M emacs '^R' percol_select_history
|
||||||
|
bindkey -M viins '^R' percol_select_history
|
||||||
|
bindkey -M vicmd '^R' percol_select_history
|
||||||
|
|
||||||
|
if (( ${+functions[marks]} )); then
|
||||||
|
function percol_select_marks() {
|
||||||
|
# parse directory from marks output (markname -> path) and quote if necessary
|
||||||
|
BUFFER=${(q)"$(marks | percol --query "$LBUFFER")"##*-> }
|
||||||
CURSOR=$#BUFFER
|
CURSOR=$#BUFFER
|
||||||
zle -R -c
|
zle -R -c
|
||||||
}
|
}
|
||||||
|
|
||||||
zle -N percol_select_history
|
|
||||||
bindkey '^R' percol_select_history
|
|
||||||
|
|
||||||
if which marks &> /dev/null; then
|
|
||||||
function percol_select_marks() {
|
|
||||||
BUFFER=$(marks | percol --query "$LBUFFER" | awk '{print $3}')
|
|
||||||
CURSOR=$#BUFFER # move cursor
|
|
||||||
zle -R -c # refresh
|
|
||||||
}
|
|
||||||
zle -N percol_select_marks
|
zle -N percol_select_marks
|
||||||
bindkey '^B' percol_select_marks
|
bindkey -M emacs '^B' percol_select_marks
|
||||||
fi
|
bindkey -M viins '^B' percol_select_marks
|
||||||
|
bindkey -M vicmd '^B' percol_select_marks
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -78,7 +78,7 @@ if [[ $FOUND_PYENV -eq 1 ]]; then
|
||||||
eval "$(pyenv init - --no-rehash zsh)"
|
eval "$(pyenv init - --no-rehash zsh)"
|
||||||
|
|
||||||
# If pyenv-virtualenv exists, load it
|
# If pyenv-virtualenv exists, load it
|
||||||
if [[ -d "$(pyenv root)/plugins/pyenv-virtualenv" && "$ZSH_PYENV_VIRTUALENV" != false ]]; then
|
if [[ "$(pyenv commands)" =~ "virtualenv-init" && "$ZSH_PYENV_VIRTUALENV" != false ]]; then
|
||||||
eval "$(pyenv virtualenv-init - zsh)"
|
eval "$(pyenv virtualenv-init - zsh)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ plugins=(... python)
|
||||||
|
|
||||||
| Command | Description |
|
| Command | Description |
|
||||||
|------------------|---------------------------------------------------------------------------------|
|
|------------------|---------------------------------------------------------------------------------|
|
||||||
|
| `py` | Runs `python` |
|
||||||
| `ipython` | Runs the appropriate `ipython` version according to the activated virtualenv |
|
| `ipython` | Runs the appropriate `ipython` version according to the activated virtualenv |
|
||||||
| `pyfind` | Finds .py files recursively in the current directory |
|
| `pyfind` | Finds .py files recursively in the current directory |
|
||||||
| `pyclean [dirs]` | Deletes byte-code and cache files from a list of directories or the current one |
|
| `pyclean [dirs]` | Deletes byte-code and cache files from a list of directories or the current one |
|
||||||
|
|
|
@ -4,11 +4,20 @@ if ! (( $+commands[curl] )); then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function quote {
|
function quote {
|
||||||
emulate -L zsh
|
setopt localoptions nopromptsubst
|
||||||
Q=$(curl -s --connect-timeout 2 "http://www.quotationspage.com/random.php" | iconv -c -f ISO-8859-1 -t UTF-8 | grep -m 1 "dt ")
|
|
||||||
|
|
||||||
TXT=$(echo "$Q" | sed -e 's/<\/dt>.*//g' -e 's/.*html//g' -e 's/^[^a-zA-Z]*//' -e 's/<\/a..*$//g')
|
# Get random quote data
|
||||||
WHO=$(echo "$Q" | sed -e 's/.*\/quotes\///g' -e 's/<.*//g' -e 's/.*">//g')
|
local data
|
||||||
|
data="$(command curl -s --connect-timeout 2 "http://www.quotationspage.com/random.php" \
|
||||||
|
| iconv -c -f ISO-8859-1 -t UTF-8 \
|
||||||
|
| command grep -a -m 1 'dt class="quote"')"
|
||||||
|
|
||||||
[[ -n "$WHO" && -n "$TXT" ]] && print -P "%F{3}${WHO}%f: “%F{5}${TXT}%f”"
|
# Exit if could not fetch random quote
|
||||||
|
[[ -n "$data" ]] || return 0
|
||||||
|
|
||||||
|
local quote author
|
||||||
|
quote=$(sed -e 's|</dt>.*||g' -e 's|.*html||g' -e 's|^[^a-zA-Z]*||' -e 's|</a..*$||g' <<< "$data")
|
||||||
|
author=$(sed -e 's|.*/quotes/||g' -e 's|<.*||g' -e 's|.*">||g' <<< "$data")
|
||||||
|
|
||||||
|
print -P "%F{3}${author}%f: “%F{5}${quote}%f”"
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,21 @@ plugins=(... ruby)
|
||||||
## Aliases
|
## Aliases
|
||||||
|
|
||||||
| Alias | Command | Description |
|
| Alias | Command | Description |
|
||||||
|-------|----------------------------------------|------------------------------------------------------|
|
|--------|----------------------------------------|------------------------------------------------------|
|
||||||
| rb | `ruby` | The Ruby command |
|
| rb | `ruby` | The Ruby command |
|
||||||
| sgem | `sudo gem` | Run sudo gem on the system ruby, not the active ruby |
|
| sgem | `sudo gem` | Run sudo gem on the system ruby, not the active ruby |
|
||||||
| rfind | `find . -name "*.rb" \| xargs grep -n` | Find ruby file |
|
| rfind | `find . -name "*.rb" \| xargs grep -n` | Find ruby file |
|
||||||
| gin | `gem install` | Install a gem into the local repository |
|
| gein | `gem install` | Install a gem into the local repository |
|
||||||
| gun | `gem uninstall` | Uninstall gems from the local repository |
|
| geun | `gem uninstall` | Uninstall gems from the local repository |
|
||||||
| gli | `gem list` | Display gems installed locally |
|
| geli | `gem list` | Display gems installed locally |
|
||||||
|
| gei | `gem info` | Show information for the given gem |
|
||||||
|
| geiall | `gem info --all` | Display all gem versions |
|
||||||
|
| geca | `gem cert --add` | Add a trusted certificate |
|
||||||
|
| gecr | `gem cert --remove` | Remove a trusted certificate |
|
||||||
|
| gecb | `gem cert --build` | Build private key and self-signed certificate |
|
||||||
|
| geclup | `gem cleanup -n` | Do not uninstall gem |
|
||||||
|
| gegi | `gem generate_index` | Generate index file for gem server |
|
||||||
|
| geh | `gem help` | Provide additional help |
|
||||||
|
| gel | `gem lock` | Generate a lockdown list of gems |
|
||||||
|
| geo | `gem open` | Open gem source in default editor |
|
||||||
|
| geoe | `gem open -e` | Open gem sources in preferred editor |
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
# TODO: Make this compatible with rvm.
|
# Run sudo gem on the system ruby, not the active ruby
|
||||||
# Run sudo gem on the system ruby, not the active ruby.
|
|
||||||
alias sgem='sudo gem'
|
alias sgem='sudo gem'
|
||||||
|
|
||||||
# Find ruby file
|
# Find ruby file
|
||||||
|
@ -9,6 +8,17 @@ alias rfind='find . -name "*.rb" | xargs grep -n'
|
||||||
alias rb="ruby"
|
alias rb="ruby"
|
||||||
|
|
||||||
# Gem Command Shorthands
|
# Gem Command Shorthands
|
||||||
alias gin="gem install"
|
alias gein="gem install"
|
||||||
alias gun="gem uninstall"
|
alias geun="gem uninstall"
|
||||||
alias gli="gem list"
|
alias geli="gem list"
|
||||||
|
alias gei="gem info"
|
||||||
|
alias geiall="gem info --all"
|
||||||
|
alias geca="gem cert --add"
|
||||||
|
alias gecr="gem cert --remove"
|
||||||
|
alias gecb="gem cert --build"
|
||||||
|
alias geclup="gem cleanup -n"
|
||||||
|
alias gegi="gem generate_index"
|
||||||
|
alias geh="gem help"
|
||||||
|
alias gel="gem lock"
|
||||||
|
alias geo="gem open"
|
||||||
|
alias geoe="gem open -e"
|
||||||
|
|
|
@ -270,7 +270,7 @@ fi
|
||||||
|
|
||||||
# Determine the last recorded directory
|
# Determine the last recorded directory
|
||||||
if [[ -s ${SCD_HISTFILE} ]]; then
|
if [[ -s ${SCD_HISTFILE} ]]; then
|
||||||
last_directory=${"$(tail -1 ${SCD_HISTFILE})"#*;}
|
last_directory=${"$(tail -n 1 ${SCD_HISTFILE})"#*;}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# The "record" function adds its arguments to the directory index.
|
# The "record" function adds its arguments to the directory index.
|
||||||
|
|
|
@ -21,7 +21,23 @@ zstyle :omz:plugins:ssh-agent agent-forwarding on
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
To **load multiple identities** use the `identities` style, For example:
|
To **NOT load any identities on start** use the `lazy` setting. This is particularly
|
||||||
|
useful when combined with the `AddKeysToAgent` setting (available since OpenSSH 7.2),
|
||||||
|
since it allows to enter the password only on first use. _NOTE: you can know your
|
||||||
|
OpenSSH version with `ssh -V`._
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zstyle :omz:plugins:ssh-agent lazy yes
|
||||||
|
```
|
||||||
|
|
||||||
|
You can enable `AddKeysToAgent` by passing `-o AddKeysToAgent=yes` to the `ssh` command,
|
||||||
|
or by adding `AddKeysToAgent yes` to your `~/.ssh/config` file [1].
|
||||||
|
See the [OpenSSH 7.2 Release Notes](http://www.openssh.com/txt/release-7.2).
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
To **load multiple identities** use the `identities` style (**this has no effect
|
||||||
|
if the `lazy` setting is enabled**). For example:
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
zstyle :omz:plugins:ssh-agent identities id_rsa id_rsa2 id_github
|
zstyle :omz:plugins:ssh-agent identities id_rsa id_rsa2 id_github
|
||||||
|
|
|
@ -6,9 +6,11 @@ function _start_agent() {
|
||||||
if [[ -f "$ssh_env_cache" ]]; then
|
if [[ -f "$ssh_env_cache" ]]; then
|
||||||
. "$ssh_env_cache" > /dev/null
|
. "$ssh_env_cache" > /dev/null
|
||||||
|
|
||||||
{
|
# Test if $SSH_AUTH_SOCK is visible
|
||||||
[[ "$USERNAME" = root ]] && command ps ax || command ps x
|
zmodload zsh/net/socket
|
||||||
} | command grep ssh-agent | command grep -q $SSH_AGENT_PID && return 0
|
if [[ -S "$SSH_AUTH_SOCK" ]] && zsocket "$SSH_AUTH_SOCK" 2>/dev/null; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set a maximum lifetime for identities added to ssh-agent
|
# Set a maximum lifetime for identities added to ssh-agent
|
||||||
|
@ -96,7 +98,10 @@ else
|
||||||
_start_agent
|
_start_agent
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_add_identities
|
# Don't add identities if lazy-loading is enabled
|
||||||
|
if ! zstyle -t :omz:plugins:ssh-agent lazy; then
|
||||||
|
_add_identities
|
||||||
|
fi
|
||||||
|
|
||||||
unset agent_forwarding ssh_env_cache
|
unset agent_forwarding ssh_env_cache
|
||||||
unfunction _start_agent _add_identities
|
unfunction _start_agent _add_identities
|
||||||
|
|
|
@ -17,6 +17,7 @@ alias stn=create_project
|
||||||
if [[ "$OSTYPE" == linux* ]]; then
|
if [[ "$OSTYPE" == linux* ]]; then
|
||||||
if [[ "$(uname -r)" = *icrosoft* ]]; then
|
if [[ "$(uname -r)" = *icrosoft* ]]; then
|
||||||
_sublime_paths=(
|
_sublime_paths=(
|
||||||
|
"$(wslpath -u 'C:\Program Files\Sublime Text\sublime_text.exe' 2>/dev/null)"
|
||||||
"$(wslpath -u 'C:\Program Files\Sublime Text 3\subl.exe' 2>/dev/null)"
|
"$(wslpath -u 'C:\Program Files\Sublime Text 3\subl.exe' 2>/dev/null)"
|
||||||
"$(wslpath -u 'C:\Program Files\Sublime Text 2\subl.exe' 2>/dev/null)"
|
"$(wslpath -u 'C:\Program Files\Sublime Text 2\subl.exe' 2>/dev/null)"
|
||||||
)
|
)
|
||||||
|
@ -52,6 +53,7 @@ alias stn=create_project
|
||||||
)
|
)
|
||||||
elif [[ "$OSTYPE" = msys ]]; then
|
elif [[ "$OSTYPE" = msys ]]; then
|
||||||
_sublime_paths=(
|
_sublime_paths=(
|
||||||
|
"/c/Program Files/Sublime Text/sublime_text.exe"
|
||||||
"/c/Program Files/Sublime Text 2/subl.exe"
|
"/c/Program Files/Sublime Text 2/subl.exe"
|
||||||
"/c/Program Files/Sublime Text 3/subl.exe"
|
"/c/Program Files/Sublime Text 3/subl.exe"
|
||||||
)
|
)
|
||||||
|
|
|
@ -17,9 +17,9 @@ plugins=(... systemadmin)
|
||||||
| path | `print -l $path` | Displays PATH with each entry on a separate line |
|
| path | `print -l $path` | Displays PATH with each entry on a separate line |
|
||||||
| mkdir | `mkdir -pv` | Automatically create parent directories and display verbose output |
|
| mkdir | `mkdir -pv` | Automatically create parent directories and display verbose output |
|
||||||
| psmem | `ps -e -orss=,args= \| sort -b -k1 -nr` | Display the processes using the most memory |
|
| psmem | `ps -e -orss=,args= \| sort -b -k1 -nr` | Display the processes using the most memory |
|
||||||
| psmem10 | `ps -e -orss=,args= \| sort -b -k1 -nr \| head -10` | Display the top 10 processes using the most memory |
|
| psmem10 | `ps -e -orss=,args= \| sort -b -k1 -nr \| head -n 10` | Display the top 10 processes using the most memory |
|
||||||
| pscpu | `ps -e -o pcpu,cpu,nice,state,cputime,args \|sort -k1 -nr` | Display the top processes using the most CPU |
|
| pscpu | `ps -e -o pcpu,cpu,nice,state,cputime,args \|sort -k1 -nr` | Display the top processes using the most CPU |
|
||||||
| pscpu10 | `ps -e -o pcpu,cpu,nice,state,cputime,args \|sort -k1 -nr \| head -10` | Display the top 10 processes using the most CPU |
|
| pscpu10 | `ps -e -o pcpu,cpu,nice,state,cputime,args \|sort -k1 -nr \| head -n 10` | Display the top 10 processes using the most CPU |
|
||||||
| hist10 | `print -l ${(o)history%% *} \| uniq -c \| sort -nr \| head -n 10` | Display the top 10 most used commands in the history |
|
| hist10 | `print -l ${(o)history%% *} \| uniq -c \| sort -nr \| head -n 10` | Display the top 10 most used commands in the history |
|
||||||
|
|
||||||
## Functions
|
## Functions
|
||||||
|
|
|
@ -26,10 +26,10 @@ alias path='print -l $path'
|
||||||
alias mkdir='mkdir -pv'
|
alias mkdir='mkdir -pv'
|
||||||
# get top process eating memory
|
# get top process eating memory
|
||||||
alias psmem='ps -e -orss=,args= | sort -b -k1 -nr'
|
alias psmem='ps -e -orss=,args= | sort -b -k1 -nr'
|
||||||
alias psmem10='ps -e -orss=,args= | sort -b -k1 -nr | head -10'
|
alias psmem10='ps -e -orss=,args= | sort -b -k1 -nr | head -n 10'
|
||||||
# get top process eating cpu if not work try excute : export LC_ALL='C'
|
# get top process eating cpu if not work try excute : export LC_ALL='C'
|
||||||
alias pscpu='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr'
|
alias pscpu='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr'
|
||||||
alias pscpu10='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr | head -10'
|
alias pscpu10='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr | head -n 10'
|
||||||
# top10 of the history
|
# top10 of the history
|
||||||
alias hist10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
|
alias hist10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ req20() {
|
||||||
|
|
||||||
# top20 of Using tcpdump port 80 access to view
|
# top20 of Using tcpdump port 80 access to view
|
||||||
http20() {
|
http20() {
|
||||||
sudo tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F"." '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort -nr |head -20
|
sudo tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F"." '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort -nr |head -n 20
|
||||||
}
|
}
|
||||||
|
|
||||||
# top20 of Find time_wait connection
|
# top20 of Find time_wait connection
|
||||||
|
@ -99,14 +99,14 @@ accessip10() {
|
||||||
|
|
||||||
# top20 of Most Visited file or page
|
# top20 of Most Visited file or page
|
||||||
visitpage20() {
|
visitpage20() {
|
||||||
awk '{print $11}' "$(retlog)"|sort|uniq -c|sort -nr|head -20
|
awk '{print $11}' "$(retlog)"|sort|uniq -c|sort -nr|head -n 20
|
||||||
}
|
}
|
||||||
|
|
||||||
# top100 of Page lists the most time-consuming (more than 60 seconds) as well as the corresponding page number of occurrences
|
# top100 of Page lists the most time-consuming (more than 60 seconds) as well as the corresponding page number of occurrences
|
||||||
consume100() {
|
consume100() {
|
||||||
awk '($NF > 60 && $7~/\.php/){print $7}' "$(retlog)" |sort -n|uniq -c|sort -nr|head -100
|
awk '($NF > 60 && $7~/\.php/){print $7}' "$(retlog)" |sort -n|uniq -c|sort -nr|head -n 100
|
||||||
# if django website or other webiste make by no suffix language
|
# if django website or other webiste make by no suffix language
|
||||||
# awk '{print $7}' "$(retlog)" |sort -n|uniq -c|sort -nr|head -100
|
# awk '{print $7}' "$(retlog)" |sort -n|uniq -c|sort -nr|head -n 100
|
||||||
}
|
}
|
||||||
|
|
||||||
# Website traffic statistics (G)
|
# Website traffic statistics (G)
|
||||||
|
|
|
@ -39,3 +39,4 @@ The plugin also supports the following:
|
||||||
| `ZSH_TMUX_FIXTERM_WITH_256COLOR` | `$TERM` to use for 256-color terminals (default: `screen-256color` |
|
| `ZSH_TMUX_FIXTERM_WITH_256COLOR` | `$TERM` to use for 256-color terminals (default: `screen-256color` |
|
||||||
| `ZSH_TMUX_CONFIG` | Set the configuration path (default: `$HOME/.tmux.conf`) |
|
| `ZSH_TMUX_CONFIG` | Set the configuration path (default: `$HOME/.tmux.conf`) |
|
||||||
| `ZSH_TMUX_UNICODE` | Set `tmux -u` option to support unicode |
|
| `ZSH_TMUX_UNICODE` | Set `tmux -u` option to support unicode |
|
||||||
|
| `ZSH_TMUX_DEFAULT_SESSION_NAME` | Set tmux default session name when autostart is enabled |
|
||||||
|
|
|
@ -76,8 +76,12 @@ function _zsh_tmux_plugin_run() {
|
||||||
elif [[ -e "$ZSH_TMUX_CONFIG" ]]; then
|
elif [[ -e "$ZSH_TMUX_CONFIG" ]]; then
|
||||||
tmux_cmd+=(-f "$ZSH_TMUX_CONFIG")
|
tmux_cmd+=(-f "$ZSH_TMUX_CONFIG")
|
||||||
fi
|
fi
|
||||||
|
if [[ -n "$ZSH_TMUX_DEFAULT_SESSION_NAME" ]]; then
|
||||||
|
$tmux_cmd new-session -s $ZSH_TMUX_DEFAULT_SESSION_NAME
|
||||||
|
else
|
||||||
$tmux_cmd new-session
|
$tmux_cmd new-session
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$ZSH_TMUX_AUTOQUIT" == "true" ]]; then
|
if [[ "$ZSH_TMUX_AUTOQUIT" == "true" ]]; then
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -26,7 +26,7 @@ plugins=(... xcode)
|
||||||
|
|
||||||
### `xc`
|
### `xc`
|
||||||
|
|
||||||
Opens the current directory in Xcode as an Xcode project. This will open one of the `.xcworkspace` and `.xcodeproj` files that it can find in the current working directory. You can also specify a directory to look in for the Xcode files.
|
Opens the current directory in Xcode as an Xcode project or a Swift package. This will open one of the `.xcworkspace`, `.xcodeproj` and `Package.swift` files that it can find in the current working directory. You can also specify a directory to look in for the Xcode files.
|
||||||
Returns 1 if it didn't find any relevant files.
|
Returns 1 if it didn't find any relevant files.
|
||||||
|
|
||||||
### `xx`
|
### `xx`
|
||||||
|
|
|
@ -6,28 +6,18 @@ alias xcsel='sudo xcode-select --switch'
|
||||||
# original author: @subdigital
|
# original author: @subdigital
|
||||||
# source: https://gist.github.com/subdigital/5420709
|
# source: https://gist.github.com/subdigital/5420709
|
||||||
function xc {
|
function xc {
|
||||||
local xcode_proj
|
local xcode_files
|
||||||
if [[ $# == 0 ]]; then
|
xcode_files=(${1:-.}/{*.{xcworkspace,xcodeproj},Package.swift}(N))
|
||||||
xcode_proj=(*.{xcworkspace,xcodeproj}(N))
|
|
||||||
else
|
|
||||||
xcode_proj=($1/*.{xcworkspace,xcodeproj}(N))
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
if [[ ${#xcode_files} -eq 0 ]]; then
|
||||||
if [[ ${#xcode_proj} -eq 0 ]]; then
|
echo "No Xcode files found in ${1:-the current directory}." >&2
|
||||||
if [[ $# == 0 ]]; then
|
|
||||||
echo "No xcworkspace/xcodeproj file found in the current directory."
|
|
||||||
else
|
|
||||||
echo "No xcworkspace/xcodeproj file found in $1."
|
|
||||||
fi
|
|
||||||
return 1
|
return 1
|
||||||
else
|
|
||||||
local active_path
|
|
||||||
active_path=$(xcode-select -p)
|
|
||||||
active_path=${active_path%%/Contents/Developer*}
|
|
||||||
echo "Found ${xcode_proj[1]}. Opening with ${active_path}"
|
|
||||||
open -a "$active_path" "${xcode_proj[1]}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local active_path
|
||||||
|
active_path=${"$(xcode-select -p)"%%/Contents/Developer*}
|
||||||
|
echo "Found ${xcode_files[1]}. Opening with ${active_path}"
|
||||||
|
open -a "$active_path" "${xcode_files[1]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Opens a file or files in the Xcode IDE. Multiple files are opened in multi-file browser
|
# Opens a file or files in the Xcode IDE. Multiple files are opened in multi-file browser
|
||||||
|
|
|
@ -28,6 +28,7 @@ plugins=(... yarn)
|
||||||
| yi | `yarn init` | Interactively creates or updates a package.json file |
|
| yi | `yarn init` | Interactively creates or updates a package.json file |
|
||||||
| yin | `yarn install` | Install dependencies defined in `package.json` |
|
| yin | `yarn install` | Install dependencies defined in `package.json` |
|
||||||
| yln | `yarn lint` | Run the lint script defined in `package.json` |
|
| yln | `yarn lint` | Run the lint script defined in `package.json` |
|
||||||
|
| ylnf | `yarn lint --fix` | Run the lint script defined in `package.json`to automatically fix problems |
|
||||||
| yls | `yarn list` | List installed packages |
|
| yls | `yarn list` | List installed packages |
|
||||||
| yout | `yarn outdated` | Check for outdated package dependencies |
|
| yout | `yarn outdated` | Check for outdated package dependencies |
|
||||||
| yp | `yarn pack` | Create a compressed gzip archive of package dependencies |
|
| yp | `yarn pack` | Create a compressed gzip archive of package dependencies |
|
||||||
|
|
|
@ -32,15 +32,21 @@
|
||||||
# -------
|
# -------
|
||||||
#
|
#
|
||||||
# * Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
|
# * Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
|
||||||
|
# * Shohei YOSHIDA <syohex@gmail.com>
|
||||||
#
|
#
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
declare -g _yarn_run_cwd
|
||||||
|
|
||||||
_commands=(
|
_commands=(
|
||||||
'access'
|
'access'
|
||||||
|
'audit:Checks for known security issues with the installed packages'
|
||||||
'autoclean:Clean and remove unnecessary files from package dependencies'
|
'autoclean:Clean and remove unnecessary files from package dependencies'
|
||||||
'cache:List or clean every cached package'
|
'cache:List or clean every cached package'
|
||||||
"check:Verify package dependencies agains yarn's lock file"
|
"check:Verify package dependencies against yarn's lock file"
|
||||||
'config:Manages the yarn configuration files'
|
'config:Manages the yarn configuration files'
|
||||||
|
'create:Creates new projects from any create-* starter kits'
|
||||||
|
'exec'
|
||||||
'generate-lock-entry:Generates a lock file entry'
|
'generate-lock-entry:Generates a lock file entry'
|
||||||
'global:Install packages globally on your operating system'
|
'global:Install packages globally on your operating system'
|
||||||
'help:Show information about a command'
|
'help:Show information about a command'
|
||||||
|
@ -50,25 +56,30 @@ _commands=(
|
||||||
'install:Install all the dependencies listed within package.json'
|
'install:Install all the dependencies listed within package.json'
|
||||||
'licenses:List licenses for installed packages'
|
'licenses:List licenses for installed packages'
|
||||||
'link:Symlink a package folder during development'
|
'link:Symlink a package folder during development'
|
||||||
'list:List installed packages'
|
|
||||||
'login:Store registry username and email'
|
'login:Store registry username and email'
|
||||||
'logout:Clear registry username and email'
|
'logout:Clear registry username and email'
|
||||||
|
'node:Runs Node with the same version that the one used by Yarn itself'
|
||||||
'outdated:Check for outdated package dependencies'
|
'outdated:Check for outdated package dependencies'
|
||||||
'owner:Manage package owners'
|
'owner:Manage package owners'
|
||||||
'pack:Create a compressed gzip archive of package dependencies'
|
'pack:Create a compressed gzip archive of package dependencies'
|
||||||
|
'policies:Defines project-wide policies for your project'
|
||||||
'publish:Publish a package to the npm registry'
|
'publish:Publish a package to the npm registry'
|
||||||
'run:Run a defined package script'
|
'run:Run a defined package script'
|
||||||
'tag:Add, remove, or list tags on a package'
|
'tag:Add, remove, or list tags on a package'
|
||||||
'team:Maintain team memberships'
|
'team:Maintain team memberships'
|
||||||
'unlink:Unlink a previously created symlink for a package'
|
'unlink:Unlink a previously created symlink for a package'
|
||||||
|
'unplug:Temporarily copies a package outside of the global cache for debugging purposes'
|
||||||
'version:Update the package version'
|
'version:Update the package version'
|
||||||
'versions:Display version information of currently installed Yarn, Node.js, and its dependencies'
|
'versions:Display version information of currently installed Yarn, Node.js, and its dependencies'
|
||||||
'why:Show information about why a package is installed'
|
'why:Show information about why a package is installed'
|
||||||
|
'workspace'
|
||||||
|
'workspaces:Show information about your workspaces'
|
||||||
)
|
)
|
||||||
|
|
||||||
_global_commands=(
|
_global_commands=(
|
||||||
'add:Installs a package and any packages that it depends on'
|
'add:Installs a package and any packages that it depends on'
|
||||||
'bin:Displays the location of the yarn bin folder'
|
'bin:Displays the location of the yarn bin folder'
|
||||||
|
'list:List installed packages'
|
||||||
'remove:Remove installed package from dependencies updating package.json'
|
'remove:Remove installed package from dependencies updating package.json'
|
||||||
'upgrade:Upgrades packages to their latest version based on the specified range'
|
'upgrade:Upgrades packages to their latest version based on the specified range'
|
||||||
'upgrade-interactive:Interactively upgrade packages'
|
'upgrade-interactive:Interactively upgrade packages'
|
||||||
|
@ -76,7 +87,12 @@ _global_commands=(
|
||||||
|
|
||||||
_yarn_commands_scripts() {
|
_yarn_commands_scripts() {
|
||||||
local -a scripts
|
local -a scripts
|
||||||
|
if [[ -n $opt_args[--cwd] ]]; then
|
||||||
|
scripts=($(cd $opt_args[--cwd] && yarn run --json 2>/dev/null | sed -E '/Commands available|possibleCommands/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g' | tr , '\n' | sed -e 's/:/\\:/g'))
|
||||||
|
else
|
||||||
scripts=($(yarn run --json 2>/dev/null | sed -E '/Commands available|possibleCommands/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g' | tr , '\n' | sed -e 's/:/\\:/g'))
|
scripts=($(yarn run --json 2>/dev/null | sed -E '/Commands available|possibleCommands/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g' | tr , '\n' | sed -e 's/:/\\:/g'))
|
||||||
|
fi
|
||||||
|
|
||||||
_describe 'command or script' _commands -- _global_commands -- scripts
|
_describe 'command or script' _commands -- _global_commands -- scripts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +101,11 @@ _yarn_scripts() {
|
||||||
local -a scriptNames scriptCommands
|
local -a scriptNames scriptCommands
|
||||||
local i runJSON
|
local i runJSON
|
||||||
|
|
||||||
|
if [[ -n $_yarn_run_cwd ]]; then
|
||||||
|
runJSON=$(cd $_yarn_run_cwd && yarn run --json 2>/dev/null)
|
||||||
|
else
|
||||||
runJSON=$(yarn run --json 2>/dev/null)
|
runJSON=$(yarn run --json 2>/dev/null)
|
||||||
|
fi
|
||||||
# Some sed utilities (e.g. Mac OS / BSD) don't interpret `\n` in a replacement
|
# Some sed utilities (e.g. Mac OS / BSD) don't interpret `\n` in a replacement
|
||||||
# pattern as a newline. See https://superuser.com/q/307165
|
# pattern as a newline. See https://superuser.com/q/307165
|
||||||
binaries=($(sed -E '/Commands available/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g;s/:/\\:/g;s/,/\'$'\n/g' <<< "$runJSON"))
|
binaries=($(sed -E '/Commands available/!d;s/.*Commands available from binary scripts: ([^"]+)".*/\1/;s/.*"items":\[([^]]+).*/\1/;s/[" ]//g;s/:/\\:/g;s/,/\'$'\n/g' <<< "$runJSON"))
|
||||||
|
@ -96,7 +116,7 @@ _yarn_scripts() {
|
||||||
scripts+=("${scriptNames[$i]}:${scriptCommands[$i]}")
|
scripts+=("${scriptNames[$i]}:${scriptCommands[$i]}")
|
||||||
done
|
done
|
||||||
|
|
||||||
commands=($scripts $binaries)
|
commands=('env' $scripts $binaries)
|
||||||
_describe 'command' commands
|
_describe 'command' commands
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,6 +130,17 @@ _yarn_commands() {
|
||||||
_describe 'command' _commands -- _global_commands
|
_describe 'command' _commands -- _global_commands
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_yarn_add_files() {
|
||||||
|
if compset -P "(file|link):"; then
|
||||||
|
_files
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_yarn_workspaces() {
|
||||||
|
local -a workspaces=(${(@f)$(yarn workspaces info |sed -n -e 's/^ "\([^"]*\)": {/\1/p')})
|
||||||
|
_describe 'workspace' workspaces
|
||||||
|
}
|
||||||
|
|
||||||
_yarn() {
|
_yarn() {
|
||||||
local context state state_descr line
|
local context state state_descr line
|
||||||
typeset -A opt_args
|
typeset -A opt_args
|
||||||
|
@ -118,37 +149,51 @@ _yarn() {
|
||||||
'(-h --help)'{-h,--help}'[output usage information]' \
|
'(-h --help)'{-h,--help}'[output usage information]' \
|
||||||
'(-V --version)'{-V,--version}'[output the version number]' \
|
'(-V --version)'{-V,--version}'[output the version number]' \
|
||||||
'--verbose[output verbose messages on internal operations]' \
|
'--verbose[output verbose messages on internal operations]' \
|
||||||
'--offline[trigger an error if any required dependencies are not available in local cache]' \
|
|
||||||
'--prefer-offline[use network only if dependencies are not available in local cache]' \
|
|
||||||
'--strict-semver' \
|
|
||||||
'--json' \
|
|
||||||
"--ignore-scripts[don't run lifecycle scripts]" \
|
|
||||||
'--har[save HAR output of network traffic]' \
|
|
||||||
'--ignore-platform[ignore platform checks]' \
|
|
||||||
'--ignore-engines[ignore engines check]' \
|
|
||||||
'--ignore-optional[ignore optional dependencies]' \
|
|
||||||
'--force[install and build packages even if they were built before, overwrite lockfile]' \
|
|
||||||
'--skip-integrity-check[run install without checking if node_modules is installed]' \
|
|
||||||
'--check-files[install will verify file tree of packages for consistency]' \
|
|
||||||
"--no-bin-links[don't generate bin links when setting up packages]" \
|
|
||||||
'--flat[only allow one version of a package]' \
|
|
||||||
'(--prod --production)'{--prod,--production} \
|
|
||||||
"--no-lockfile[don't read or generate a lockfile]" \
|
|
||||||
"--pure-lockfile[don't generate a lockfile]" \
|
|
||||||
"--frozen-lockfile[don't generate a lockfile and fail if an update is needed]" \
|
|
||||||
'--link-duplicates[create hardlinks to the repeated modules in node_modules]' \
|
|
||||||
'--global-folder=[modules folder]:folder:_files -/' \
|
|
||||||
'--modules-folder=[rather than installing modules into the node_modules folder relative to the cwd, output them here]:folder:_files -/' \
|
|
||||||
'--cache-folder=[specify a custom folder to store the yarn cache]:folder:_files -/' \
|
'--cache-folder=[specify a custom folder to store the yarn cache]:folder:_files -/' \
|
||||||
|
'--check-files[install will verify file tree of packages for consistency]' \
|
||||||
|
'--cwd=[working directory to use]:path:_files -/' \
|
||||||
|
"(--enable-pnp --pnp)--disable-pnp[disable the Plug'n'Play installation]" \
|
||||||
|
'(--no-emoji)--emoji=[enable emoji in output(default: false)]:enabled:(true false)' \
|
||||||
|
'(--emoji)--no-emoji[disable emoji in output]' \
|
||||||
|
'(--disable-pnp)'{--enable-pnp,--pnp}"[enable the Plug'n'Play installation]" \
|
||||||
|
'--flat[only allow one version of a package]' \
|
||||||
|
'--focus[Focus on a single workspace by installing remote copies of its sibiling workspaces]' \
|
||||||
|
'--force[install and build packages even if they were built before, overwrite lockfile]' \
|
||||||
|
"--frozen-lockfile[don't generate a lockfile and fail if an update is needed]" \
|
||||||
|
'--global-folder=[modules folder]:folder:_files -/' \
|
||||||
|
'--har[save HAR output of network traffic]' \
|
||||||
|
'--https-proxy=[HTTPS proxy]:host:_hosts' \
|
||||||
|
'--ignore-engines[ignore engines check]' \
|
||||||
|
"--ignore-scripts[don't run lifecycle scripts]" \
|
||||||
|
'--ignore-optional[ignore optional dependencies]' \
|
||||||
|
'--ignore-platform[ignore platform checks]' \
|
||||||
|
'--json[format Yarn log messages as lines of JSON]' \
|
||||||
|
'--link-duplicates[create hardlinks to the repeated modules in node_modules]' \
|
||||||
|
'--link-folder=[specify a custom folder to store global links]' \
|
||||||
|
'--modules-folder=[rather than installing modules into the node_modules folder relative to the cwd, output them here]:folder:_files -/' \
|
||||||
'--mutex=[use a mutex to ensure only one yarn instance is executing]:type[\:specifier]' \
|
'--mutex=[use a mutex to ensure only one yarn instance is executing]:type[\:specifier]' \
|
||||||
'--no-emoji[disable emoji in output]' \
|
|
||||||
'(-s --silent)'{-s,--silent}'[skip Yarn console logs, other types of logs (script output) will be printed]' \
|
|
||||||
'--proxy=:host:_hosts' \
|
|
||||||
'--https-proxy=:host:_hosts' \
|
|
||||||
'--no-progress[disable progress bar]' \
|
|
||||||
'--network-concurrency=[maximum number of concurrent network requests]:number' \
|
'--network-concurrency=[maximum number of concurrent network requests]:number' \
|
||||||
'--network-timeout=[TCP timeout for network requests]:milliseconds' \
|
'--network-timeout=[TCP timeout for network requests]:milliseconds' \
|
||||||
|
"--no-bin-links[don't generate bin links when setting up packages]" \
|
||||||
|
'--no-default-rc[prevent Yarn from automatically detecting yarnrc and npmrc files]' \
|
||||||
|
"--no-lockfile[don't read or generate a lockfile]" \
|
||||||
'--non-interactive[do not show interactive prompts]' \
|
'--non-interactive[do not show interactive prompts]' \
|
||||||
|
'--no-node-version-check[do not warn when using a potentially unsupported Node version]' \
|
||||||
|
'--no-progress[disable progress bar]' \
|
||||||
|
'--offline[trigger an error if any required dependencies are not available in local cache]' \
|
||||||
|
'--otp=[one-time password for two factor authentication]:otpcode' \
|
||||||
|
'--prefer-offline[use network only if dependencies are not available in local cache]' \
|
||||||
|
'--preferred-cache-folder=[specify a custom folder to store the yarn cache if possible]:folder:_files -/' \
|
||||||
|
'(--prod --production)'{--prod,--production}'[install only production dependencies]' \
|
||||||
|
'--proxy=[HTTP proxy]:host:_hosts' \
|
||||||
|
"--pure-lockfile[don't generate a lockfile]" \
|
||||||
|
'--registry=[override configuration registry]:url:_urls' \
|
||||||
|
'(-s --silent)'{-s,--silent}'[skip Yarn console logs, other types of logs (script output) will be printed]' \
|
||||||
|
'--scripts-prepend-node-path=[prepend the node executable dir to the PATH in scripts]:bool:(true false)' \
|
||||||
|
'--skip-integrity-check[run install without checking if node_modules is installed]' \
|
||||||
|
"--strict-semver[don't compare semver loosely]" \
|
||||||
|
'--update-checksum[update package checksums from current repository]' \
|
||||||
|
'--use-yarnrc=[specifies a yarnrc that Yarn should use]:yarnrc:_files' \
|
||||||
'1: :_yarn_commands_scripts' \
|
'1: :_yarn_commands_scripts' \
|
||||||
'*:: :->command_args'
|
'*:: :->command_args'
|
||||||
|
|
||||||
|
@ -173,18 +218,29 @@ _yarn() {
|
||||||
'(-O --optional)'{-O,--optional}'[install packages in optionalDependencies]' \
|
'(-O --optional)'{-O,--optional}'[install packages in optionalDependencies]' \
|
||||||
'(-E --exact)'{-E,--exact}'[install packages as exact versions]' \
|
'(-E --exact)'{-E,--exact}'[install packages as exact versions]' \
|
||||||
'(-T --tilde)'{-T,--tilde}'[install the most recent release of the packages that have the same minor version]' \
|
'(-T --tilde)'{-T,--tilde}'[install the most recent release of the packages that have the same minor version]' \
|
||||||
'*:package-name:'
|
'(--ignore-workspace-root-check -W)'{--ignore-workspace-root-check,-W}'[allows a package to be installed at the workspaces root]' \
|
||||||
|
'--audit[checks for known security issues with the installed packages]' \
|
||||||
|
'*:package-name:_yarn_add_files'
|
||||||
|
;;
|
||||||
|
|
||||||
|
audit)
|
||||||
|
_arguments \
|
||||||
|
'--verbose[output verbose message]' \
|
||||||
|
'--json[format Yarn log messages as lines of JSON]' \
|
||||||
|
'--level=[only print advisories with severity greater than or equal to]:level:(info low moderate high critical)' \
|
||||||
|
'--groups=[only audit dependencies from listed groups]:groups:->groups_args'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
cache)
|
cache)
|
||||||
_arguments \
|
_arguments \
|
||||||
'1: :(ls dir clean)'
|
'1: :(list dir clean)' \
|
||||||
|
'*:: :->cache_args'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
check)
|
check)
|
||||||
_arguments \
|
_arguments \
|
||||||
'--integrity' \
|
'--integrity[Verifies that versions and hashed values of the package contents in package.json]' \
|
||||||
'--verify-tree'
|
'--verify-tree[Recursively verifies that the dependencies in package.json are present in node_modules]'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
config)
|
config)
|
||||||
|
@ -223,12 +279,13 @@ _yarn() {
|
||||||
|
|
||||||
list)
|
list)
|
||||||
_arguments \
|
_arguments \
|
||||||
'--depth[Limit the depth of the shown dependencies]:depth'
|
'--depth=[Limit the depth of the shown dependencies]:depth' \
|
||||||
|
'--pattern=[filter the list of dependencies by the pattern]'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
owner)
|
owner)
|
||||||
_arguments \
|
_arguments \
|
||||||
'1: :(ls add rm)' \
|
'1: :(list add rm)' \
|
||||||
'*:: :->owner_args'
|
'*:: :->owner_args'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
@ -247,12 +304,22 @@ _yarn() {
|
||||||
'1: :_files'
|
'1: :_files'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
policies)
|
||||||
|
_arguments \
|
||||||
|
'1: :(set-version)'
|
||||||
|
;;
|
||||||
|
|
||||||
remove|upgrade)
|
remove|upgrade)
|
||||||
_arguments \
|
_arguments \
|
||||||
'*:package:'
|
'*:package:'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
run)
|
run)
|
||||||
|
if [[ -n $opt_args[--cwd] ]]; then
|
||||||
|
_yarn_run_cwd=$opt_args[--cwd]
|
||||||
|
else
|
||||||
|
_yarn_run_cwd=''
|
||||||
|
fi
|
||||||
_arguments \
|
_arguments \
|
||||||
'1: :_yarn_scripts' \
|
'1: :_yarn_scripts' \
|
||||||
'*:: :_default'
|
'*:: :_default'
|
||||||
|
@ -260,26 +327,33 @@ _yarn() {
|
||||||
|
|
||||||
tag)
|
tag)
|
||||||
_arguments \
|
_arguments \
|
||||||
'1: :(ls add rm)' \
|
'1: :(lists add rm)' \
|
||||||
'*:: :->tag_args'
|
'*:: :->tag_args'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
team)
|
team)
|
||||||
_arguments \
|
_arguments \
|
||||||
'1: :(create destroy add rm ls)' \
|
'1: :(create destroy add rm list)' \
|
||||||
'*:: :->team_args'
|
'*:: :->team_args'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
upgrade-interactive)
|
upgrade-interactive)
|
||||||
_arguments \
|
_arguments \
|
||||||
'--latest:use the version tagged latest in the registry:'
|
'--latest[use the version tagged latest in the registry]'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
version)
|
version)
|
||||||
_arguments \
|
_arguments \
|
||||||
'--new-version:version:' \
|
'--new-version[create a new version using an interactive session to prompt you]:version:' \
|
||||||
'--message:message:' \
|
'--major[creates a new version by incrementing the major version]' \
|
||||||
'--no-git-tag-version'
|
'--minor[creates a new version by incrementing the minor version]' \
|
||||||
|
'--patch[creates a new version by incrementing the patch version]' \
|
||||||
|
'--premajor[creates a new prerelease version by incrementing the major version]' \
|
||||||
|
'--preminor[creates a new prerelease version by incrementing the minor version]' \
|
||||||
|
'--prepatch[creates a new prerelease version by incrementing the patch version]' \
|
||||||
|
'--prerelease[increments the prerelease version number keeping the main version]' \
|
||||||
|
'--no-git-tag-version[creates a new version without creating a git tag]' \
|
||||||
|
'--no-commit-hooks[bypasses running commit hooks when committing the new version]'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
why)
|
why)
|
||||||
|
@ -287,6 +361,18 @@ _yarn() {
|
||||||
'1:query:_files'
|
'1:query:_files'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
workspace)
|
||||||
|
_arguments \
|
||||||
|
'1:workspace:_yarn_workspaces' \
|
||||||
|
'*:: :_yarn_global_commands'
|
||||||
|
;;
|
||||||
|
|
||||||
|
workspaces)
|
||||||
|
_arguments \
|
||||||
|
'--json[format Yarn log messages as lines of JSON]' \
|
||||||
|
'1:commands:(info run)'
|
||||||
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
_default
|
_default
|
||||||
;;
|
;;
|
||||||
|
@ -295,6 +381,12 @@ _yarn() {
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case $state in
|
case $state in
|
||||||
|
cache_args)
|
||||||
|
if [[ $words[1] == "list" ]]; then
|
||||||
|
_arguments \
|
||||||
|
'--pattern=[print out every cached package that matches the pattern]:pattern:'
|
||||||
|
fi
|
||||||
|
;;
|
||||||
config_args)
|
config_args)
|
||||||
case $words[1] in
|
case $words[1] in
|
||||||
get|delete)
|
get|delete)
|
||||||
|
@ -310,6 +402,10 @@ _yarn() {
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
groups_args)
|
||||||
|
local dependency_groups=(devDependencies dependencies optionalDependencies peerDependencies bundledDependencies)
|
||||||
|
_values -s ',' 'groups' $dependency_groups
|
||||||
|
;;
|
||||||
|
|
||||||
owner_args)
|
owner_args)
|
||||||
case $words[1] in
|
case $words[1] in
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
# Add yarn bin directory to $PATH if it exists and not in $PATH already
|
||||||
|
bindir=$(yarn global bin 2>/dev/null) \
|
||||||
|
&& [[ -d "$bindir" ]] \
|
||||||
|
&& (( ! ${path[(Ie)$bindir]} )) \
|
||||||
|
&& path+=("$bindir")
|
||||||
|
unset bindir
|
||||||
|
|
||||||
alias y="yarn"
|
alias y="yarn"
|
||||||
alias ya="yarn add"
|
alias ya="yarn add"
|
||||||
alias yad="yarn add --dev"
|
alias yad="yarn add --dev"
|
||||||
|
@ -13,6 +20,7 @@ alias yh="yarn help"
|
||||||
alias yi="yarn init"
|
alias yi="yarn init"
|
||||||
alias yin="yarn install"
|
alias yin="yarn install"
|
||||||
alias yln="yarn lint"
|
alias yln="yarn lint"
|
||||||
|
alias ylnf="yarn lint --fix"
|
||||||
alias yls="yarn list"
|
alias yls="yarn list"
|
||||||
alias yout="yarn outdated"
|
alias yout="yarn outdated"
|
||||||
alias yp="yarn pack"
|
alias yp="yarn pack"
|
||||||
|
|
|
@ -42,6 +42,8 @@ _z() {
|
||||||
[ -z "$_Z_OWNER" -a -f "$datafile" -a ! -O "$datafile" ] && return
|
[ -z "$_Z_OWNER" -a -f "$datafile" -a ! -O "$datafile" ] && return
|
||||||
|
|
||||||
_z_dirs () {
|
_z_dirs () {
|
||||||
|
[ -f "$datafile" ] || return
|
||||||
|
|
||||||
local line
|
local line
|
||||||
while read line; do
|
while read line; do
|
||||||
# only count directories
|
# only count directories
|
||||||
|
@ -54,14 +56,16 @@ _z() {
|
||||||
if [ "$1" = "--add" ]; then
|
if [ "$1" = "--add" ]; then
|
||||||
shift
|
shift
|
||||||
|
|
||||||
# $HOME isn't worth matching
|
# $HOME and / aren't worth matching
|
||||||
[ "$*" = "$HOME" ] && return
|
[ "$*" = "$HOME" -o "$*" = '/' ] && return
|
||||||
|
|
||||||
# don't track excluded directory trees
|
# don't track excluded directory trees
|
||||||
|
if [ ${#_Z_EXCLUDE_DIRS[@]} -gt 0 ]; then
|
||||||
local exclude
|
local exclude
|
||||||
for exclude in "${_Z_EXCLUDE_DIRS[@]}"; do
|
for exclude in "${_Z_EXCLUDE_DIRS[@]}"; do
|
||||||
case "$*" in "$exclude*") return;; esac
|
case "$*" in "$exclude"*) return;; esac
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# maintain the data file
|
# maintain the data file
|
||||||
local tempfile="$datafile.$RANDOM"
|
local tempfile="$datafile.$RANDOM"
|
||||||
|
|
|
@ -1,23 +1,3 @@
|
||||||
# zsh_reload plugin
|
# zsh_reload plugin
|
||||||
|
|
||||||
The zsh_reload plugin defines a function to reload the zsh session with
|
**This plugin is deprecated.** Use `omz reload` or `exec zsh` instead.
|
||||||
just a few keystrokes.
|
|
||||||
|
|
||||||
To use it, add `zsh_reload` to the plugins array in your zshrc file:
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
plugins=(... zsh_reload)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
To reload the zsh session, just run `src`:
|
|
||||||
|
|
||||||
```zsh
|
|
||||||
$ vim ~/.zshrc # enabled a plugin
|
|
||||||
$ src
|
|
||||||
re-compiling /home/user/.zshrc.zwc: succeeded
|
|
||||||
re-compiling /home/user/.oh-my-zsh/cache/zcomp-host.zwc: succeeded
|
|
||||||
|
|
||||||
# you now have a fresh zsh session. happy hacking!
|
|
||||||
```
|
|
||||||
|
|
|
@ -1,22 +1,7 @@
|
||||||
|
print ${(%):-"%F{yellow}The \`zsh_reload\` plugin is deprecated and will be removed."}
|
||||||
|
print ${(%):-"Use \`%Bomz reload%b\` or \`%Bexec zsh%b\` instead.%f"}
|
||||||
|
|
||||||
src() {
|
src() {
|
||||||
local cache="$ZSH_CACHE_DIR"
|
print ${(%):-"%F{yellow}$0 is deprecated. Use \`%Bomz reload%b\` or \`%Bexec zsh%b\` instead.%f\n"}
|
||||||
autoload -U compinit zrecompile
|
omz reload
|
||||||
compinit -i -d "$cache/zcomp-$HOST"
|
|
||||||
|
|
||||||
for f in ${ZDOTDIR:-~}/.zshrc "$cache/zcomp-$HOST"; do
|
|
||||||
zrecompile -p $f && command rm -f $f.zwc.old
|
|
||||||
done
|
|
||||||
|
|
||||||
# Use $SHELL if it's available and a zsh shell
|
|
||||||
local shell="$ZSH_ARGZERO"
|
|
||||||
if [[ "${${SHELL:t}#-}" = zsh ]]; then
|
|
||||||
shell="$SHELL"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Remove leading dash if login shell and run accordingly
|
|
||||||
if [[ "${shell:0:1}" = "-" ]]; then
|
|
||||||
exec -l "${shell#-}"
|
|
||||||
else
|
|
||||||
exec "$shell"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,14 +23,13 @@ ZSH_THEME="robbyrussell"
|
||||||
# Case-sensitive completion must be off. _ and - will be interchangeable.
|
# Case-sensitive completion must be off. _ and - will be interchangeable.
|
||||||
# HYPHEN_INSENSITIVE="true"
|
# HYPHEN_INSENSITIVE="true"
|
||||||
|
|
||||||
# Uncomment the following line to disable bi-weekly auto-update checks.
|
# Uncomment one of the following lines to change the auto-update behavior
|
||||||
# DISABLE_AUTO_UPDATE="true"
|
# zstyle ':omz:update' mode disabled # disable automatic updates
|
||||||
|
# zstyle ':omz:update' mode auto # update automatically without asking
|
||||||
# Uncomment the following line to automatically update without prompting.
|
# zstyle ':omz:update' mode reminder # just remind me to update when it's time
|
||||||
# DISABLE_UPDATE_PROMPT="true"
|
|
||||||
|
|
||||||
# Uncomment the following line to change how often to auto-update (in days).
|
# Uncomment the following line to change how often to auto-update (in days).
|
||||||
# export UPDATE_ZSH_DAYS=13
|
# zstyle ':omz:update' frequency 13
|
||||||
|
|
||||||
# Uncomment the following line if pasting URLs and other text is messed up.
|
# Uncomment the following line if pasting URLs and other text is messed up.
|
||||||
# DISABLE_MAGIC_FUNCTIONS="true"
|
# DISABLE_MAGIC_FUNCTIONS="true"
|
||||||
|
|
|
@ -51,9 +51,9 @@ root_prompt="$emoji[skull]"
|
||||||
warn_prompt="$emoji[collision_symbol]"
|
warn_prompt="$emoji[collision_symbol]"
|
||||||
|
|
||||||
vcs_unstaged_glyph="%{$emoji[circled_latin_capital_letter_m]$emoji2[emoji_style] %2G%}"
|
vcs_unstaged_glyph="%{$emoji[circled_latin_capital_letter_m]$emoji2[emoji_style] %2G%}"
|
||||||
vcs_staged_glyph="%{$emoji[high_voltage_sign] %2G%}"
|
vcs_staged_glyph="%{$emoji[high_voltage_sign]%2G%}"
|
||||||
vcs_branch_glyph=$(print -P $'\Ue0a0') #
|
vcs_branch_glyph=$'\Ue0a0' #
|
||||||
vcs_action_glyph=$(print -P $'\U276f') # ❯
|
vcs_action_glyph=$'\U276f' # ❯
|
||||||
|
|
||||||
red="$FG[001]"
|
red="$FG[001]"
|
||||||
yellow="$FG[003]"
|
yellow="$FG[003]"
|
||||||
|
|
|
@ -2,10 +2,9 @@ if [ "$USERNAME" = "root" ]; then CARETCOLOR="red"; else CARETCOLOR="blue"; fi
|
||||||
|
|
||||||
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
|
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
|
||||||
|
|
||||||
PROMPT='%{$fg[green]%}[%*]%{$reset_color%} %{$fg_no_bold[cyan]%}%n %{${fg_bold[blue]}%}::%{$reset_color%} %{$fg[yellow]%}%m%{$reset_color%} %{$fg_no_bold[magenta]%} ➜ %{$reset_color%} %{${fg[green]}%}%3~ $(git_prompt_info)%{${fg_bold[$CARETCOLOR]}%}»%{${reset_color}%} '
|
PROMPT='%{$fg[green]%}[%D{%H:%M:%S}]%{$reset_color%} %{$fg_no_bold[cyan]%}%n %{${fg_bold[blue]}%}::%{$reset_color%} %{$fg[yellow]%}%m%{$reset_color%} %{$fg_no_bold[magenta]%} ➜ %{$reset_color%} %{${fg[green]}%}%3~ $(git_prompt_info)%{${fg_bold[$CARETCOLOR]}%}»%{${reset_color}%} '
|
||||||
|
|
||||||
RPS1="${return_code}"
|
RPS1="${return_code}"
|
||||||
|
|
||||||
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[red]%}‹"
|
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[red]%}‹"
|
||||||
ZSH_THEME_GIT_PROMPT_SUFFIX="› %{$reset_color%}"
|
ZSH_THEME_GIT_PROMPT_SUFFIX="› %{$reset_color%}"
|
||||||
|
|
||||||
|
|
|
@ -35,19 +35,20 @@ prompt_setup_pygmalion(){
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt_pygmalion_precmd(){
|
prompt_pygmalion_precmd(){
|
||||||
setopt localoptions extendedglob
|
setopt localoptions nopromptsubst extendedglob
|
||||||
|
|
||||||
local gitinfo=$(git_prompt_info)
|
local gitinfo=$(git_prompt_info)
|
||||||
local gitinfo_nocolor=${gitinfo//\%\{[^\}]##\}}
|
local gitinfo_nocolor=${gitinfo//\%\{[^\}]##\}}
|
||||||
local exp_nocolor="$(print -P \"$base_prompt_nocolor$gitinfo_nocolor$post_prompt_nocolor\")"
|
local exp_nocolor="$(print -P \"${base_prompt_nocolor}${gitinfo_nocolor}${post_prompt_nocolor}\")"
|
||||||
local prompt_length=${#exp_nocolor}
|
local prompt_length=${#exp_nocolor}
|
||||||
|
|
||||||
|
# add new line on prompt longer than 40 characters
|
||||||
local nl=""
|
local nl=""
|
||||||
|
|
||||||
if [[ $prompt_length -gt 40 ]]; then
|
if [[ $prompt_length -gt 40 ]]; then
|
||||||
nl=$'\n%{\r%}';
|
nl=$'\n%{\r%}'
|
||||||
fi
|
fi
|
||||||
PROMPT="$base_prompt$gitinfo$nl$post_prompt"
|
|
||||||
|
PROMPT="${base_prompt}\$(git_prompt_info)${nl}${post_prompt}"
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt_setup_pygmalion
|
prompt_setup_pygmalion
|
||||||
|
|
|
@ -19,14 +19,14 @@ prompt_setup_pygmalion(){
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt_pygmalion_precmd(){
|
prompt_pygmalion_precmd(){
|
||||||
setopt localoptions extendedglob
|
setopt localoptions nopromptsubst extendedglob
|
||||||
|
|
||||||
local gitinfo=$(git_prompt_info)
|
local gitinfo=$(git_prompt_info)
|
||||||
local gitinfo_nocolor=${gitinfo//\%\{[^\}]##\}}
|
local gitinfo_nocolor=${gitinfo//\%\{[^\}]##\}}
|
||||||
local exp_nocolor="$(print -P \"$base_prompt_nocolor$gitinfo_nocolor$post_prompt_nocolor\")"
|
local exp_nocolor="$(print -P \"${base_prompt_nocolor}${gitinfo_nocolor}${post_prompt_nocolor}\")"
|
||||||
local prompt_length=${#exp_nocolor}
|
local prompt_length=${#exp_nocolor}
|
||||||
|
|
||||||
PROMPT="${base_prompt}${gitinfo}${post_prompt}"
|
PROMPT="${base_prompt}\$(git_prompt_info)${post_prompt}"
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt_setup_pygmalion
|
prompt_setup_pygmalion
|
||||||
|
|
|
@ -33,8 +33,8 @@ autoload -Uz vcs_info
|
||||||
zstyle ':vcs_info:*' enable hg bzr git
|
zstyle ':vcs_info:*' enable hg bzr git
|
||||||
zstyle ':vcs_info:*:*' unstagedstr '!'
|
zstyle ':vcs_info:*:*' unstagedstr '!'
|
||||||
zstyle ':vcs_info:*:*' stagedstr '+'
|
zstyle ':vcs_info:*:*' stagedstr '+'
|
||||||
zstyle ':vcs_info:*:*' formats "$FX[bold]%r$FX[no-bold]/%S" "%s/%b" "%%u%c"
|
zstyle ':vcs_info:*:*' formats "$FX[bold]%r$FX[no-bold]/%S" "%s:%b" "%%u%c"
|
||||||
zstyle ':vcs_info:*:*' actionformats "$FX[bold]%r$FX[no-bold]/%S" "%s/%b" "%u%c (%a)"
|
zstyle ':vcs_info:*:*' actionformats "$FX[bold]%r$FX[no-bold]/%S" "%s:%b" "%u%c (%a)"
|
||||||
zstyle ':vcs_info:*:*' nvcsformats "%~" "" ""
|
zstyle ':vcs_info:*:*' nvcsformats "%~" "" ""
|
||||||
|
|
||||||
# Fastest possible way to check if repo is dirty
|
# Fastest possible way to check if repo is dirty
|
||||||
|
@ -70,6 +70,7 @@ preexec() {
|
||||||
# Output additional information about paths, repos and exec time
|
# Output additional information about paths, repos and exec time
|
||||||
#
|
#
|
||||||
precmd() {
|
precmd() {
|
||||||
|
setopt localoptions nopromptsubst
|
||||||
vcs_info # Get version control info before we start outputting stuff
|
vcs_info # Get version control info before we start outputting stuff
|
||||||
print -P "\n$(repo_information) %F{yellow}$(cmd_exec_time)%f"
|
print -P "\n$(repo_information) %F{yellow}$(cmd_exec_time)%f"
|
||||||
unset cmd_timestamp #Reset cmd exec time.
|
unset cmd_timestamp #Reset cmd exec time.
|
||||||
|
|
|
@ -5,8 +5,10 @@
|
||||||
#
|
#
|
||||||
# Mar 2013 Yad Smood
|
# Mar 2013 Yad Smood
|
||||||
|
|
||||||
|
typeset +H my_gray="$FG[247]"
|
||||||
|
|
||||||
# VCS
|
# VCS
|
||||||
YS_VCS_PROMPT_PREFIX1=" %{$fg[white]%}on%{$reset_color%} "
|
YS_VCS_PROMPT_PREFIX1=" %{$my_gray%}on%{$reset_color%} "
|
||||||
YS_VCS_PROMPT_PREFIX2=":%{$fg[cyan]%}"
|
YS_VCS_PROMPT_PREFIX2=":%{$fg[cyan]%}"
|
||||||
YS_VCS_PROMPT_SUFFIX="%{$reset_color%}"
|
YS_VCS_PROMPT_SUFFIX="%{$reset_color%}"
|
||||||
YS_VCS_PROMPT_DIRTY=" %{$fg[red]%}x"
|
YS_VCS_PROMPT_DIRTY=" %{$fg[red]%}x"
|
||||||
|
@ -60,13 +62,13 @@ local exit_code="%(?,,C:%{$fg[red]%}%?%{$reset_color%})"
|
||||||
PROMPT="
|
PROMPT="
|
||||||
%{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \
|
%{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \
|
||||||
%(#,%{$bg[yellow]%}%{$fg[black]%}%n%{$reset_color%},%{$fg[cyan]%}%n) \
|
%(#,%{$bg[yellow]%}%{$fg[black]%}%n%{$reset_color%},%{$fg[cyan]%}%n) \
|
||||||
%{$fg[white]%}@ \
|
%{$my_gray%}@ \
|
||||||
%{$fg[green]%}%m \
|
%{$fg[green]%}%m \
|
||||||
%{$fg[white]%}in \
|
%{$my_gray%}in \
|
||||||
%{$terminfo[bold]$fg[yellow]%}%~%{$reset_color%}\
|
%{$terminfo[bold]$fg[yellow]%}%~%{$reset_color%}\
|
||||||
${hg_info}\
|
${hg_info}\
|
||||||
${git_info}\
|
${git_info}\
|
||||||
${venv_info}\
|
${venv_info}\
|
||||||
\
|
\
|
||||||
%{$fg[white]%}[%*] $exit_code
|
%{$my_gray%}[%*] $exit_code
|
||||||
%{$terminfo[bold]$fg[red]%}$ %{$reset_color%}"
|
%{$terminfo[bold]$fg[red]%}$ %{$reset_color%}"
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
cd "$ZSH"
|
||||||
|
setopt extendedglob
|
||||||
|
|
||||||
##############################
|
##############################
|
||||||
# CHANGELOG SCRIPT CONSTANTS #
|
# CHANGELOG SCRIPT CONSTANTS #
|
||||||
##############################
|
##############################
|
||||||
|
@ -49,10 +52,15 @@ function parse-commit {
|
||||||
# make a breaking change
|
# make a breaking change
|
||||||
|
|
||||||
function commit:type {
|
function commit:type {
|
||||||
local type="$(sed -E 's/^([a-zA-Z_\-]+)(\(.+\))?!?: .+$/\1/' <<< "$1")"
|
local type
|
||||||
|
|
||||||
|
# Parse commit type from the subject
|
||||||
|
if [[ "$1" =~ '^([a-zA-Z_\-]+)(\(.+\))?!?: .+$' ]]; then
|
||||||
|
type="${match[1]}"
|
||||||
|
fi
|
||||||
|
|
||||||
# If $type doesn't appear in $TYPES array mark it as 'other'
|
# If $type doesn't appear in $TYPES array mark it as 'other'
|
||||||
if [[ -n "${(k)TYPES[(i)$type]}" ]]; then
|
if [[ -n "$type" && -n "${(k)TYPES[(i)$type]}" ]]; then
|
||||||
echo $type
|
echo $type
|
||||||
else
|
else
|
||||||
echo other
|
echo other
|
||||||
|
@ -63,25 +71,30 @@ function parse-commit {
|
||||||
local scope
|
local scope
|
||||||
|
|
||||||
# Try to find scope in "type(<scope>):" format
|
# Try to find scope in "type(<scope>):" format
|
||||||
scope=$(sed -nE 's/^[a-zA-Z_\-]+\((.+)\)!?: .+$/\1/p' <<< "$1")
|
if [[ "$1" =~ '^[a-zA-Z_\-]+\((.+)\)!?: .+$' ]]; then
|
||||||
if [[ -n "$scope" ]]; then
|
echo "${match[1]}"
|
||||||
echo "$scope"
|
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If no scope found, try to find it in "<scope>:" format
|
# If no scope found, try to find it in "<scope>:" format
|
||||||
|
if [[ "$1" =~ '^([a-zA-Z_\-]+): .+$' ]]; then
|
||||||
|
scope="${match[1]}"
|
||||||
# Make sure it's not a type before printing it
|
# Make sure it's not a type before printing it
|
||||||
scope=$(sed -nE 's/^([a-zA-Z_\-]+): .+$/\1/p' <<< "$1")
|
|
||||||
if [[ -z "${(k)TYPES[(i)$scope]}" ]]; then
|
if [[ -z "${(k)TYPES[(i)$scope]}" ]]; then
|
||||||
echo "$scope"
|
echo "$scope"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function commit:subject {
|
function commit:subject {
|
||||||
# Only display the relevant part of the commit, i.e. if it has the format
|
# Only display the relevant part of the commit, i.e. if it has the format
|
||||||
# type[(scope)!]: subject, where the part between [] is optional, only
|
# type[(scope)!]: subject, where the part between [] is optional, only
|
||||||
# displays subject. If it doesn't match the format, returns the whole string.
|
# displays subject. If it doesn't match the format, returns the whole string.
|
||||||
sed -E 's/^[a-zA-Z_\-]+(\(.+\))?!?: (.+)$/\2/' <<< "$1"
|
if [[ "$1" =~ '^[a-zA-Z_\-]+(\(.+\))?!?: (.+)$' ]]; then
|
||||||
|
echo "${match[2]}"
|
||||||
|
else
|
||||||
|
echo "$1"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Return subject if the body or subject match the breaking change format
|
# Return subject if the body or subject match the breaking change format
|
||||||
|
@ -114,15 +127,8 @@ function parse-commit {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Ignore commit if it is a merge commit
|
|
||||||
if [[ $(command git show -s --format=%p $1 | wc -w) -gt 1 ]]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Parse commit with hash $1
|
# Parse commit with hash $1
|
||||||
local hash="$1" subject body warning rhash
|
local hash="$1" subject="$2" body="$3" warning rhash
|
||||||
subject="$(command git show -s --format=%s $hash)"
|
|
||||||
body="$(command git show -s --format=%b $hash)"
|
|
||||||
|
|
||||||
# Commits following Conventional Commits (https://www.conventionalcommits.org/)
|
# Commits following Conventional Commits (https://www.conventionalcommits.org/)
|
||||||
# have the following format, where parts between [] are optional:
|
# have the following format, where parts between [] are optional:
|
||||||
|
@ -195,9 +201,9 @@ function display-release {
|
||||||
#* Uses $hash from outer scope
|
#* Uses $hash from outer scope
|
||||||
local hash="${1:-$hash}"
|
local hash="${1:-$hash}"
|
||||||
case "$output" in
|
case "$output" in
|
||||||
raw) printf "$hash" ;;
|
raw) printf '%s' "$hash" ;;
|
||||||
text) printf "\e[33m$hash\e[0m" ;; # red
|
text) printf '\e[33m%s\e[0m' "$hash" ;; # red
|
||||||
md) printf "[\`$hash\`](https://github.com/ohmyzsh/ohmyzsh/commit/$hash)" ;;
|
md) printf '[`%s`](https://github.com/ohmyzsh/ohmyzsh/commit/%s)' "$hash" ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,16 +215,16 @@ function display-release {
|
||||||
case "$output" in
|
case "$output" in
|
||||||
raw)
|
raw)
|
||||||
case "$level" in
|
case "$level" in
|
||||||
1) printf "$header\n$(printf '%.0s=' {1..${#header}})\n\n" ;;
|
1) printf '%s\n%s\n\n' "$header" "$(printf '%.0s=' {1..${#header}})" ;;
|
||||||
2) printf "$header\n$(printf '%.0s-' {1..${#header}})\n\n" ;;
|
2) printf '%s\n%s\n\n' "$header" "$(printf '%.0s-' {1..${#header}})" ;;
|
||||||
*) printf "$header:\n\n" ;;
|
*) printf '%s:\n\n' "$header" ;;
|
||||||
esac ;;
|
esac ;;
|
||||||
text)
|
text)
|
||||||
case "$level" in
|
case "$level" in
|
||||||
1|2) printf "\e[1;4m$header\e[0m\n\n" ;; # bold, underlined
|
1|2) printf '\e[1;4m%s\e[0m\n\n' "$header" ;; # bold, underlined
|
||||||
*) printf "\e[1m$header:\e[0m\n\n" ;; # bold
|
*) printf '\e[1m%s:\e[0m\n\n' "$header" ;; # bold
|
||||||
esac ;;
|
esac ;;
|
||||||
md) printf "$(printf '%.0s#' {1..${level}}) $header\n\n" ;;
|
md) printf '%s %s\n\n' "$(printf '%.0s#' {1..${level}})" "$header" ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,8 +250,8 @@ function display-release {
|
||||||
|
|
||||||
# Print [scope]
|
# Print [scope]
|
||||||
case "$output" in
|
case "$output" in
|
||||||
raw|md) printf "[$scope]${padding} " ;;
|
raw|md) printf '[%s]%s ' "$scope" "$padding";;
|
||||||
text) printf "[\e[38;5;9m$scope\e[0m]${padding} " ;; # red 9
|
text) printf '[\e[38;5;9m%s\e[0m]%s ' "$scope" "$padding";; # red 9
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +264,7 @@ function display-release {
|
||||||
subject="${(U)subject:0:1}${subject:1}"
|
subject="${(U)subject:0:1}${subject:1}"
|
||||||
|
|
||||||
case "$output" in
|
case "$output" in
|
||||||
raw) printf "$subject" ;;
|
raw) printf '%s' "$subject" ;;
|
||||||
# In text mode, highlight (#<issue>) and dim text between `backticks`
|
# In text mode, highlight (#<issue>) and dim text between `backticks`
|
||||||
text) sed -E $'s|#([0-9]+)|\e[32m#\\1\e[0m|g;s|`([^`]+)`|`\e[2m\\1\e[0m`|g' <<< "$subject" ;;
|
text) sed -E $'s|#([0-9]+)|\e[32m#\\1\e[0m|g;s|`([^`]+)`|`\e[2m\\1\e[0m`|g' <<< "$subject" ;;
|
||||||
# In markdown mode, link to (#<issue>) issues
|
# In markdown mode, link to (#<issue>) issues
|
||||||
|
@ -271,8 +277,8 @@ function display-release {
|
||||||
local type="${1:-${TYPES[$type]:-${(C)type}}}"
|
local type="${1:-${TYPES[$type]:-${(C)type}}}"
|
||||||
[[ -z "$type" ]] && return 0
|
[[ -z "$type" ]] && return 0
|
||||||
case "$output" in
|
case "$output" in
|
||||||
raw|md) printf "$type: " ;;
|
raw|md) printf '%s: ' "$type" ;;
|
||||||
text) printf "\e[4m$type\e[24m: " ;; # underlined
|
text) printf '\e[4m%s\e[24m: ' "$type" ;; # underlined
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,7 +292,7 @@ function display-release {
|
||||||
(( $#breaking != 0 )) || return 0
|
(( $#breaking != 0 )) || return 0
|
||||||
|
|
||||||
case "$output" in
|
case "$output" in
|
||||||
text) fmt:header "\e[31mBREAKING CHANGES" 3 ;;
|
text) printf '\e[31m'; fmt:header "BREAKING CHANGES" 3 ;;
|
||||||
raw) fmt:header "BREAKING CHANGES" 3 ;;
|
raw) fmt:header "BREAKING CHANGES" 3 ;;
|
||||||
md) fmt:header "BREAKING CHANGES ⚠" 3 ;;
|
md) fmt:header "BREAKING CHANGES ⚠" 3 ;;
|
||||||
esac
|
esac
|
||||||
|
@ -384,7 +390,8 @@ function main {
|
||||||
# Commit classification arrays
|
# Commit classification arrays
|
||||||
local -A commits subjects scopes breaking reverts
|
local -A commits subjects scopes breaking reverts
|
||||||
local truncate=0 read_commits=0
|
local truncate=0 read_commits=0
|
||||||
local hash version tag
|
local version tag
|
||||||
|
local hash refs subject body
|
||||||
|
|
||||||
# Get the first version name:
|
# Get the first version name:
|
||||||
# 1) try tag-like version, or
|
# 1) try tag-like version, or
|
||||||
|
@ -396,17 +403,41 @@ function main {
|
||||||
|| version=$(command git symbolic-ref --quiet --short $until 2>/dev/null) \
|
|| version=$(command git symbolic-ref --quiet --short $until 2>/dev/null) \
|
||||||
|| version=$(command git rev-parse --short $until 2>/dev/null)
|
|| version=$(command git rev-parse --short $until 2>/dev/null)
|
||||||
|
|
||||||
# Get commit list from $until commit until $since commit, or until root
|
# Get commit list from $until commit until $since commit, or until root commit if $since is unset
|
||||||
# commit if $since is unset, in short hash form.
|
local range=${since:+$since..}$until
|
||||||
command git rev-list --abbrev-commit --abbrev=7 ${since:+$since..}$until | while read hash; do
|
|
||||||
|
# Git log options
|
||||||
|
# -z: commits are delimited by null bytes
|
||||||
|
# --format: [7-char hash]<field sep>[ref names]<field sep>[subject]<field sep>[body]
|
||||||
|
# --abbrev=7: force commit hashes to be 7 characters long
|
||||||
|
# --no-merges: merge commits are omitted
|
||||||
|
# --first-parent: commits from merged branches are omitted
|
||||||
|
local SEP="0mZmAgIcSeP"
|
||||||
|
local -a raw_commits
|
||||||
|
raw_commits=(${(0)"$(command git log -z \
|
||||||
|
--format="%h${SEP}%D${SEP}%s${SEP}%b" --abbrev=7 \
|
||||||
|
--no-merges --first-parent $range)"})
|
||||||
|
|
||||||
|
local raw_commit
|
||||||
|
local -a raw_fields
|
||||||
|
for raw_commit in $raw_commits; do
|
||||||
# Truncate list on versions with a lot of commits
|
# Truncate list on versions with a lot of commits
|
||||||
if [[ -z "$since" ]] && (( ++read_commits > 35 )); then
|
if [[ -z "$since" ]] && (( ++read_commits > 35 )); then
|
||||||
truncate=1
|
truncate=1
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Read the commit fields (@ is needed to keep empty values)
|
||||||
|
eval "raw_fields=(\"\${(@ps:$SEP:)raw_commit}\")"
|
||||||
|
hash="${raw_fields[1]}"
|
||||||
|
refs="${raw_fields[2]}"
|
||||||
|
subject="${raw_fields[3]}"
|
||||||
|
body="${raw_fields[4]}"
|
||||||
|
|
||||||
# If we find a new release (exact tag)
|
# If we find a new release (exact tag)
|
||||||
if tag=$(command git describe --exact-match --tags $hash 2>/dev/null); then
|
if [[ "$refs" = *tag:\ * ]]; then
|
||||||
|
# Parse tag name (needs: setopt extendedglob)
|
||||||
|
tag="${${refs##*tag: }%%,# *}"
|
||||||
# Output previous release
|
# Output previous release
|
||||||
display-release
|
display-release
|
||||||
# Reinitialize commit storage
|
# Reinitialize commit storage
|
||||||
|
@ -420,7 +451,7 @@ function main {
|
||||||
read_commits=1
|
read_commits=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
parse-commit "$hash"
|
parse-commit "$hash" "$subject" "$body"
|
||||||
done
|
done
|
||||||
|
|
||||||
display-release
|
display-release
|
||||||
|
@ -431,8 +462,6 @@ function main {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cd "$ZSH"
|
|
||||||
|
|
||||||
# Use raw output if stdout is not a tty
|
# Use raw output if stdout is not a tty
|
||||||
if [[ ! -t 1 && -z "$3" ]]; then
|
if [[ ! -t 1 && -z "$3" ]]; then
|
||||||
main "$1" "$2" --raw
|
main "$1" "$2" --raw
|
||||||
|
|
|
@ -3,22 +3,80 @@ if [[ -f ~/.zsh-update && ! -f "${ZSH_CACHE_DIR}/.zsh-update" ]]; then
|
||||||
mv ~/.zsh-update "${ZSH_CACHE_DIR}/.zsh-update"
|
mv ~/.zsh-update "${ZSH_CACHE_DIR}/.zsh-update"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Get user's update preferences
|
||||||
|
#
|
||||||
|
# Supported update modes:
|
||||||
|
# - prompt (default): the user is asked before updating when it's time to update
|
||||||
|
# - auto: the update is performed automatically when it's time
|
||||||
|
# - reminder: a reminder is shown to the user when it's time to update
|
||||||
|
# - disabled: automatic update is turned off
|
||||||
|
zstyle -s ':omz:update' mode update_mode || update_mode=prompt
|
||||||
|
|
||||||
|
# Support old-style settings
|
||||||
|
[[ "$DISABLE_UPDATE_PROMPT" != true ]] || update_mode=auto
|
||||||
|
[[ "$DISABLE_AUTO_UPDATE" != true ]] || update_mode=disabled
|
||||||
|
|
||||||
# Cancel update if:
|
# Cancel update if:
|
||||||
# - the automatic update is disabled.
|
# - the automatic update is disabled.
|
||||||
# - the current user doesn't have write permissions nor owns the $ZSH directory.
|
# - the current user doesn't have write permissions nor owns the $ZSH directory.
|
||||||
# - git is unavailable on the system.
|
# - git is unavailable on the system.
|
||||||
if [[ "$DISABLE_AUTO_UPDATE" = true ]] \
|
if [[ "$update_mode" = disabled ]] \
|
||||||
|| [[ ! -w "$ZSH" || ! -O "$ZSH" ]] \
|
|| [[ ! -w "$ZSH" || ! -O "$ZSH" ]] \
|
||||||
|| ! command -v git &>/dev/null; then
|
|| ! command -v git &>/dev/null; then
|
||||||
|
unset update_mode
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
function current_epoch() {
|
function current_epoch() {
|
||||||
zmodload zsh/datetime
|
zmodload zsh/datetime
|
||||||
echo $(( EPOCHSECONDS / 60 / 60 / 24 ))
|
echo $(( EPOCHSECONDS / 60 / 60 / 24 ))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function is_update_available() {
|
||||||
|
local branch
|
||||||
|
branch=${"$(cd "$ZSH"; git config --local oh-my-zsh.branch)":-master}
|
||||||
|
|
||||||
|
local remote remote_url remote_repo
|
||||||
|
remote=${"$(cd "$ZSH"; git config --local oh-my-zsh.remote)":-origin}
|
||||||
|
remote_url=$(cd "$ZSH"; git config remote.$remote.url)
|
||||||
|
|
||||||
|
local repo
|
||||||
|
case "$remote_url" in
|
||||||
|
https://github.com/*) repo=${${remote_url#https://github.com/}%.git} ;;
|
||||||
|
git@github.com:*) repo=${${remote_url#git@github.com:}%.git} ;;
|
||||||
|
*)
|
||||||
|
# If the remote is not using GitHub we can't check for updates
|
||||||
|
# Let's assume there are updates
|
||||||
|
return 0 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# If the remote repo is not the official one, let's assume there are updates available
|
||||||
|
[[ "$repo" = ohmyzsh/ohmyzsh ]] || return 0
|
||||||
|
local api_url="https://api.github.com/repos/${repo}/commits/${branch}"
|
||||||
|
|
||||||
|
# Get local HEAD. If this fails assume there are updates
|
||||||
|
local local_head
|
||||||
|
local_head=$(cd "$ZSH"; git rev-parse $branch 2>/dev/null) || return 0
|
||||||
|
|
||||||
|
# Get remote HEAD. If no suitable command is found assume there are updates
|
||||||
|
# On any other error, skip the update (connection may be down)
|
||||||
|
local remote_head
|
||||||
|
remote_head=$(
|
||||||
|
if (( ${+commands[curl]} )); then
|
||||||
|
curl -fsSL -H 'Accept: application/vnd.github.v3.sha' $api_url 2>/dev/null
|
||||||
|
elif (( ${+commands[wget]} )); then
|
||||||
|
wget -O- --header='Accept: application/vnd.github.v3.sha' $api_url 2>/dev/null
|
||||||
|
elif (( ${+commands[fetch]} )); then
|
||||||
|
HTTP_ACCEPT='Accept: application/vnd.github.v3.sha' fetch -o - $api_url 2>/dev/null
|
||||||
|
else
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
) || return 1
|
||||||
|
|
||||||
|
# Compare local and remote HEADs
|
||||||
|
[[ "$local_head" != "$remote_head" ]]
|
||||||
|
}
|
||||||
|
|
||||||
function update_last_updated_file() {
|
function update_last_updated_file() {
|
||||||
echo "LAST_EPOCH=$(current_epoch)" >! "${ZSH_CACHE_DIR}/.zsh-update"
|
echo "LAST_EPOCH=$(current_epoch)" >! "${ZSH_CACHE_DIR}/.zsh-update"
|
||||||
}
|
}
|
||||||
|
@ -56,7 +114,8 @@ function update_ohmyzsh() {
|
||||||
# the shell actually exits what it's running.
|
# the shell actually exits what it's running.
|
||||||
trap "
|
trap "
|
||||||
ret=\$?
|
ret=\$?
|
||||||
unset -f current_epoch update_last_updated_file update_ohmyzsh 2>/dev/null
|
unset update_mode
|
||||||
|
unset -f current_epoch is_update_available update_last_updated_file update_ohmyzsh 2>/dev/null
|
||||||
command rm -rf '$ZSH/log/update.lock'
|
command rm -rf '$ZSH/log/update.lock'
|
||||||
return \$ret
|
return \$ret
|
||||||
" EXIT INT QUIT
|
" EXIT INT QUIT
|
||||||
|
@ -68,15 +127,22 @@ function update_ohmyzsh() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Number of days before trying to update again
|
# Number of days before trying to update again
|
||||||
epoch_target=${UPDATE_ZSH_DAYS:-13}
|
zstyle -s ':omz:update' frequency epoch_target || epoch_target=${UPDATE_ZSH_DAYS:-13}
|
||||||
# Test if enough time has passed until the next update
|
# Test if enough time has passed until the next update
|
||||||
if (( ( $(current_epoch) - $LAST_EPOCH ) < $epoch_target )); then
|
if (( ( $(current_epoch) - $LAST_EPOCH ) < $epoch_target )); then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ask for confirmation before updating unless disabled
|
# Check if there are updates available before proceeding
|
||||||
if [[ "$DISABLE_UPDATE_PROMPT" = true ]]; then
|
if ! is_update_available; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ask for confirmation before updating unless in auto mode
|
||||||
|
if [[ "$update_mode" = auto ]]; then
|
||||||
update_ohmyzsh
|
update_ohmyzsh
|
||||||
|
elif [[ "$update_mode" = reminder ]]; then
|
||||||
|
echo "[oh-my-zsh] It's time to update! You can do that by running \`omz update\`"
|
||||||
else
|
else
|
||||||
# input sink to swallow all characters typed before the prompt
|
# input sink to swallow all characters typed before the prompt
|
||||||
# and add a newline if there wasn't one after characters typed
|
# and add a newline if there wasn't one after characters typed
|
||||||
|
@ -92,3 +158,6 @@ function update_ohmyzsh() {
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unset update_mode
|
||||||
|
unset -f current_epoch is_update_available update_last_updated_file update_ohmyzsh
|
||||||
|
|
|
@ -311,7 +311,7 @@ EOF
|
||||||
# 1. Use the most preceding one based on $PATH, then check that it's in the shells file
|
# 1. Use the most preceding one based on $PATH, then check that it's in the shells file
|
||||||
# 2. If that fails, get a zsh path from the shells file, then check it actually exists
|
# 2. If that fails, get a zsh path from the shells file, then check it actually exists
|
||||||
if ! zsh=$(command -v zsh) || ! grep -qx "$zsh" "$shells_file"; then
|
if ! zsh=$(command -v zsh) || ! grep -qx "$zsh" "$shells_file"; then
|
||||||
if ! zsh=$(grep '^/.*/zsh$' "$shells_file" | tail -1) || [ ! -f "$zsh" ]; then
|
if ! zsh=$(grep '^/.*/zsh$' "$shells_file" | tail -n 1) || [ ! -f "$zsh" ]; then
|
||||||
fmt_error "no zsh binary found or not present in '$shells_file'"
|
fmt_error "no zsh binary found or not present in '$shells_file'"
|
||||||
fmt_error "change your default shell manually."
|
fmt_error "change your default shell manually."
|
||||||
return
|
return
|
||||||
|
|
101
tools/upgrade.sh
101
tools/upgrade.sh
|
@ -15,11 +15,98 @@ cd "$ZSH"
|
||||||
# Use colors, but only if connected to a terminal
|
# Use colors, but only if connected to a terminal
|
||||||
# and that terminal supports them.
|
# and that terminal supports them.
|
||||||
|
|
||||||
|
# The [ -t 1 ] check only works when the function is not called from
|
||||||
|
# a subshell (like in `$(...)` or `(...)`, so this hack redefines the
|
||||||
|
# function at the top level to always return false when stdout is not
|
||||||
|
# a tty.
|
||||||
|
if [ -t 1 ]; then
|
||||||
|
is_tty() {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
else
|
||||||
|
is_tty() {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# This function uses the logic from supports-hyperlinks[1][2], which is
|
||||||
|
# made by Kat Marchán (@zkat) and licensed under the Apache License 2.0.
|
||||||
|
# [1] https://github.com/zkat/supports-hyperlinks
|
||||||
|
# [2] https://crates.io/crates/supports-hyperlinks
|
||||||
|
#
|
||||||
|
# Copyright (c) 2021 Kat Marchán
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
supports_hyperlinks() {
|
||||||
|
# $FORCE_HYPERLINK must be set and be non-zero (this acts as a logic bypass)
|
||||||
|
if [ -n "$FORCE_HYPERLINK" ]; then
|
||||||
|
[ "$FORCE_HYPERLINK" != 0 ]
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If stdout is not a tty, it doesn't support hyperlinks
|
||||||
|
is_tty || return 1
|
||||||
|
|
||||||
|
# DomTerm terminal emulator (domterm.org)
|
||||||
|
if [ -n "$DOMTERM" ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# VTE-based terminals above v0.50 (Gnome Terminal, Guake, ROXTerm, etc)
|
||||||
|
if [ -n "$VTE_VERSION" ]; then
|
||||||
|
[ $VTE_VERSION -ge 5000 ]
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If $TERM_PROGRAM is set, these terminals support hyperlinks
|
||||||
|
case "$TERM_PROGRAM" in
|
||||||
|
Hyper|iTerm.app|terminology|WezTerm) return 0 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# kitty supports hyperlinks
|
||||||
|
if [ "$TERM" = xterm-kitty ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Windows Terminal or Konsole also support hyperlinks
|
||||||
|
if [ -n "$WT_SESSION" ] || [ -n "$KONSOLE_VERSION" ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt_link() {
|
||||||
|
# $1: text, $2: url, $3: fallback mode
|
||||||
|
if supports_hyperlinks; then
|
||||||
|
printf '\033]8;;%s\a%s\033]8;;\a\n' "$2" "$1"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$3" in
|
||||||
|
--text) printf '%s\n' "$1" ;;
|
||||||
|
--url|*) fmt_underline "$2" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt_underline() {
|
||||||
|
is_tty && printf '\033[4m%s\033[24m\n' "$*" || printf '%s\n' "$*"
|
||||||
|
}
|
||||||
|
|
||||||
setopt typeset_silent
|
setopt typeset_silent
|
||||||
typeset -a RAINBOW
|
typeset -a RAINBOW
|
||||||
typeset RED GREEN YELLOW BLUE BOLD DIM UNDER RESET
|
|
||||||
|
|
||||||
if [ -t 1 ]; then
|
if is_tty; then
|
||||||
RAINBOW=(
|
RAINBOW=(
|
||||||
"$(printf '\033[38;5;196m')"
|
"$(printf '\033[38;5;196m')"
|
||||||
"$(printf '\033[38;5;202m')"
|
"$(printf '\033[38;5;202m')"
|
||||||
|
@ -35,8 +122,6 @@ if [ -t 1 ]; then
|
||||||
YELLOW=$(printf '\033[33m')
|
YELLOW=$(printf '\033[33m')
|
||||||
BLUE=$(printf '\033[34m')
|
BLUE=$(printf '\033[34m')
|
||||||
BOLD=$(printf '\033[1m')
|
BOLD=$(printf '\033[1m')
|
||||||
DIM=$(printf '\033[2m')
|
|
||||||
UNDER=$(printf '\033[4m')
|
|
||||||
RESET=$(printf '\033[0m')
|
RESET=$(printf '\033[0m')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -104,10 +189,10 @@ if git pull --rebase --stat $remote $branch; then
|
||||||
printf '%s\____/%s_/ /_/ %s /_/ /_/ /_/%s\__, / %s /___/%s____/%s_/ /_/ %s\n' $RAINBOW $RESET
|
printf '%s\____/%s_/ /_/ %s /_/ /_/ /_/%s\__, / %s /___/%s____/%s_/ /_/ %s\n' $RAINBOW $RESET
|
||||||
printf '%s %s %s %s /____/ %s %s %s %s\n' $RAINBOW $RESET
|
printf '%s %s %s %s /____/ %s %s %s %s\n' $RAINBOW $RESET
|
||||||
printf '\n'
|
printf '\n'
|
||||||
printf "${BLUE}%s${RESET}\n" "$message"
|
printf "${BLUE}%s${RESET}\n\n" "$message"
|
||||||
printf "${BLUE}${BOLD}%s ${UNDER}%s${RESET}\n" "To keep up with the latest news and updates, follow us on Twitter:" "https://twitter.com/ohmyzsh"
|
printf "${BLUE}${BOLD}%s %s${RESET}\n" "To keep up with the latest news and updates, follow us on Twitter:" "$(fmt_link @ohmyzsh https://twitter.com/ohmyzsh)"
|
||||||
printf "${BLUE}${BOLD}%s ${UNDER}%s${RESET}\n" "Want to get involved in the community? Join our Discord:" "https://discord.gg/ohmyzsh"
|
printf "${BLUE}${BOLD}%s %s${RESET}\n" "Want to get involved in the community? Join our Discord:" "$(fmt_link "Discord server" https://discord.gg/ohmyzsh)"
|
||||||
printf "${BLUE}${BOLD}%s ${UNDER}%s${RESET}\n" "Get your Oh My Zsh swag at:" "https://shop.planetargon.com/collections/oh-my-zsh"
|
printf "${BLUE}${BOLD}%s %s${RESET}\n" "Get your Oh My Zsh swag at:" "$(fmt_link "Planet Argon Shop" https://shop.planetargon.com/collections/oh-my-zsh)"
|
||||||
else
|
else
|
||||||
ret=$?
|
ret=$?
|
||||||
printf "${RED}%s${RESET}\n" 'There was an error updating. Try again later?'
|
printf "${RED}%s${RESET}\n" 'There was an error updating. Try again later?'
|
||||||
|
|
Loading…
Reference in a new issue