This commit is contained in:
abc 2023-09-18 11:12:08 +08:00
commit ea8b5ffe3b
45 changed files with 1207 additions and 607 deletions

View file

@ -51,5 +51,4 @@ jobs:
run: |
cp tools/install.sh .github/workflows/installer/install.sh
cd .github/workflows/installer
vc link --yes -t ${{ secrets.VERCEL_TOKEN }}
vc deploy --prod -t ${{ secrets.VERCEL_TOKEN }}

View file

@ -100,8 +100,8 @@ function detect-clipboard() {
fi
}
# Detect at startup. A non-zero exit here indicates that the dummy clipboards were set,
# which is not really an error. If the user calls them, they will attempt to redetect
# (for example, perhaps the user has now installed xclip) and then either print an error
# or proceed successfully.
detect-clipboard || true
function clipcopy clippaste {
unfunction clipcopy clippaste
detect-clipboard || true # let one retry
"$0" "$@"
}

View file

@ -17,7 +17,7 @@ function title {
: ${2=$1}
case "$TERM" in
cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*|foot|contour*)
cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*|foot*|contour*)
print -Pn "\e]2;${2:q}\a" # set window name
print -Pn "\e]1;${1:q}\a" # set tab name
;;

View file

@ -1,14 +1,14 @@
# ANSI formatting function (\033[<code>m)
# 0: reset, 1: bold, 4: underline, 22: no bold, 24: no underline, 31: red, 33: yellow
omz_f() {
[ $# -gt 0 ] || return
IFS=";" printf "\033[%sm" $*
}
# If stdout is not a terminal ignore all formatting
[ -t 1 ] || omz_f() { :; }
# Protect against non-zsh execution of Oh My Zsh (use POSIX syntax here)
[ -n "$ZSH_VERSION" ] || {
# ANSI formatting function (\033[<code>m)
# 0: reset, 1: bold, 4: underline, 22: no bold, 24: no underline, 31: red, 33: yellow
omz_f() {
[ $# -gt 0 ] || return
IFS=";" printf "\033[%sm" $*
}
# If stdout is not a terminal ignore all formatting
[ -t 1 ] || omz_f() { :; }
omz_ptree() {
# Get process tree of the current process
pid=$$; pids="$pid"
@ -38,6 +38,15 @@
return 1
}
# Check if in emulation mode, if so early return
# https://github.com/ohmyzsh/ohmyzsh/issues/11686
[[ "$(emulate)" = zsh ]] || {
printf "$(omz_f 1 31)Error:$(omz_f 22) Oh My Zsh can't be loaded in \`$(emulate)\` emulation mode.$(omz_f 0)\n" >&2
return 1
}
unset -f omz_f
# If ZSH is not defined, use the current script's directory.
[[ -z "$ZSH" ]] && export ZSH="${${(%):-%x}:a:h}"
@ -187,12 +196,12 @@ _omz_source() {
fi
}
# Load all of the config files in ~/oh-my-zsh that end in .zsh
# Load all of the lib files in ~/oh-my-zsh/lib that end in .zsh
# TIP: Add files you don't want in git to .gitignore
for config_file ("$ZSH"/lib/*.zsh); do
_omz_source "lib/${config_file:t}"
for lib_file ("$ZSH"/lib/*.zsh); do
_omz_source "lib/${lib_file:t}"
done
unset custom_config_file
unset lib_file
# Load all of the plugins that were defined in ~/.zshrc
for plugin ($plugins); do

View file

@ -0,0 +1,9 @@
tap: false
directories:
tests: tests
output: tests/_output
support: tests/_support
time_limit: 0
fail_fast: false
allow_risky: false
verbose: true

View file

@ -2,45 +2,32 @@
This plugin searches the defined aliases and outputs any that match the command inputted. This makes learning new aliases easier.
## Usage
To use it, add `alias-finder` to the `plugins` array of your zshrc file:
```
plugins=(... alias-finder)
```
## Usage
To see if there is an alias defined for the command, pass it as an argument to `alias-finder`. This can also run automatically before each command you input - add `ZSH_ALIAS_FINDER_AUTOMATIC=true` to your zshrc if you want this.
To enable it for every single command, set zstyle in your `~/.zshrc`.
## Options
```zsh
# ~/.zshrc
zstyle ':omz:plugins:alias-finder' autoload yes # disabled by default
zstyle ':omz:plugins:alias-finder' longer yes # disabled by default
zstyle ':omz:plugins:alias-finder' exact yes # disabled by default
zstyle ':omz:plugins:alias-finder' cheaper yes # disabled by default
```
As you can see, options are also available with zstyle.
### Options
> In order to clarify, let's say `alias a=abc` has source 'abc' and destination 'a'.
- Use `--longer` or `-l` to include aliases where the source is longer than the input (in other words, the source could contain the whole input).
- Use `--exact` or `-e` to avoid aliases where the source is shorter than the input (in other words, the source must be the same with the input).
- Use `--cheaper` or `-c` to avoid aliases where the destination is longer than the input (in other words, the destination must be the shorter than the input).
- Use `--longer` or `-l` to allow the aliases to be longer than the input (match aliases if they contain the input).
- Use `--exact` or `-e` to avoid matching aliases that are shorter than the input.
## Examples
```
$ alias-finder "git pull"
gl='git pull'
g=git
```
```
$ alias-finder "web_search google oh my zsh"
google='web_search google'
```
```
$ alias-finder "git commit -v"
gc="git commit -v"
g=git
```
```
$ alias-finder -e "git commit -v"
gc='git commit -v'
```
```
$ alias-finder -l "git commit -v"
gc='git commit -v'
'gc!'='git commit -v --amend'
gca='git commit -v -a'
'gca!'='git commit -v -a --amend'
'gcan!'='git commit -v -a --no-edit --amend'
'gcans!'='git commit -v -a -s --no-edit --amend'
'gcn!'='git commit -v --no-edit --amend'
```

View file

@ -1,44 +1,59 @@
alias-finder() {
local cmd="" exact="" longer="" wordStart="" wordEnd="" multiWordEnd=""
for i in $@; do
case $i in
local cmd=" " exact="" longer="" cheaper="" wordEnd="'{0,1}$" finder="" filter=""
# build command and options
for c in "$@"; do
case $c in
# TODO: Remove backward compatibility (other than zstyle form)
# set options if exist
-e|--exact) exact=true;;
-l|--longer) longer=true;;
*)
if [[ -z $cmd ]]; then
cmd=$i
else
cmd="$cmd $i"
fi
;;
-c|--cheaper) cheaper=true;;
# concatenate cmd
*) cmd="$cmd$c " ;;
esac
done
cmd=$(sed 's/[].\|$(){}?+*^[]/\\&/g' <<< $cmd) # adds escaping for grep
if (( $(wc -l <<< $cmd) == 1 )); then
while [[ $cmd != "" ]]; do
if [[ $longer = true ]]; then
wordStart="'{0,1}"
else
wordEnd="$"
multiWordEnd="'$"
fi
if [[ $cmd == *" "* ]]; then
local finder="'$cmd$multiWordEnd"
else
local finder=$wordStart$cmd$wordEnd
fi
alias | grep -E "=$finder"
if [[ $exact = true || $longer = true ]]; then
break
else
cmd=$(sed -E 's/ {0,1}[^ ]*$//' <<< $cmd) # removes last word
fi
done
zstyle -t ':omz:plugins:alias-finder' longer && longer=true
zstyle -t ':omz:plugins:alias-finder' exact && exact=true
zstyle -t ':omz:plugins:alias-finder' cheaper && cheaper=true
# format cmd for grep
## - replace newlines with spaces
## - trim both ends
## - replace multiple spaces with one space
## - add escaping character to special characters
cmd=$(echo -n "$cmd" | tr '\n' ' ' | xargs | tr -s '[:space:]' | sed 's/[].\|$(){}?+*^[]/\\&/g')
if [[ $longer == true ]]; then
wordEnd="" # remove wordEnd to find longer aliases
fi
# find with alias and grep, removing last word each time until no more words
while [[ $cmd != "" ]]; do
finder="'{0,1}$cmd$wordEnd"
# make filter to find only shorter results than current cmd
if [[ $cheaper == true ]]; then
cmdLen=$(echo -n "$cmd" | wc -c)
filter="^'{0,1}.{0,$((cmdLen - 1))}="
fi
alias | grep -E "$filter" | grep -E "=$finder"
if [[ $exact == true ]]; then
break # because exact case is only one
elif [[ $longer = true ]]; then
break # because above grep command already found every longer aliases during first cycle
fi
cmd=$(sed -E 's/ {0,}[^ ]*$//' <<< "$cmd") # remove last word
done
}
preexec_alias-finder() {
if [[ $ZSH_ALIAS_FINDER_AUTOMATIC = true ]]; then
# TODO: Remove backward compatibility (other than zstyle form)
zstyle -t ':omz:plugins:alias-finder' autoload && alias-finder $1 || if [[ $ZSH_ALIAS_FINDER_AUTOMATIC = true ]]; then
alias-finder $1
fi
}

View file

@ -0,0 +1,2 @@
#!/usr/bin/env zsh
# Write your bootstrap code here

View file

@ -0,0 +1,107 @@
#!/usr/bin/env zunit
@setup {
load ../alias-finder.plugin.zsh
set_git_aliases() {
unalias -a # all
alias g="git"
alias gc="git commit"
alias gcv="git commit -v"
alias gcvs="git commit -v -S"
}
}
@test 'find aliases that contain input' {
set_git_aliases
run alias-finder "git"
assert "${#lines[@]}" equals 1
assert "${lines[1]}" same_as "g=git"
}
@test 'find aliases that contain input with whitespaces at ends' {
set_git_aliases
run alias-finder " git "
assert "${#lines[@]}" equals 1
assert "${lines[1]}" same_as "g=git"
}
@test 'find aliases that contain multiple words' {
set_git_aliases
run alias-finder "git commit -v"
assert "${#lines[@]}" equals 3
assert "${lines[1]}" same_as "gcv='git commit -v'"
assert "${lines[2]}" same_as "gc='git commit'"
assert "${lines[3]}" same_as "g=git"
}
@test 'find alias that is the same with input when --exact option is set' {
set_git_aliases
run alias-finder -e "git"
assert "${#lines[@]}" equals 1
assert "${lines[1]}" same_as "g=git"
}
@test 'find alias that is the same with multiple words input when --exact option is set' {
set_git_aliases
run alias-finder -e "git commit -v"
assert "${#lines[@]}" equals 1
assert "${lines[1]}" same_as "gcv='git commit -v'"
}
@test 'find alias that is the same with or longer than input when --longer option is set' {
set_git_aliases
run alias-finder -l "git"
assert "${#lines[@]}" equals 4
assert "${lines[1]}" same_as "g=git"
assert "${lines[2]}" same_as "gc='git commit'"
assert "${lines[3]}" same_as "gcv='git commit -v'"
assert "${lines[4]}" same_as "gcvs='git commit -v -S'"
}
@test 'find alias that is the same with or longer than multiple words input when --longer option is set' {
set_git_aliases
run alias-finder -l "git commit -v"
assert "${#lines[@]}" equals 2
assert "${lines[1]}" same_as "gcv='git commit -v'"
assert "${lines[2]}" same_as "gcvs='git commit -v -S'"
}
@test 'find aliases including expensive (longer) than input' {
set_git_aliases
alias expensiveCommands="git commit"
run alias-finder "git commit -v"
assert "${#lines[@]}" equals 4
assert "${lines[1]}" same_as "gcv='git commit -v'"
assert "${lines[2]}" same_as "expensiveCommands='git commit'"
assert "${lines[3]}" same_as "gc='git commit'"
assert "${lines[4]}" same_as "g=git"
}
@test 'find aliases excluding expensive (longer) than input when --cheap option is set' {
set_git_aliases
alias expensiveCommands="git commit"
run alias-finder -c "git commit -v"
assert "${#lines[@]}" equals 3
assert "${lines[1]}" same_as "gcv='git commit -v'"
assert "${lines[2]}" same_as "gc='git commit'"
assert "${lines[3]}" same_as "g=git"
}

View file

@ -25,4 +25,4 @@ Requirements: Python needs to be installed.
- `als --groups`: show only group names
![screenshot](https://cloud.githubusercontent.com/assets/3602957/11581913/cb54fb8a-9a82-11e5-846b-5a67f67ad9ad.png)
![screenshot](https://github.com/ohmyzsh/ohmyzsh/assets/66907184/5bfa00ea-5fc3-4e97-8b22-2f74f6b948c7)

View file

@ -13,6 +13,10 @@
# Author: Avneet Singh (kalsi-avneet) #
# Modified to add support for Android #
###########################################
# Author: Not Pua (im-notpua) #
# Modified to add support for OpenBSD #
###########################################
if [[ "$OSTYPE" = darwin* ]]; then
function battery_is_charging() {
@ -139,6 +143,46 @@ elif [[ "$OSTYPE" = linux-android ]] && (( ${+commands[termux-battery-status]} )
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi
}
elif [[ "$OSTYPE" = openbsd* ]]; then
function battery_is_charging() {
[[ $(apm -b) -eq 3 ]]
}
function battery_pct() {
apm -l
}
function battery_pct_remaining() {
if ! battery_is_charging; then
battery_pct
else
echo "External Power"
fi
}
function battery_time_remaining() {
local remaining_time
remaining_time=$(apm -m)
if [[ $remaining_time -ge 0 ]]; then
((hour = $remaining_time / 60 ))
((minute = $remaining_time % 60 ))
printf %02d:%02d $hour $minute
fi
}
function battery_pct_prompt() {
local battery_pct color
battery_pct=$(battery_pct_remaining)
if battery_is_charging; then
echo "∞"
else
if [[ $battery_pct -gt 50 ]]; then
color='green'
elif [[ $battery_pct -gt 20 ]]; then
color='yellow'
else
color='red'
fi
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi
}
elif [[ "$OSTYPE" = linux* ]]; then
function battery_is_charging() {
if (( $+commands[acpitool] )); then

View file

@ -10,10 +10,12 @@ plugins=(... brew)
## Shellenv
If `brew` is not found in the PATH, this plugin will attempt to find it in common
locations, and execute `brew shellenv` to set the environment appropriately.
This plugin will also export `HOMEBREW_PREFIX="$(brew --prefix)"` if not previously
defined for convenience.
If `brew` is not found in the PATH, this plugin will attempt to find it in common locations, and execute
`brew shellenv` to set the environment appropriately. This plugin will also export
`HOMEBREW_PREFIX="$(brew --prefix)"` if not previously defined for convenience.
In case you installed `brew` in a non-common location, you can still set `BREW_LOCATION` variable pointing to
the `brew` binary before sourcing `oh-my-zsh.sh` and it'll set up the environment.
## Aliases
@ -33,9 +35,9 @@ defined for convenience.
## Completion
This plugin configures paths with Homebrew's completion functions automatically, so you don't need to do it manually. See: https://docs.brew.sh/Shell-Completion#configuring-completions-in-zsh.
This plugin configures paths with Homebrew's completion functions automatically, so you don't need to do it
manually. See: https://docs.brew.sh/Shell-Completion#configuring-completions-in-zsh.
With the release of Homebrew 1.0, they decided to bundle the zsh completion as part of the
brew installation, so we no longer ship it with the brew plugin; now it only has brew
aliases. If you find that brew completion no longer works, make sure you have your Homebrew
installation fully up to date.
With the release of Homebrew 1.0, they decided to bundle the zsh completion as part of the brew installation,
so we no longer ship it with the brew plugin; now it only has brew aliases. If you find that brew completion
no longer works, make sure you have your Homebrew installation fully up to date.

View file

@ -1,5 +1,10 @@
if (( ! $+commands[brew] )); then
if [[ -x /opt/homebrew/bin/brew ]]; then
if [[ -n "$BREW_LOCATION" ]]; then
if [[ ! -x "$BREW_LOCATION" ]]; then
echo "[oh-my-zsh] $BREW_LOCATION is not executable"
return
fi
elif [[ -x /opt/homebrew/bin/brew ]]; then
BREW_LOCATION="/opt/homebrew/bin/brew"
elif [[ -x /usr/local/bin/brew ]]; then
BREW_LOCATION="/usr/local/bin/brew"

20
plugins/bun/README.md Normal file
View file

@ -0,0 +1,20 @@
# Bun Plugin
This plugin sets up completion for [Bun](https://bun.sh).
To use it, add `bun` to the plugins array in your zshrc file:
```zsh
plugins=(... bun)
```
This plugin does not add any aliases.
## Cache
This plugin caches the completion script and is automatically updated when the
plugin is loaded, which is usually when you start up a new terminal emulator.
The cache is stored at:
- `$ZSH_CACHE_DIR/completions/_bun_` completions script

View file

@ -0,0 +1,14 @@
# If Bun is not found, don't do the rest of the script
if (( ! $+commands[bun] )); then
return
fi
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `bun`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_bun" ]]; then
typeset -g -A _comps
autoload -Uz _bun
_comps[bun]=_bun
fi
bun completions >| "$ZSH_CACHE_DIR/completions/_bun" &|

View file

@ -36,6 +36,7 @@ function colored() {
# Prefer `less` whenever available, since we specifically configured
# environment for it.
environment+=( PAGER="${commands[less]:-$PAGER}" )
environment+=( GROFF_NO_SGR=1 )
# See ./nroff script.
if [[ "$OSTYPE" = solaris* ]]; then

View file

@ -30,6 +30,11 @@ EOF
local file="$1" full_path="${1:A}"
local extract_dir="${1:t:r}"
# Remove the .tar extension if the file name is .tar.*
if [[ $extract_dir =~ '\.tar$' ]]; then
extract_dir="${extract_dir:r}"
fi
# If there's a file or directory with the same name as the archive
# add a random string to the end of the extract directory
if [[ -e "$extract_dir" ]]; then
@ -64,7 +69,7 @@ EOF
(*.tar.lz) (( $+commands[lzip] )) && tar xvf "$full_path" ;;
(*.tar.lz4) lz4 -c -d "$full_path" | tar xvf - ;;
(*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$full_path" ;;
(*.gz) (( $+commands[pigz] )) && pigz -dk "$full_path" || gunzip -k "$full_path" ;;
(*.gz) (( $+commands[pigz] )) && pigz -cdk "$full_path" > "${file:t:r}" || gunzip -ck "$full_path" > "${file:t:r}" ;;
(*.bz2) bunzip2 "$full_path" ;;
(*.xz) unxz "$full_path" ;;
(*.lrz) (( $+commands[lrunzip] )) && lrunzip "$full_path" ;;
@ -106,19 +111,19 @@ EOF
# - Y2: at most give 2 files
local -a content
content=("${extract_dir}"/*(DNY2))
if [[ ${#content} -eq 1 && -d "${content[1]}" ]]; then
# The extracted folder (${content[1]}) may have the same name as $extract_dir
if [[ ${#content} -eq 1 && -e "${content[1]}" ]]; then
# The extracted file/folder (${content[1]}) may have the same name as $extract_dir
# If so, we need to rename it to avoid conflicts in a 3-step process
#
# 1. Move and rename the extracted folder to a temporary random name
# 1. Move and rename the extracted file/folder to a temporary random name
# 2. Delete the empty folder
# 3. Rename the extracted folder to the original name
# 3. Rename the extracted file/folder to the original name
if [[ "${content[1]:t}" == "$extract_dir" ]]; then
# =(:) gives /tmp/zsh<random>, with :t it gives zsh<random>
local tmp_dir==(:); tmp_dir="${tmp_dir:t}"
command mv "${content[1]}" "$tmp_dir" \
local tmp_name==(:); tmp_name="${tmp_name:t}"
command mv "${content[1]}" "$tmp_name" \
&& command rmdir "$extract_dir" \
&& command mv "$tmp_dir" "$extract_dir"
&& command mv "$tmp_name" "$extract_dir"
# Otherwise, if the extracted folder name already exists in the current
# directory (because of a previous file / folder), keep the extract_dir
elif [[ ! -e "${content[1]:t}" ]]; then

View file

@ -0,0 +1,36 @@
# git-commit plugin
The git-commit plugin adds several [git aliases](https://www.git-scm.com/docs/git-config#Documentation/git-config.txt-alias) for [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/#summary) messages.
To use it, add `git-commit` to the plugins array in your zshrc file:
```zsh
plugins=(... git-commit)
```
## Syntax
```zshrc
git <type> [(-s, --scope) "<scope>"] "<message>"
```
> ⚠️ Single/Double quotes around the scope and message are required
Where `type` is one of the following:
- `build`
- `chore`
- `ci`
- `docs`
- `feat`
- `fix`
- `perf`
- `refactor`
- `revert`
- `style`
- `test`
## Examples
`git style "remove trailing whitespace"` -> `git commit -m "style: remove trailing whitespace"`
`git fix -s "router" "correct redirect link"` -> `git commit -m "fix(router): correct redirect link"`

View file

@ -0,0 +1,27 @@
function _git_commit_register {
if ! git config --global --get-all alias.$1 >/dev/null 2>&1; then
git config --global alias.$1 '!a() { if [ "$1" = "-s" ] || [ "$1" = "--scope" ]; then local scope="$2"; shift 2; git commit -m "'$1'(${scope}): ${@}"; else git commit -m "'$1': ${@}"; fi }; a'
fi
}
local -a _git_commit_aliases
_git_commit_aliases=(
'build'
'chore'
'ci'
'docs'
'feat'
'fix'
'perf'
'refactor'
'revert'
'style'
'test'
)
for _alias in "${_git_commit_aliases[@]}"; do
_git_commit_register $_alias
done
unfunction _git_commit_register
unset _alias

View file

@ -10,213 +10,216 @@ plugins=(... git)
## Aliases
| Alias | Command |
| :------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| g | git |
| ga | git add |
| gaa | git add --all |
| gapa | git add --patch |
| gau | git add --update |
| gav | git add --verbose |
| gap | git apply |
| gapt | git apply --3way |
| gb | git branch |
| gba | git branch --all |
| gbd | git branch --delete |
| gbda | git branch --no-color --merged \| grep -vE "^([+*]\|\s*(<span>$</span>(git_main_branch)\|<span>$</span>(git_develop_branch))\s*<span>$</span>)" \| xargs git branch --delete 2>/dev/null |
| gbD | git branch --delete --force |
| gbg | git branch -vv | grep ": gone\]" |
| gbgd | git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -d |
| gbgD | git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -D |
| gbl | git blame -b -w |
| gbnm | git branch --no-merged |
| gbr | git branch --remote |
| gbs | git bisect |
| gbsb | git bisect bad |
| gbsg | git bisect good |
| gbsr | git bisect reset |
| gbss | git bisect start |
| gc | git commit --verbose |
| gc! | git commit --verbose --amend |
| gcn! | git commit --verbose --no-edit --amend |
| gca | git commit --verbose --all |
| gca! | git commit --verbose --all --amend |
| gcan! | git commit --verbose --all --no-edit --amend |
| gcans! | git commit --verbose --all --signoff --no-edit --amend |
| gcam | git commit --all --message |
| gcas | git commit --all --signoff |
| gcasm | git commit --all --signoff --message |
| gcsm | git commit --signoff --message |
| gcb | git checkout -b |
| gcf | git config --list |
| gcl | git clone --recurse-submodules |
| gccd | git clone --recurse-submodules "<span>$</span>@" && cd "<span>$</span>(basename <span>$</span>\_ .git)" |
| gclean | git clean --interactive -d |
| gpristine | git reset --hard && git clean -dffx |
| gcm | git checkout $(git_main_branch) |
| gcd | git checkout $(git_develop_branch) |
| gcmsg | git commit --message |
| gco | git checkout |
| gcor | git checkout --recurse-submodules |
| gcount | git shortlog --summary -n |
| gcp | git cherry-pick |
| gcpa | git cherry-pick --abort |
| gcpc | git cherry-pick --continue |
| gcs | git commit -S |
| gcss | git commit -S -s |
| gcssm | git commit -S -s -m |
| gd | git diff |
| gdca | git diff --cached |
| gdcw | git diff --cached --word-diff |
| gdct | git describe --tags $(git rev-list --tags --max-count=1) |
| gds | git diff --staged |
| gdt | git diff-tree --no-commit-id --name-only -r |
| gdnolock | git diff $@ ":(exclude)package-lock.json" ":(exclude)\*.lock" |
| gdup | git diff @{upstream} |
| gdv | git diff -w $@ \| view - |
| gdw | git diff --word-diff |
| gf | git fetch |
| gfa | git fetch --all --prune |
| gfg | git ls-files \| grep |
| gfo | git fetch origin |
| gg | git gui citool |
| gga | git gui citool --amend |
| ggf | git push --force origin $(current_branch) |
| ggfl | git push --force-with-lease origin $(current_branch) |
| ggl | git pull origin $(current_branch) |
| ggp | git push origin $(current_branch) |
| ggpnp | ggl && ggp |
| ggpull | git pull origin "$(git_current_branch)" |
| ggpur | ggu |
| ggpush | git push origin "$(git_current_branch)" |
| ggsup | git branch --set-upstream-to=origin/$(git_current_branch) |
| ggu | git pull --rebase origin $(current_branch) |
| gpsup | git push --set-upstream origin $(git_current_branch) |
| gpsupf | git push --set-upstream origin $(git_current_branch) --force-with-lease --force-if-includes (git version >= 2.30) |
| gpsupf | git push --set-upstream origin $(git_current_branch) --force-with-lease (git version < 2.30) |
| ghh | git help |
| gignore | git update-index --assume-unchanged |
| gignored | git ls-files -v \| grep "^[[:lower:]]" |
| git-svn-dcommit-push | git svn dcommit && git push github $(git_main_branch):svntrunk |
| gk | gitk --all --branches &! |
| gke | gitk --all $(git log --walk-reflogs --pretty=%h) &! |
| gl | git pull |
| glg | git log --stat |
| glgp | git log --stat --patch |
| glgg | git log --graph |
| glgga | git log --graph --decorate --all |
| glgm | git log --graph --max-count=10 |
| glo | git log --oneline --decorate |
| glol | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' |
| glols | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat |
| glod | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' |
| glods | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short |
| glola | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --all |
| glog | git log --oneline --decorate --graph |
| gloga | git log --oneline --decorate --graph --all |
| glp | git log --pretty=\<format\> |
| gm | git merge |
| gms | git merge --squash |
| gmom | git merge origin/$(git_main_branch) |
| gmtl | git mergetool --no-prompt |
| gmtlvim | git mergetool --no-prompt --tool=vimdiff |
| gmum | git merge upstream/$(git_main_branch) |
| gma | git merge --abort |
| gp | git push |
| gpd | git push --dry-run |
| gpf | git push --force-with-lease --force-if-includes (git version >= 2.30) |
| gpf | git push --force-with-lease (git version < 2.30) |
| gpf! | git push --force |
| gpoat | git push origin --all && git push origin --tags |
| gpod | git push origin --delete |
| gpr | git pull --rebase |
| gpu | git push upstream |
| gpv | git push --verbose |
| gr | git remote |
| gra | git remote add |
| grb | git rebase |
| grba | git rebase --abort |
| grbc | git rebase --continue |
| grbd | git rebase $(git_develop_branch) |
| grbi | git rebase --interactive |
| grbm | git rebase $(git_main_branch) |
| grbom | git rebase origin/$(git_main_branch) |
| grbo | git rebase --onto |
| grbs | git rebase --skip |
| grev | git revert |
| grh | git reset |
| grhh | git reset --hard |
| groh | git reset origin/$(git_current_branch) --hard |
| grm | git rm |
| grmc | git rm --cached |
| grmv | git remote rename |
| grrm | git remote remove |
| grs | git restore |
| grset | git remote set-url |
| grss | git restore --source |
| grst | git restore --staged |
| grt | cd "$(git rev-parse --show-toplevel \|\| echo .)" |
| gru | git reset -- |
| grup | git remote update |
| grv | git remote --verbose |
| gsb | git status --short -b |
| gsd | git svn dcommit |
| gsh | git show |
| gsi | git submodule init |
| gsps | git show --pretty=short --show-signature |
| gsr | git svn rebase |
| gss | git status --short |
| gst | git status |
| gsta | git stash push (git version >= 2.13) |
| gsta | git stash save (git version < 2.13) |
| gstaa | git stash apply |
| gstc | git stash clear |
| gstd | git stash drop |
| gstl | git stash list |
| gstp | git stash pop |
| gsts | git stash show --text |
| gstu | git stash --include-untracked |
| gstall | git stash --all |
| gsu | git submodule update |
| gsw | git switch |
| gswc | git switch -c |
| gswm | git switch $(git_main_branch) |
| gswd | git switch $(git_develop_branch) |
| gts | git tag -s |
| gtv | git tag \| sort -V |
| gtl | gtl(){ git tag --sort=-v:refname -n --list ${1}\* }; noglob gtl |
| gunignore | git update-index --no-assume-unchanged |
| gunwip | git rev-list --max-count=1 --format="%s" HEAD \| grep -q "\-\-wip\-\-" && git reset HEAD~1 |
| gup | git pull --rebase |
| gupv | git pull --rebase --verbose |
| gupa | git pull --rebase --autostash |
| gupav | git pull --rebase --autostash --verbose |
| gupom | git pull --rebase origin $(git_main_branch) |
| gupomi | git pull --rebase=interactive origin $(git_main_branch) |
| glum | git pull upstream $(git_main_branch) |
| gluc | git pull upstream $(git_current_branch) |
| gwch | git whatchanged -p --abbrev-commit --pretty=medium |
| gwip | git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]" |
| gam | git am |
| gamc | git am --continue |
| gams | git am --skip |
| gama | git am --abort |
| gamscp | git am --show-current-patch |
| gwt | git worktree |
| gwtls | git worktree list |
| gwtmv | git worktree move |
| gwtrm | git worktree remove |
| Alias | Command |
| :------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| grt | cd "$(git rev-parse --show-toplevel &#124;&#124; echo .)" |
| ggpnp | ggl && ggp |
| ggpur | ggu |
| g | git |
| ga | git add |
| gaa | git add --all |
| gapa | git add --patch |
| gau | git add --update |
| gav | git add --verbose |
| gwip | git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]" |
| gam | git am |
| gama | git am --abort |
| gamc | git am --continue |
| gamscp | git am --show-current-patch |
| gams | git am --skip |
| gap | git apply |
| gapt | git apply --3way |
| gbs | git bisect |
| gbsb | git bisect bad |
| gbsg | git bisect good |
| gbsn | git bisect new |
| gbso | git bisect old |
| gbsr | git bisect reset |
| gbss | git bisect start |
| gbl | git blame -w |
| gb | git branch |
| gba | git branch --all |
| gbd | git branch --delete |
| gbD | git branch --delete --force |
| gbda | git branch --no-color --merged &#124; grep -vE "^([+]&#124;\s($(git_main_branch)&#124;$(git_develop_branch))\s\*$)" &#124; xargs git branch --delete 2>/dev/null |
| gbgd | LANG=C git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -d |
| gbgD | LANG=C git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -D |
| gbnm | git branch --no-merged |
| gbr | git branch --remote |
| ggsup | git branch --set-upstream-to=origin/$(git_current_branch) |
| gbg | LANG=C git branch -vv | grep ": gone\]" |
| gco | git checkout |
| gcor | git checkout --recurse-submodules |
| gcb | git checkout -b |
| gcd | git checkout $(git_develop_branch) |
| gcm | git checkout $(git_main_branch) |
| gcp | git cherry-pick |
| gcpa | git cherry-pick --abort |
| gcpc | git cherry-pick --continue |
| gclean | git clean --interactive -d |
| gcl | git clone --recurse-submodules |
| gccd | git clone --recurse-submodules "$@" && cd "$(basename $\_ .git)" |
| gcam | git commit --all --message |
| gcas | git commit --all --signoff |
| gcasm | git commit --all --signoff --message |
| gcmsg | git commit --message |
| gcsm | git commit --signoff --message |
| gc | git commit --verbose |
| gca | git commit --verbose --all |
| gca! | git commit --verbose --all --amend |
| gcan! | git commit --verbose --all --no-edit --amend |
| gcans! | git commit --verbose --all --signoff --no-edit --amend |
| gc! | git commit --verbose --amend |
| gcn! | git commit --verbose --no-edit --amend |
| gcs | git commit -S |
| gcss | git commit -S -s |
| gcssm | git commit -S -s -m |
| gcf | git config --list |
| gdct | git describe --tags $(git rev-list --tags --max-count=1) |
| gd | git diff |
| gdca | git diff --cached |
| gdcw | git diff --cached --word-diff |
| gds | git diff --staged |
| gdw | git diff --word-diff |
| gdv | git diff -w $@ &#124; view - |
| gdup | git diff @{upstream} |
| gdnolock | git diff $@ ":(exclude)package-lock.json" ":(exclude)\*.lock" |
| gdt | git diff-tree --no-commit-id --name-only -r |
| gf | git fetch |
| gfa | git fetch --all --prune |
| gfo | git fetch origin |
| gg | git gui citool |
| gga | git gui citool --amend |
| ghh | git help |
| glgg | git log --graph |
| glgga | git log --graph --decorate --all |
| glgm | git log --graph --max-count=10 |
| glod | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' |
| glods | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short |
| glol | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' |
| glola | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --all |
| glols | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat |
| glo | git log --oneline --decorate |
| glog | git log --oneline --decorate --graph |
| gloga | git log --oneline --decorate --graph --all |
| glp | git log --pretty=\<format> |
| glg | git log --stat |
| glgp | git log --stat --patch |
| gignored | git ls-files -v &#124; grep "^[[:lower:]]" |
| gfg | git ls-files &#124; grep |
| gm | git merge |
| gma | git merge --abort |
| gms | git merge --squash |
| gmom | git merge origin/$(git_main_branch) |
| gmum | git merge upstream/$(git_main_branch) |
| gmtl | git mergetool --no-prompt |
| gmtlvim | git mergetool --no-prompt --tool=vimdiff |
| gl | git pull |
| gpr | git pull --rebase |
| gup | git pull --rebase |
| gupa | git pull --rebase --autostash |
| gupav | git pull --rebase --autostash --verbose |
| gupv | git pull --rebase --verbose |
| ggu | git pull --rebase origin $(current_branch) |
| gupom | git pull --rebase origin $(git_main_branch) |
| gupomi | git pull --rebase=interactive origin $(git_main_branch) |
| ggpull | git pull origin "$(git_current_branch)" |
| ggl | git pull origin $(current_branch) |
| gluc | git pull upstream $(git_current_branch) |
| glum | git pull upstream $(git_main_branch) |
| gp | git push |
| gpd | git push --dry-run |
| gpf! | git push --force |
| ggf | git push --force origin $(current_branch) |
| gpf | git push --force-with-lease --force-if-includes (git version >= 2.30) |
| gpf | git push --force-with-lease (git version < 2.30) |
| ggfl | git push --force-with-lease origin $(current_branch) |
| gpsup | git push --set-upstream origin $(git_current_branch) |
| gpsupf | git push --set-upstream origin $(git_current_branch) --force-with-lease --force-if-includes (git version >= 2.30) |
| gpsupf | git push --set-upstream origin $(git_current_branch) --force-with-lease (git version < 2.30) |
| gpv | git push --verbose |
| gpoat | git push origin --all && git push origin --tags |
| gpod | git push origin --delete |
| ggpush | git push origin "$(git_current_branch)" |
| ggp | git push origin $(current_branch) |
| gpu | git push upstream |
| grb | git rebase |
| grba | git rebase --abort |
| grbc | git rebase --continue |
| grbi | git rebase --interactive |
| grbo | git rebase --onto |
| grbs | git rebase --skip |
| grbd | git rebase $(git_develop_branch) |
| grbm | git rebase $(git_main_branch) |
| grbom | git rebase origin/$(git_main_branch) |
| gr | git remote |
| grv | git remote --verbose |
| gra | git remote add |
| grrm | git remote remove |
| grmv | git remote rename |
| grset | git remote set-url |
| grup | git remote update |
| grh | git reset |
| gru | git reset -- |
| grhh | git reset --hard |
| gpristine | git reset --hard && git clean -dffx |
| groh | git reset origin/$(git_current_branch) --hard |
| grs | git restore |
| grss | git restore --source |
| grst | git restore --staged |
| gunwip | git rev-list --max-count=1 --format="%s" HEAD &#124; grep -q "--wip--" && git reset HEAD~1 |
| grev | git revert |
| grm | git rm |
| grmc | git rm --cached |
| gcount | git shortlog --summary -n |
| gsh | git show |
| gsps | git show --pretty=short --show-signature |
| gstall | git stash --all |
| gstu | git stash --include-untracked |
| gstaa | git stash apply |
| gstc | git stash clear |
| gstd | git stash drop |
| gstl | git stash list |
| gstp | git stash pop |
| gsta | git stash push (git version >= 2.13) |
| gsta | git stash save (git version < 2.13) |
| gsts | git stash show --text |
| gst | git status |
| gss | git status --short |
| gsb | git status --short -b |
| gsi | git submodule init |
| gsu | git submodule update |
| gsd | git svn dcommit |
| git-svn-dcommit-push | git svn dcommit && git push github $(git_main_branch):svntrunk |
| gsr | git svn rebase |
| gsw | git switch |
| gswc | git switch -c |
| gswd | git switch $(git_develop_branch) |
| gswm | git switch $(git_main_branch) |
| gts | git tag -s |
| gtv | git tag &#124; sort -V |
| gignore | git update-index --assume-unchanged |
| gunignore | git update-index --no-assume-unchanged |
| gwch | git whatchanged -p --abbrev-commit --pretty=medium |
| gwt | git worktree |
| gwtls | git worktree list |
| gwtmv | git worktree move |
| gwtrm | git worktree remove |
| gk | gitk --all --branches &! |
| gke | gitk --all $(git log --walk-reflogs --pretty=%h) &! |
| gtl | gtl(){ git tag --sort=-v:refname -n --list ${1}\* }; noglob gtl |
### Main branch preference
Following the recent push for removing racially-charged words from our technical vocabulary, the git plugin favors using
a branch name other than `master`. In this case, we favor the shorter, neutral and descriptive term `main`. This means
that any aliases and functions that previously used `master`, will use `main` if that branch exists. We do this via the
function `git_main_branch`.
Following the recent push for removing racially-charged words from our technical vocabulary, the git plugin
favors using a branch name other than `master`. In this case, we favor the shorter, neutral and descriptive
term `main`. This means that any aliases and functions that previously used `master`, will use `main` if that
branch exists. We do this via the function `git_main_branch`.
### Deprecated aliases
These are aliases that have been removed, renamed, or otherwise modified in a way that may, or may not, receive further support.
These are aliases that have been removed, renamed, or otherwise modified in a way that may, or may not,
receive further support.
| Alias | Command | Modification |
| :----- | :----------------------------------------------------- | :----------------------------------------------------- |
@ -238,23 +241,27 @@ These are aliases that have been removed, renamed, or otherwise modified in a wa
| Command | Description |
| :--------------------- | :------------------------------------------------------------------------------------------------------- |
| `grename <old> <new>` | Rename `old` branch to `new`, including in origin remote |
| current_branch | Return the name of the current branch |
| git_current_user_name | Returns the `user.name` config value |
| git_current_user_email | Returns the `user.email` config value |
| git_main_branch | Returns the name of the main branch: `main` if it exists, `master` otherwise |
| git_current_user_email | Returns the `user.email` config value (lives in lib/git.zsh) |
| git_current_user_name | Returns the `user.name` config value (lives in lib/git.zsh) |
| git_develop_branch | Returns the name of the develop branch: `dev`, `devel`, `development` if they exist, `develop` otherwise |
| git_main_branch | Returns the name of the main branch: `main` if it exists, `master` otherwise |
| grename \<old> \<new> | Rename `old` branch to `new`, including in origin remote |
### Work in Progress (WIP)
These features allow to pause a branch development and switch to another one (_"Work in Progress"_, or wip). When you want to go back to work, just unwip it.
These features allow to pause a branch development and switch to another one (_"Work in Progress"_, or wip).
When you want to go back to work, just unwip it.
| Command | Description |
| :--------------- | :---------------------------------------------- |
| work_in_progress | Echoes a warning if the current branch is a wip |
| gwip | Commit wip branch |
| gunwip | Uncommit wip branch |
| gunwipall | Uncommit all recent `--wip--` commits |
| work_in_progress | Echoes a warning if the current branch is a wip |
Note that `gwip` and `gunwip` are effectivly alias, but are also documented here to group all related WIP
features.
### Deprecated functions

View file

@ -3,7 +3,9 @@ autoload -Uz is-at-least
git_version="${${(As: :)$(git version 2>/dev/null)}[3]}"
#
# Functions
# Functions Current
# (sorted alphabetically by function name)
# (order should follow README)
#
# The name of the current branch
@ -14,42 +16,6 @@ function current_branch() {
git_current_branch
}
# Pretty log messages
function _git_log_prettily(){
if ! [ -z $1 ]; then
git log --pretty=$1
fi
}
compdef _git _git_log_prettily=git-log
# Warn if the current branch is a WIP
function work_in_progress() {
command git -c log.showSignature=false log -n 1 2>/dev/null | grep -q -- "--wip--" && echo "WIP!!"
}
# Similar to `gunwip` but recursive "Unwips" all recent `--wip--` commits not just the last one
function gunwipall() {
local _commit=$(git log --grep='--wip--' --invert-grep --max-count=1 --format=format:%H)
# Check if a commit without "--wip--" was found and it's not the same as HEAD
if [[ "$_commit" != "$(git rev-parse HEAD)" ]]; then
git reset $_commit || return 1
fi
}
# Check if main exists and use instead of master
function git_main_branch() {
command git rev-parse --git-dir &>/dev/null || return
local ref
for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk,mainline,default}; do
if command git show-ref -q --verify $ref; then
echo ${ref:t}
return
fi
done
echo master
}
# Check for develop and similarly named branches
function git_develop_branch() {
command git rev-parse --git-dir &>/dev/null || return
@ -63,289 +29,18 @@ function git_develop_branch() {
echo develop
}
#
# Aliases
# (sorted alphabetically)
#
alias g='git'
alias ga='git add'
alias gaa='git add --all'
alias gapa='git add --patch'
alias gau='git add --update'
alias gav='git add --verbose'
alias gap='git apply'
alias gapt='git apply --3way'
alias gb='git branch'
alias gba='git branch --all'
alias gbd='git branch --delete'
alias gbda='git branch --no-color --merged | command grep -vE "^([+*]|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs git branch --delete 2>/dev/null'
alias gbD='git branch --delete --force'
alias gbg='git branch -vv | grep ": gone\]"'
alias gbgd='git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -d'
alias gbgD='git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -D'
alias gbl='git blame -b -w'
alias gbnm='git branch --no-merged'
alias gbr='git branch --remote'
alias gbs='git bisect'
alias gbsb='git bisect bad'
alias gbsg='git bisect good'
alias gbsr='git bisect reset'
alias gbss='git bisect start'
alias gc='git commit --verbose'
alias gc!='git commit --verbose --amend'
alias gcn!='git commit --verbose --no-edit --amend'
alias gca='git commit --verbose --all'
alias gca!='git commit --verbose --all --amend'
alias gcan!='git commit --verbose --all --no-edit --amend'
alias gcans!='git commit --verbose --all --signoff --no-edit --amend'
alias gcam='git commit --all --message'
alias gcsm='git commit --signoff --message'
alias gcas='git commit --all --signoff'
alias gcasm='git commit --all --signoff --message'
alias gcb='git checkout -b'
alias gcf='git config --list'
function gccd() {
command git clone --recurse-submodules "$@"
[[ -d "$_" ]] && cd "$_" || cd "${${_:t}%.git}"
# Check if main exists and use instead of master
function git_main_branch() {
command git rev-parse --git-dir &>/dev/null || return
local ref
for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk,mainline,default}; do
if command git show-ref -q --verify $ref; then
echo ${ref:t}
return
fi
done
echo master
}
compdef _git gccd=git-clone
alias gcl='git clone --recurse-submodules'
alias gclean='git clean --interactive -d'
alias gpristine='git reset --hard && git clean --force -dfx'
alias gcm='git checkout $(git_main_branch)'
alias gcd='git checkout $(git_develop_branch)'
alias gcmsg='git commit --message'
alias gco='git checkout'
alias gcor='git checkout --recurse-submodules'
alias gcount='git shortlog --summary --numbered'
alias gcp='git cherry-pick'
alias gcpa='git cherry-pick --abort'
alias gcpc='git cherry-pick --continue'
alias gcs='git commit --gpg-sign'
alias gcss='git commit --gpg-sign --signoff'
alias gcssm='git commit --gpg-sign --signoff --message'
alias gd='git diff'
alias gdca='git diff --cached'
alias gdcw='git diff --cached --word-diff'
alias gdct='git describe --tags $(git rev-list --tags --max-count=1)'
alias gds='git diff --staged'
alias gdt='git diff-tree --no-commit-id --name-only -r'
alias gdup='git diff @{upstream}'
alias gdw='git diff --word-diff'
function gdnolock() {
git diff "$@" ":(exclude)package-lock.json" ":(exclude)*.lock"
}
compdef _git gdnolock=git-diff
function gdv() { git diff -w "$@" | view - }
compdef _git gdv=git-diff
alias gf='git fetch'
# --jobs=<n> was added in git 2.8
is-at-least 2.8 "$git_version" \
&& alias gfa='git fetch --all --prune --jobs=10' \
|| alias gfa='git fetch --all --prune'
alias gfo='git fetch origin'
alias gfg='git ls-files | grep'
alias gg='git gui citool'
alias gga='git gui citool --amend'
function ggf() {
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
git push --force origin "${b:=$1}"
}
compdef _git ggf=git-checkout
function ggfl() {
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
git push --force-with-lease origin "${b:=$1}"
}
compdef _git ggfl=git-checkout
function ggl() {
if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
git pull origin "${*}"
else
[[ "$#" == 0 ]] && local b="$(git_current_branch)"
git pull origin "${b:=$1}"
fi
}
compdef _git ggl=git-checkout
function ggp() {
if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
git push origin "${*}"
else
[[ "$#" == 0 ]] && local b="$(git_current_branch)"
git push origin "${b:=$1}"
fi
}
compdef _git ggp=git-checkout
function ggpnp() {
if [[ "$#" == 0 ]]; then
ggl && ggp
else
ggl "${*}" && ggp "${*}"
fi
}
compdef _git ggpnp=git-checkout
function ggu() {
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
git pull --rebase origin "${b:=$1}"
}
compdef _git ggu=git-checkout
alias ggpur='ggu'
alias ggpull='git pull origin "$(git_current_branch)"'
alias ggpush='git push origin "$(git_current_branch)"'
alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)'
alias gpsup='git push --set-upstream origin $(git_current_branch)'
is-at-least 2.30 "$git_version" \
&& alias gpsupf='git push --set-upstream origin $(git_current_branch) --force-with-lease --force-if-includes' \
|| alias gpsupf='git push --set-upstream origin $(git_current_branch) --force-with-lease'
alias ghh='git help'
alias gignore='git update-index --assume-unchanged'
alias gignored='git ls-files -v | grep "^[[:lower:]]"'
alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk'
alias gk='\gitk --all --branches &!'
alias gke='\gitk --all $(git log --walk-reflogs --pretty=%h) &!'
alias gl='git pull'
alias glg='git log --stat'
alias glgp='git log --stat --patch'
alias glgg='git log --graph'
alias glgga='git log --graph --decorate --all'
alias glgm='git log --graph --max-count=10'
alias glo='git log --oneline --decorate'
alias glol="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset'"
alias glols="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat"
alias glod="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'"
alias glods="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short"
alias glola="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --all"
alias glog='git log --oneline --decorate --graph'
alias gloga='git log --oneline --decorate --graph --all'
alias glp="_git_log_prettily"
alias gm='git merge'
alias gmom='git merge origin/$(git_main_branch)'
alias gmtl='git mergetool --no-prompt'
alias gmtlvim='git mergetool --no-prompt --tool=vimdiff'
alias gmum='git merge upstream/$(git_main_branch)'
alias gma='git merge --abort'
alias gms="git merge --squash"
alias gp='git push'
alias gpd='git push --dry-run'
is-at-least 2.30 "$git_version" \
&& alias gpf='git push --force-with-lease --force-if-includes' \
|| alias gpf='git push --force-with-lease'
alias gpf!='git push --force'
alias gpoat='git push origin --all && git push origin --tags'
alias gpod='git push origin --delete'
alias gpr='git pull --rebase'
alias gpu='git push upstream'
alias gpv='git push --verbose'
alias gr='git remote'
alias gra='git remote add'
alias grb='git rebase'
alias grba='git rebase --abort'
alias grbc='git rebase --continue'
alias grbd='git rebase $(git_develop_branch)'
alias grbi='git rebase --interactive'
alias grbm='git rebase $(git_main_branch)'
alias grbom='git rebase origin/$(git_main_branch)'
alias grbo='git rebase --onto'
alias grbs='git rebase --skip'
alias grev='git revert'
alias grh='git reset'
alias grhh='git reset --hard'
alias groh='git reset origin/$(git_current_branch) --hard'
alias grm='git rm'
alias grmc='git rm --cached'
alias grmv='git remote rename'
alias grrm='git remote remove'
alias grs='git restore'
alias grset='git remote set-url'
alias grss='git restore --source'
alias grst='git restore --staged'
alias grt='cd "$(git rev-parse --show-toplevel || echo .)"'
alias gru='git reset --'
alias grup='git remote update'
alias grv='git remote --verbose'
alias gsb='git status --short --branch'
alias gsd='git svn dcommit'
alias gsh='git show'
alias gsi='git submodule init'
alias gsps='git show --pretty=short --show-signature'
alias gsr='git svn rebase'
alias gss='git status --short'
alias gst='git status'
# use the default stash push on git 2.13 and newer
is-at-least 2.13 "$git_version" \
&& alias gsta='git stash push' \
|| alias gsta='git stash save'
alias gstaa='git stash apply'
alias gstc='git stash clear'
alias gstd='git stash drop'
alias gstl='git stash list'
alias gstp='git stash pop'
alias gsts='git stash show --text'
alias gstu='gsta --include-untracked'
alias gstall='git stash --all'
alias gsu='git submodule update'
alias gsw='git switch'
alias gswc='git switch --create'
alias gswm='git switch $(git_main_branch)'
alias gswd='git switch $(git_develop_branch)'
alias gts='git tag --sign'
alias gtv='git tag | sort -V'
alias gtl='gtl(){ git tag --sort=-v:refname -n --list "${1}*" }; noglob gtl'
alias gunignore='git update-index --no-assume-unchanged'
alias gunwip='git rev-list --max-count=1 --format="%s" HEAD | grep -q "\--wip--" && git reset HEAD~1'
alias gup='git pull --rebase'
alias gupv='git pull --rebase --verbose'
alias gupa='git pull --rebase --autostash'
alias gupav='git pull --rebase --autostash --verbose'
alias gupom='git pull --rebase origin $(git_main_branch)'
alias gupomi='git pull --rebase=interactive origin $(git_main_branch)'
alias glum='git pull upstream $(git_main_branch)'
alias gluc='git pull upstream $(git_current_branch)'
alias gwch='git whatchanged -p --abbrev-commit --pretty=medium'
alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"'
alias gwt='git worktree'
alias gwta='git worktree add'
alias gwtls='git worktree list'
alias gwtmv='git worktree move'
alias gwtrm='git worktree remove'
alias gam='git am'
alias gamc='git am --continue'
alias gams='git am --skip'
alias gama='git am --abort'
alias gamscp='git am --show-current-patch'
function grename() {
if [[ -z "$1" || -z "$2" ]]; then
@ -361,4 +56,307 @@ function grename() {
fi
}
#
# Functions Work in Progress (WIP)
# (sorted alphabetically by function name)
# (order should follow README)
#
# Similar to `gunwip` but recursive "Unwips" all recent `--wip--` commits not just the last one
function gunwipall() {
local _commit=$(git log --grep='--wip--' --invert-grep --max-count=1 --format=format:%H)
# Check if a commit without "--wip--" was found and it's not the same as HEAD
if [[ "$_commit" != "$(git rev-parse HEAD)" ]]; then
git reset $_commit || return 1
fi
}
# Warn if the current branch is a WIP
function work_in_progress() {
command git -c log.showSignature=false log -n 1 2>/dev/null | grep -q -- "--wip--" && echo "WIP!!"
}
#
# Aliases
# (sorted alphabetically by command)
# (order should follow README)
# (in some cases force the alisas order to match README, like for example gke and gk)
#
alias grt='cd "$(git rev-parse --show-toplevel || echo .)"'
function ggpnp() {
if [[ "$#" == 0 ]]; then
ggl && ggp
else
ggl "${*}" && ggp "${*}"
fi
}
compdef _git ggpnp=git-checkout
alias ggpur='ggu'
alias g='git'
alias ga='git add'
alias gaa='git add --all'
alias gapa='git add --patch'
alias gau='git add --update'
alias gav='git add --verbose'
alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"'
alias gam='git am'
alias gama='git am --abort'
alias gamc='git am --continue'
alias gamscp='git am --show-current-patch'
alias gams='git am --skip'
alias gap='git apply'
alias gapt='git apply --3way'
alias gbs='git bisect'
alias gbsb='git bisect bad'
alias gbsg='git bisect good'
alias gbsn='git bisect new'
alias gbso='git bisect old'
alias gbsr='git bisect reset'
alias gbss='git bisect start'
alias gbl='git blame -w'
alias gb='git branch'
alias gba='git branch --all'
alias gbd='git branch --delete'
alias gbD='git branch --delete --force'
alias gbda='git branch --no-color --merged | command grep -vE "^([+*]|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs git branch --delete 2>/dev/null'
alias gbgd='LANG=C git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -d'
alias gbgD='LANG=C git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -D'
alias gbnm='git branch --no-merged'
alias gbr='git branch --remote'
alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)'
alias gbg='LANG=C git branch -vv | grep ": gone\]"'
alias gco='git checkout'
alias gcor='git checkout --recurse-submodules'
alias gcb='git checkout -b'
alias gcd='git checkout $(git_develop_branch)'
alias gcm='git checkout $(git_main_branch)'
alias gcp='git cherry-pick'
alias gcpa='git cherry-pick --abort'
alias gcpc='git cherry-pick --continue'
alias gclean='git clean --interactive -d'
alias gcl='git clone --recurse-submodules'
function gccd() {
command git clone --recurse-submodules "$@"
[[ -d "$_" ]] && cd "$_" || cd "${${_:t}%.git}"
}
compdef _git gccd=git-clone
alias gcam='git commit --all --message'
alias gcas='git commit --all --signoff'
alias gcasm='git commit --all --signoff --message'
alias gcs='git commit --gpg-sign'
alias gcss='git commit --gpg-sign --signoff'
alias gcssm='git commit --gpg-sign --signoff --message'
alias gcmsg='git commit --message'
alias gcsm='git commit --signoff --message'
alias gc='git commit --verbose'
alias gca='git commit --verbose --all'
alias gca!='git commit --verbose --all --amend'
alias gcan!='git commit --verbose --all --no-edit --amend'
alias gcans!='git commit --verbose --all --signoff --no-edit --amend'
alias gc!='git commit --verbose --amend'
alias gcn!='git commit --verbose --no-edit --amend'
alias gcf='git config --list'
alias gdct='git describe --tags $(git rev-list --tags --max-count=1)'
alias gd='git diff'
alias gdca='git diff --cached'
alias gdcw='git diff --cached --word-diff'
alias gds='git diff --staged'
alias gdw='git diff --word-diff'
function gdv() { git diff -w "$@" | view - }
compdef _git gdv=git-diff
alias gdup='git diff @{upstream}'
function gdnolock() {
git diff "$@" ":(exclude)package-lock.json" ":(exclude)*.lock"
}
compdef _git gdnolock=git-diff
alias gdt='git diff-tree --no-commit-id --name-only -r'
alias gf='git fetch'
# --jobs=<n> was added in git 2.8
is-at-least 2.8 "$git_version" \
&& alias gfa='git fetch --all --prune --jobs=10' \
|| alias gfa='git fetch --all --prune'
alias gfo='git fetch origin'
alias gg='git gui citool'
alias gga='git gui citool --amend'
alias ghh='git help'
alias glgg='git log --graph'
alias glgga='git log --graph --decorate --all'
alias glgm='git log --graph --max-count=10'
alias glods='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset" --date=short'
alias glod='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset"'
alias glola='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" --all'
alias glols='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" --stat'
alias glol='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset"'
alias glo='git log --oneline --decorate'
alias glog='git log --oneline --decorate --graph'
alias gloga='git log --oneline --decorate --graph --all'
# Pretty log messages
function _git_log_prettily(){
if ! [ -z $1 ]; then
git log --pretty=$1
fi
}
compdef _git _git_log_prettily=git-log
alias glp='_git_log_prettily'
alias glg='git log --stat'
alias glgp='git log --stat --patch'
alias gignored='git ls-files -v | grep "^[[:lower:]]"'
alias gfg='git ls-files | grep'
alias gm='git merge'
alias gma='git merge --abort'
alias gms="git merge --squash"
alias gmom='git merge origin/$(git_main_branch)'
alias gmum='git merge upstream/$(git_main_branch)'
alias gmtl='git mergetool --no-prompt'
alias gmtlvim='git mergetool --no-prompt --tool=vimdiff'
alias gl='git pull'
alias gpr='git pull --rebase'
alias gup='git pull --rebase'
alias gupa='git pull --rebase --autostash'
alias gupav='git pull --rebase --autostash --verbose'
alias gupv='git pull --rebase --verbose'
function ggu() {
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
git pull --rebase origin "${b:=$1}"
}
compdef _git ggu=git-checkout
alias gupom='git pull --rebase origin $(git_main_branch)'
alias gupomi='git pull --rebase=interactive origin $(git_main_branch)'
alias ggpull='git pull origin "$(git_current_branch)"'
function ggl() {
if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
git pull origin "${*}"
else
[[ "$#" == 0 ]] && local b="$(git_current_branch)"
git pull origin "${b:=$1}"
fi
}
compdef _git ggl=git-checkout
alias gluc='git pull upstream $(git_current_branch)'
alias glum='git pull upstream $(git_main_branch)'
alias gp='git push'
alias gpd='git push --dry-run'
function ggf() {
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
git push --force origin "${b:=$1}"
}
compdef _git ggf=git-checkout
alias gpf!='git push --force'
is-at-least 2.30 "$git_version" \
&& alias gpf='git push --force-with-lease --force-if-includes' \
|| alias gpf='git push --force-with-lease'
function ggfl() {
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
git push --force-with-lease origin "${b:=$1}"
}
compdef _git ggfl=git-checkout
alias gpsup='git push --set-upstream origin $(git_current_branch)'
is-at-least 2.30 "$git_version" \
&& alias gpsupf='git push --set-upstream origin $(git_current_branch) --force-with-lease --force-if-includes' \
|| alias gpsupf='git push --set-upstream origin $(git_current_branch) --force-with-lease'
alias gpv='git push --verbose'
alias gpoat='git push origin --all && git push origin --tags'
alias gpod='git push origin --delete'
alias ggpush='git push origin "$(git_current_branch)"'
function ggp() {
if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
git push origin "${*}"
else
[[ "$#" == 0 ]] && local b="$(git_current_branch)"
git push origin "${b:=$1}"
fi
}
compdef _git ggp=git-checkout
alias gpu='git push upstream'
alias grb='git rebase'
alias grba='git rebase --abort'
alias grbc='git rebase --continue'
alias grbi='git rebase --interactive'
alias grbo='git rebase --onto'
alias grbs='git rebase --skip'
alias grbd='git rebase $(git_develop_branch)'
alias grbm='git rebase $(git_main_branch)'
alias grbom='git rebase origin/$(git_main_branch)'
alias gr='git remote'
alias grv='git remote --verbose'
alias gra='git remote add'
alias grrm='git remote remove'
alias grmv='git remote rename'
alias grset='git remote set-url'
alias grup='git remote update'
alias grh='git reset'
alias gru='git reset --'
alias grhh='git reset --hard'
alias gpristine='git reset --hard && git clean --force -dfx'
alias groh='git reset origin/$(git_current_branch) --hard'
alias grs='git restore'
alias grss='git restore --source'
alias grst='git restore --staged'
alias gunwip='git rev-list --max-count=1 --format="%s" HEAD | grep -q "\--wip--" && git reset HEAD~1'
alias grev='git revert'
alias grm='git rm'
alias grmc='git rm --cached'
alias gcount='git shortlog --summary --numbered'
alias gsh='git show'
alias gsps='git show --pretty=short --show-signature'
alias gstall='git stash --all'
alias gstaa='git stash apply'
alias gstc='git stash clear'
alias gstd='git stash drop'
alias gstl='git stash list'
alias gstp='git stash pop'
# use the default stash push on git 2.13 and newer
is-at-least 2.13 "$git_version" \
&& alias gsta='git stash push' \
|| alias gsta='git stash save'
alias gsts='git stash show --text'
alias gst='git status'
alias gss='git status --short'
alias gsb='git status --short --branch'
alias gsi='git submodule init'
alias gsu='git submodule update'
alias gsd='git svn dcommit'
alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk'
alias gsr='git svn rebase'
alias gsw='git switch'
alias gswc='git switch --create'
alias gswd='git switch $(git_develop_branch)'
alias gswm='git switch $(git_main_branch)'
alias gts='git tag --sign'
alias gtv='git tag | sort -V'
alias gignore='git update-index --assume-unchanged'
alias gunignore='git update-index --no-assume-unchanged'
alias gwch='git whatchanged -p --abbrev-commit --pretty=medium'
alias gwt='git worktree'
alias gwta='git worktree add'
alias gwtls='git worktree list'
alias gwtmv='git worktree move'
alias gwtrm='git worktree remove'
alias gstu='gsta --include-untracked'
alias gtl='gtl(){ git tag --sort=-v:refname -n --list "${1}*" }; noglob gtl'
alias gk='\gitk --all --branches &!'
alias gke='\gitk --all $(git log --walk-reflogs --pretty=%h) &!'
unset git_version

View file

@ -1,6 +1,6 @@
# gitignore
This plugin enables you the use of [gitignore.io](https://www.gitignore.io/) from the command line. You need an active internet connection.
This plugin enables you the use of [gitignore.io](https://www.toptal.com/developers/gitignore) from the command line. You need an active internet connection.
To use it, add `gitignore` to the plugins array in your zshrc file:

View file

@ -1,7 +1,7 @@
function gi() { curl -fLw '\n' https://www.gitignore.io/api/"${(j:,:)@}" }
function gi() { curl -fLw '\n' https://www.toptal.com/developers/gitignore/api/"${(j:,:)@}" }
_gitignoreio_get_command_list() {
curl -sfL https://www.gitignore.io/api/list | tr "," "\n"
curl -sfL https://www.toptal.com/developers/gitignore/api/list | tr "," "\n"
}
_gitignoreio () {

View file

@ -2,8 +2,9 @@
# common grc.zsh paths
files=(
/etc/grc.zsh # default
/usr/local/etc/grc.zsh # homebrew
/etc/grc.zsh # default
/usr/local/etc/grc.zsh # homebrew darwin-x64
/opt/homebrew/etc/grc.zsh # homebrew darwin-arm64
)
# verify the file is readable and source it

View file

@ -1,7 +1,7 @@
#!/usr/bin/env bash
function spotify() {
# Copyright (c) 2012--2019 Harish Narayanan <mail@harishnarayanan.org>
# Copyright (c) 2012--2023 Harish Narayanan <mail@harishnarayanan.org>
#
# Contains numerous helpful contributions from Jorge Colindres, Thomas
# Pritchard, iLan Epstein, Gabriele Bonetti, Sean Heller, Eric Martin
@ -35,6 +35,9 @@ if ! [[ -f "${USER_CONFIG_FILE}" ]]; then
fi
source "${USER_CONFIG_FILE}";
# Set the percent change in volume for vol up and vol down
VOL_INCREMENT=10
showAPIHelp() {
echo;
echo "Connecting to Spotify's API:";
@ -170,12 +173,12 @@ while [ $# -gt 0 ]; do
if [ -z "${CLIENT_ID}" ]; then
cecho "Invalid Client ID, please update ${USER_CONFIG_FILE}";
showAPIHelp;
return 1
return 1;
fi
if [ -z "${CLIENT_SECRET}" ]; then
cecho "Invalid Client Secret, please update ${USER_CONFIG_FILE}";
showAPIHelp;
return 1
return 1;
fi
SHPOTIFY_CREDENTIALS=$(printf "${CLIENT_ID}:${CLIENT_SECRET}" | base64 | tr -d "\n"|tr -d '\r');
SPOTIFY_PLAY_URI="";
@ -198,7 +201,7 @@ while [ $# -gt 0 ]; do
fi
SPOTIFY_ACCESS_TOKEN=$( \
printf "${SPOTIFY_TOKEN_RESPONSE_DATA}" \
| grep -E -o '"access_token":".*",' \
| command grep -E -o '"access_token":".*",' \
| sed 's/"access_token"://g' \
| sed 's/"//g' \
| sed 's/,.*//g' \
@ -219,9 +222,8 @@ while [ $# -gt 0 ]; do
-H "Accept: application/json" \
--data-urlencode "q=$Q" \
-d "type=$type&limit=1&offset=0" \
| grep -E -o "spotify:$type:[a-zA-Z0-9]+" -m 1
| command grep -E -o "spotify:$type:[a-zA-Z0-9]+" -m 1
)
echo "play uri: ${SPOTIFY_PLAY_URI}"
}
case $2 in
@ -235,11 +237,11 @@ while [ $# -gt 0 ]; do
results=$( \
curl -s -G $SPOTIFY_SEARCH_API --data-urlencode "q=$Q" -d "type=playlist&limit=10&offset=0" -H "Accept: application/json" -H "Authorization: Bearer ${SPOTIFY_ACCESS_TOKEN}" \
| grep -E -o "spotify:playlist:[a-zA-Z0-9]+" -m 10 \
| command grep -E -o "spotify:playlist:[a-zA-Z0-9]+" -m 10 \
)
count=$( \
echo "$results" | grep -c "spotify:playlist" \
echo "$results" | command grep -c "spotify:playlist" \
)
if [ "$count" -gt 0 ]; then
@ -333,16 +335,16 @@ while [ $# -gt 0 ]; do
cecho "Current Spotify volume level is $vol.";
break ;
elif [ "$2" = "up" ]; then
if [ $vol -le 90 ]; then
newvol=$(( vol+10 ));
if [ $vol -le $(( 100-$VOL_INCREMENT )) ]; then
newvol=$(( vol+$VOL_INCREMENT ));
cecho "Increasing Spotify volume to $newvol.";
else
newvol=100;
cecho "Spotify volume level is at max.";
fi
elif [ "$2" = "down" ]; then
if [ $vol -ge 10 ]; then
newvol=$(( vol-10 ));
if [ $vol -ge $(( $VOL_INCREMENT )) ]; then
newvol=$(( vol-$VOL_INCREMENT ));
cecho "Reducing Spotify volume to $newvol.";
else
newvol=0;
@ -354,11 +356,11 @@ while [ $# -gt 0 ]; do
else
echo "Improper use of 'vol' command"
echo "The 'vol' command should be used as follows:"
echo " vol up # Increases the volume by 10%.";
echo " vol down # Decreases the volume by 10%.";
echo " vol up # Increases the volume by $VOL_INCREMENT%.";
echo " vol down # Decreases the volume by $VOL_INCREMENT%.";
echo " vol [amount] # Sets the volume to an amount between 0 and 100.";
echo " vol # Shows the current Spotify volume.";
return 1
return 1;
fi
osascript -e "tell application \"Spotify\" to set sound volume to $newvol";
@ -468,10 +470,9 @@ while [ $# -gt 0 ]; do
"help" )
showHelp;
break ;;
* )
showHelp;
return 1 ;;
return 1;
esac
done

View file

@ -1,6 +1,7 @@
# Pipenv
## Installation
In your `.zshrc` file, add `pipenv` to the plugins section
```
@ -8,7 +9,9 @@ plugins=(... pipenv ...)
```
## Features
This plugin provides some features to simplify the use of Pipenv while working on ZSH.
This plugin provides some features to simplify the use of Pipenv while working on ZSH.
- Adds completion for pipenv
- Auto activates and deactivates pipenv shell
- Adds short aliases for common pipenv commands
@ -27,3 +30,13 @@ This plugin provides some features to simplify the use of Pipenv while working o
- `pwh` is aliased to `pipenv --where`
- `pvenv` is aliased to `pipenv --venv`
- `ppy` is aliased to `pipenv --py`
## Configuration
### Shell activation
If you want to disable the shell activation and deactivation feature, add the following style to your `.zshrc` before sourcing `oh-my-zsh.sh`:
```zsh
zstyle ':omz:plugins:pipenv' auto-shell no
```

View file

@ -12,28 +12,30 @@ fi
_PIPENV_COMPLETE=zsh_source pipenv >| "$ZSH_CACHE_DIR/completions/_pipenv" &|
# Automatic pipenv shell activation/deactivation
_togglePipenvShell() {
# deactivate shell if Pipfile doesn't exist and not in a subdir
if [[ ! -f "$PWD/Pipfile" ]]; then
if [[ "$PIPENV_ACTIVE" == 1 ]]; then
if [[ "$PWD" != "$pipfile_dir"* ]]; then
exit
if zstyle -T ':omz:plugins:pipenv' auto-shell; then
# Automatic pipenv shell activation/deactivation
_togglePipenvShell() {
# deactivate shell if Pipfile doesn't exist and not in a subdir
if [[ ! -f "$PWD/Pipfile" ]]; then
if [[ "$PIPENV_ACTIVE" == 1 ]]; then
if [[ "$PWD" != "$pipfile_dir"* ]]; then
exit
fi
fi
fi
fi
# activate the shell if Pipfile exists
if [[ "$PIPENV_ACTIVE" != 1 ]]; then
if [[ -f "$PWD/Pipfile" ]]; then
export pipfile_dir="$PWD"
pipenv shell
# activate the shell if Pipfile exists
if [[ "$PIPENV_ACTIVE" != 1 ]]; then
if [[ -f "$PWD/Pipfile" ]]; then
export pipfile_dir="$PWD"
pipenv shell
fi
fi
fi
}
autoload -U add-zsh-hook
add-zsh-hook chpwd _togglePipenvShell
_togglePipenvShell
}
autoload -U add-zsh-hook
add-zsh-hook chpwd _togglePipenvShell
_togglePipenvShell
fi
# Aliases
alias pch="pipenv check"

47
plugins/podman/README.md Normal file
View file

@ -0,0 +1,47 @@
# Podman plugin
This plugin adds auto-completion and aliases for [podman](https://podman.io/).
To use it add `podman` to the plugins array in your zshrc file.
```zsh
plugins=(... podman)
```
## Aliases
| Alias | Command | Description |
| :------ | :-------------------------------------------- | :--------------------------------------------------------------------------------------- |
| pbl | `podman build` | Build an image from a Dockerfile |
| pcin | `podman container inspect` | Display detailed information on one or more containers |
| pcls | `podman container ls` | List all the running podman containers |
| pclsa | `podman container ls --all` | List all running and stopped containers |
| pib | `podman image build` | Build an image from a Dockerfile (same as podman build) |
| pii | `podman image inspect` | Display detailed information on one or more images |
| pils | `podman image ls` | List podman images |
| pipu | `podman image push` | Push an image or repository to a remote registry |
| pirm | `podman image rm` | Remove one or more images |
| pit | `podman image tag` | Add a name and tag to a particular image |
| plo | `podman container logs` | Fetch the logs of a podman container |
| pnc | `podman network create` | Create a new network |
| pncn | `podman network connect` | Connect a container to a network |
| pndcn | `podman network disconnect` | Disconnect a container from a network |
| pni | `podman network inspect` | Return information about one or more networks |
| pnls | `podman network ls` | List all networks the engine daemon knows about, including those spanning multiple hosts |
| pnrm | `podman network rm` | Remove one or more networks |
| ppo | `podman container port` | List port mappings or a specific mapping for the container |
| ppu | `podman pull` | Pull an image or a repository from a registry |
| pr | `podman container run` | Create a new container and start it using the specified command |
| prit | `podman container run --interactive --tty` | Create a new container and start it in an interactive shell |
| prm | `podman container rm` | Remove the specified container(s) |
| prm! | `podman container rm --force` | Force the removal of a running container (uses SIGKILL) |
| pst | `podman container start` | Start one or more stopped containers |
| prs | `podman container restart` | Restart one or more containers |
| psta | `podman stop $(podman ps -q)` | Stop all running containers |
| pstp | `podman container stop` | Stop one or more running containers |
| ptop | `podman top` | Display the running processes of a container |
| pvi | `podman volume inspect` | Display detailed information about one or more volumes |
| pvls | `podman volume ls` | List all the volumes known to podman |
| pvprune | `podman volume prune` | Cleanup dangling volumes |
| pxc | `podman container exec` | Run a new command in a running container |
| pxcit | `podman container exec --interactive --tty` | Run a new command in a running container in an interactive shell |

View file

@ -0,0 +1,47 @@
if (( ! $+commands[podman] )); then
return
fi
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `podman`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_podman" ]]; then
typeset -g -A _comps
autoload -Uz _podman
_comps[podman]=_podman
fi
podman completion zsh 2> /dev/null >| "$ZSH_CACHE_DIR/completions/_podman" &|
alias pbl='podman build'
alias pcin='podman container inspect'
alias pcls='podman container ls'
alias pclsa='podman container ls --all'
alias pib='podman image build'
alias pii='podman image inspect'
alias pils='podman image ls'
alias pipu='podman image push'
alias pirm='podman image rm'
alias pit='podman image tag'
alias plo='podman container logs'
alias pnc='podman network create'
alias pncn='podman network connect'
alias pndcn='podman network disconnect'
alias pni='podman network inspect'
alias pnls='podman network ls'
alias pnrm='podman network rm'
alias ppo='podman container port'
alias ppu='podman pull'
alias pr='podman container run'
alias prit='podman container run --interactive --tty'
alias prm='podman container rm'
alias 'prm!'='podman container rm --force'
alias pst='podman container start'
alias prs='podman container restart'
alias psta='podman stop $(podman ps --quiet)'
alias pstp='podman container stop'
alias ptop='podman top'
alias pvi='podman volume inspect'
alias pvls='podman volume ls'
alias pvprune='podman volume prune'
alias pxc='podman container exec'
alias pxcit='podman container exec --interactive --tty'

20
plugins/qodana/README.md Normal file
View file

@ -0,0 +1,20 @@
# JetBrains Qodana CLI plugin
This plugin adds completion for the [JetBrains Qodana CLI](https://github.com/JetBrains/qodana-cli).
To use it, add `qodana` to the plugins array in your zshrc file:
```zsh
plugins=(... qodana)
```
This plugin does not add any aliases.
## Cache
This plugin caches the completion script and is automatically updated when the
plugin is loaded, which is usually when you start up a new terminal emulator.
The cache is stored at:
- `$ZSH_CACHE_DIR/completions/_qodana` completions script

View file

@ -0,0 +1,14 @@
# Autocompletion for the JetBrains Qodana CLI (qodana).
if (( ! $+commands[qodana] )); then
return
fi
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `qodana`. Otherwise, compinit will have already done that.
if [[ ! -f "$ZSH_CACHE_DIR/completions/_qodana" ]]; then
typeset -g -A _comps
autoload -Uz _qodana
_comps[qodana]=_qodana
fi
qodana completion zsh >| "$ZSH_CACHE_DIR/completions/_qodana" &|

View file

@ -12,6 +12,7 @@ plugins=(... systemd)
| Alias | Command | Description |
|:-----------------------|:-----------------------------------|:-----------------------------------------------------------------|
| `sc-failed` | `systemctl --failed` | List failed systemd units |
| `sc-list-units` | `systemctl list-units` | List all units systemd has in memory |
| `sc-is-active` | `systemctl is-active` | Show whether a unit is active |
| `sc-status` | `systemctl status` | Show terse runtime status information about one or more units |

View file

@ -93,6 +93,9 @@ alias scu-enable-now="scu-enable --now"
alias scu-disable-now="scu-disable --now"
alias scu-mask-now="scu-mask --now"
# --failed commands
alias scu-failed='systemctl --user --failed'
alias sc-failed='systemctl --failed'
function systemd_prompt_info {
local unit

View file

@ -1,7 +1,7 @@
# Terraform plugin
Plugin for Terraform, a tool from Hashicorp for managing infrastructure safely and efficiently.
It adds completion for `terraform`, as well as aliases and a prompt function.
Plugin for Terraform, a tool from Hashicorp for managing infrastructure safely and efficiently. It adds
completion for `terraform`, as well as aliases and a prompt function.
To use it, add `terraform` to the plugins array of your `~/.zshrc` file:
@ -11,7 +11,7 @@ plugins=(... terraform)
## Requirements
* [Terraform](https://terraform.io/)
- [Terraform](https://terraform.io/)
## Aliases
@ -29,11 +29,12 @@ plugins=(... terraform)
## Prompt function
You can add the current Terraform workspace in your prompt by adding `$(tf_prompt_info)`
to your `PROMPT` or `RPROMPT` variable.
You can add the current Terraform workspace in your prompt by adding `$(tf_prompt_info)`,
`$(tf_version_prompt_info)` to your `PROMPT` or `RPROMPT` variable.
```sh
RPROMPT='$(tf_prompt_info)'
RPROMPT='$(tf_version_prompt_info)'
```
You can also specify the PREFIX and SUFFIX for the workspace with the following variables:
@ -41,4 +42,6 @@ You can also specify the PREFIX and SUFFIX for the workspace with the following
```sh
ZSH_THEME_TF_PROMPT_PREFIX="%{$fg[white]%}"
ZSH_THEME_TF_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_TF_VERSION_PROMPT_PREFIX="%{$fg[white]%}"
ZSH_THEME_TF_VERSION_PROMPT_SUFFIX="%{$reset_color%}"
```

View file

@ -8,6 +8,13 @@ function tf_prompt_info() {
echo "${ZSH_THEME_TF_PROMPT_PREFIX-[}${workspace:gs/%/%%}${ZSH_THEME_TF_PROMPT_SUFFIX-]}"
}
function tf_version_prompt_info() {
local terraform_version
terraform_version=$(terraform --version | head -n 1 | cut -d ' ' -f 2)
echo "${ZSH_THEME_TF_VERSION_PROMPT_PREFIX-[}${terraform_version:gs/%/%%}${ZSH_THEME_TF_VERSION_PROMPT_SUFFIX-]}"
}
alias tf='terraform'
alias tfa='terraform apply'
alias tfc='terraform console'

View file

@ -28,16 +28,16 @@ The plugin also supports the following:
## Configuration Variables
| Variable | Description |
| ----------------------------------- | ----------------------------------------------------------------------------- |
| `ZSH_TMUX_AUTOSTART` | Automatically starts tmux (default: `false`) |
| `ZSH_TMUX_AUTOSTART_ONCE` | Autostart only if tmux hasn't been started previously (default: `true`) |
| `ZSH_TMUX_AUTOCONNECT` | Automatically connect to a previous session if it exits (default: `true`) |
| `ZSH_TMUX_AUTOQUIT` | Automatically closes terminal once tmux exits (default: `ZSH_TMUX_AUTOSTART`) |
| `ZSH_TMUX_FIXTERM` | Sets `$TERM` to 256-color term or not based on current terminal support |
| `ZSH_TMUX_ITERM2` | Sets the `-CC` option for iTerm2 tmux integration (default: `false`) |
| `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `screen`) |
| `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_UNICODE` | Set `tmux -u` option to support unicode |
| `ZSH_TMUX_DEFAULT_SESSION_NAME` | Set tmux default session name when autostart is enabled |
| Variable | Description |
| ----------------------------------- | ------------------------------------------------------------------------------------------- |
| `ZSH_TMUX_AUTOSTART` | Automatically starts tmux (default: `false`) |
| `ZSH_TMUX_AUTOSTART_ONCE` | Autostart only if tmux hasn't been started previously (default: `true`) |
| `ZSH_TMUX_AUTOCONNECT` | Automatically connect to a previous session if it exits (default: `true`) |
| `ZSH_TMUX_AUTOQUIT` | Automatically closes terminal once tmux exits (default: `ZSH_TMUX_AUTOSTART`) |
| `ZSH_TMUX_FIXTERM` | Sets `$TERM` to 256-color term or not based on current terminal support |
| `ZSH_TMUX_ITERM2` | Sets the `-CC` option for iTerm2 tmux integration (default: `false`) |
| `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `screen`) |
| `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`, `$XDG_CONFIG_HOME/tmux/tmux.conf`) |
| `ZSH_TMUX_UNICODE` | Set `tmux -u` option to support unicode |
| `ZSH_TMUX_DEFAULT_SESSION_NAME` | Set tmux default session name when autostart is enabled |

View file

@ -26,12 +26,17 @@ fi
# systems without the proper terminfo
: ${ZSH_TMUX_FIXTERM_WITH_256COLOR:=screen-256color}
# Set the configuration path
: ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf}
if [[ -e $HOME/.tmux.conf ]]; then
: ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf}
elif [[ -e ${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf ]]; then
: ${ZSH_TMUX_CONFIG:=${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf}
else
: ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf}
fi
# Set -u option to support unicode
: ${ZSH_TMUX_UNICODE:=false}
# ALIASES
alias ta='tmux attach -t'
alias tad='tmux attach -d -t'
alias ts='tmux new-session -s'

View file

@ -25,6 +25,7 @@ function web_search() {
archive "https://web.archive.org/web/*/"
scholar "https://scholar.google.com/scholar?q="
ask "https://www.ask.com/web?q="
youtube "https://www.youtube.com/results?search_query="
)
# check whether the search engine is supported
@ -66,11 +67,12 @@ alias wolframalpha='web_search wolframalpha'
alias archive='web_search archive'
alias scholar='web_search scholar'
alias ask='web_search ask'
alias youtube='web_search youtube'
#add your own !bang searches here
alias wiki='web_search duckduckgo \!w'
alias news='web_search duckduckgo \!n'
alias youtube='web_search duckduckgo \!yt'
#alias youtube='web_search duckduckgo \!yt'
alias map='web_search duckduckgo \!m'
alias image='web_search duckduckgo \!i'
alias ducky='web_search duckduckgo \!'

View file

@ -1,24 +1,140 @@
# Depends on the git plugin for work_in_progress()
(( $+functions[work_in_progress] )) || work_in_progress() {}
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}["
ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[cyan]%}[%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg[cyan]%}]"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_CLEAN=""
# Customized git status, oh-my-zsh currently does not allow render dirty status before branch
git_custom_status() {
local branch=$(git_current_branch)
[[ -n "$branch" ]] || return 0
echo "$(parse_git_dirty)\
%{${fg_bold[yellow]}%}$(work_in_progress)%{$reset_color%}\
${ZSH_THEME_GIT_PROMPT_PREFIX}${branch}${ZSH_THEME_GIT_PROMPT_SUFFIX}"
print "%{${fg_bold[yellow]}%}$(work_in_progress)%{$reset_color%}\
${ZSH_THEME_GIT_PROMPT_PREFIX}$(parse_git_dirty)${branch}\
${ZSH_THEME_GIT_PROMPT_SUFFIX}"
}
autoload -U colors && colors
#export VCS_PROMPT=hg_prompt_info
export VCS_PROMPT=git_custom_status
base_prompt="%{$fg[cyan]%}[%~% ]%(?.%{$fg[green]%}.%{$fg[red]%})%B$%b "
custom_prompt=""
last_run_time=""
last_vcs_info=""
function pipestatus_parse {
PIPESTATUS="$pipestatus"
ERROR=0
for i in "${(z)PIPESTATUS}"; do
if [[ "$i" -ne 0 ]]; then
ERROR=1
fi
done
if [[ "$ERROR" -ne 0 ]]; then
print "[%{$fg[red]%}$PIPESTATUS%{$fg[cyan]%}]"
fi
}
# RVM component of prompt
ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[red]%}["
ZSH_THEME_RUBY_PROMPT_SUFFIX="]%{$reset_color%}"
# Combine it all into a final right-side prompt
RPS1="\$(git_custom_status)\$(ruby_prompt_info)${RPS1:+ $RPS1}"
PROMPT='%{$fg[cyan]%}[%~% ]%(?.%{$fg[green]%}.%{$fg[red]%})%B$%b '
function preexec() {
last_run_time=$(perl -MTime::HiRes=time -e 'printf "%.9f\n", time')
}
function duration() {
local duration
local now=$(perl -MTime::HiRes=time -e 'printf "%.9f\n", time')
local last=$1
local last_split=("${(@s/./)last}")
local now_split=("${(@s/./)now}")
local T=$((now_split[1] - last_split[1]))
local D=$((T/60/60/24))
local H=$((T/60/60%24))
local M=$((T/60%60))
local S=$((T%60))
local s=$(((now_split[2] - last_split[2]) / 1000000000.))
local m=$(((now_split[2] - last_split[2]) / 1000000.))
(( $D > 0 )) && duration+="${D}d"
(( $H > 0 )) && duration+="${H}h"
(( $M > 0 )) && duration+="${M}m"
if [[ $S -le 0 ]]; then
printf "%ims" "$m"
else
if ! [[ -z $duration ]] && printf "%s" "$duration"
local sec_milli=$((S + s))
printf "%.3fs" "$sec_milli"
fi
}
function precmd() {
RETVAL=$(pipestatus_parse)
local info=""
if [ ! -z "$last_run_time" ]; then
local elapsed=$(duration $last_run_time)
last_run_time=$(print $last_run_time | tr -d ".")
if [ $(( $(perl -MTime::HiRes=time -e 'printf "%.9f\n", time' | tr -d ".") - $last_run_time )) -gt $(( 120 * 1000 * 1000 * 1000 )) ]; then
local elapsed_color="%{$fg[magenta]%}"
elif [ $(( $(perl -MTime::HiRes=time -e 'printf "%.9f\n", time' | tr -d ".") - $last_run_time )) -gt $(( 60 * 1000 * 1000 * 1000 )) ]; then
local elapsed_color="%{$fg[red]%}"
elif [ $(( $(perl -MTime::HiRes=time -e 'printf "%.9f\n", time' | tr -d ".") - $last_run_time )) -gt $(( 10 * 1000 * 1000 * 1000 )) ]; then
local elapsed_color="%{$fg[yellow]%}"
else
local elapsed_color="%{$fg[green]%}"
fi
info=$(printf "%s%s%s%s%s" "%{$fg[cyan]%}[" "$elapsed_color" "$elapsed" "%{$fg[cyan]%}]" "$RETVAL")
unset last_run_time
fi
if [ -z "$info" -a ! -z "$last_vcs_info" ]; then
custom_prompt="$last_vcs_info$base_prompt"
return;
fi
if (( ${+VCS_PROMPT} )); then
last_vcs_info=$($VCS_PROMPT)
if [ ! -z "$last_vcs_info" ]; then
[ -z "$info" ] && info=$last_vcs_info || info="$info$last_vcs_info"
fi
fi
[ -z "$info" ] && custom_prompt="$base_prompt" || custom_prompt="$info$base_prompt"
}
function hg_prompt_info() {
unset output info parts branch_parts branch
local output=""
if ! output="$(hg status 2> /dev/null)"; then
return
fi
local info=$(hg log -l1 --template '{author}:{node|short}:{remotenames}:{phabdiff}')
local parts=(${(@s/:/)info})
local branch_parts=(${(@s,/,)parts[3]})
local branch=${branch_parts[-1]}
[ ! -z "${parts[3]}" ] && [[ "${parts[1]}" =~ "$USER@" ]] && branch=${parts[3]}
[ -z "${parts[3]}" ] && branch=${parts[2]}
if [[ ! -z "$output" ]]; then
local color="%{$fg[red]%}"
elif [[ "${branch}" == "master" || "${branch}" == "warm" ]]; then
local color="%{$fg[yellow]%}"
else
local color="%{$fg[green]%}"
fi
print "%{$fg[cyan]%}[${color}${branch}%{$fg[cyan]%}]"
}
setopt PROMPT_SUBST
PROMPT='$custom_prompt'

View file

@ -51,8 +51,14 @@ function ssh_connection() {
fi
}
function _toolbox_prompt_info() {
if typeset -f toolbox_prompt_info > /dev/null; then
toolbox_prompt_info
fi
}
local ret_status="%(?:%{$fg_bold[green]%}:%{$fg_bold[red]%})%?%{$reset_color%}"
PROMPT=$'\n$(ssh_connection)%{$fg_bold[green]%}%n@%m%{$reset_color%}$(my_git_prompt) : %~\n[${ret_status}] %# '
PROMPT=$'\n$(_toolbox_prompt_info)$(ssh_connection)%{$fg_bold[green]%}%n@%m%{$reset_color%}$(my_git_prompt) : %~\n[${ret_status}] %# '
ZSH_THEME_PROMPT_RETURNCODE_PREFIX="%{$fg_bold[red]%}"
ZSH_THEME_GIT_PROMPT_PREFIX=" $fg[white] %{$fg_bold[yellow]%}"

View file

@ -0,0 +1,24 @@
# Depends on the git plugin for work_in_progress()
(( $+functions[work_in_progress] )) || work_in_progress() {}
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}["
ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=""
# Customized git status, oh-my-zsh currently does not allow render dirty status before branch
git_custom_status() {
local branch=$(git_current_branch)
[[ -n "$branch" ]] || return 0
echo "$(parse_git_dirty)\
%{${fg_bold[yellow]}%}$(work_in_progress)%{$reset_color%}\
${ZSH_THEME_GIT_PROMPT_PREFIX}${branch}${ZSH_THEME_GIT_PROMPT_SUFFIX}"
}
# RVM component of prompt
ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[red]%}["
ZSH_THEME_RUBY_PROMPT_SUFFIX="]%{$reset_color%}"
# Combine it all into a final right-side prompt
RPS1="\$(git_custom_status)\$(ruby_prompt_info)${RPS1:+ $RPS1}"
PROMPT='%{$fg[cyan]%}[%~% ]%(?.%{$fg[green]%}.%{$fg[red]%})%B$%b '

View file

@ -366,7 +366,7 @@ function display-release {
# In text mode, highlight (#<issue>) and dim text between `backticks`
text)
if supports_hyperlinks; then
sed -E $'s|#([0-9]+)|\e]8;;https://github.com/ohmyzsh/ohmyzsh/issues/\\1\a\e[32m#\\1\e[0m\e]8;;\a|g' <<< "$subject"
sed -E $'s|#([0-9]+)|\e]8;;https://github.com/ohmyzsh/ohmyzsh/issues/\\1\a\e[32m#\\1\e[0m\e]8;;\a|g;s|`([^`]+)`|`\e[2m\\1\e[0m`|g' <<< "$subject"
else
sed -E $'s|#([0-9]+)|\e[32m#\\1\e[0m|g;s|`([^`]+)`|`\e[2m\\1\e[0m`|g' <<< "$subject"
fi ;;

View file

@ -1,4 +1,5 @@
#!/usr/bin/env zsh
set +u # disable nounset
local ret=0 # exit code