mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-19 02:02:32 +01:00
Merge branch 'ohmyzsh:master' into master
This commit is contained in:
commit
a4c3c67308
418 changed files with 12295 additions and 5099 deletions
|
|
@ -14,16 +14,18 @@ clipboard.
|
|||
## `opswd`
|
||||
|
||||
The `opswd` command is a wrapper around the `op` command. It takes a service
|
||||
name as an argument and copies the password for that service to the clipboard.
|
||||
name as an argument and copies the username, then the password for that service
|
||||
to the clipboard, after confirmation on the user part.
|
||||
|
||||
If the service also contains a TOTP, it is copied to the clipboard after 10 seconds.
|
||||
Finally, after 20 seconds, the clipboard is cleared.
|
||||
If the service also contains a TOTP, it is copied to the clipboard after confirmation
|
||||
on the user part. Finally, after 20 seconds, the clipboard is cleared.
|
||||
|
||||
The function has completion support, so you can use tab completion to select
|
||||
which service you want to get.
|
||||
For example, `opswd github.com` will put your GitHub username into your clipboard. Then,
|
||||
it will ask for confirmation to continue, and copy the password to your clipboard. Finally,
|
||||
if a TOTP is available, it will be copied to the clipboard after your confirmation.
|
||||
|
||||
For example, `opswd github.com` will put your GitHub password into your clipboard, and if
|
||||
a TOTP is available, it will be copied to the clipboard after 10 seconds.
|
||||
This function has completion support, so you can use tab completion to select which
|
||||
service you want to get.
|
||||
|
||||
> NOTE: you need to be signed in for `opswd` to work. If you are using biometric unlock,
|
||||
> 1Password CLI will automatically prompt you to sign in. See:
|
||||
|
|
|
|||
|
|
@ -14,6 +14,17 @@ function opswd() {
|
|||
# If not logged in, print error and return
|
||||
op user list > /dev/null || return
|
||||
|
||||
local username
|
||||
# Copy the username to the clipboard
|
||||
if ! username=$(op item get "$service" --fields username 2>/dev/null); then
|
||||
echo "error: could not obtain username for $service"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo -n "$username" | clipcopy
|
||||
echo "✔ username for service $service copied to the clipboard. Press Enter to continue"
|
||||
read
|
||||
|
||||
local password
|
||||
# Copy the password to the clipboard
|
||||
if ! password=$(op item get "$service" --fields password 2>/dev/null); then
|
||||
|
|
@ -22,12 +33,13 @@ function opswd() {
|
|||
fi
|
||||
|
||||
echo -n "$password" | clipcopy
|
||||
echo "✔ password for $service copied to clipboard"
|
||||
echo "✔ password for $service copied to clipboard. Press Enter to continue"
|
||||
read
|
||||
|
||||
# If there's a one time password, copy it to the clipboard after 10 seconds
|
||||
# If there's a one time password, copy it to the clipboard
|
||||
local totp
|
||||
if totp=$(op item get --otp "$service" 2>/dev/null) && [[ -n "$totp" ]]; then
|
||||
sleep 10 && echo -n "$totp" | clipcopy
|
||||
echo -n "$totp" | clipcopy
|
||||
echo "✔ TOTP for $service copied to clipboard"
|
||||
fi
|
||||
|
||||
|
|
|
|||
9
plugins/alias-finder/.zunit.yml
Normal file
9
plugins/alias-finder/.zunit.yml
Normal 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
|
||||
|
|
@ -2,45 +2,67 @@
|
|||
|
||||
This plugin searches the defined aliases and outputs any that match the command inputted. This makes learning new aliases easier.
|
||||
|
||||
## Setup
|
||||
|
||||
To use it, add `alias-finder` to the `plugins` array of your zshrc file:
|
||||
```
|
||||
plugins=(... alias-finder)
|
||||
```
|
||||
|
||||
To enable it for every single command, set zstyle in your `~/.zshrc`.
|
||||
|
||||
```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.
|
||||
|
||||
## 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.
|
||||
|
||||
## Options
|
||||
When you execute a command alias finder will look at your defined aliases and suggest shorter aliases you could have used, for example:
|
||||
|
||||
- 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.
|
||||
Running the un-aliased `git status` command:
|
||||
```sh
|
||||
╭─tim@fox ~/repo/gitopolis ‹main›
|
||||
╰─$ git status
|
||||
|
||||
## Examples
|
||||
gst='git status' # <=== shorter suggestion from alias-finder
|
||||
|
||||
On branch main
|
||||
Your branch is up-to-date with 'origin/main'.
|
||||
nothing to commit, working tree clean
|
||||
```
|
||||
$ alias-finder "git pull"
|
||||
gl='git pull'
|
||||
g=git
|
||||
|
||||
Running a shorter `git st` alias from `.gitconfig` that it suggested :
|
||||
```sh
|
||||
╭─tim@fox ~/repo/gitopolis ‹main›
|
||||
╰─$ git st
|
||||
gs='git st' # <=== shorter suggestion from alias-finder
|
||||
## main...origin/main
|
||||
```
|
||||
|
||||
Running the shortest `gs` shell alias that it found:
|
||||
```sh
|
||||
╭─tim@fox ~/repo/gitopolis ‹main›
|
||||
╰─$ gs
|
||||
# <=== no suggestions alias-finder because this is the shortest
|
||||
## main...origin/main
|
||||
```
|
||||
$ 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'
|
||||
```
|
||||
|
||||

|
||||
|
||||
|
||||
### 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).
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
0
plugins/alias-finder/tests/_output/.gitkeep
Normal file
0
plugins/alias-finder/tests/_output/.gitkeep
Normal file
0
plugins/alias-finder/tests/_support/.gitkeep
Normal file
0
plugins/alias-finder/tests/_support/.gitkeep
Normal file
2
plugins/alias-finder/tests/_support/bootstrap
Normal file
2
plugins/alias-finder/tests/_support/bootstrap
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#!/usr/bin/env zsh
|
||||
# Write your bootstrap code here
|
||||
107
plugins/alias-finder/tests/test_run.sh
Normal file
107
plugins/alias-finder/tests/test_run.sh
Normal 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"
|
||||
}
|
||||
|
|
@ -15,8 +15,14 @@ Requirements: Python needs to be installed.
|
|||
|
||||
## Usage
|
||||
|
||||
- `acs`: show all aliases by group.
|
||||
- `als`: show all aliases by group
|
||||
|
||||
- `acs <keyword>`: filter aliases by `<keyword>` and highlight.
|
||||
- `als -h/--help`: print help message
|
||||
|
||||

|
||||
- `als <keyword(s)>`: filter and highlight aliases by `<keyword>`
|
||||
|
||||
- `als -g <group>/--group <group>`: show only aliases for group `<group>`. Multiple uses of the flag show all groups
|
||||
|
||||
- `als --groups`: show only group names
|
||||
|
||||

|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
# with lots of 3rd-party amazing aliases installed, just need something to explore it quickly.
|
||||
#
|
||||
# - acs: alias cheatsheet
|
||||
# group alias by command, pass addition argv to grep.
|
||||
function acs(){
|
||||
(( $+commands[python3] )) || {
|
||||
echo "[error] No python executable detected"
|
||||
return
|
||||
# Handle $0 according to the standard:
|
||||
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
|
||||
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
||||
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||
|
||||
eval '
|
||||
function als(){
|
||||
(( $+commands[python3] )) || {
|
||||
echo "[error] No python executable detected"
|
||||
return
|
||||
}
|
||||
alias | python3 "'"${0:h}"'/cheatsheet.py" "$@"
|
||||
}
|
||||
alias | python3 ${functions_source[$0]:h}/cheatsheet.py $@
|
||||
}
|
||||
'
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
import sys
|
||||
import itertools
|
||||
import termcolor
|
||||
import argparse
|
||||
|
||||
def parse(line):
|
||||
left = line[0:line.find('=')].strip()
|
||||
|
|
@ -14,6 +15,7 @@ def parse(line):
|
|||
|
||||
def cheatsheet(lines):
|
||||
exps = [ parse(line) for line in lines ]
|
||||
exps.sort(key=lambda exp:exp[2])
|
||||
cheatsheet = {'_default': []}
|
||||
for key, group in itertools.groupby(exps, lambda exp:exp[2]):
|
||||
group_list = [ item for item in group ]
|
||||
|
|
@ -26,7 +28,7 @@ def cheatsheet(lines):
|
|||
target_aliases.extend(group_list)
|
||||
return cheatsheet
|
||||
|
||||
def pretty_print_group(key, aliases, highlight=None):
|
||||
def pretty_print_group(key, aliases, highlight=None, only_groupname=False):
|
||||
if len(aliases) == 0:
|
||||
return
|
||||
group_hl_formatter = lambda g, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'red') for part in ('[%s]' % g).split(hl)])
|
||||
|
|
@ -35,21 +37,33 @@ def pretty_print_group(key, aliases, highlight=None):
|
|||
alias_formatter = lambda alias: termcolor.colored('\t%s = %s' % alias[0:2], 'green')
|
||||
if highlight and len(highlight)>0:
|
||||
print (group_hl_formatter(key, highlight))
|
||||
print ('\n'.join([alias_hl_formatter(alias, highlight) for alias in aliases]))
|
||||
if not only_groupname:
|
||||
print ('\n'.join([alias_hl_formatter(alias, highlight) for alias in aliases]))
|
||||
else:
|
||||
print (group_formatter(key))
|
||||
print ('\n'.join([alias_formatter(alias) for alias in aliases]))
|
||||
if not only_groupname:
|
||||
print ('\n'.join([alias_formatter(alias) for alias in aliases]))
|
||||
print ('')
|
||||
|
||||
def pretty_print(cheatsheet, wfilter):
|
||||
def pretty_print(cheatsheet, wfilter, group_list=None, groups_only=False):
|
||||
sorted_key = sorted(cheatsheet.keys())
|
||||
for key in sorted_key:
|
||||
if group_list and key not in group_list:
|
||||
continue
|
||||
aliases = cheatsheet.get(key)
|
||||
if not wfilter:
|
||||
pretty_print_group(key, aliases, wfilter)
|
||||
pretty_print_group(key, aliases, wfilter, groups_only)
|
||||
else:
|
||||
pretty_print_group(key, [ alias for alias in aliases if alias[0].find(wfilter)>-1 or alias[1].find(wfilter)>-1], wfilter)
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description="Pretty print aliases.", prog="als")
|
||||
parser.add_argument('filter', nargs="*", metavar="<keyword>", help="search aliases matching keywords")
|
||||
parser.add_argument('-g', '--group', dest="group_list", action='append', help="only print aliases in given groups")
|
||||
parser.add_argument('--groups', dest='groups_only', action='store_true', help="only print alias groups")
|
||||
args = parser.parse_args()
|
||||
|
||||
lines = sys.stdin.readlines()
|
||||
pretty_print(cheatsheet(lines), sys.argv[1] if len(sys.argv)>1 else None)
|
||||
group_list = args.group_list or None
|
||||
wfilter = " ".join(args.filter) or None
|
||||
pretty_print(cheatsheet(lines), wfilter, group_list, args.groups_only)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ plugins=(... ansible)
|
|||
| `acon` | command `ansible-console` |
|
||||
| `ainv` | command `ansible-inventory` |
|
||||
| `aplaybook` | command `ansible-playbook` |
|
||||
| `ainv` | command `ansible-inventory` |
|
||||
| `adoc` | command `ansible-doc` |
|
||||
| `agal` | command `ansible-galaxy` |
|
||||
| `apull` | command `ansible-pull` |
|
||||
|
|
@ -29,6 +28,6 @@ plugins=(... ansible)
|
|||
|
||||
## Maintainer
|
||||
|
||||
### [Deepankumar](https://github.com/deepan10)
|
||||
### [Deepankumar](https://github.com/deepan10)
|
||||
|
||||
[https://github.com/deepan10/oh-my-zsh/tree/features/ansible-plugin](https://github.com/deepan10/oh-my-zsh/tree/features/ansible-plugin)
|
||||
|
|
|
|||
|
|
@ -181,3 +181,4 @@ whether the package manager is installed, checked in the following order:
|
|||
- Ybalrid (Arthur Brainville) - ybalrid@ybalrid.info
|
||||
- Jeff M. Hubbard - jeffmhubbard@gmail.com
|
||||
- K. Harishankar(harishnkr) - hari2menon1234@gmail.com
|
||||
- WH-2099 - wh2099@outlook.com
|
||||
|
|
@ -23,30 +23,27 @@ alias pacfiles='pacman -F'
|
|||
alias pacls='pacman -Ql'
|
||||
alias pacown='pacman -Qo'
|
||||
alias pacupd="sudo pacman -Sy"
|
||||
alias upgrade='sudo pacman -Syu'
|
||||
|
||||
function paclist() {
|
||||
# Based on https://bbs.archlinux.org/viewtopic.php?id=93683
|
||||
pacman -Qqe | \
|
||||
xargs -I '{}' \
|
||||
expac "${bold_color}% 20n ${fg_no_bold[white]}%d${reset_color}" '{}'
|
||||
pacman -Qqe | xargs -I{} -P0 --no-run-if-empty pacman -Qs --color=auto "^{}\$"
|
||||
}
|
||||
|
||||
function pacdisowned() {
|
||||
local tmp db fs
|
||||
tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$
|
||||
db=$tmp/db
|
||||
fs=$tmp/fs
|
||||
local tmp_dir db fs
|
||||
tmp_dir=$(mktemp --directory)
|
||||
db=$tmp_dir/db
|
||||
fs=$tmp_dir/fs
|
||||
|
||||
mkdir "$tmp"
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
trap "rm -rf $tmp_dir" EXIT
|
||||
|
||||
pacman -Qlq | sort -u > "$db"
|
||||
|
||||
find /bin /etc /lib /sbin /usr ! -name lost+found \
|
||||
find /etc /usr ! -name lost+found \
|
||||
\( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
|
||||
|
||||
comm -23 "$fs" "$db"
|
||||
|
||||
rm -rf $tmp_dir
|
||||
}
|
||||
|
||||
alias pacmanallkeys='sudo pacman-key --refresh-keys'
|
||||
|
|
@ -109,7 +106,6 @@ if (( $+commands[aura] )); then
|
|||
alias auupd="sudo aura -Sy"
|
||||
alias auupg='sudo sh -c "aura -Syu && aura -Au"'
|
||||
alias ausu='sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"'
|
||||
alias upgrade='sudo aura -Syu'
|
||||
|
||||
# extra bonus specially for aura
|
||||
alias auown="aura -Qqo"
|
||||
|
|
@ -136,7 +132,6 @@ if (( $+commands[pacaur] )); then
|
|||
alias painsd='pacaur -S --asdeps'
|
||||
alias pamir='pacaur -Syy'
|
||||
alias paupd="pacaur -Sy"
|
||||
alias upgrade='pacaur -Syu'
|
||||
fi
|
||||
|
||||
if (( $+commands[trizen] )); then
|
||||
|
|
@ -158,7 +153,6 @@ if (( $+commands[trizen] )); then
|
|||
alias trinsd='trizen -S --asdeps'
|
||||
alias trmir='trizen -Syy'
|
||||
alias trupd="trizen -Sy"
|
||||
alias upgrade='trizen -Syu'
|
||||
fi
|
||||
|
||||
if (( $+commands[yay] )); then
|
||||
|
|
@ -180,5 +174,30 @@ if (( $+commands[yay] )); then
|
|||
alias yainsd='yay -S --asdeps'
|
||||
alias yamir='yay -Syy'
|
||||
alias yaupd="yay -Sy"
|
||||
alias upgrade='yay -Syu'
|
||||
fi
|
||||
|
||||
# Check Arch Linux PGP Keyring before System Upgrade to prevent failure.
|
||||
function upgrade() {
|
||||
echo ":: Checking Arch Linux PGP Keyring..."
|
||||
local installedver="$(LANG= sudo pacman -Qi archlinux-keyring | grep -Po '(?<=Version : ).*')"
|
||||
local currentver="$(LANG= sudo pacman -Si archlinux-keyring | grep -Po '(?<=Version : ).*')"
|
||||
if [ $installedver != $currentver ]; then
|
||||
echo " Arch Linux PGP Keyring is out of date."
|
||||
echo " Updating before full system upgrade."
|
||||
sudo pacman -Sy --needed --noconfirm archlinux-keyring
|
||||
else
|
||||
echo " Arch Linux PGP Keyring is up to date."
|
||||
echo " Proceeding with full system upgrade."
|
||||
fi
|
||||
if (( $+commands[yay] )); then
|
||||
yay -Syu
|
||||
elif (( $+commands[trizen] )); then
|
||||
trizen -Syu
|
||||
elif (( $+commands[pacaur] )); then
|
||||
pacaur -Syu
|
||||
elif (( $+commands[aura] )); then
|
||||
sudo aura -Syu
|
||||
else
|
||||
sudo pacman -Syu
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
20
plugins/argocd/README.md
Normal file
20
plugins/argocd/README.md
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# Argo CD plugin
|
||||
|
||||
This plugin adds completion for the [Argo CD](https://argoproj.github.io/cd/) CLI.
|
||||
|
||||
To use it, add `argocd` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... argocd)
|
||||
```
|
||||
|
||||
This plugin does not add any aliases.
|
||||
|
||||
## Cache
|
||||
|
||||
This plugin caches the completion script and is automatically updated asynchronously when the plugin is
|
||||
loaded, which is usually when you start up a new terminal emulator.
|
||||
|
||||
The cache is stored at:
|
||||
|
||||
- `$ZSH_CACHE/completions/_argocd` completions script
|
||||
14
plugins/argocd/argocd.plugin.zsh
Normal file
14
plugins/argocd/argocd.plugin.zsh
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Autocompletion for argocd.
|
||||
if (( ! $+commands[argocd] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `argocd`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_argocd" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _argocd
|
||||
_comps[argocd]=_argocd
|
||||
fi
|
||||
|
||||
argocd completion zsh >| "$ZSH_CACHE_DIR/completions/_argocd" &|
|
||||
|
|
@ -6,22 +6,25 @@ Adds integration with [asdf](https://github.com/asdf-vm/asdf), the extendable ve
|
|||
|
||||
### Installation
|
||||
|
||||
1. Enable the plugin by adding it to your `plugins` definition in `~/.zshrc`.
|
||||
1. [Download asdf](https://asdf-vm.com/guide/getting-started.html#_2-download-asdf) by running the following:
|
||||
|
||||
```
|
||||
git clone https://github.com/asdf-vm/asdf.git ~/.asdf
|
||||
```
|
||||
|
||||
2. [Enable asdf](https://asdf-vm.com/guide/getting-started.html#_3-install-asdf) by adding it to your `plugins` definition in `~/.zshrc`.
|
||||
|
||||
```
|
||||
plugins=(asdf)
|
||||
```
|
||||
|
||||
2. [Install asdf](https://github.com/asdf-vm/asdf#setup) by running the following:
|
||||
```
|
||||
git clone https://github.com/asdf-vm/asdf.git ~/.asdf
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
See the [asdf usage documentation](https://github.com/asdf-vm/asdf#usage) for information on how to use asdf:
|
||||
See the [asdf documentation](https://asdf-vm.com/guide/getting-started.html#_4-install-a-plugin) for information on how to use asdf:
|
||||
|
||||
```
|
||||
asdf plugin-add nodejs git@github.com:asdf-vm/asdf-nodejs.git
|
||||
asdf install nodejs 5.9.1
|
||||
asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs.git
|
||||
asdf install nodejs latest
|
||||
asdf global nodejs latest
|
||||
asdf local nodejs latest
|
||||
```
|
||||
|
|
|
|||
|
|
@ -2,26 +2,29 @@
|
|||
ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
|
||||
ASDF_COMPLETIONS="$ASDF_DIR/completions"
|
||||
|
||||
# If not found, check for archlinux/AUR package (/opt/asdf-vm/)
|
||||
if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/asdf.bash" ]] && [[ -f "/opt/asdf-vm/asdf.sh" ]]; then
|
||||
ASDF_DIR="/opt/asdf-vm"
|
||||
ASDF_COMPLETIONS="$ASDF_DIR"
|
||||
fi
|
||||
|
||||
# If not found, check for Homebrew package
|
||||
if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/asdf.bash" ]] && (( $+commands[brew] )); then
|
||||
brew_prefix="$(brew --prefix asdf)"
|
||||
ASDF_DIR="${brew_prefix}/libexec"
|
||||
ASDF_COMPLETIONS="${brew_prefix}/etc/bash_completion.d"
|
||||
unset brew_prefix
|
||||
if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/_asdf" ]]; then
|
||||
# If not found, check for archlinux/AUR package (/opt/asdf-vm/)
|
||||
if [[ -f "/opt/asdf-vm/asdf.sh" ]]; then
|
||||
ASDF_DIR="/opt/asdf-vm"
|
||||
ASDF_COMPLETIONS="$ASDF_DIR"
|
||||
# If not found, check for Homebrew package
|
||||
elif (( $+commands[brew] )); then
|
||||
_ASDF_PREFIX="$(brew --prefix asdf)"
|
||||
ASDF_DIR="${_ASDF_PREFIX}/libexec"
|
||||
ASDF_COMPLETIONS="${_ASDF_PREFIX}/share/zsh/site-functions"
|
||||
unset _ASDF_PREFIX
|
||||
else
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
# Load command
|
||||
if [[ -f "$ASDF_DIR/asdf.sh" ]]; then
|
||||
. "$ASDF_DIR/asdf.sh"
|
||||
|
||||
source "$ASDF_DIR/asdf.sh"
|
||||
# Load completions
|
||||
if [[ -f "$ASDF_COMPLETIONS/asdf.bash" ]]; then
|
||||
. "$ASDF_COMPLETIONS/asdf.bash"
|
||||
if [[ -f "$ASDF_COMPLETIONS/_asdf" ]]; then
|
||||
fpath+=("$ASDF_COMPLETIONS")
|
||||
autoload -Uz _asdf
|
||||
compdef _asdf asdf # compdef is already loaded before loading plugins
|
||||
fi
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -17,9 +17,13 @@ if ! type autoenv_init >/dev/null; then
|
|||
/usr/local/bin
|
||||
/usr/share/autoenv-git
|
||||
~/Library/Python/bin
|
||||
.venv/bin
|
||||
venv/bin
|
||||
env/bin
|
||||
.env/bin
|
||||
)
|
||||
for d ( $install_locations ); do
|
||||
if [[ -e $d/activate.sh ]]; then
|
||||
if [[ -e $d/activate || -e $d/activate.sh ]]; then
|
||||
autoenv_dir=$d
|
||||
break
|
||||
fi
|
||||
|
|
@ -29,13 +33,13 @@ if ! type autoenv_init >/dev/null; then
|
|||
# Look for Homebrew path as a last resort
|
||||
if [[ -z "$autoenv_dir" ]] && (( $+commands[brew] )); then
|
||||
d=$(brew --prefix)/opt/autoenv
|
||||
if [[ -e $d/activate.sh ]]; then
|
||||
if [[ -e $d/activate || -e $d/activate.sh ]]; then
|
||||
autoenv_dir=$d
|
||||
fi
|
||||
fi
|
||||
|
||||
# Complain if autoenv is not installed
|
||||
if [[ -z $autoenv_dir ]]; then
|
||||
if [[ -z $autoenv_dir ]]; then
|
||||
cat <<END >&2
|
||||
-------- AUTOENV ---------
|
||||
Could not locate autoenv installation.
|
||||
|
|
@ -46,7 +50,11 @@ END
|
|||
return 1
|
||||
fi
|
||||
# Load autoenv
|
||||
source $autoenv_dir/activate.sh
|
||||
if [[ -e $autoenv_dir/activate ]]; then
|
||||
source $autoenv_dir/activate
|
||||
else
|
||||
source $autoenv_dir/activate.sh
|
||||
fi
|
||||
fi
|
||||
}
|
||||
[[ $? != 0 ]] && return $?
|
||||
|
|
|
|||
|
|
@ -1,17 +1,21 @@
|
|||
declare -a autojump_paths
|
||||
autojump_paths=(
|
||||
$HOME/.autojump/etc/profile.d/autojump.zsh # manual installation
|
||||
$HOME/.autojump/share/autojump/autojump.zsh # manual installation
|
||||
$HOME/.nix-profile/etc/profile.d/autojump.sh # NixOS installation
|
||||
/run/current-system/sw/share/autojump/autojump.zsh # NixOS installation
|
||||
/usr/share/autojump/autojump.zsh # Debian and Ubuntu package
|
||||
/etc/profile.d/autojump.zsh # manual installation
|
||||
/etc/profile.d/autojump.sh # Gentoo installation
|
||||
/usr/local/share/autojump/autojump.zsh # FreeBSD installation
|
||||
/usr/pkg/share/autojump/autojump.zsh # NetBSD installation
|
||||
/opt/local/etc/profile.d/autojump.sh # macOS with MacPorts
|
||||
/usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default)
|
||||
/opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs)
|
||||
$HOME/.autojump/etc/profile.d/autojump.zsh # manual installation
|
||||
$HOME/.autojump/share/autojump/autojump.zsh # manual installation
|
||||
$HOME/.nix-profile/etc/profile.d/autojump.sh # NixOS installation
|
||||
/run/current-system/sw/share/autojump/autojump.zsh # NixOS installation
|
||||
/etc/profiles/per-user/$USER/share/autojump/autojump.zsh # Home Manager, NixOS with user-scoped packages
|
||||
/usr/share/autojump/autojump.zsh # Debian and Ubuntu package
|
||||
/etc/profile.d/autojump.zsh # manual installation
|
||||
/etc/profile.d/autojump.sh # Gentoo installation
|
||||
/usr/local/share/autojump/autojump.zsh # FreeBSD installation
|
||||
/usr/pkg/share/autojump/autojump.zsh # NetBSD installation
|
||||
/opt/local/etc/profile.d/autojump.sh # macOS with MacPorts
|
||||
/usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default)
|
||||
/opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs)
|
||||
/opt/pkg/share/autojump/autojump.zsh # macOS with pkgsrc
|
||||
/etc/profiles/per-user/$USER/etc/profile.d/autojump.sh # macOS Nix, Home Manager and flakes
|
||||
/nix/var/nix/gcroots/current-system/sw/share/zsh/site-functions/autojump.zsh # macOS Nix, nix-darwin
|
||||
)
|
||||
|
||||
for file in $autojump_paths; do
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
# aws
|
||||
|
||||
This plugin provides completion support for [awscli](https://docs.aws.amazon.com/cli/latest/reference/index.html)
|
||||
and a few utilities to manage AWS profiles and display them in the prompt.
|
||||
This plugin provides completion support for [awscli v2](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/index.html)
|
||||
and a few utilities to manage AWS profiles/regions and display them in the prompt.
|
||||
[awscli v1](https://docs.aws.amazon.com/cli/latest/userguide/cliv2-migration.html) is no longer supported.
|
||||
|
||||
To use it, add `aws` to the plugins array in your zshrc file.
|
||||
|
||||
|
|
@ -12,9 +13,14 @@ plugins=(... aws)
|
|||
## Plugin commands
|
||||
|
||||
* `asp [<profile>]`: sets `$AWS_PROFILE` and `$AWS_DEFAULT_PROFILE` (legacy) to `<profile>`.
|
||||
It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI.
|
||||
It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI. It sets `$AWS_PROFILE_REGION` for display in `aws_prompt_info`.
|
||||
Run `asp` without arguments to clear the profile.
|
||||
* `asp [<profile>] login`: If AWS SSO has been configured in your aws profile, it will run the `aws sso login` command following profile selection.
|
||||
* `asp [<profile>] login`: If AWS SSO has been configured in your aws profile, it will run the `aws sso login` command following profile selection.
|
||||
* `asp [<profile>] login [<sso_session>]`: In addition to `asp [<profile>] login`, if SSO session has been configured in your aws profile, it will run the `aws sso login --sso-session <sso_session>` command following profile selection.
|
||||
* `asp [<profile>] logout`: If AWS SSO has been configured in your aws profile, it will run the `aws sso logout` command following profile selection.
|
||||
|
||||
* `asr [<region>]`: sets `$AWS_REGION` and `$AWS_DEFAULT_REGION` (legacy) to `<region>`.
|
||||
Run `asr` without arguments to clear the profile.
|
||||
|
||||
* `acp [<profile>] [<mfa_token>]`: in addition to `asp` functionality, it actually changes
|
||||
the profile by assuming the role specified in the `<profile>` configuration. It supports
|
||||
|
|
@ -25,25 +31,41 @@ plugins=(... aws)
|
|||
|
||||
* `agp`: gets the current value of `$AWS_PROFILE`.
|
||||
|
||||
* `agr`: gets the current value of `$AWS_REGION`.
|
||||
|
||||
* `aws_change_access_key`: changes the AWS access key of a profile.
|
||||
|
||||
* `aws_profiles`: lists the available profiles in the `$AWS_CONFIG_FILE` (default: `~/.aws/config`).
|
||||
Used to provide completion for the `asp` function.
|
||||
|
||||
* `aws_regions`: lists the available regions.
|
||||
Used to provide completion for the `asr` function.
|
||||
|
||||
## Plugin options
|
||||
|
||||
* Set `SHOW_AWS_PROMPT=false` in your zshrc file if you want to prevent the plugin from modifying your RPROMPT.
|
||||
Some themes might overwrite the value of RPROMPT instead of appending to it, so they'll need to be fixed to
|
||||
see the AWS profile prompt.
|
||||
see the AWS profile/region prompt.
|
||||
|
||||
* Set `AWS_PROFILE_STATE_ENABLED=true` in your zshrc file if you want the aws profile to persist between shell sessions.
|
||||
This option might slow down your shell startup time.
|
||||
By default the state file path is `/tmp/.aws_current_profile`. This means that the state won't survive a reboot or otherwise GC.
|
||||
You can control the state file path using the `AWS_STATE_FILE` environment variable.
|
||||
|
||||
## Theme
|
||||
|
||||
The plugin creates an `aws_prompt_info` function that you can use in your theme, which displays
|
||||
the current `$AWS_PROFILE`. It uses two variables to control how that is shown:
|
||||
the current `$AWS_PROFILE` and `$AWS_REGION`. It uses four variables to control how that is shown:
|
||||
|
||||
* ZSH_THEME_AWS_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to `<aws:`.
|
||||
* ZSH_THEME_AWS_PROFILE_PREFIX: sets the prefix of the AWS_PROFILE. Defaults to `<aws:`.
|
||||
|
||||
* ZSH_THEME_AWS_SUFFIX: sets the suffix of the AWS_PROFILE. Defaults to `>`.
|
||||
* ZSH_THEME_AWS_PROFILE_SUFFIX: sets the suffix of the AWS_PROFILE. Defaults to `>`.
|
||||
|
||||
* ZSH_THEME_AWS_REGION_PREFIX: sets the prefix of the AWS_REGION. Defaults to `<region:`.
|
||||
|
||||
* ZSH_THEME_AWS_REGION_SUFFIX: sets the suffix of the AWS_REGION. Defaults to `>`.
|
||||
|
||||
* ZSH_THEME_AWS_DIVIDER: sets the divider between ZSH_THEME_AWS_PROFILE_SUFFIX and ZSH_THEME_AWS_REGION_PREFIX. Defaults to ` ` (single space).
|
||||
|
||||
## Configuration
|
||||
|
||||
|
|
@ -53,7 +75,7 @@ the current `$AWS_PROFILE`. It uses two variables to control how that is shown:
|
|||
|
||||
Source profile credentials in `~/.aws/credentials`:
|
||||
|
||||
```
|
||||
```ini
|
||||
[source-profile-name]
|
||||
aws_access_key_id = ...
|
||||
aws_secret_access_key = ...
|
||||
|
|
@ -61,7 +83,7 @@ aws_secret_access_key = ...
|
|||
|
||||
Role configuration in `~/.aws/config`:
|
||||
|
||||
```
|
||||
```ini
|
||||
[profile source-profile-name]
|
||||
mfa_serial = arn:aws:iam::111111111111:mfa/myuser
|
||||
region = us-east-1
|
||||
|
|
|
|||
|
|
@ -2,10 +2,30 @@ function agp() {
|
|||
echo $AWS_PROFILE
|
||||
}
|
||||
|
||||
function agr() {
|
||||
echo $AWS_REGION
|
||||
}
|
||||
|
||||
# Update state file if enabled
|
||||
function _aws_update_state() {
|
||||
if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
|
||||
test -d $(dirname ${AWS_STATE_FILE}) || exit 1
|
||||
echo "${AWS_PROFILE} ${AWS_REGION}" > "${AWS_STATE_FILE}"
|
||||
fi
|
||||
}
|
||||
|
||||
function _aws_clear_state() {
|
||||
if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
|
||||
test -d $(dirname ${AWS_STATE_FILE}) || exit 1
|
||||
echo -n > "${AWS_STATE_FILE}"
|
||||
fi
|
||||
}
|
||||
|
||||
# AWS profile selection
|
||||
function asp() {
|
||||
if [[ -z "$1" ]]; then
|
||||
unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE
|
||||
unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE AWS_PROFILE_REGION
|
||||
_aws_clear_state
|
||||
echo AWS profile cleared.
|
||||
return
|
||||
fi
|
||||
|
|
@ -22,11 +42,42 @@ function asp() {
|
|||
export AWS_PROFILE=$1
|
||||
export AWS_EB_PROFILE=$1
|
||||
|
||||
export AWS_PROFILE_REGION=$(aws configure get region)
|
||||
|
||||
_aws_update_state
|
||||
|
||||
if [[ "$2" == "login" ]]; then
|
||||
aws sso login
|
||||
if [[ -n "$3" ]]; then
|
||||
aws sso login --sso-session $3
|
||||
else
|
||||
aws sso login
|
||||
fi
|
||||
elif [[ "$2" == "logout" ]]; then
|
||||
aws sso logout
|
||||
fi
|
||||
}
|
||||
|
||||
# AWS region selection
|
||||
function asr() {
|
||||
if [[ -z "$1" ]]; then
|
||||
unset AWS_DEFAULT_REGION AWS_REGION
|
||||
_aws_update_state
|
||||
echo AWS region cleared.
|
||||
return
|
||||
fi
|
||||
|
||||
local -a available_regions
|
||||
available_regions=($(aws_regions))
|
||||
if [[ -z "${available_regions[(r)$1]}" ]]; then
|
||||
echo "${fg[red]}Available regions: \n$(aws_regions)"
|
||||
return 1
|
||||
fi
|
||||
|
||||
export AWS_REGION=$1
|
||||
export AWS_DEFAULT_REGION=$1
|
||||
_aws_update_state
|
||||
}
|
||||
|
||||
# AWS profile switch
|
||||
function acp() {
|
||||
if [[ -z "$1" ]]; then
|
||||
|
|
@ -135,21 +186,69 @@ function aws_change_access_key() {
|
|||
return 1
|
||||
fi
|
||||
|
||||
echo "Insert the credentials when asked."
|
||||
asp "$1" || return 1
|
||||
AWS_PAGER="" aws iam create-access-key
|
||||
AWS_PAGER="" aws configure --profile "$1"
|
||||
local profile="$1"
|
||||
# Get current access key
|
||||
local original_aws_access_key_id="$(aws configure get aws_access_key_id --profile $profile)"
|
||||
|
||||
echo "You can now safely delete the old access key running \`aws iam delete-access-key --access-key-id ID\`"
|
||||
asp "$profile" || return 1
|
||||
echo "Generating a new access key pair for you now."
|
||||
if aws --no-cli-pager iam create-access-key; then
|
||||
echo "Insert the newly generated credentials when asked."
|
||||
aws --no-cli-pager configure --profile $profile
|
||||
else
|
||||
echo "Current access keys:"
|
||||
aws --no-cli-pager iam list-access-keys
|
||||
echo "Profile \"${profile}\" is currently using the $original_aws_access_key_id key. You can delete an old access key by running \`aws --profile $profile iam delete-access-key --access-key-id AccessKeyId\`"
|
||||
return 1
|
||||
fi
|
||||
|
||||
read -q "yn?Would you like to disable your previous access key (${original_aws_access_key_id}) now? "
|
||||
case $yn in
|
||||
[Yy]*)
|
||||
echo -n "\nDisabling access key ${original_aws_access_key_id}..."
|
||||
if aws --no-cli-pager iam update-access-key --access-key-id ${original_aws_access_key_id} --status Inactive; then
|
||||
echo "done."
|
||||
else
|
||||
echo "\nFailed to disable ${original_aws_access_key_id} key."
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo ""
|
||||
;;
|
||||
esac
|
||||
echo "You can now safely delete the old access key by running \`aws --profile $profile iam delete-access-key --access-key-id ${original_aws_access_key_id}\`"
|
||||
echo "Your current keys are:"
|
||||
AWS_PAGER="" aws iam list-access-keys
|
||||
aws --no-cli-pager iam list-access-keys
|
||||
}
|
||||
|
||||
function aws_regions() {
|
||||
local region
|
||||
if [[ $AWS_DEFAULT_REGION ]];then
|
||||
region="$AWS_DEFAULT_REGION"
|
||||
elif [[ $AWS_REGION ]];then
|
||||
region="$AWS_REGION"
|
||||
else
|
||||
region="us-west-1"
|
||||
fi
|
||||
|
||||
if [[ $AWS_DEFAULT_PROFILE || $AWS_PROFILE ]];then
|
||||
aws ec2 describe-regions --region $region |grep RegionName | awk -F ':' '{gsub(/"/, "", $2);gsub(/,/, "", $2);gsub(/ /, "", $2); print $2}'
|
||||
else
|
||||
echo "You must specify a AWS profile."
|
||||
fi
|
||||
}
|
||||
|
||||
function aws_profiles() {
|
||||
aws --no-cli-pager configure list-profiles 2> /dev/null && return
|
||||
[[ -r "${AWS_CONFIG_FILE:-$HOME/.aws/config}" ]] || return 1
|
||||
grep --color=never -Eo '\[.*\]' "${AWS_CONFIG_FILE:-$HOME/.aws/config}" | sed -E 's/^[[:space:]]*\[(profile)?[[:space:]]*([-_[:alnum:]\.@]+)\][[:space:]]*$/\2/g'
|
||||
grep --color=never -Eo '\[.*\]' "${AWS_CONFIG_FILE:-$HOME/.aws/config}" | sed -E 's/^[[:space:]]*\[(profile)?[[:space:]]*([^[:space:]]+)\][[:space:]]*$/\2/g'
|
||||
}
|
||||
|
||||
function _aws_regions() {
|
||||
reply=($(aws_regions))
|
||||
}
|
||||
compctl -K _aws_regions asr
|
||||
|
||||
function _aws_profiles() {
|
||||
reply=($(aws_profiles))
|
||||
}
|
||||
|
|
@ -157,14 +256,40 @@ compctl -K _aws_profiles asp acp aws_change_access_key
|
|||
|
||||
# AWS prompt
|
||||
function aws_prompt_info() {
|
||||
[[ -n "$AWS_PROFILE" ]] || return
|
||||
echo "${ZSH_THEME_AWS_PREFIX=<aws:}${AWS_PROFILE:gs/%/%%}${ZSH_THEME_AWS_SUFFIX=>}"
|
||||
local _aws_to_show
|
||||
local region="${AWS_REGION:-${AWS_DEFAULT_REGION:-$AWS_PROFILE_REGION}}"
|
||||
|
||||
if [[ -n "$AWS_PROFILE" ]];then
|
||||
_aws_to_show+="${ZSH_THEME_AWS_PROFILE_PREFIX="<aws:"}${AWS_PROFILE}${ZSH_THEME_AWS_PROFILE_SUFFIX=">"}"
|
||||
fi
|
||||
|
||||
if [[ -n "$region" ]]; then
|
||||
[[ -n "$_aws_to_show" ]] && _aws_to_show+="${ZSH_THEME_AWS_DIVIDER=" "}"
|
||||
_aws_to_show+="${ZSH_THEME_AWS_REGION_PREFIX="<region:"}${region}${ZSH_THEME_AWS_REGION_SUFFIX=">"}"
|
||||
fi
|
||||
|
||||
echo "$_aws_to_show"
|
||||
}
|
||||
|
||||
if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then
|
||||
RPROMPT='$(aws_prompt_info)'"$RPROMPT"
|
||||
fi
|
||||
|
||||
if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
|
||||
AWS_STATE_FILE="${AWS_STATE_FILE:-/tmp/.aws_current_profile}"
|
||||
test -s "${AWS_STATE_FILE}" || return
|
||||
|
||||
aws_state=($(cat $AWS_STATE_FILE))
|
||||
|
||||
export AWS_DEFAULT_PROFILE="${aws_state[1]}"
|
||||
export AWS_PROFILE="$AWS_DEFAULT_PROFILE"
|
||||
export AWS_EB_PROFILE="$AWS_DEFAULT_PROFILE"
|
||||
|
||||
test -z "${aws_state[2]}" && AWS_REGION=$(aws configure get region)
|
||||
|
||||
export AWS_REGION=${AWS_REGION:-$aws_state[2]}
|
||||
export AWS_DEFAULT_REGION="$AWS_REGION"
|
||||
fi
|
||||
|
||||
# Load awscli completions
|
||||
|
||||
|
|
@ -210,3 +335,4 @@ else
|
|||
[[ -r $_aws_zsh_completer_path ]] && source $_aws_zsh_completer_path
|
||||
unset _aws_zsh_completer_path _brew_prefix
|
||||
fi
|
||||
|
||||
|
|
|
|||
49
plugins/azure/README.md
Normal file
49
plugins/azure/README.md
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
# azure
|
||||
|
||||
This plugin provides completion support for [azure cli](https://docs.microsoft.com/en-us/cli/azure/)
|
||||
and a few utilities to manage azure subscriptions and display them in the prompt.
|
||||
|
||||
To use it, add `azure` to the plugins array in your zshrc file.
|
||||
|
||||
```zsh
|
||||
plugins=(... azure)
|
||||
```
|
||||
|
||||
## Plugin commands
|
||||
|
||||
|
||||
* `az_subscriptions`: lists the available subscriptions in the `AZURE_CONFIG_DIR` (default: `~/.azure/`).
|
||||
Used to provide completion for the `azss` function.
|
||||
|
||||
* `azgs`: gets the current value of `$azure_subscription`.
|
||||
|
||||
* `azss [<subscription>]`: sets the `$azure_subscription`.
|
||||
|
||||
|
||||
NOTE : because azure keeps the state of active subscription in ${AZURE_CONFIG_DIR:-$HOME/.azure/azureProfile.json}, the prompt command requires `jq` to be enabled to parse the file. If jq is not in the path the prompt will show nothing
|
||||
|
||||
## Theme
|
||||
|
||||
The plugin creates an `azure_prompt_info` function that you can use in your theme, which displays
|
||||
the current `$azure_subscription`. It uses two variables to control how that is shown:
|
||||
|
||||
- ZSH_THEME_AZURE_PREFIX: sets the prefix of the azure_subscription. Defaults to `<az:`.
|
||||
|
||||
- ZSH_THEME_azure_SUFFIX: sets the suffix of the azure_subscription. Defaults to `>`.
|
||||
|
||||
|
||||
```
|
||||
RPROMPT='$(azure_prompt_info)'
|
||||
```
|
||||
|
||||
## Develop
|
||||
|
||||
On ubuntu get a working environment with :
|
||||
|
||||
` docker run -it -v $(pwd):/mnt -w /mnt ubuntu bash`
|
||||
|
||||
```
|
||||
apt install -y curl jq zsh git vim
|
||||
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
|
||||
curl -sL https://aka.ms/InstallAzureCLIDeb | bash
|
||||
```
|
||||
60
plugins/azure/azure.plugin.zsh
Normal file
60
plugins/azure/azure.plugin.zsh
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
# AZ Get Subscriptions
|
||||
function azgs() {
|
||||
az account show --output tsv --query 'name' 2>/dev/null
|
||||
}
|
||||
|
||||
# AZ Subscription Selection
|
||||
alias azss="az account set --subscription"
|
||||
|
||||
|
||||
function az_subscriptions() {
|
||||
az account list --all --output tsv --query '[*].name' 2> /dev/null
|
||||
}
|
||||
|
||||
function _az_subscriptions() {
|
||||
reply=($(az_subscriptions))
|
||||
}
|
||||
compctl -K _az_subscriptions azss
|
||||
|
||||
# Azure prompt
|
||||
function azure_prompt_info() {
|
||||
[[ ! -f "${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json" ]] && return
|
||||
# azgs is too expensive, if we have jq, we enable the prompt
|
||||
(( $+commands[jq] )) || return 1
|
||||
azgs=$(jq -r '.subscriptions[] | select(.isDefault==true) .name' "${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json")
|
||||
echo "${ZSH_THEME_AZURE_PREFIX:=<az:}${azgs}${ZSH_THEME_AZURE_SUFFIX:=>}"
|
||||
}
|
||||
|
||||
|
||||
# Load az completions
|
||||
function _az-homebrew-installed() {
|
||||
# check if Homebrew is installed
|
||||
(( $+commands[brew] )) || return 1
|
||||
|
||||
# if so, we assume it's default way to install brew
|
||||
if [[ ${commands[brew]:t2} == bin/brew ]]; then
|
||||
_brew_prefix="${commands[brew]:h:h}" # remove trailing /bin/brew
|
||||
else
|
||||
# ok, it is not in the default prefix
|
||||
# this call to brew is expensive (about 400 ms), so at least let's make it only once
|
||||
_brew_prefix=$(brew --prefix)
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# get az.completion.sh location from $PATH
|
||||
_az_zsh_completer_path="$commands[az_zsh_completer.sh]"
|
||||
|
||||
# otherwise check common locations
|
||||
if [[ -z $_az_zsh_completer_path ]]; then
|
||||
# Homebrew
|
||||
if _az-homebrew-installed; then
|
||||
_az_zsh_completer_path=$_brew_prefix/etc/bash_completion.d/az
|
||||
# Linux
|
||||
else
|
||||
_az_zsh_completer_path=/etc/bash_completion.d/azure-cli
|
||||
fi
|
||||
fi
|
||||
|
||||
[[ -r $_az_zsh_completer_path ]] && autoload -U +X bashcompinit && bashcompinit && source $_az_zsh_completer_path
|
||||
unset _az_zsh_completer_path _brew_prefix
|
||||
|
|
@ -12,6 +12,13 @@ Then, add the `battery_pct_prompt` function to your custom theme. For example:
|
|||
RPROMPT='$(battery_pct_prompt) ...'
|
||||
```
|
||||
|
||||
Also, you set the `BATTERY_CHARGING` variable to your favor.
|
||||
For example:
|
||||
|
||||
```zsh
|
||||
BATTERY_CHARGING="⚡️"
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
- On Linux, you must have the `acpi` or `acpitool` commands installed on your operating system.
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
@ -54,7 +58,7 @@ if [[ "$OSTYPE" = darwin* ]]; then
|
|||
fi
|
||||
echo "%{$fg[$color]%}[${battery_pct}%%]%{$reset_color%}"
|
||||
else
|
||||
echo "∞"
|
||||
echo "${BATTERY_CHARGING-⚡️}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
# Bazel plugin
|
||||
|
||||
This plugin adds completion for [bazel](https://bazel.build), an open-source build and
|
||||
test tool that scalably supports multi-language and multi-platform projects.
|
||||
This plugin adds completion and aliases for [bazel](https://bazel.build), an open-source build and test tool that scalably supports multi-language and multi-platform projects.
|
||||
|
||||
To use it, add `bazel` to the plugins array in your zshrc file:
|
||||
|
||||
|
|
@ -12,3 +11,12 @@ plugins=(... bazel)
|
|||
The plugin has a copy of [the completion script from the git repository][1].
|
||||
|
||||
[1]: https://github.com/bazelbuild/bazel/blob/master/scripts/zsh_completion/_bazel
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
| ------- | -------------------------------------- | ------------------------------------------------------ |
|
||||
| bzb | `bazel build` | The `bazel build` command |
|
||||
| bzt | `bazel test` | The `bazel test` command |
|
||||
| bzr | `bazel run` | The `bazel run` command |
|
||||
| bzq | `bazel query` | The `bazel query` command |
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#compdef bazel
|
||||
#compdef bazel bazelisk
|
||||
|
||||
# Copyright 2015 The Bazel Authors. All rights reserved.
|
||||
#
|
||||
|
|
|
|||
5
plugins/bazel/bazel.plugin.zsh
Normal file
5
plugins/bazel/bazel.plugin.zsh
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# Aliases for bazel
|
||||
alias bzb='bazel build'
|
||||
alias bzt='bazel test'
|
||||
alias bzr='bazel run'
|
||||
alias bzq='bazel query'
|
||||
|
|
@ -1,19 +1,19 @@
|
|||
# bgnotify zsh plugin
|
||||
|
||||
cross-platform background notifications for long running commands! Supports OSX and Ubuntu linux.
|
||||
cross-platform background notifications for long running commands! Supports OSX and Linux.
|
||||
|
||||
Standalone homepage: [t413/zsh-background-notify](https://github.com/t413/zsh-background-notify)
|
||||
|
||||
----------------------------------
|
||||
---
|
||||
|
||||
## How to use!
|
||||
## How to use
|
||||
|
||||
Just add bgnotify to your plugins list in your `.zshrc`
|
||||
|
||||
- On OS X you'll need [terminal-notifier](https://github.com/alloy/terminal-notifier)
|
||||
* `brew install terminal-notifier` (or `gem install terminal-notifier`)
|
||||
- On ubuntu you're already all set!
|
||||
- On windows you can use [notifu](https://www.paralint.com/projects/notifu/) or the Cygwin Ports libnotify package
|
||||
- On Linux, make sure you have `notify-send` or `kdialog` installed. If you're using Ubuntu you should already be all set!
|
||||
- On Windows you can use [notifu](https://www.paralint.com/projects/notifu/) or the Cygwin Ports libnotify package
|
||||
|
||||
|
||||
## Screenshots
|
||||
|
|
@ -35,20 +35,29 @@ Just add bgnotify to your plugins list in your `.zshrc`
|
|||
|
||||
One can configure a few things:
|
||||
|
||||
- `bgnotify_bell` enabled or disables the terminal bell (default true)
|
||||
- `bgnotify_threshold` sets the notification threshold time (default 6 seconds)
|
||||
- `function bgnotify_formatted` lets you change the notification
|
||||
- `function bgnotify_formatted` lets you change the notification. You can for instance customize the message and pass in an icon.
|
||||
|
||||
Use these by adding a function definition before the your call to source. Example:
|
||||
|
||||
~~~ sh
|
||||
```sh
|
||||
bgnotify_bell=false ## disable terminal bell
|
||||
bgnotify_threshold=4 ## set your own notification threshold
|
||||
|
||||
function bgnotify_formatted {
|
||||
## $1=exit_status, $2=command, $3=elapsed_time
|
||||
[ $1 -eq 0 ] && title="Holy Smokes Batman!" || title="Holy Graf Zeppelin!"
|
||||
bgnotify "$title -- after $3 s" "$2";
|
||||
|
||||
# Humanly readable elapsed time
|
||||
local elapsed="$(( $3 % 60 ))s"
|
||||
(( $3 < 60 )) || elapsed="$((( $3 % 3600) / 60 ))m $elapsed"
|
||||
(( $3 < 3600 )) || elapsed="$(( $3 / 3600 ))h $elapsed"
|
||||
|
||||
[ $1 -eq 0 ] && title="Holy Smokes Batman" || title="Holy Graf Zeppelin"
|
||||
[ $1 -eq 0 ] && icon="$HOME/icons/success.png" || icon="$HOME/icons/fail.png"
|
||||
bgnotify "$title - took ${elapsed}" "$2" "$icon"
|
||||
}
|
||||
|
||||
plugins=(git bgnotify) ## add to plugins list
|
||||
source $ZSH/oh-my-zsh.sh ## existing source call
|
||||
~~~
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,93 +1,141 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
## setup ##
|
||||
## Setup
|
||||
|
||||
[[ -o interactive ]] || return #interactive only!
|
||||
zmodload zsh/datetime || { print "can't load zsh/datetime"; return } # faster than date()
|
||||
autoload -Uz add-zsh-hook || { print "can't add zsh hook!"; return }
|
||||
[[ -o interactive ]] || return # don't load on non-interactive shells
|
||||
[[ -z "$SSH_CLIENT" && -z "$SSH_TTY" ]] || return # don't load on a SSH connection
|
||||
|
||||
(( ${+bgnotify_threshold} )) || bgnotify_threshold=5 #default 10 seconds
|
||||
zmodload zsh/datetime # faster than `date`
|
||||
|
||||
|
||||
## definitions ##
|
||||
## Zsh Hooks
|
||||
|
||||
if ! (type bgnotify_formatted | grep -q 'function'); then ## allow custom function override
|
||||
function bgnotify_formatted { ## args: (exit_status, command, elapsed_seconds)
|
||||
elapsed="$(( $3 % 60 ))s"
|
||||
(( $3 >= 60 )) && elapsed="$((( $3 % 3600) / 60 ))m $elapsed"
|
||||
(( $3 >= 3600 )) && elapsed="$(( $3 / 3600 ))h $elapsed"
|
||||
[ $1 -eq 0 ] && bgnotify "#win (took $elapsed)" "$2" || bgnotify "#fail (took $elapsed)" "$2"
|
||||
}
|
||||
fi
|
||||
|
||||
currentAppId () {
|
||||
if (( $+commands[osascript] )); then
|
||||
osascript -e 'tell application (path to frontmost application as text) to id' 2>/dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
currentWindowId () {
|
||||
if hash osascript 2>/dev/null; then #osx
|
||||
osascript -e 'tell application (path to frontmost application as text) to id of front window' 2&> /dev/null || echo "0"
|
||||
elif (hash notify-send 2>/dev/null || hash kdialog 2>/dev/null); then #ubuntu!
|
||||
xprop -root 2> /dev/null | awk '/NET_ACTIVE_WINDOW/{print $5;exit} END{exit !$5}' || echo "0"
|
||||
else
|
||||
echo $EPOCHSECONDS #fallback for windows
|
||||
fi
|
||||
}
|
||||
|
||||
bgnotify () { ## args: (title, subtitle)
|
||||
if hash terminal-notifier 2>/dev/null; then #osx
|
||||
local term_id="$bgnotify_appid"
|
||||
if [[ -z "$term_id" ]]; then
|
||||
case "$TERM_PROGRAM" in
|
||||
iTerm.app) term_id='com.googlecode.iterm2' ;;
|
||||
Apple_Terminal) term_id='com.apple.terminal' ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
## now call terminal-notifier, (hopefully with $term_id!)
|
||||
if [[ -z "$term_id" ]]; then
|
||||
terminal-notifier -message "$2" -title "$1" >/dev/null
|
||||
else
|
||||
terminal-notifier -message "$2" -title "$1" -activate "$term_id" -sender "$term_id" >/dev/null
|
||||
fi
|
||||
elif hash growlnotify 2>/dev/null; then #osx growl
|
||||
growlnotify -m "$1" "$2"
|
||||
elif hash notify-send 2>/dev/null; then #ubuntu gnome!
|
||||
notify-send "$1" "$2"
|
||||
elif hash kdialog 2>/dev/null; then #ubuntu kde!
|
||||
kdialog --title "$1" --passivepopup "$2" 5
|
||||
elif hash notifu 2>/dev/null; then #cygwyn support!
|
||||
notifu /m "$2" /p "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
## Zsh hooks ##
|
||||
|
||||
bgnotify_begin() {
|
||||
function bgnotify_begin {
|
||||
bgnotify_timestamp=$EPOCHSECONDS
|
||||
bgnotify_lastcmd="${1:-$2}"
|
||||
bgnotify_appid="$(currentAppId)"
|
||||
bgnotify_windowid=$(currentWindowId)
|
||||
}
|
||||
|
||||
bgnotify_end() {
|
||||
didexit=$?
|
||||
elapsed=$(( EPOCHSECONDS - bgnotify_timestamp ))
|
||||
past_threshold=$(( elapsed >= bgnotify_threshold ))
|
||||
if (( bgnotify_timestamp > 0 )) && (( past_threshold )); then
|
||||
if [[ $(currentAppId) != "$bgnotify_appid" || $(currentWindowId) != "$bgnotify_windowid" ]]; then
|
||||
print -n "\a"
|
||||
bgnotify_formatted "$didexit" "$bgnotify_lastcmd" "$elapsed"
|
||||
fi
|
||||
function bgnotify_end {
|
||||
{
|
||||
local exit_status=$?
|
||||
local elapsed=$(( EPOCHSECONDS - bgnotify_timestamp ))
|
||||
|
||||
# check time elapsed
|
||||
[[ $bgnotify_timestamp -gt 0 ]] || return 0
|
||||
[[ $elapsed -ge $bgnotify_threshold ]] || return 0
|
||||
|
||||
# check if Terminal app is not active
|
||||
[[ $(bgnotify_appid) != "$bgnotify_termid" ]] || return 0
|
||||
|
||||
bgnotify_formatted "$exit_status" "$bgnotify_lastcmd" "$elapsed"
|
||||
} always {
|
||||
bgnotify_timestamp=0
|
||||
}
|
||||
}
|
||||
|
||||
autoload -Uz add-zsh-hook
|
||||
add-zsh-hook preexec bgnotify_begin
|
||||
add-zsh-hook precmd bgnotify_end
|
||||
|
||||
|
||||
## Functions
|
||||
|
||||
# allow custom function override
|
||||
(( ${+functions[bgnotify_formatted]} )) || \
|
||||
function bgnotify_formatted {
|
||||
local exit_status=$1
|
||||
local cmd="$2"
|
||||
|
||||
# humanly readable elapsed time
|
||||
local elapsed="$(( $3 % 60 ))s"
|
||||
(( $3 < 60 )) || elapsed="$((( $3 % 3600) / 60 ))m $elapsed"
|
||||
(( $3 < 3600 )) || elapsed="$(( $3 / 3600 ))h $elapsed"
|
||||
|
||||
[[ $bgnotify_bell = true ]] && printf '\a' # beep sound
|
||||
if [[ $exit_status -eq 0 ]]; then
|
||||
bgnotify "#win (took $elapsed)" "$cmd"
|
||||
else
|
||||
bgnotify "#fail (took $elapsed)" "$cmd"
|
||||
fi
|
||||
bgnotify_timestamp=0 #reset it to 0!
|
||||
}
|
||||
|
||||
## only enable if a local (non-ssh) connection
|
||||
if [ -z "$SSH_CLIENT" ] && [ -z "$SSH_TTY" ]; then
|
||||
add-zsh-hook preexec bgnotify_begin
|
||||
add-zsh-hook precmd bgnotify_end
|
||||
fi
|
||||
function bgnotify_appid {
|
||||
if (( ${+commands[osascript]} )); then
|
||||
osascript -e "tell application id \"$(bgnotify_programid)\" to get the {id, frontmost, id of front window, visible of front window}" 2>/dev/null
|
||||
elif [[ -n $WAYLAND_DISPLAY ]] && (( ${+commands[swaymsg]} )); then # wayland+sway
|
||||
local app_id=$(bgnotify_find_sway_appid)
|
||||
[[ -n "$app_id" ]] && echo "$app_id" || echo $EPOCHSECONDS
|
||||
elif [[ -z $WAYLAND_DISPLAY ]] && [[ -n $DISPLAY ]] && (( ${+commands[xprop]} )); then
|
||||
xprop -root _NET_ACTIVE_WINDOW 2>/dev/null | cut -d' ' -f5
|
||||
else
|
||||
echo $EPOCHSECONDS
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
function bgnotify_find_sway_appid {
|
||||
# output is "app_id,container_id", for example "Alacritty,1694"
|
||||
# see example swaymsg output: https://github.com/ohmyzsh/ohmyzsh/files/13463939/output.json
|
||||
if (( ${+commands[jq]} )); then
|
||||
swaymsg -t get_tree | jq '.. | select(.type?) | select(.focused==true) | {app_id, id} | join(",")'
|
||||
else
|
||||
swaymsg -t get_tree | awk '
|
||||
BEGIN { Id = ""; Appid = ""; FocusNesting = -1; Nesting = 0 }
|
||||
{
|
||||
# Enter a block
|
||||
if ($0 ~ /.*{$/) Nesting++
|
||||
|
||||
# Exit a block. If Nesting is now less than FocusNesting, we have the data we are looking for
|
||||
if ($0 ~ /^[[:blank:]]*}.*/) { Nesting--; if (FocusNesting > 0 && Nesting < FocusNesting) exit 0 }
|
||||
|
||||
# Save the Id, it is potentially what we are looking for
|
||||
if ($0 ~ /^[[:blank:]]*"id": [0-9]*,?$/) { sub(/^[[:blank:]]*"id": /, ""); sub(/,$/, ""); Id = $0 }
|
||||
|
||||
# Save the Appid, it is potentially what we are looking for
|
||||
if ($0 ~ /^[[:blank:]]*"app_id": ".*",?$/) { sub(/^[[:blank:]]*"app_id": "/, ""); sub(/",$/, ""); Appid = $0 }
|
||||
|
||||
# Window is focused, this nesting block contains the Id and Appid we want!
|
||||
if ($0 ~ /^[[:blank:]]*"focused": true,?$/) { FocusNesting = Nesting }
|
||||
}
|
||||
END {
|
||||
if (Appid != "" && Id != "" && FocusNesting != -1) print Appid "," Id
|
||||
else print ""
|
||||
}'
|
||||
fi
|
||||
}
|
||||
|
||||
function bgnotify_programid {
|
||||
case "$TERM_PROGRAM" in
|
||||
iTerm.app) echo 'com.googlecode.iterm2' ;;
|
||||
Apple_Terminal) echo 'com.apple.terminal' ;;
|
||||
esac
|
||||
}
|
||||
|
||||
function bgnotify {
|
||||
local title="$1"
|
||||
local message="$2"
|
||||
local icon="$3"
|
||||
if (( ${+commands[terminal-notifier]} )); then # macOS
|
||||
local term_id=$(bgnotify_programid)
|
||||
terminal-notifier -message "$message" -title "$title" ${=icon:+-appIcon "$icon"} ${=term_id:+-activate "$term_id"} &>/dev/null
|
||||
elif (( ${+commands[growlnotify]} )); then # macOS growl
|
||||
growlnotify -m "$title" "$message"
|
||||
elif (( ${+commands[notify-send]} )); then
|
||||
notify-send "$title" "$message" ${=icon:+--icon "$icon"}
|
||||
elif (( ${+commands[kdialog]} )); then # KDE
|
||||
kdialog --title "$title" --passivepopup "$message" 5
|
||||
elif (( ${+commands[notifu]} )); then # cygwin
|
||||
notifu /m "$message" /p "$title" ${=icon:+/i "$icon"}
|
||||
fi
|
||||
}
|
||||
|
||||
## Defaults
|
||||
|
||||
# enable terminal bell on notify by default
|
||||
bgnotify_bell=${bgnotify_bell:-true}
|
||||
|
||||
# notify if command took longer than 5s by default
|
||||
bgnotify_threshold=${bgnotify_threshold:-5}
|
||||
|
||||
# bgnotify_appid is slow in macOS and the terminal ID won't change, so cache it at startup
|
||||
bgnotify_termid="$(bgnotify_appid)"
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ index 2fd5f2cd..9d89a464 100644
|
|||
PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
|
||||
-PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
|
||||
+PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(branch_prompt_info)'
|
||||
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
|
||||
```
|
||||
|
|
|
|||
|
|
@ -8,23 +8,36 @@ To use it, add `brew` to the plugins array of your zshrc file:
|
|||
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.
|
||||
|
||||
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
|
||||
|
||||
| Alias | Command | Description |
|
||||
|----------|---------------------------------------|---------------------------------------------------------------------|
|
||||
| `brewp` | `brew pin` | Pin a specified formula so that it's not upgraded. |
|
||||
| `brews` | `brew list -1` | List installed formulae or the installed files for a given formula. |
|
||||
| `brewsp` | `brew list --pinned` | List pinned formulae, or show the version of a given formula. |
|
||||
| `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. |
|
||||
| `bubc` | `brew upgrade && brew cleanup` | Upgrade outdated formulae and casks, then run cleanup. |
|
||||
| `bubu` | `bubo && bubc` | Do the last two operations above. |
|
||||
| `buf` | `brew upgrade --formula` | Upgrade only formulas (not casks). |
|
||||
| `bcubo` | `brew update && brew outdated --cask` | Update Homebrew data, then list outdated casks. |
|
||||
| `bcubc` | `brew upgrade --cask && brew cleanup` | Update outdated casks, then run cleanup. |
|
||||
| Alias | Command | Description |
|
||||
| -------- | --------------------------------------- | ------------------------------------------------------------------- |
|
||||
| `bcubc` | `brew upgrade --cask && brew cleanup` | Update outdated casks, then run cleanup. |
|
||||
| `bcubo` | `brew update && brew outdated --cask` | Update Homebrew data, then list outdated casks. |
|
||||
| `brewp` | `brew pin` | Pin a specified formula so that it's not upgraded. |
|
||||
| `brews` | `brew list -1` | List installed formulae or the installed files for a given formula. |
|
||||
| `brewsp` | `brew list --pinned` | List pinned formulae, or show the version of a given formula. |
|
||||
| `bubc` | `brew upgrade && brew cleanup` | Upgrade outdated formulae and casks, then run cleanup. |
|
||||
| `bugbc` | `brew upgrade --greedy && brew cleanup` | Upgrade outdated formulae and casks (greedy), then run cleanup. |
|
||||
| `bubo` | `brew update && brew outdated` | Update Homebrew data, then list outdated formulae and casks. |
|
||||
| `bubu` | `bubo && bubc` | Do the last two operations above. |
|
||||
| `bfu` | `brew upgrade --formula` | Upgrade only formulas (not casks). |
|
||||
| `buz` | `brew uninstall --zap` | Remove all files associated with a cask. |
|
||||
|
||||
## Completion
|
||||
|
||||
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.
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -1,15 +1,54 @@
|
|||
if (( ! $+commands[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"
|
||||
elif [[ -x /home/linuxbrew/.linuxbrew/bin/brew ]]; then
|
||||
BREW_LOCATION="/home/linuxbrew/.linuxbrew/bin/brew"
|
||||
elif [[ -x "$HOME/.linuxbrew/bin/brew" ]]; then
|
||||
BREW_LOCATION="$HOME/.linuxbrew/bin/brew"
|
||||
else
|
||||
return
|
||||
fi
|
||||
|
||||
# Only add Homebrew installation to PATH, MANPATH, and INFOPATH if brew is
|
||||
# not already on the path, to prevent duplicate entries. This aligns with
|
||||
# the behavior of the brew installer.sh post-install steps.
|
||||
eval "$("$BREW_LOCATION" shellenv)"
|
||||
unset BREW_LOCATION
|
||||
fi
|
||||
|
||||
if [[ -z "$HOMEBREW_PREFIX" ]]; then
|
||||
# Maintain compatability with potential custom user profiles, where we had
|
||||
# previously relied on always sourcing shellenv. OMZ plugins should not rely
|
||||
# on this to be defined due to out of order processing.
|
||||
export HOMEBREW_PREFIX="$(brew --prefix)"
|
||||
fi
|
||||
|
||||
if [[ -d "$HOMEBREW_PREFIX/share/zsh/site-functions" ]]; then
|
||||
fpath+=("$HOMEBREW_PREFIX/share/zsh/site-functions")
|
||||
fi
|
||||
|
||||
alias bcubc='brew upgrade --cask && brew cleanup'
|
||||
alias bcubo='brew update && brew outdated --cask'
|
||||
alias brewp='brew pin'
|
||||
alias brewsp='brew list --pinned'
|
||||
alias bubo='brew update && brew outdated'
|
||||
alias bubc='brew upgrade && brew cleanup'
|
||||
alias bugbc='brew upgrade --greedy && brew cleanup'
|
||||
alias bubo='brew update && brew outdated'
|
||||
alias bubu='bubo && bubc'
|
||||
alias buf='brew upgrade --formula'
|
||||
alias bcubo='brew update && brew outdated --cask'
|
||||
alias bcubc='brew upgrade --cask && brew cleanup'
|
||||
alias bubug='bubo && bugbc'
|
||||
alias bfu='brew upgrade --formula'
|
||||
alias buz='brew uninstall --zap'
|
||||
|
||||
function brews() {
|
||||
local formulae="$(brew leaves | xargs brew deps --installed --for-each)"
|
||||
local casks="$(brew list --cask)"
|
||||
local casks="$(brew list --cask 2>/dev/null)"
|
||||
|
||||
local blue="$(tput setaf 4)"
|
||||
local bold="$(tput bold)"
|
||||
|
|
|
|||
26
plugins/bridgetown/README.md
Normal file
26
plugins/bridgetown/README.md
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# Bridgetown plugin
|
||||
|
||||
This plugin adds some aliases and autocompletion for common [Bridgetown](https://bridgetownrb.com/) commands.
|
||||
|
||||
To use it, add `bridgetown` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... bridgetown)
|
||||
```
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command |
|
||||
|-------|----------------------------|
|
||||
| br | `bridgetown` |
|
||||
| bra | `bin/bridgetown apply` |
|
||||
| brb | `bin/bridgetown build` |
|
||||
| brc | `bin/bridgetown console` |
|
||||
| brclean | `bin/bridgetown clean` |
|
||||
| brd | `bin/bridgetown deploy` |
|
||||
| brdoc | `bin/bridgetown doctor` |
|
||||
| brh | `bin/bridgetown help` |
|
||||
| brn | `bridgetown new` |
|
||||
| brp | `bridgetown plugins` |
|
||||
| brpl | `bridgetown plugins list` |
|
||||
| brs | `bin/bridgetown start` |
|
||||
12
plugins/bridgetown/bridgetown.plugin.zsh
Normal file
12
plugins/bridgetown/bridgetown.plugin.zsh
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
alias br='bridgetown'
|
||||
alias bra='bin/bridgetown apply'
|
||||
alias brb='bin/bridgetown build'
|
||||
alias brc='bin/bridgetown console'
|
||||
alias brclean='bin/bridgetown clean'
|
||||
alias brd='bin/bridgetown deploy'
|
||||
alias brdoc='bin/bridgetown doctor'
|
||||
alias brh='bin/bridgetown help'
|
||||
alias brn='bridgetown new'
|
||||
alias brp='bridgetown plugins'
|
||||
alias brpl='bridgetown plugins list'
|
||||
alias brs='bin/bridgetown start'
|
||||
20
plugins/bun/README.md
Normal file
20
plugins/bun/README.md
Normal 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
|
||||
14
plugins/bun/bun.plugin.zsh
Normal file
14
plugins/bun/bun.plugin.zsh
Normal 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
|
||||
|
||||
SHELL=zsh bun completions >| "$ZSH_CACHE_DIR/completions/_bun" &|
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#compdef bundle
|
||||
#compdef bundle bundler
|
||||
|
||||
local curcontext="$curcontext" state line _gems _opts ret=1
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
# CakePHP 3 basic command completion
|
||||
_cakephp3_get_command_list () {
|
||||
bin/cake Completion commands
|
||||
bin/cake completion commands
|
||||
}
|
||||
|
||||
_cakephp3_get_sub_command_list () {
|
||||
bin/cake Completion subcommands ${words[2]}
|
||||
bin/cake completion subcommands ${words[2]}
|
||||
}
|
||||
|
||||
_cakephp3_get_3rd_argument () {
|
||||
|
|
@ -34,5 +34,5 @@ compdef _cakephp3 cake
|
|||
|
||||
#Alias
|
||||
alias c3='bin/cake'
|
||||
alias c3cache='bin/cake orm_cache clear'
|
||||
alias c3cache='bin/cake schema_cache clear'
|
||||
alias c3migrate='bin/cake migrations migrate'
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# catimg
|
||||
|
||||
Plugin for displaying images on the terminal using the the `catimg.sh` script provided by [posva](https://github.com/posva/catimg)
|
||||
Plugin for displaying images on the terminal using the `catimg.sh` script provided by [posva](https://github.com/posva/catimg)
|
||||
|
||||
To use it, add `catimg` to the plugins array in your zshrc file:
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
_source-from-omz-settings() {
|
||||
local _chruby_path _chruby_auto
|
||||
|
||||
|
||||
zstyle -s :omz:plugins:chruby path _chruby_path || return 1
|
||||
zstyle -s :omz:plugins:chruby auto _chruby_auto || return 1
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ _source-from-homebrew() {
|
|||
if [[ -h /usr/local/opt/chruby ]];then
|
||||
_brew_prefix="/usr/local/opt/chruby"
|
||||
else
|
||||
# ok , it is not default prefix
|
||||
# ok , it is not default prefix
|
||||
# this call to brew is expensive ( about 400 ms ), so at least let's make it only once
|
||||
_brew_prefix=$(brew --prefix chruby)
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ Alternatively, seek out the [online documentation][3]. And don't forget, there a
|
|||
|
||||
## Contributors
|
||||
|
||||
Contributed to `oh_my_zsh` by [benwilcock][2].
|
||||
Contributed to `oh_my_zsh` by [benwilcock][2].
|
||||
|
||||
[1]: https://docs.cloudfoundry.org/cf-cli/install-go-cli.html
|
||||
[2]: https://github.com/benwilcock
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ Also provides the following aliases:
|
|||
* **cfc:** Copies the compiled JS to your clipboard. Very useful when you want
|
||||
to run the code in a JS console.
|
||||
|
||||
* **cfp:** Compiles from your currently copied clipboard. Useful when you want
|
||||
* **cfp:** Compiles from your currently copied clipboard. Useful when you want
|
||||
to compile large/multi-line snippets
|
||||
|
||||
* **cfpc:** Paste coffeescript from clipboard, compile to JS, then copy the
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#compdef coffee
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright (c) 2011 Github zsh-users - https://github.com/zsh-users
|
||||
# Copyright (c) 2011 GitHub zsh-users - https://github.com/zsh-users
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ colorize_check_requirements() {
|
|||
if [[ ${available_tools[(Ie)$ZSH_COLORIZE_TOOL]} -eq 0 ]]; then
|
||||
echo "ZSH_COLORIZE_TOOL '$ZSH_COLORIZE_TOOL' not recognized. Available options are 'pygmentize' and 'chroma'." >&2
|
||||
return 1
|
||||
elif (( $+commands["$ZSH_COLORIZE_TOOL"] )); then
|
||||
elif ! (( $+commands[$ZSH_COLORIZE_TOOL] )); then
|
||||
echo "Package '$ZSH_COLORIZE_TOOL' is not installed!" >&2
|
||||
return 1
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -30,5 +30,6 @@ It works out of the box with the command-not-found packages for:
|
|||
- [NixOS](https://github.com/NixOS/nixpkgs/tree/master/nixos/modules/programs/command-not-found)
|
||||
- [Termux](https://github.com/termux/command-not-found)
|
||||
- [SUSE](https://www.unix.com/man-page/suse/1/command-not-found/)
|
||||
- [Gentoo](https://github.com/AndrewAmmerlaan/command-not-found-gentoo/tree/main)
|
||||
|
||||
You can add support for other platforms by submitting a Pull Request.
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@
|
|||
for file (
|
||||
# Arch Linux. Must have pkgfile installed: https://wiki.archlinux.org/index.php/Pkgfile#Command_not_found
|
||||
/usr/share/doc/pkgfile/command-not-found.zsh
|
||||
# macOS (M1 and classic Homebrew): https://github.com/Homebrew/homebrew-command-not-found
|
||||
# Homebrew: https://github.com/Homebrew/homebrew-command-not-found
|
||||
/opt/homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh
|
||||
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh
|
||||
/home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh
|
||||
); do
|
||||
if [[ -r "$file" ]]; then
|
||||
source "$file"
|
||||
|
|
|
|||
|
|
@ -35,9 +35,11 @@ plugins=(... common-aliases)
|
|||
| mv | `mv -i` | Move a file |
|
||||
| zshrc | `${=EDITOR} ~/.zshrc` | Quickly access the ~/.zshrc file |
|
||||
| dud | `du -d 1 -h` | Display the size of files at depth 1 in current location in human-readable form |
|
||||
| duf | `du -sh` | Display the size of files in current location in human-readable form |
|
||||
| duf\* | `du -sh` | Display the size of files in current location in human-readable form |
|
||||
| t | `tail -f` | Shorthand for tail which outputs the last part of a file |
|
||||
|
||||
\* Only if the [`duf`](https://github.com/muesli/duf) command isn't installed.
|
||||
|
||||
### find and grep
|
||||
|
||||
| Alias | Command | Description |
|
||||
|
|
@ -66,12 +68,15 @@ These aliases are expanded in any position in the command line, meaning you can
|
|||
end of the command you've typed. Examples:
|
||||
|
||||
Quickly pipe to less:
|
||||
|
||||
```zsh
|
||||
$ ls -l /var/log L
|
||||
# will run
|
||||
$ ls -l /var/log | less
|
||||
```
|
||||
|
||||
Silences stderr output:
|
||||
|
||||
```zsh
|
||||
$ find . -type f NE
|
||||
# will run
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ alias -g NUL="> /dev/null 2>&1"
|
|||
alias -g P="2>&1| pygmentize -l pytb"
|
||||
|
||||
alias dud='du -d 1 -h'
|
||||
alias duf='du -sh *'
|
||||
(( $+commands[duf] )) || alias duf='du -sh *'
|
||||
(( $+commands[fd] )) || alias fd='find . -type d -name'
|
||||
alias ff='find . -type f -name'
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
if (( ${+commands[compleat]} )); then
|
||||
local prefix="${commands[compleat]:h:h}"
|
||||
local setup="${prefix}/share/compleat-1.0/compleat_setup"
|
||||
local setup="${prefix}/share/compleat-1.0/compleat_setup"
|
||||
|
||||
if [[ -f "$setup" ]]; then
|
||||
if ! bashcompinit >/dev/null 2>&1; then
|
||||
|
|
@ -15,6 +15,6 @@ if (( ${+commands[compleat]} )); then
|
|||
bashcompinit -i
|
||||
fi
|
||||
|
||||
source "$setup"
|
||||
source "$setup"
|
||||
fi
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# `copybuffer` plugin
|
||||
|
||||
This plugin binds the ctrl-o keyboard shortcut to a command that copies the text
|
||||
that is currently typed in the command line ($BUFFER) to the system clipboard.
|
||||
This plugin adds the <kbd>ctrl-o</kbd> keyboard shortcut to copy the current text
|
||||
in the command line to the system clipboard.
|
||||
|
||||
This is useful if you type a command - and before you hit enter to execute it - want
|
||||
to copy it maybe so you can paste it into a script, gist or whatnot.
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# copy the active line from the command line buffer
|
||||
# copy the active line from the command line buffer
|
||||
# onto the system clipboard
|
||||
|
||||
copybuffer () {
|
||||
if which clipcopy &>/dev/null; then
|
||||
if builtin which clipcopy &>/dev/null; then
|
||||
printf "%s" "$BUFFER" | clipcopy
|
||||
else
|
||||
zle -M "clipcopy not found. Please make sure you have Oh My Zsh installed correctly."
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ dash
|
|||
|
||||
- Query for something in dash app: `dash query`
|
||||
```
|
||||
dash golang
|
||||
dash golang
|
||||
```
|
||||
|
||||
- You can optionally provide a keyword: `dash [keyword:]query`
|
||||
|
|
|
|||
29
plugins/dbt/README.md
Normal file
29
plugins/dbt/README.md
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# dbt plugin
|
||||
|
||||
## Introduction
|
||||
|
||||
The `dbt plugin` adds several aliases for useful [dbt](https://docs.getdbt.com/) commands and
|
||||
[aliases](#aliases).
|
||||
|
||||
To use it, add `dbt` to the plugins array of your zshrc file:
|
||||
|
||||
```
|
||||
plugins=(... dbt)
|
||||
```
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
| ------ | ------------------------------------------------ | ---------------------------------------------------- |
|
||||
| dbtlm | `dbt ls -s state:modified` | List modified models only |
|
||||
| dbtrm | `dbt run -s state:modified` | Run modified models only |
|
||||
| dbttm | `dbt test -m state:modified` | Test modified models only |
|
||||
| dbtrtm | `dbtrm && dbttm` | Run and test modified models only |
|
||||
| dbtrs | `dbt clean; dbt deps; dbt seed` | Re-seed data |
|
||||
| dbtfrt | `dbtrs; dbt run --full-refresh; dbt test` | Perform a full fresh run with tests |
|
||||
| dbtcds | `dbt docs generate; dbt docs serve` | Generate docs without compiling |
|
||||
| dbtds | `dbt docs generate --no-compile; dbt docs serve` | Generate and serve docs skipping doc. re-compilation |
|
||||
|
||||
## Maintainer
|
||||
|
||||
### [msempere](https://github.com/msempere)
|
||||
23
plugins/dbt/dbt.plugin.zsh
Normal file
23
plugins/dbt/dbt.plugin.zsh
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# list modified models only
|
||||
alias dbtlm="dbt ls -s state:modified"
|
||||
|
||||
# run modified models only
|
||||
alias dbtrm="dbt run -s state:modified"
|
||||
|
||||
# test modified models only
|
||||
alias dbttm="dbt test -m state:modified"
|
||||
|
||||
# run and test modified models only
|
||||
alias dbtrtm="dbtrm && dbttm"
|
||||
|
||||
# re-seed data
|
||||
alias dbtrs="dbt clean; dbt deps; dbt seed"
|
||||
|
||||
# perform a full fresh run with tests
|
||||
alias dbtfrt="dbtrs; dbt run --full-refresh; dbt test"
|
||||
|
||||
# generate and serve docs
|
||||
alias dbtcds="dbt docs generate; dbt docs serve"
|
||||
|
||||
# generate and serve docs skipping doc. re-compilation
|
||||
alias dbtds="dbt docs generate --no-compile; dbt docs serve"
|
||||
|
|
@ -13,7 +13,12 @@ plugins=(... debian)
|
|||
- `$apt_pref`: use aptitude or apt if installed, fallback is apt-get.
|
||||
- `$apt_upgr`: use upgrade or safe-upgrade (for aptitude).
|
||||
|
||||
Set `$apt_pref` and `$apt_upgr` to whatever command you want (before sourcing Oh My Zsh) to override this behavior.
|
||||
Set **both** `$apt_pref` and `$apt_upgr` to whatever command you want (before sourcing Oh My Zsh) to override this behavior, e.g.:
|
||||
|
||||
```sh
|
||||
apt_pref='apt'
|
||||
apt_upgr='full-upgrade'
|
||||
```
|
||||
|
||||
## Common Aliases
|
||||
|
||||
|
|
@ -30,26 +35,25 @@ Set `$apt_pref` and `$apt_upgr` to whatever command you want (before sourcing Oh
|
|||
|
||||
## Superuser Operations Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
| -------- | -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
|
||||
| `aac` | `sudo $apt_pref autoclean` | Clears out the local repository of retrieved package files |
|
||||
| `aar` | `sudo $apt_pref autoremove` | Removes packages installed automatically that are no longer needed |
|
||||
| `abd` | `sudo $apt_pref build-dep` | Installs all dependencies for building packages |
|
||||
| `ac` | `sudo $apt_pref clean` | Clears out the local repository of retrieved package files except lock files |
|
||||
| `ad` | `sudo $apt_pref update` | Updates the package lists for upgrades for packages |
|
||||
| `adg` | `sudo $apt_pref update && sudo $apt_pref $apt_upgr` | Update and upgrade packages |
|
||||
| `ads` | `sudo apt-get dselect-upgrade` | Installs packages from list and removes all not in the list |
|
||||
| `adu` | `sudo $apt_pref update && sudo $apt_pref dist-upgrade` | Smart upgrade that handles dependencies |
|
||||
| `afu` | `sudo apt-file update` | Update the files in packages |
|
||||
| `ai` | `sudo $apt_pref install` | Command-line tool to install package |
|
||||
| `ail` | `sed -e 's/ */ /g' -e 's/ *//' \| cut -s -d ' ' -f 1 \| xargs sudo $apt_pref install` | Install all packages given on the command line while using only the first word of each line |
|
||||
| `alu` | `sudo apt update && apt list -u && sudo apt upgrade` | Update, list and upgrade packages |
|
||||
| `ap` | `sudo $apt_pref purge` | Removes packages along with configuration files |
|
||||
| `ar` | `sudo $apt_pref remove` | Removes packages, keeps the configuration files |
|
||||
| `au` | `sudo $apt_pref $apt_upgr` | Install package upgrades |
|
||||
| `di` | `sudo dpkg -i` | Install all .deb files in the current directory |
|
||||
| `dia` | `sudo dpkg -i ./*.deb` | Install all .deb files in the current directory |
|
||||
| `kclean` | `sudo aptitude remove -P ?and(~i~nlinux-(ima\|hea) ?not(~n$(uname -r)))` | Remove ALL kernel images and headers EXCEPT the one in use |
|
||||
| Alias | Command | Description |
|
||||
| -------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
|
||||
| `aac` | `sudo $apt_pref autoclean` | Clears out the local repository of retrieved package files |
|
||||
| `aar` | `sudo $apt_pref autoremove` | Removes packages installed automatically that are no longer needed |
|
||||
| `abd` | `sudo $apt_pref build-dep` | Installs all dependencies for building packages |
|
||||
| `ac` | `sudo $apt_pref clean` | Clears out the local repository of retrieved package files except lock files |
|
||||
| `ad` | `sudo $apt_pref update` | Updates the package lists for upgrades for packages |
|
||||
| `adg` | `sudo $apt_pref update && sudo $apt_pref $apt_upgr` | Update and upgrade packages |
|
||||
| `ads` | `sudo apt-get dselect-upgrade` | Installs packages from list and removes all not in the list |
|
||||
| `adu` | `sudo $apt_pref update && sudo $apt_pref dist-upgrade` | Smart upgrade that handles dependencies |
|
||||
| `afu` | `sudo apt-file update` | Update the files in packages |
|
||||
| `ai` | `sudo $apt_pref install` | Command-line tool to install package |
|
||||
| `ail` | `sed -e 's/ */ /g' -e 's/ *//' \| cut -s -d ' ' -f 1 \| xargs sudo $apt_pref install` | Install all packages given on the command line while using only the first word of each line |
|
||||
| `alu` | `sudo apt update && apt list -u && sudo apt upgrade` | Update, list and upgrade packages |
|
||||
| `ap` | `sudo $apt_pref purge` | Removes packages along with configuration files |
|
||||
| `au` | `sudo $apt_pref $apt_upgr` | Install package upgrades |
|
||||
| `di` | `sudo dpkg -i` | Install all .deb files in the current directory |
|
||||
| `dia` | `sudo dpkg -i ./*.deb` | Install all .deb files in the current directory |
|
||||
| `kclean` | `sudo aptitude remove -P ?and(~i~nlinux-(ima\|hea) ?not(~n$(uname -r)))` | Remove ALL kernel images and headers EXCEPT the one in use |
|
||||
|
||||
## Aliases - Commands using `su`
|
||||
|
||||
|
|
|
|||
|
|
@ -51,11 +51,10 @@ if [[ $use_sudo -eq 1 ]]; then
|
|||
alias au="sudo $apt_pref $apt_upgr"
|
||||
alias ai="sudo $apt_pref install"
|
||||
# Install all packages given on the command line while using only the first word of each line:
|
||||
# acs ... | ail
|
||||
# acse ... | ail
|
||||
|
||||
alias ail="sed -e 's/ */ /g' -e 's/ *//' | cut -s -d ' ' -f 1 | xargs sudo $apt_pref install"
|
||||
alias ap="sudo $apt_pref purge"
|
||||
alias ar="sudo $apt_pref remove"
|
||||
alias aar="sudo $apt_pref autoremove"
|
||||
|
||||
# apt-get only
|
||||
|
|
@ -89,22 +88,17 @@ else
|
|||
alias afu="su -lc '$apt-file update'"
|
||||
alias au="su -lc '$apt_pref $apt_upgr' root"
|
||||
function ai() {
|
||||
cmd="su -lc 'aptitude -P install $@' root"
|
||||
cmd="su -lc '$apt_pref install $@' root"
|
||||
print "$cmd"
|
||||
eval "$cmd"
|
||||
}
|
||||
function ap() {
|
||||
cmd="su -lc '$apt_pref -P purge $@' root"
|
||||
print "$cmd"
|
||||
eval "$cmd"
|
||||
}
|
||||
function ar() {
|
||||
cmd="su -lc '$apt_pref -P remove $@' root"
|
||||
cmd="su -lc '$apt_pref purge $@' root"
|
||||
print "$cmd"
|
||||
eval "$cmd"
|
||||
}
|
||||
function aar() {
|
||||
cmd="su -lc '$apt_pref -P autoremove $@' root"
|
||||
cmd="su -lc '$apt_pref autoremove $@' root"
|
||||
print "$cmd"
|
||||
eval "$cmd"
|
||||
}
|
||||
|
|
@ -147,7 +141,6 @@ apt_pref_compdef au "$apt_upgr"
|
|||
apt_pref_compdef ai "install"
|
||||
apt_pref_compdef ail "install"
|
||||
apt_pref_compdef ap "purge"
|
||||
apt_pref_compdef ar "remove"
|
||||
apt_pref_compdef aar "autoremove"
|
||||
apt_pref_compdef ads "dselect-upgrade"
|
||||
|
||||
|
|
|
|||
|
|
@ -4,16 +4,17 @@ This plugin sets up completion and aliases for [Deno](https://deno.land).
|
|||
|
||||
## Aliases
|
||||
|
||||
| Alias | Full command |
|
||||
| ----- | ---------------- |
|
||||
| db | deno bundle |
|
||||
| dc | deno compile |
|
||||
| dca | deno cache |
|
||||
| dfmt | deno fmt |
|
||||
| dh | deno help |
|
||||
| dli | deno lint |
|
||||
| drn | deno run |
|
||||
| drA | deno run -A |
|
||||
| drw | deno run --watch |
|
||||
| dts | deno test |
|
||||
| dup | deno upgrade |
|
||||
| Alias | Full command |
|
||||
| ----- | ------------------- |
|
||||
| db | deno bundle |
|
||||
| dc | deno compile |
|
||||
| dca | deno cache |
|
||||
| dfmt | deno fmt |
|
||||
| dh | deno help |
|
||||
| dli | deno lint |
|
||||
| drn | deno run |
|
||||
| drA | deno run -A |
|
||||
| drw | deno run --watch |
|
||||
| dru | deno run --unstable |
|
||||
| dts | deno test |
|
||||
| dup | deno upgrade |
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ alias dli='deno lint'
|
|||
alias drn='deno run'
|
||||
alias drA='deno run -A'
|
||||
alias drw='deno run --watch'
|
||||
alias dru='deno run --unstable'
|
||||
alias dts='deno test'
|
||||
alias dup='deno upgrade'
|
||||
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ _direnv_hook() {
|
|||
trap - SIGINT;
|
||||
}
|
||||
typeset -ag precmd_functions;
|
||||
if [[ -z ${precmd_functions[(r)_direnv_hook]} ]]; then
|
||||
if [[ -z "${precmd_functions[(r)_direnv_hook]+1}" ]]; then
|
||||
precmd_functions=( _direnv_hook ${precmd_functions[@]} )
|
||||
fi
|
||||
typeset -ag chpwd_functions;
|
||||
if [[ -z ${chpwd_functions[(r)_direnv_hook]} ]]; then
|
||||
if [[ -z "${chpwd_functions[(r)_direnv_hook]+1}" ]]; then
|
||||
chpwd_functions=( _direnv_hook ${chpwd_functions[@]} )
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -19,15 +19,17 @@ export DIRHISTORY_SIZE=30
|
|||
# Returns the element if the array was not empty,
|
||||
# otherwise returns empty string.
|
||||
function pop_past() {
|
||||
typeset -g $1="${dirhistory_past[$#dirhistory_past]}"
|
||||
setopt localoptions no_ksh_arrays
|
||||
if [[ $#dirhistory_past -gt 0 ]]; then
|
||||
typeset -g $1="${dirhistory_past[$#dirhistory_past]}"
|
||||
dirhistory_past[$#dirhistory_past]=()
|
||||
fi
|
||||
}
|
||||
|
||||
function pop_future() {
|
||||
typeset -g $1="${dirhistory_future[$#dirhistory_future]}"
|
||||
setopt localoptions no_ksh_arrays
|
||||
if [[ $#dirhistory_future -gt 0 ]]; then
|
||||
typeset -g $1="${dirhistory_future[$#dirhistory_future]}"
|
||||
dirhistory_future[$#dirhistory_future]=()
|
||||
fi
|
||||
}
|
||||
|
|
@ -35,6 +37,7 @@ function pop_future() {
|
|||
# Push a new element onto the end of dirhistory_past. If the size of the array
|
||||
# is >= DIRHISTORY_SIZE, the array is shifted
|
||||
function push_past() {
|
||||
setopt localoptions no_ksh_arrays
|
||||
if [[ $#dirhistory_past -ge $DIRHISTORY_SIZE ]]; then
|
||||
shift dirhistory_past
|
||||
fi
|
||||
|
|
@ -44,6 +47,7 @@ function push_past() {
|
|||
}
|
||||
|
||||
function push_future() {
|
||||
setopt localoptions no_ksh_arrays
|
||||
if [[ $#dirhistory_future -ge $DIRHISTORY_SIZE ]]; then
|
||||
shift dirhistory_future
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ To use it, add `dnf` to the plugins array in your zshrc file:
|
|||
plugins=(... dnf)
|
||||
```
|
||||
|
||||
Classic `dnf` is getting superseded by `dnf5`; this plugin detects the presence
|
||||
of `dnf5` and uses it as drop-in alternative to the slower `dnf`.
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
|
|
|
|||
|
|
@ -1,15 +1,19 @@
|
|||
## Aliases
|
||||
local dnfprog="dnf"
|
||||
|
||||
alias dnfl="dnf list" # List packages
|
||||
alias dnfli="dnf list installed" # List installed packages
|
||||
alias dnfgl="dnf grouplist" # List package groups
|
||||
alias dnfmc="dnf makecache" # Generate metadata cache
|
||||
alias dnfp="dnf info" # Show package information
|
||||
alias dnfs="dnf search" # Search package
|
||||
# Prefer dnf5 if installed
|
||||
command -v dnf5 > /dev/null && dnfprog=dnf5
|
||||
|
||||
alias dnfu="sudo dnf upgrade" # Upgrade package
|
||||
alias dnfi="sudo dnf install" # Install package
|
||||
alias dnfgi="sudo dnf groupinstall" # Install package group
|
||||
alias dnfr="sudo dnf remove" # Remove package
|
||||
alias dnfgr="sudo dnf groupremove" # Remove package group
|
||||
alias dnfc="sudo dnf clean all" # Clean cache
|
||||
alias dnfl="${dnfprog} list" # List packages
|
||||
alias dnfli="${dnfprog} list installed" # List installed packages
|
||||
alias dnfgl="${dnfprog} grouplist" # List package groups
|
||||
alias dnfmc="${dnfprog} makecache" # Generate metadata cache
|
||||
alias dnfp="${dnfprog} info" # Show package information
|
||||
alias dnfs="${dnfprog} search" # Search package
|
||||
|
||||
alias dnfu="sudo ${dnfprog} upgrade" # Upgrade package
|
||||
alias dnfi="sudo ${dnfprog} install" # Install package
|
||||
alias dnfgi="sudo ${dnfprog} groupinstall" # Install package group
|
||||
alias dnfr="sudo ${dnfprog} remove" # Remove package
|
||||
alias dnfgr="sudo ${dnfprog} groupremove" # Remove package group
|
||||
alias dnfc="sudo ${dnfprog} clean all" # Clean cache
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Dnote Plugin
|
||||
|
||||
This plugin adds auto-completion for [Dnote](https://dnote.io) project.
|
||||
This plugin adds auto-completion for [Dnote](https://www.getdnote.com/), a simple command line notebook.
|
||||
|
||||
To use it, add `dnote` to the plugins array in your zshrc file:
|
||||
|
||||
|
|
|
|||
|
|
@ -11,22 +11,24 @@ plugins=(... docker-compose)
|
|||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
|-----------|--------------------------------|------------------------------------------------------------------|
|
||||
| dco | `docker-compose` | Docker-compose main command |
|
||||
| dcb | `docker-compose build` | Build containers |
|
||||
| dce | `docker-compose exec` | Execute command inside a container |
|
||||
| dcps | `docker-compose ps` | List containers |
|
||||
| dcrestart | `docker-compose restart` | Restart container |
|
||||
| dcrm | `docker-compose rm` | Remove container |
|
||||
| dcr | `docker-compose run` | Run a command in container |
|
||||
| dcstop | `docker-compose stop` | Stop a container |
|
||||
| dcup | `docker-compose up` | Build, (re)create, start, and attach to containers for a service |
|
||||
| dcupb | `docker-compose up --build` | Same as `dcup`, but build images before starting containers |
|
||||
| dcupd | `docker-compose up -d` | Same as `dcup`, but starts as daemon |
|
||||
| dcdn | `docker-compose down` | Stop and remove containers |
|
||||
| dcl | `docker-compose logs` | Show logs of container |
|
||||
| dclf | `docker-compose logs -f` | Show logs and follow output |
|
||||
| dcpull | `docker-compose pull` | Pull image of a service |
|
||||
| dcstart | `docker-compose start` | Start a container |
|
||||
| dck | `docker-compose kill` | Kills containers |
|
||||
| Alias | Command | Description |
|
||||
|-----------|----------------------------------|----------------------------------------------------------------------------------|
|
||||
| dco | `docker-compose` | Docker-compose main command |
|
||||
| dcb | `docker-compose build` | Build containers |
|
||||
| dce | `docker-compose exec` | Execute command inside a container |
|
||||
| dcps | `docker-compose ps` | List containers |
|
||||
| dcrestart | `docker-compose restart` | Restart container |
|
||||
| dcrm | `docker-compose rm` | Remove container |
|
||||
| dcr | `docker-compose run` | Run a command in container |
|
||||
| dcstop | `docker-compose stop` | Stop a container |
|
||||
| dcup | `docker-compose up` | Build, (re)create, start, and attach to containers for a service |
|
||||
| dcupb | `docker-compose up --build` | Same as `dcup`, but build images before starting containers |
|
||||
| dcupd | `docker-compose up -d` | Same as `dcup`, but starts as daemon |
|
||||
| dcupdb | `docker-compose up -d --build` | Same as `dcup`, but build images before starting containers and starts as daemon |
|
||||
| dcdn | `docker-compose down` | Stop and remove containers |
|
||||
| dcl | `docker-compose logs` | Show logs of container |
|
||||
| dclf | `docker-compose logs -f` | Show logs and follow output |
|
||||
| dclF | `docker-compose logs -f --tail0` | Just follow recent logs |
|
||||
| dcpull | `docker-compose pull` | Pull image of a service |
|
||||
| dcstart | `docker-compose start` | Start a container |
|
||||
| dck | `docker-compose kill` | Kills containers |
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ __docker-compose_subcommand() {
|
|||
'--resolve-image-digests[Pin image tags to digests.]' \
|
||||
'--services[Print the service names, one per line.]' \
|
||||
'--volumes[Print the volume names, one per line.]' \
|
||||
'--hash[Print the service config hash, one per line. Set "service1,service2" for a list of specified services.]' \ && ret=0
|
||||
'--hash[Print the service config hash, one per line. Set "service1,service2" for a list of specified services.]' && ret=0
|
||||
;;
|
||||
(create)
|
||||
_arguments \
|
||||
|
|
|
|||
|
|
@ -12,9 +12,11 @@ alias dcstop="$dccmd stop"
|
|||
alias dcup="$dccmd up"
|
||||
alias dcupb="$dccmd up --build"
|
||||
alias dcupd="$dccmd up -d"
|
||||
alias dcupdb="$dccmd up -d --build"
|
||||
alias dcdn="$dccmd down"
|
||||
alias dcl="$dccmd logs"
|
||||
alias dclf="$dccmd logs -f"
|
||||
alias dclF="$dccmd logs -f --tail 0"
|
||||
alias dcpull="$dccmd pull"
|
||||
alias dcstart="$dccmd start"
|
||||
alias dck="$dccmd kill"
|
||||
|
|
|
|||
|
|
@ -335,9 +335,9 @@ _docker-machine() {
|
|||
'--tls-ca-key[Private key to generate certificates]:file:_files' \
|
||||
'--tls-client-cert[Client cert to use for TLS]:file:_files' \
|
||||
'--tls-client-key[Private key used in client TLS auth]:file:_files' \
|
||||
'--github-api-token[Token to use for requests to the Github API]' \
|
||||
'--github-api-token[Token to use for requests to the GitHub API]' \
|
||||
'--native-ssh[Use the native (Go-based) SSH implementation.]' \
|
||||
'--bugsnag-api-token[BugSnag API token for crash reporting]' \
|
||||
'--bugsnag-api-token[Bugsnag API token for crash reporting]' \
|
||||
'(- :)'{-v,--version}'[Print the version]' \
|
||||
"(-): :->command" \
|
||||
"(-)*:: :->option-or-argument" && ret=0
|
||||
|
|
|
|||
|
|
@ -13,18 +13,15 @@ https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker
|
|||
|
||||
## Settings
|
||||
|
||||
By default, the completion doesn't allow option-stacking, meaning if you try to
|
||||
complete `docker run -it <TAB>` it won't work, because you're _stacking_ the
|
||||
`-i` and `-t` options.
|
||||
By default, the completion doesn't allow option-stacking, meaning if you try to complete
|
||||
`docker run -it <TAB>` it won't work, because you're _stacking_ the `-i` and `-t` options.
|
||||
|
||||
[You can enable it](https://github.com/docker/cli/commit/b10fb43048) by **adding
|
||||
the lines below to your zshrc file**, but be aware of the side effects:
|
||||
[You can enable it](https://github.com/docker/cli/commit/b10fb43048) by **adding the lines below to your zshrc
|
||||
file**, but be aware of the side effects:
|
||||
|
||||
> This enables Zsh to understand commands like `docker run -it
|
||||
> ubuntu`. However, by enabling this, this also makes Zsh complete
|
||||
> `docker run -u<tab>` with `docker run -uapprox` which is not valid. The
|
||||
> users have to put the space or the equal sign themselves before trying
|
||||
> to complete.
|
||||
> This enables Zsh to understand commands like `docker run -it ubuntu`. However, by enabling this, this also
|
||||
> makes Zsh complete `docker run -u<tab>` with `docker run -uapprox` which is not valid. The users have to put
|
||||
> the space or the equal sign themselves before trying to complete.
|
||||
>
|
||||
> Therefore, this behavior is disabled by default. To enable it:
|
||||
>
|
||||
|
|
@ -33,41 +30,51 @@ the lines below to your zshrc file**, but be aware of the side effects:
|
|||
> zstyle ':completion:*:*:docker-*:*' option-stacking yes
|
||||
> ```
|
||||
|
||||
### Use old-style completion
|
||||
|
||||
If the current completion does not work well for you, you can enable legacy completion instead with the
|
||||
following setting. See https://github.com/ohmyzsh/ohmyzsh/issues/11789 for more information.
|
||||
|
||||
```zsh
|
||||
zstyle ':omz:plugins:docker' legacy-completion yes
|
||||
```
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
| :------ | :-------------------------- | :--------------------------------------------------------------------------------------- |
|
||||
| dbl | `docker build` | Build an image from a Dockerfile |
|
||||
| dcin | `docker container inspect` | Display detailed information on one or more containers |
|
||||
| dlo | `docker container logs` | Fetch the logs of a docker container |
|
||||
| dcls | `docker container ls` | List all the running docker containers |
|
||||
| dclsa | `docker container ls -a` | List all running and stopped containers |
|
||||
| dpo | `docker container port` | List port mappings or a specific mapping for the container |
|
||||
| dpu | `docker pull` | Pull an image or a repository from a registry |
|
||||
| dr | `docker container run` | Create a new container and start it using the specified command |
|
||||
| drit | `docker container run -it` | Create a new container and start it in an interactive shell |
|
||||
| drm | `docker container rm` | Remove the specified container(s) |
|
||||
| drm! | `docker container rm -f` | Force the removal of a running container (uses SIGKILL) |
|
||||
| dst | `docker container start` | Start one or more stopped containers |
|
||||
| dstp | `docker container stop` | Stop one or more running containers |
|
||||
| dtop | `docker top` | Display the running processes of a container |
|
||||
| dxc | `docker container exec` | Run a new command in a running container |
|
||||
| dxcit | `docker container exec -it` | Run a new command in a running container in an interactive shell |
|
||||
| | | **Docker Images** |
|
||||
| dib | `docker image build` | Build an image from a Dockerfile (same as docker build) |
|
||||
| dii | `docker image inspect` | Display detailed information on one or more images |
|
||||
| dils | `docker image ls` | List docker images |
|
||||
| dipu | `docker image push` | Push an image or repository to a remote registry |
|
||||
| dirm | `docker image rm` | Remove one or more images |
|
||||
| dit | `docker image tag` | Add a name and tag to a particular image |
|
||||
| | | **Docker Network** |
|
||||
| dnc | `docker network create` | Create a new network |
|
||||
| dncn | `docker network connect` | Connect a container to a network |
|
||||
| dndcn | `docker network disconnect` | Disconnect a container from a network |
|
||||
| dni | `docker network inspect` | Return information about one or more networks |
|
||||
| dnls | `docker network ls` | List all networks the engine daemon knows about, including those spanning multiple hosts |
|
||||
| dnrm | `docker network rm` | Remove one or more networks |
|
||||
| | | **Docker Volume** |
|
||||
| dvi | `docker volume inspect` | Display detailed information about one or more volumes |
|
||||
| dvls | `docker volume ls` | List all the volumes known to docker |
|
||||
| dvprune | `docker volume prune` | Cleanup dangling volumes |
|
||||
| Alias | Command | Description |
|
||||
| :------ | :---------------------------- | :--------------------------------------------------------------------------------------- |
|
||||
| dbl | `docker build` | Build an image from a Dockerfile |
|
||||
| dcin | `docker container inspect` | Display detailed information on one or more containers |
|
||||
| dcls | `docker container ls` | List all the running docker containers |
|
||||
| dclsa | `docker container ls -a` | List all running and stopped containers |
|
||||
| dib | `docker image build` | Build an image from a Dockerfile (same as docker build) |
|
||||
| dii | `docker image inspect` | Display detailed information on one or more images |
|
||||
| dils | `docker image ls` | List docker images |
|
||||
| dipu | `docker image push` | Push an image or repository to a remote registry |
|
||||
| dirm | `docker image rm` | Remove one or more images |
|
||||
| dit | `docker image tag` | Add a name and tag to a particular image |
|
||||
| dlo | `docker container logs` | Fetch the logs of a docker container |
|
||||
| dnc | `docker network create` | Create a new network |
|
||||
| dncn | `docker network connect` | Connect a container to a network |
|
||||
| dndcn | `docker network disconnect` | Disconnect a container from a network |
|
||||
| dni | `docker network inspect` | Return information about one or more networks |
|
||||
| dnls | `docker network ls` | List all networks the engine daemon knows about, including those spanning multiple hosts |
|
||||
| dnrm | `docker network rm` | Remove one or more networks |
|
||||
| dpo | `docker container port` | List port mappings or a specific mapping for the container |
|
||||
| dps | `docker ps` | List all the running docker containers |
|
||||
| dpsa | `docker ps -a` | List all running and stopped containers |
|
||||
| dpu | `docker pull` | Pull an image or a repository from a registry |
|
||||
| dr | `docker container run` | Create a new container and start it using the specified command |
|
||||
| drit | `docker container run -it` | Create a new container and start it in an interactive shell |
|
||||
| drm | `docker container rm` | Remove the specified container(s) |
|
||||
| drm! | `docker container rm -f` | Force the removal of a running container (uses SIGKILL) |
|
||||
| dst | `docker container start` | Start one or more stopped containers |
|
||||
| drs | `docker container restart` | Restart one or more containers |
|
||||
| dsta | `docker stop $(docker ps -q)` | Stop all running containers |
|
||||
| dstp | `docker container stop` | Stop one or more running containers |
|
||||
| dtop | `docker top` | Display the running processes of a container |
|
||||
| dvi | `docker volume inspect` | Display detailed information about one or more volumes |
|
||||
| dvls | `docker volume ls` | List all the volumes known to docker |
|
||||
| dvprune | `docker volume prune` | Cleanup dangling volumes |
|
||||
| dxc | `docker container exec` | Run a new command in a running container |
|
||||
| dxcit | `docker container exec -it` | Run a new command in a running container in an interactive shell |
|
||||
|
|
|
|||
|
|
@ -567,7 +567,7 @@ __docker_container_commands() {
|
|||
"cp:Copy files/folders between a container and the local filesystem"
|
||||
"create:Create a new container"
|
||||
"diff:Inspect changes on a container's filesystem"
|
||||
"exec:Run a command in a running container"
|
||||
"exec:Execute a command in a running container"
|
||||
"export:Export a container's filesystem as a tar archive"
|
||||
"inspect:Display detailed information on one or more containers"
|
||||
"kill:Kill one or more running containers"
|
||||
|
|
@ -579,7 +579,7 @@ __docker_container_commands() {
|
|||
"rename:Rename a container"
|
||||
"restart:Restart one or more containers"
|
||||
"rm:Remove one or more containers"
|
||||
"run:Run a command in a new container"
|
||||
"run:Create and run a new container from an image"
|
||||
"start:Start one or more stopped containers"
|
||||
"stats:Display a live stream of container(s) resource usage statistics"
|
||||
"stop:Stop one or more running containers"
|
||||
|
|
@ -602,6 +602,7 @@ __docker_container_subcommand() {
|
|||
opts_create_run=(
|
||||
"($help -a --attach)"{-a=,--attach=}"[Attach to stdin, stdout or stderr]:device:(STDIN STDOUT STDERR)"
|
||||
"($help)*--add-host=[Add a custom host-to-IP mapping]:host\:ip mapping: "
|
||||
"($help)*--annotation=[Add an annotation to the container (passed through to the OCI runtime)]:annotations: "
|
||||
"($help)*--blkio-weight-device=[Block IO (relative device weight)]:device:Block IO weight: "
|
||||
"($help)*--cap-add=[Add Linux capabilities]:capability: "
|
||||
"($help)*--cap-drop=[Drop Linux capabilities]:capability: "
|
||||
|
|
@ -650,6 +651,7 @@ __docker_container_subcommand() {
|
|||
"($help)*"{-p=,--publish=}"[Expose a container's port to the host]:port:_ports"
|
||||
"($help)--pid=[PID namespace to use]:PID namespace:__docker_complete_pid"
|
||||
"($help)--privileged[Give extended privileges to this container]"
|
||||
"($help -q --quiet)"{-q,--quiet}"[Suppress the pull output]"
|
||||
"($help)--read-only[Mount the container's root filesystem as read only]"
|
||||
"($help)*--security-opt=[Security options]:security option: "
|
||||
"($help)*--shm-size=[Size of '/dev/shm' (format is '<number><unit>')]:shm size: "
|
||||
|
|
@ -661,7 +663,7 @@ __docker_container_subcommand() {
|
|||
"($help)*--ulimit=[ulimit options]:ulimit: "
|
||||
"($help)--userns=[Container user namespace]:user namespace:(host)"
|
||||
"($help)--tmpfs[mount tmpfs]"
|
||||
"($help)*-v[Bind mount a volume]:volume: "
|
||||
"($help)*-v[Bind mount a volume]:volume:_directories -W / -P '/' -S '\:' -r '/ '"
|
||||
"($help)--volume-driver=[Optional volume driver for the container]:volume driver:(local)"
|
||||
"($help)*--volumes-from=[Mount volumes from the specified container]:volume: "
|
||||
"($help -w --workdir)"{-w=,--workdir=}"[Working directory inside the container]:directory:_directories"
|
||||
|
|
@ -802,7 +804,7 @@ __docker_container_subcommand() {
|
|||
"($help -a --all)"{-a,--all}"[Show all containers]" \
|
||||
"($help)--before=[Show only container created before...]:containers:__docker_complete_containers" \
|
||||
"($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_ps_filters" \
|
||||
"($help)--format=[Pretty-print containers using a Go template]:template: " \
|
||||
"($help)--format=[Format the output using the given Go template]:template: " \
|
||||
"($help -l --latest)"{-l,--latest}"[Show only the latest created container]" \
|
||||
"($help -n --last)"{-n=,--last=}"[Show n last created containers (includes all states)]:n:(1 5 10 25 50)" \
|
||||
"($help)--no-trunc[Do not truncate output]" \
|
||||
|
|
@ -907,7 +909,7 @@ __docker_container_subcommand() {
|
|||
_arguments $(__docker_arguments) \
|
||||
$opts_help \
|
||||
"($help -a --all)"{-a,--all}"[Show all containers (default shows just running)]" \
|
||||
"($help)--format=[Pretty-print images using a Go template]:template: " \
|
||||
"($help)--format=[Format the output using the given Go template]:template: " \
|
||||
"($help)--no-stream[Disable streaming stats and only pull the first result]" \
|
||||
"($help)--no-trunc[Do not truncate output]" \
|
||||
"($help -)*:containers:__docker_complete_running_containers" && ret=0
|
||||
|
|
@ -973,8 +975,8 @@ __docker_image_commands() {
|
|||
"load:Load an image from a tar archive or STDIN"
|
||||
"ls:List images"
|
||||
"prune:Remove unused images"
|
||||
"pull:Pull an image or a repository from a registry"
|
||||
"push:Push an image or a repository to a registry"
|
||||
"pull:Download an image from a registry"
|
||||
"push:Upload an image to a registry"
|
||||
"rm:Remove one or more images"
|
||||
"save:Save one or more images to a tar archive (streamed to STDOUT by default)"
|
||||
"tag:Tag an image into a repository"
|
||||
|
|
@ -1060,7 +1062,7 @@ __docker_image_subcommand() {
|
|||
"($help -a --all)"{-a,--all}"[Show all images]" \
|
||||
"($help)--digests[Show digests]" \
|
||||
"($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_images_filters" \
|
||||
"($help)--format=[Pretty-print images using a Go template]:template: " \
|
||||
"($help)--format=[Format the output using the given Go template]:template: " \
|
||||
"($help)--no-trunc[Do not truncate output]" \
|
||||
"($help -q --quiet)"{-q,--quiet}"[Only show image IDs]" \
|
||||
"($help -): :__docker_complete_repositories" && ret=0
|
||||
|
|
@ -1082,7 +1084,7 @@ __docker_image_subcommand() {
|
|||
(push)
|
||||
_arguments $(__docker_arguments) \
|
||||
$opts_help \
|
||||
"($help -a --all-tags)"{-a,--all-tags}"[Push all tagged images in the repository]" \
|
||||
"($help -a --all-tags)"{-a,--all-tags}"[Push all tags of an image to the repository]" \
|
||||
"($help)--disable-content-trust[Skip image signing]" \
|
||||
"($help -): :__docker_complete_images" && ret=0
|
||||
;;
|
||||
|
|
@ -1292,7 +1294,7 @@ __docker_network_subcommand() {
|
|||
$opts_help \
|
||||
"($help)--no-trunc[Do not truncate the output]" \
|
||||
"($help)*"{-f=,--filter=}"[Provide filter values]:filter:__docker_network_complete_ls_filters" \
|
||||
"($help)--format=[Pretty-print networks using a Go template]:template: " \
|
||||
"($help)--format=[Format the output using the given Go template]:template: " \
|
||||
"($help -q --quiet)"{-q,--quiet}"[Only display network IDs]" && ret=0
|
||||
;;
|
||||
(prune)
|
||||
|
|
@ -2050,7 +2052,7 @@ __docker_service_subcommand() {
|
|||
_arguments $(__docker_arguments) \
|
||||
$opts_help \
|
||||
"($help)*"{-f=,--filter=}"[Filter output based on conditions provided]:filter:__docker_service_complete_ls_filters" \
|
||||
"($help)--format=[Pretty-print services using a Go template]:template: " \
|
||||
"($help)--format=[Format the output using the given Go template]:template: " \
|
||||
"($help -q --quiet)"{-q,--quiet}"[Only display IDs]" && ret=0
|
||||
;;
|
||||
(rm|remove)
|
||||
|
|
@ -2253,7 +2255,7 @@ __docker_stack_subcommand() {
|
|||
_arguments $(__docker_arguments) \
|
||||
$opts_help \
|
||||
"($help)*"{-f=,--filter=}"[Filter output based on conditions provided]:filter:__docker_stack_complete_services_filters" \
|
||||
"($help)--format=[Pretty-print services using a Go template]:template: " \
|
||||
"($help)--format=[Format the output using the given Go template]:template: " \
|
||||
"($help -q --quiet)"{-q,--quiet}"[Only display IDs]" \
|
||||
"($help -):stack:__docker_complete_stacks" && ret=0
|
||||
;;
|
||||
|
|
@ -2520,12 +2522,14 @@ __docker_volume_subcommand() {
|
|||
_arguments $(__docker_arguments) \
|
||||
$opts_help \
|
||||
"($help)*"{-f=,--filter=}"[Provide filter values]:filter:__docker_volume_complete_ls_filters" \
|
||||
"($help)--format=[Pretty-print volumes using a Go template]:template: " \
|
||||
"($help)--format=[Format the output using the given Go template]:template: " \
|
||||
"($help -q --quiet)"{-q,--quiet}"[Only display volume names]" && ret=0
|
||||
;;
|
||||
(prune)
|
||||
_arguments $(__docker_arguments) \
|
||||
$opts_help \
|
||||
"($help -a --all)"{-a,--all}"[Remove all unused local volumes, not just anonymous ones]" \
|
||||
"($help)*--filter=[Filter values]:filter:__docker_complete_prune_filters" \
|
||||
"($help -f --force)"{-f,--force}"[Do not prompt for confirmation]" && ret=0
|
||||
;;
|
||||
(rm)
|
||||
|
|
@ -2582,10 +2586,8 @@ __docker_context_subcommand() {
|
|||
(create)
|
||||
_arguments $(__docker_arguments) \
|
||||
$opts_help \
|
||||
"($help)--default-stack-orchestrator=[Default orchestrator for stack operations to use with this context]:default-stack-orchestrator:(swarm kubernetes all)" \
|
||||
"($help)--description=[Description of the context]:description:" \
|
||||
"($help)--docker=[Set the docker endpoint]:docker:" \
|
||||
"($help)--kubernetes=[Set the kubernetes endpoint]:kubernetes:" \
|
||||
"($help)--from=[Create context from a named context]:from:__docker_complete_contexts" \
|
||||
"($help -):name: " && ret=0
|
||||
;;
|
||||
|
|
@ -2607,10 +2609,8 @@ __docker_context_subcommand() {
|
|||
(update)
|
||||
_arguments $(__docker_arguments) \
|
||||
$opts_help \
|
||||
"($help)--default-stack-orchestrator=[Default orchestrator for stack operations to use with this context]:default-stack-orchestrator:(swarm kubernetes all)" \
|
||||
"($help)--description=[Description of the context]:description:" \
|
||||
"($help)--docker=[Set the docker endpoint]:docker:" \
|
||||
"($help)--kubernetes=[Set the kubernetes endpoint]:kubernetes:" \
|
||||
"($help -):name:" && ret=0
|
||||
;;
|
||||
esac
|
||||
|
|
@ -2734,9 +2734,6 @@ __docker_subcommand() {
|
|||
"($help -b --bridge)"{-b=,--bridge=}"[Attach containers to a network bridge]:bridge:_net_interfaces" \
|
||||
"($help)--bip=[Network bridge IP]:IP address: " \
|
||||
"($help)--cgroup-parent=[Parent cgroup for all containers]:cgroup: " \
|
||||
"($help)--cluster-advertise=[Address or interface name to advertise]:Instance to advertise (host\:port): " \
|
||||
"($help)--cluster-store=[URL of the distributed storage backend]:Cluster Store:->cluster-store" \
|
||||
"($help)*--cluster-store-opt=[Cluster store options]:Cluster options:->cluster-store-options" \
|
||||
"($help)--config-file=[Path to daemon configuration file]:Config File:_files" \
|
||||
"($help)--containerd=[Path to containerd socket]:socket:_files -g \"*.sock\"" \
|
||||
"($help)--containerd-namespace=[Containerd namespace to use]:containerd namespace:" \
|
||||
|
|
@ -2771,16 +2768,16 @@ __docker_subcommand() {
|
|||
"($help)--live-restore[Enable live restore of docker when containers are still running]" \
|
||||
"($help)--log-driver=[Default driver for container logs]:logging driver:__docker_complete_log_drivers" \
|
||||
"($help)*--log-opt=[Default log driver options for containers]:log driver options:__docker_complete_log_options" \
|
||||
"($help)--max-concurrent-downloads[Set the max concurrent downloads for each pull]" \
|
||||
"($help)--max-concurrent-uploads[Set the max concurrent uploads for each push]" \
|
||||
"($help)--max-concurrent-downloads[Set the max concurrent downloads]" \
|
||||
"($help)--max-concurrent-uploads[Set the max concurrent uploads]" \
|
||||
"($help)--max-download-attempts[Set the max download attempts for each pull]" \
|
||||
"($help)--mtu=[Network MTU]:mtu:(0 576 1420 1500 9000)" \
|
||||
"($help)--oom-score-adjust=[Set the oom_score_adj for the daemon]:oom-score:(-500)" \
|
||||
"($help -p --pidfile)"{-p=,--pidfile=}"[Path to use for daemon PID file]:PID file:_files" \
|
||||
"($help)--raw-logs[Full timestamps without ANSI coloring]" \
|
||||
"($help)*--registry-mirror=[Preferred Docker registry mirror]:registry mirror: " \
|
||||
"($help)*--registry-mirror=[Preferred registry mirror]:registry mirror: " \
|
||||
"($help)--seccomp-profile=[Path to seccomp profile]:path:_files -g \"*.json\"" \
|
||||
"($help -s --storage-driver)"{-s=,--storage-driver=}"[Storage driver to use]:driver:(aufs btrfs devicemapper overlay overlay2 vfs zfs)" \
|
||||
"($help -s --storage-driver)"{-s=,--storage-driver=}"[Storage driver to use]:driver:(btrfs devicemapper overlay2 vfs zfs)" \
|
||||
"($help)--selinux-enabled[Enable selinux support]" \
|
||||
"($help)--shutdown-timeout=[Set the shutdown timeout value in seconds]:time: " \
|
||||
"($help)*--storage-opt=[Storage driver options]:storage driver options: " \
|
||||
|
|
@ -2795,22 +2792,6 @@ __docker_subcommand() {
|
|||
"($help)--validate[Validate daemon configuration and exit]" && ret=0
|
||||
|
||||
case $state in
|
||||
(cluster-store)
|
||||
if compset -P '*://'; then
|
||||
_message 'host:port' && ret=0
|
||||
else
|
||||
store=('consul' 'etcd' 'zk')
|
||||
_describe -t cluster-store "Cluster Store" store -qS "://" && ret=0
|
||||
fi
|
||||
;;
|
||||
(cluster-store-options)
|
||||
if compset -P '*='; then
|
||||
_files && ret=0
|
||||
else
|
||||
opts=('discovery.heartbeat' 'discovery.ttl' 'kv.cacertfile' 'kv.certfile' 'kv.keyfile' 'kv.path')
|
||||
_describe -t cluster-store-opts "Cluster Store Options" opts -qS "=" && ret=0
|
||||
fi
|
||||
;;
|
||||
(users-groups)
|
||||
if compset -P '*:'; then
|
||||
_groups && ret=0
|
||||
|
|
@ -3095,6 +3076,7 @@ _docker() {
|
|||
_arguments $(__docker_arguments) -C \
|
||||
"(: -)"{-h,--help}"[Print usage]" \
|
||||
"($help)--config[Location of client config files]:path:_directories" \
|
||||
"($help -c --context)"{-c=,--context=}"[Execute the command in a docker context]:context:__docker_complete_contexts" \
|
||||
"($help -D --debug)"{-D,--debug}"[Enable debug mode]" \
|
||||
"($help -H --host)"{-H=,--host=}"[tcp://host:port to bind/connect to]:host: " \
|
||||
"($help -l --log-level)"{-l=,--log-level=}"[Logging level]:level:(debug info warn error fatal)" \
|
||||
|
|
@ -3110,7 +3092,8 @@ _docker() {
|
|||
|
||||
local host=${opt_args[-H]}${opt_args[--host]}
|
||||
local config=${opt_args[--config]}
|
||||
local docker_options="${host:+--host $host} ${config:+--config $config}"
|
||||
local context=${opt_args[-c]}${opt_args[--context]}
|
||||
local docker_options="${host:+--host $host} ${config:+--config $config} ${context:+--context $context} "
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
|
|
@ -1,39 +1,64 @@
|
|||
alias dbl='docker build'
|
||||
alias dpu='docker pull'
|
||||
alias dtop='docker top'
|
||||
|
||||
# docker containers
|
||||
alias dcin='docker container inspect'
|
||||
alias dlo='docker container logs'
|
||||
alias dcls='docker container ls'
|
||||
alias dclsa='docker container ls -a'
|
||||
alias dpo='docker container port'
|
||||
alias dr='docker container run'
|
||||
alias drit='docker container run -it'
|
||||
alias drm='docker container rm'
|
||||
alias 'drm!'='docker container rm -f'
|
||||
alias dst='docker container start'
|
||||
alias dstp='docker container stop'
|
||||
alias dxc='docker container exec'
|
||||
alias dxcit='docker container exec -it'
|
||||
|
||||
# docker images
|
||||
alias dib='docker image build'
|
||||
alias dii='docker image inspect'
|
||||
alias dils='docker image ls'
|
||||
alias dipu='docker image push'
|
||||
alias dirm='docker image rm'
|
||||
alias dit='docker image tag'
|
||||
|
||||
# docker network
|
||||
alias dlo='docker container logs'
|
||||
alias dnc='docker network create'
|
||||
alias dncn='docker network connect'
|
||||
alias dndcn='docker network disconnect'
|
||||
alias dni='docker network inspect'
|
||||
alias dnls='docker network ls'
|
||||
alias dnrm='docker network rm'
|
||||
|
||||
# docker volume
|
||||
alias dpo='docker container port'
|
||||
alias dps='docker ps'
|
||||
alias dpsa='docker ps -a'
|
||||
alias dpu='docker pull'
|
||||
alias dr='docker container run'
|
||||
alias drit='docker container run -it'
|
||||
alias drm='docker container rm'
|
||||
alias 'drm!'='docker container rm -f'
|
||||
alias dst='docker container start'
|
||||
alias drs='docker container restart'
|
||||
alias dsta='docker stop $(docker ps -q)'
|
||||
alias dstp='docker container stop'
|
||||
alias dtop='docker top'
|
||||
alias dvi='docker volume inspect'
|
||||
alias dvls='docker volume ls'
|
||||
alias dvprune='docker volume prune'
|
||||
alias dxc='docker container exec'
|
||||
alias dxcit='docker container exec -it'
|
||||
|
||||
if (( ! $+commands[docker] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# Standarized $0 handling
|
||||
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
|
||||
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
||||
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `docker`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_docker" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _docker
|
||||
_comps[docker]=_docker
|
||||
fi
|
||||
|
||||
{
|
||||
# `docker completion` is only available from 23.0.0 on
|
||||
# docker version returns `Docker version 24.0.2, build cb74dfcd85`
|
||||
# with `s:,:` remove the comma after the version, and select third word of it
|
||||
if zstyle -t ':omz:plugins:docker' legacy-completion || \
|
||||
! is-at-least 23.0.0 ${${(s:,:z)"$(command docker --version)"}[3]}; then
|
||||
command cp "${0:h}/completions/_docker" "$ZSH_CACHE_DIR/completions/_docker"
|
||||
else
|
||||
command docker completion zsh | tee "$ZSH_CACHE_DIR/completions/_docker" > /dev/null
|
||||
fi
|
||||
} &|
|
||||
|
|
|
|||
|
|
@ -4,6 +4,14 @@
|
|||
#
|
||||
# Author: https://github.com/HalisCz
|
||||
|
||||
if [ $commands[doctl] ]; then
|
||||
source <(doctl completion zsh)
|
||||
if (( ! $+commands[doctl] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_doctl" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _doctl
|
||||
_comps[doctl]=_doctl
|
||||
fi
|
||||
|
||||
doctl completion zsh >| "$ZSH_CACHE_DIR/completions/_doctl" &|
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ plugins=(... dotnet)
|
|||
| dt | dotnet test | Run unit tests using the test runner specified in a .NET project. |
|
||||
| dw | dotnet watch | Watch for source file changes and restart the dotnet command. |
|
||||
| dwr | dotnet watch run | Watch for source file changes and restart the `run` command. |
|
||||
| dwt | dotnet watch test| Watch for source file changes and restart the `test` command. |
|
||||
| ds | dotnet sln | Modify Visual Studio solution files. |
|
||||
| da | dotnet add | Add a package or reference to a .NET project. |
|
||||
| dp | dotnet pack | Create a NuGet package. |
|
||||
|
|
|
|||
|
|
@ -1,31 +1,24 @@
|
|||
# This scripts is copied from (MIT License):
|
||||
# https://github.com/dotnet/toolset/blob/master/scripts/register-completions.zsh
|
||||
# https://raw.githubusercontent.com/dotnet/sdk/main/scripts/register-completions.zsh
|
||||
|
||||
_dotnet_zsh_complete()
|
||||
{
|
||||
local completions=("$(dotnet complete "$words")")
|
||||
|
||||
# If the completion list is empty, just continue with filename selection
|
||||
if [ -z "$completions" ]
|
||||
then
|
||||
_arguments '*::arguments: _normal'
|
||||
return
|
||||
fi
|
||||
|
||||
# This is not a variable assignment, don't remove spaces!
|
||||
_values = "${(ps:\n:)completions}"
|
||||
#compdef dotnet
|
||||
_dotnet_completion() {
|
||||
local -a completions=("${(@f)$(dotnet complete "${words}")}")
|
||||
compadd -a completions
|
||||
_files
|
||||
}
|
||||
|
||||
compdef _dotnet_zsh_complete dotnet
|
||||
compdef _dotnet_completion dotnet
|
||||
|
||||
# Aliases bellow are here for backwards compatibility
|
||||
# added by Shaun Tabone (https://github.com/xontab)
|
||||
# added by Shaun Tabone (https://github.com/xontab)
|
||||
|
||||
alias dn='dotnet new'
|
||||
alias dr='dotnet run'
|
||||
alias dt='dotnet test'
|
||||
alias dw='dotnet watch'
|
||||
alias dwr='dotnet watch run'
|
||||
alias dwt='dotnet watch test'
|
||||
alias ds='dotnet sln'
|
||||
alias da='dotnet add'
|
||||
alias dp='dotnet pack'
|
||||
|
|
|
|||
|
|
@ -25,6 +25,6 @@ The plugin uses a custom launcher (which we'll call here `$EMACS_LAUNCHER`) that
|
|||
| e | `emacs` | Same as emacs alias |
|
||||
| te | `$EMACS_LAUNCHER -nw` | Open terminal emacsclient |
|
||||
| eeval | `$EMACS_LAUNCHER --eval` | Same as `M-x eval` but from outside Emacs |
|
||||
| eframe | `emacsclient --alternate-editor "" --create-frame` | Create new X frame |
|
||||
| eframe | `emacsclient --alternate-editor="" --create-frame` | Create new X frame |
|
||||
| efile | - | Print the path to the file open in the current buffer |
|
||||
| ecd | - | Print the directory of the file open in the the current buffer |
|
||||
| ecd | - | Print the directory of the file open in the current buffer |
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ alias te="$EMACS_PLUGIN_LAUNCHER -nw"
|
|||
# same than M-x eval but from outside Emacs.
|
||||
alias eeval="$EMACS_PLUGIN_LAUNCHER --eval"
|
||||
# create a new X frame
|
||||
alias eframe='emacsclient --alternate-editor "" --create-frame'
|
||||
alias eframe='emacsclient --alternate-editor="" --create-frame'
|
||||
|
||||
# Emacs ANSI Term tracking
|
||||
if [[ -n "$INSIDE_EMACS" ]]; then
|
||||
|
|
@ -60,7 +60,7 @@ function efile {
|
|||
}
|
||||
|
||||
# Write to standard output the directory of the file
|
||||
# opened in the the current buffer
|
||||
# opened in the current buffer
|
||||
function ecd {
|
||||
local file
|
||||
file="$(efile)" || return $?
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@ emacsfun() {
|
|||
|
||||
# Only create another X frame if there isn't one present
|
||||
if [ -z "$frames" -o "$frames" = nil ]; then
|
||||
emacsclient --alternate-editor "" --create-frame "$@"
|
||||
emacsclient --alternate-editor="" --create-frame "$@"
|
||||
return $?
|
||||
fi
|
||||
|
||||
emacsclient --alternate-editor "" "$@"
|
||||
emacsclient --alternate-editor="" "$@"
|
||||
}
|
||||
|
||||
# Adapted from https://github.com/davidshepherd7/emacs-read-stdin/blob/master/emacs-read-stdin.sh
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ unset _omz_emoji_plugin_dir
|
|||
|
||||
# This is a combining character that can be placed after any other character to surround
|
||||
# it in a "keycap" symbol.
|
||||
# The digits 0-9 are already in the emoji table as keycap_digit_<N>, keycap_ten, etc.
|
||||
# The digits 0-9 are already in the emoji table as keycap_digit_<N>, keycap_ten, etc.
|
||||
# It's unclear whether this should be in the $emoji array, because those characters are all ones
|
||||
# which can be displayed on their own.
|
||||
|
||||
|
|
@ -63,9 +63,9 @@ function random_emoji() {
|
|||
[[ $list_size -eq 0 ]] && return 1
|
||||
local random_index=$(( ( RANDOM % $list_size ) + 1 ))
|
||||
local name=${names[$random_index]}
|
||||
if [[ "$group" == "flags" ]]; then
|
||||
if [[ "$group" == "flags" ]]; then
|
||||
echo ${emoji_flags[$name]}
|
||||
else
|
||||
else
|
||||
echo ${emoji[$name]}
|
||||
fi
|
||||
}
|
||||
|
|
@ -86,22 +86,22 @@ function display_emoji() {
|
|||
# terminals treat these emoji chars as single-width.
|
||||
local counter=1
|
||||
for i in $names; do
|
||||
if [[ "$group" == "flags" ]]; then
|
||||
if [[ "$group" == "flags" ]]; then
|
||||
printf '%s ' "$emoji_flags[$i]"
|
||||
else
|
||||
printf '%s ' "$emoji[$i]"
|
||||
else
|
||||
printf '%s ' "$emoji[$i]"
|
||||
fi
|
||||
# New line every 20 emoji, to avoid weirdnesses
|
||||
if (($counter % 20 == 0)); then
|
||||
printf "\n"
|
||||
printf "\n"
|
||||
fi
|
||||
let counter=$counter+1
|
||||
done
|
||||
print
|
||||
for i in $names; do
|
||||
if [[ "$group" == "flags" ]]; then
|
||||
if [[ "$group" == "flags" ]]; then
|
||||
echo "${emoji_flags[$i]} = $i"
|
||||
else
|
||||
else
|
||||
echo "${emoji[$i]} = $i"
|
||||
fi
|
||||
done
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ typeset -gAH emoji_groups
|
|||
|
||||
# def country_iso(_all_names, _omz_name):
|
||||
# """ Using the external library country_converter,
|
||||
# this funciton can detect the ISO2 and ISO3 codes
|
||||
# this function can detect the ISO2 and ISO3 codes
|
||||
# of the country. It takes as argument the array
|
||||
# with all the names of the emoji, and returns that array."""
|
||||
# omz_no_underscore = re.sub(r'_', r' ', _omz_name)
|
||||
|
|
@ -96,7 +96,7 @@ def name_to_omz(_name, _group, _subgroup, _status):
|
|||
# Special treatment by status
|
||||
# Enables us to have every emoji combination,
|
||||
# even the one that are not officially sanctionned
|
||||
# and are implemeted by, say, only one vendor
|
||||
# and are implemented by, say, only one vendor
|
||||
if _status == "unqualified":
|
||||
shortname += "_unqualified"
|
||||
elif _status == "minimally-qualified":
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
# AUTHOR: Alexis Hildebrandt (afh[at]surryhill.net)
|
||||
# VERSION: 1.0.0
|
||||
# DEPENDS: emoji plugin
|
||||
#
|
||||
#
|
||||
# There are different sets of emoji characters available, to choose a different
|
||||
# set export emotty_set to the name of the set you would like to use, e.g.:
|
||||
# % export emotty_set=nature
|
||||
|
|
|
|||
|
|
@ -10,10 +10,11 @@ plugins=(... encode64)
|
|||
|
||||
## Functions and Aliases
|
||||
|
||||
| Function | Alias | Description |
|
||||
| ---------- | ----- | ------------------------------ |
|
||||
| `encode64` | `e64` | Encodes given data to base64 |
|
||||
| `decode64` | `d64` | Decodes given data from base64 |
|
||||
| Function | Alias | Description |
|
||||
| -------------- | ------ | -------------------------------------- |
|
||||
| `encode64` | `e64` | Encodes given data to base64 |
|
||||
| `encodefile64` | `ef64` | Encodes given file's content to base64 |
|
||||
| `decode64` | `d64` | Decodes given data from base64 |
|
||||
|
||||
## Usage and examples
|
||||
|
||||
|
|
@ -37,6 +38,20 @@ plugins=(... encode64)
|
|||
b2gtbXktenNo==
|
||||
```
|
||||
|
||||
### Encoding a file
|
||||
|
||||
Encode a file's contents to base64 and save output to text file.
|
||||
**NOTE:** Takes provided file and saves encoded content as new file with `.txt` extension
|
||||
|
||||
- From parameter
|
||||
|
||||
```console
|
||||
$ encodefile64 ohmyzsh.icn
|
||||
ohmyzsh.icn's content encoded in base64 and saved as ohmyzsh.icn.txt
|
||||
$ ef64 "oh-my-zsh"
|
||||
ohmyzsh.icn's content encoded in base64 and saved as ohmyzsh.icn.txt
|
||||
```
|
||||
|
||||
### Decoding
|
||||
|
||||
- From parameter
|
||||
|
|
|
|||
|
|
@ -6,6 +6,15 @@ encode64() {
|
|||
fi
|
||||
}
|
||||
|
||||
encodefile64() {
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "You must provide a filename"
|
||||
else
|
||||
base64 $1 > $1.txt
|
||||
echo "${1}'s content encoded in base64 and saved as ${1}.txt"
|
||||
fi
|
||||
}
|
||||
|
||||
decode64() {
|
||||
if [[ $# -eq 0 ]]; then
|
||||
cat | base64 --decode
|
||||
|
|
@ -14,4 +23,5 @@ decode64() {
|
|||
fi
|
||||
}
|
||||
alias e64=encode64
|
||||
alias ef64=encodefile64
|
||||
alias d64=decode64
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
# extract plugin
|
||||
|
||||
This plugin defines a function called `extract` that extracts the archive file
|
||||
you pass it, and it supports a wide variety of archive filetypes.
|
||||
This plugin defines a function called `extract` that extracts the archive file you pass it, and it supports a
|
||||
wide variety of archive filetypes.
|
||||
|
||||
This way you don't have to know what specific command extracts a file, you just
|
||||
do `extract <filename>` and the function takes care of the rest.
|
||||
This way you don't have to know what specific command extracts a file, you just do `extract <filename>` and
|
||||
the function takes care of the rest.
|
||||
|
||||
To use it, add `extract` to the plugins array in your zshrc file:
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ plugins=(... extract)
|
|||
## Supported file extensions
|
||||
|
||||
| Extension | Description |
|
||||
|:------------------|:-------------------------------------|
|
||||
| :---------------- | :----------------------------------- |
|
||||
| `7z` | 7zip file |
|
||||
| `Z` | Z archive (LZW) |
|
||||
| `apk` | Android app file |
|
||||
|
|
@ -25,6 +25,7 @@ plugins=(... extract)
|
|||
| `cpio` | Cpio archive |
|
||||
| `deb` | Debian package |
|
||||
| `ear` | Enterprise Application aRchive |
|
||||
| `exe` | Windows executable file |
|
||||
| `gz` | Gzip file |
|
||||
| `ipa` | iOS app package |
|
||||
| `ipsw` | iOS firmware file |
|
||||
|
|
@ -32,6 +33,7 @@ plugins=(... extract)
|
|||
| `lrz` | LRZ archive |
|
||||
| `lz4` | LZ4 archive |
|
||||
| `lzma` | LZMA archive |
|
||||
| `obscpio` | cpio archive used on OBS |
|
||||
| `rar` | WinRAR archive |
|
||||
| `rpm` | RPM package |
|
||||
| `sublime-package` | Sublime Text package |
|
||||
|
|
@ -51,10 +53,13 @@ plugins=(... extract)
|
|||
| `txz` | Tarball with lzma2 compression |
|
||||
| `tzst` | Tarball with zstd compression |
|
||||
| `war` | Web Application archive (Java-based) |
|
||||
| `whl` | Python wheel file |
|
||||
| `xpi` | Mozilla XPI module file |
|
||||
| `xz` | LZMA2 archive |
|
||||
| `zip` | Zip archive |
|
||||
| `zlib` | zlib archive |
|
||||
| `zst` | Zstandard file (zstd) |
|
||||
| `zpaq` | Zpaq file |
|
||||
|
||||
See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for
|
||||
more information regarding archive formats.
|
||||
See [list of archive formats](https://en.wikipedia.org/wiki/List_of_archive_formats) for more information
|
||||
regarding archive formats.
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@
|
|||
|
||||
_arguments \
|
||||
'(-r --remove)'{-r,--remove}'[Remove archive.]' \
|
||||
"*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|cab|cpio|deb|ear|gz|ipa|ipsw|jar|lrz|lz4|lzma|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst)(-.)'" \
|
||||
"*::archive file:_files -g '(#i)*.(7z|Z|apk|aar|bz2|cab|cpio|deb|ear|gz|ipa|ipsw|jar|lrz|lz4|lzma|obscpio|rar|rpm|sublime-package|tar|tar.bz2|tar.gz|tar.lrz|tar.lz|tar.lz4|tar.xz|tar.zma|tar.zst|tbz|tbz2|tgz|tlz|txz|tzst|war|whl|xpi|xz|zip|zst|zpaq)(-.)'" \
|
||||
&& return 0
|
||||
|
|
|
|||
|
|
@ -27,59 +27,111 @@ EOF
|
|||
fi
|
||||
|
||||
local success=0
|
||||
local extract_dir="${1:t:r}"
|
||||
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
|
||||
local rnd="${(L)"${$(( [##36]$RANDOM*$RANDOM ))}":1:5}"
|
||||
extract_dir="${extract_dir}-${rnd}"
|
||||
fi
|
||||
|
||||
# Create an extraction directory based on the file name
|
||||
command mkdir -p "$extract_dir"
|
||||
builtin cd -q "$extract_dir"
|
||||
echo "extract: extracting to $extract_dir" >&2
|
||||
|
||||
case "${file:l}" in
|
||||
(*.tar.gz|*.tgz) (( $+commands[pigz] )) && { pigz -dc "$file" | tar xv } || tar zxvf "$file" ;;
|
||||
(*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$file" ;;
|
||||
(*.tar.gz|*.tgz)
|
||||
(( $+commands[pigz] )) && { tar -I pigz -xvf "$full_path" } || tar zxvf "$full_path" ;;
|
||||
(*.tar.bz2|*.tbz|*.tbz2)
|
||||
(( $+commands[pbzip2] )) && { tar -I pbzip2 -xvf "$full_path" } || tar xvjf "$full_path" ;;
|
||||
(*.tar.xz|*.txz)
|
||||
(( $+commands[pixz] )) && { tar -I pixz -xvf "$full_path" } || {
|
||||
tar --xz --help &> /dev/null \
|
||||
&& tar --xz -xvf "$file" \
|
||||
|| xzcat "$file" | tar xvf - ;;
|
||||
&& tar --xz -xvf "$full_path" \
|
||||
|| xzcat "$full_path" | tar xvf - } ;;
|
||||
(*.tar.zma|*.tlz)
|
||||
tar --lzma --help &> /dev/null \
|
||||
&& tar --lzma -xvf "$file" \
|
||||
|| lzcat "$file" | tar xvf - ;;
|
||||
&& tar --lzma -xvf "$full_path" \
|
||||
|| lzcat "$full_path" | tar xvf - ;;
|
||||
(*.tar.zst|*.tzst)
|
||||
tar --zstd --help &> /dev/null \
|
||||
&& tar --zstd -xvf "$file" \
|
||||
|| zstdcat "$file" | tar xvf - ;;
|
||||
(*.tar) tar xvf "$file" ;;
|
||||
(*.tar.lz) (( $+commands[lzip] )) && tar xvf "$file" ;;
|
||||
(*.tar.lz4) lz4 -c -d "$file" | tar xvf - ;;
|
||||
(*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$file" ;;
|
||||
(*.gz) (( $+commands[pigz] )) && pigz -dk "$file" || gunzip -k "$file" ;;
|
||||
(*.bz2) bunzip2 "$file" ;;
|
||||
(*.xz) unxz "$file" ;;
|
||||
(*.lrz) (( $+commands[lrunzip] )) && lrunzip "$file" ;;
|
||||
(*.lz4) lz4 -d "$file" ;;
|
||||
(*.lzma) unlzma "$file" ;;
|
||||
(*.z) uncompress "$file" ;;
|
||||
(*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$file" -d "$extract_dir" ;;
|
||||
(*.rar) unrar x -ad "$file" ;;
|
||||
&& tar --zstd -xvf "$full_path" \
|
||||
|| zstdcat "$full_path" | tar xvf - ;;
|
||||
(*.tar) tar xvf "$full_path" ;;
|
||||
(*.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 -cdk "$full_path" > "${file:t:r}" || gunzip -ck "$full_path" > "${file:t:r}" ;;
|
||||
(*.bz2) (( $+commands[pbzip2] )) && pbzip2 -d "$full_path" || bunzip2 "$full_path" ;;
|
||||
(*.xz) unxz "$full_path" ;;
|
||||
(*.lrz) (( $+commands[lrunzip] )) && lrunzip "$full_path" ;;
|
||||
(*.lz4) lz4 -d "$full_path" ;;
|
||||
(*.lzma) unlzma "$full_path" ;;
|
||||
(*.z) uncompress "$full_path" ;;
|
||||
(*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$full_path" ;;
|
||||
(*.rar) unrar x -ad "$full_path" ;;
|
||||
(*.rpm)
|
||||
command mkdir -p "$extract_dir" && builtin cd -q "$extract_dir" \
|
||||
&& rpm2cpio "$full_path" | cpio --quiet -id ;;
|
||||
(*.7z) 7za x "$file" ;;
|
||||
rpm2cpio "$full_path" | cpio --quiet -id ;;
|
||||
(*.7z | *.7z.[0-9]*) 7za x "$full_path" ;;
|
||||
(*.deb)
|
||||
command mkdir -p "$extract_dir/control" "$extract_dir/data"
|
||||
builtin cd -q "$extract_dir"; ar vx "$full_path" > /dev/null
|
||||
command mkdir -p "control" "data"
|
||||
ar vx "$full_path" > /dev/null
|
||||
builtin cd -q control; extract ../control.tar.*
|
||||
builtin cd -q ../data; extract ../data.tar.*
|
||||
builtin cd -q ..; command rm *.tar.* debian-binary ;;
|
||||
(*.zst) unzstd "$file" ;;
|
||||
(*.cab) cabextract -d "$extract_dir" "$file" ;;
|
||||
(*.cpio) cpio -idmvF "$file" ;;
|
||||
(*.zst) unzstd --stdout "$full_path" > "${file:t:r}" ;;
|
||||
(*.cab|*.exe) cabextract "$full_path" ;;
|
||||
(*.cpio|*.obscpio) cpio -idmvF "$full_path" ;;
|
||||
(*.zpaq) zpaq x "$full_path" ;;
|
||||
(*.zlib) zlib-flate -uncompress < "$full_path" > "${file:r}" ;;
|
||||
(*)
|
||||
echo "extract: '$file' cannot be extracted" >&2
|
||||
success=1 ;;
|
||||
esac
|
||||
|
||||
(( success = success > 0 ? success : $? ))
|
||||
(( success == 0 && remove_archive == 0 )) && rm "$full_path"
|
||||
(( success == 0 && remove_archive == 0 )) && command rm "$full_path"
|
||||
shift
|
||||
|
||||
# Go back to original working directory in case we ran cd previously
|
||||
# Go back to original working directory
|
||||
builtin cd -q "$pwd"
|
||||
|
||||
# If content of extract dir is a single directory, move its contents up
|
||||
# Glob flags:
|
||||
# - D: include files starting with .
|
||||
# - N: no error if directory is empty
|
||||
# - Y2: at most give 2 files
|
||||
local -a content
|
||||
content=("${extract_dir}"/*(DNY2))
|
||||
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 file/folder to a temporary random name
|
||||
# 2. Delete the empty folder
|
||||
# 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_name==(:); tmp_name="${tmp_name:t}"
|
||||
command mv "${content[1]}" "$tmp_name" \
|
||||
&& command rmdir "$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
|
||||
command mv "${content[1]}" . \
|
||||
&& command rmdir "$extract_dir"
|
||||
fi
|
||||
elif [[ ${#content} -eq 0 ]]; then
|
||||
command rmdir "$extract_dir"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
|
|
|||
111
plugins/eza/README.md
Normal file
111
plugins/eza/README.md
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
# eza plugin
|
||||
|
||||
This provides aliases that invoke the [`eza`](https://github.com/eza-community/eza) utility rather than `ls`
|
||||
|
||||
To use it add `eza` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... eza)
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
All configurations are done using the `zstyle` command in the `:omz:plugins:eza` namespace.
|
||||
|
||||
**NOTE:** The configuring needs to be done prior to OMZ loading the plugins. When the plugin is loaded,
|
||||
changing the `zstyle` won't have any effect.
|
||||
|
||||
### `dirs-first`
|
||||
|
||||
```zsh
|
||||
zstyle ':omz:plugins:eza' 'dirs-first' yes|no
|
||||
```
|
||||
|
||||
If `yes`, directories will be grouped first.
|
||||
|
||||
Default: `no`
|
||||
|
||||
### `git-status`
|
||||
|
||||
```zsh
|
||||
zstyle ':omz:plugins:eza' 'git-status' yes|no
|
||||
```
|
||||
|
||||
If `yes`, always add `--git` flag to indicate git status (if tracked / in a git repo).
|
||||
|
||||
Default: `no`
|
||||
|
||||
### `header`
|
||||
|
||||
```zsh
|
||||
zstyle ':omz:plugins:eza' 'header' yes|no
|
||||
```
|
||||
|
||||
If `yes`, always add `-h` flag to add a header row for each column.
|
||||
|
||||
Default: `no`
|
||||
|
||||
### `show-group`
|
||||
|
||||
```zsh
|
||||
zstyle ':omz:plugins:eza' 'show-group' yes|no
|
||||
```
|
||||
|
||||
If `yes` (default), always add `-g` flag to show the group ownership.
|
||||
|
||||
Default: `yes`
|
||||
|
||||
### `icons`
|
||||
|
||||
```zsh
|
||||
zstyle ':omz:plugins:eza' 'icons' yes|no
|
||||
```
|
||||
|
||||
If `yes`, sets the `--icons` option of `eza`, adding icons for files and folders.
|
||||
|
||||
Default: `no`
|
||||
|
||||
### `size-prefix`
|
||||
|
||||
```zsh
|
||||
zstyle ':omz:plugins:eza' 'size-prefix' (binary|none|si)
|
||||
```
|
||||
|
||||
Choose the prefix to be used in displaying file size:
|
||||
|
||||
- `binary` -- use [binary prefixes](https://en.wikipedia.org/wiki/Binary_prefix) such as "Ki", "Mi", "Gi" and
|
||||
so on
|
||||
- `none` -- don't use any prefix, show size in bytes
|
||||
- `si` (default) -- use [Metric/S.I. prefixes](https://en.wikipedia.org/wiki/Metric_prefix)
|
||||
|
||||
Default: `si`
|
||||
|
||||
### `time-style`
|
||||
|
||||
```zsh
|
||||
zstyle ':omz:plugins:eza' 'time-style' $TIME_STYLE
|
||||
```
|
||||
|
||||
Sets the `--time-style` option of `eza`. (See `man eza` for the options)
|
||||
|
||||
Default: Not set, which means the default behavior of `eza` will take place.
|
||||
|
||||
## Aliases
|
||||
|
||||
**Notes:**
|
||||
|
||||
- Aliases may be modified by Configuration
|
||||
- The term "files" without "only" qualifier means both files & directories
|
||||
|
||||
| Alias | Command | Description |
|
||||
| ------ | ----------------- | -------------------------------------------------------------------------- |
|
||||
| `la` | `eza -la` | List all files (except . and ..) as a long list |
|
||||
| `ldot` | `eza -ld .*` | List dotfiles only (directories shown as entries instead of recursed into) |
|
||||
| `lD` | `eza -lD` | List only directories (excluding dotdirs) as a long list |
|
||||
| `lDD` | `eza -laD` | List only directories (including dotdirs) as a long list |
|
||||
| `ll` | `eza -l` | List files as a long list |
|
||||
| `ls` | `eza` | Plain eza call |
|
||||
| `lsd` | `eza -d` | List specified files with directories as entries, in a grid |
|
||||
| `lsdl` | `eza -dl` | List specified files with directories as entries, in a long list |
|
||||
| `lS` | `eza -l -ssize` | List files as a long list, sorted by size |
|
||||
| `lT` | `eza -l -snewest` | List files as a long list, sorted by date (newest last) |
|
||||
65
plugins/eza/eza.plugin.zsh
Normal file
65
plugins/eza/eza.plugin.zsh
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
if ! (( $+commands[eza] )); then
|
||||
print "zsh eza plugin: eza not found. Please install eza before using this plugin." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
typeset -a _EZA_HEAD
|
||||
typeset -a _EZA_TAIL
|
||||
|
||||
function _configure_eza() {
|
||||
local _val
|
||||
# Get the head flags
|
||||
if zstyle -T ':omz:plugins:eza' 'show-group'; then
|
||||
_EZA_HEAD+=("g")
|
||||
fi
|
||||
if zstyle -t ':omz:plugins:eza' 'header'; then
|
||||
_EZA_HEAD+=("h")
|
||||
fi
|
||||
zstyle -s ':omz:plugins:eza' 'size-prefix' _val
|
||||
case "${_val:l}" in
|
||||
binary)
|
||||
_EZA_HEAD+=("b")
|
||||
;;
|
||||
none)
|
||||
_EZA_HEAD+=("B")
|
||||
;;
|
||||
esac
|
||||
# Get the tail long-options
|
||||
if zstyle -t ':omz:plugins:eza' 'dirs-first'; then
|
||||
_EZA_TAIL+=("--group-directories-first")
|
||||
fi
|
||||
if zstyle -t ':omz:plugins:eza' 'git-status'; then
|
||||
_EZA_TAIL+=("--git")
|
||||
fi
|
||||
if zstyle -t ':omz:plugins:eza' 'icons'; then
|
||||
_EZA_TAIL+=("--icons=auto")
|
||||
fi
|
||||
zstyle -s ':omz:plugins:eza' 'time-style' _val
|
||||
if [[ $_val ]]; then
|
||||
_EZA_TAIL+=("--time-style='$_val'")
|
||||
fi
|
||||
}
|
||||
|
||||
_configure_eza
|
||||
|
||||
function _alias_eza() {
|
||||
local _head="${(j::)_EZA_HEAD}$2"
|
||||
local _tail="${(j: :)_EZA_TAIL}"
|
||||
alias "$1"="eza${_head:+ -}${_head}${_tail:+ }${_tail}${3:+ }$3"
|
||||
}
|
||||
|
||||
_alias_eza la la
|
||||
_alias_eza ldot ld ".*"
|
||||
_alias_eza lD lD
|
||||
_alias_eza lDD lDa
|
||||
_alias_eza ll l
|
||||
_alias_eza ls
|
||||
_alias_eza lsd d
|
||||
_alias_eza lsdl dl
|
||||
_alias_eza lS "l -ssize"
|
||||
_alias_eza lT "l -snewest"
|
||||
|
||||
unfunction _alias_eza
|
||||
unfunction _configure_eza
|
||||
unset _EZA_HEAD
|
||||
unset _EZA_TAIL
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
# Use Ctrl-Z to switch back to Vim
|
||||
|
||||
I frequently need to execute random commands in my shell. To achieve it I pause
|
||||
I frequently need to execute random commands in my shell. To achieve it I pause
|
||||
Vim by pressing Ctrl-z, type command and press fg<Enter> to switch back to Vim.
|
||||
The fg part really hurts me. I just wanted to hit Ctrl-z once again to get back
|
||||
to Vim. I could not find a solution, so I developed one on my own that
|
||||
The fg part really hurts me. I just wanted to hit Ctrl-z once again to get back
|
||||
to Vim. I could not find a solution, so I developed one on my own that
|
||||
works wonderfully with ZSH.
|
||||
|
||||
Source: http://sheerun.net/2014/03/21/how-to-boost-your-vim-productivity/
|
||||
|
||||
Credits:
|
||||
Credits:
|
||||
- original idea by @sheerun
|
||||
- added to OMZ by @mbologna
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ plugins=(... fasd)
|
|||
|
||||
## Installation
|
||||
|
||||
Please find detailed installation guide [`here`](https://github.com/clvv/fasd#install)
|
||||
Please find detailed installation guide [`here`](https://github.com/whjvenyl/fasd#install)
|
||||
|
||||
## Aliases
|
||||
|
||||
|
|
|
|||
|
|
@ -71,13 +71,13 @@ them, add `<variable>=<value>` to your zshrc file, before Oh My Zsh is sourced.
|
|||
For example: `fastfile_var_prefix='@'`.
|
||||
|
||||
- `fastfile_var_prefix`: prefix for the global aliases created. Controls the prefix of the
|
||||
created global aliases.
|
||||
created global aliases.
|
||||
**Default:** `§` (section sign), easy to type in a german keyboard via the combination
|
||||
[`⇧ Shift`+`3`](https://en.wikipedia.org/wiki/German_keyboard_layout#/media/File:KB_Germany.svg),
|
||||
or using `⌥ Option`+`6` in macOS.
|
||||
|
||||
- `fastfile_dir`: directory where the fastfile shortcuts are stored. Needs to end
|
||||
with a trailing slash.
|
||||
with a trailing slash.
|
||||
**Default:** `$HOME/.fastfile/`.
|
||||
|
||||
## Author
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ function fwl () {
|
|||
zones=("${(@f)$(sudo firewall-cmd --get-active-zones | grep -v 'interfaces\|sources')}")
|
||||
|
||||
for i in $zones; do
|
||||
sudo firewall-cmd --zone $i --list-all
|
||||
sudo firewall-cmd --zone ${i/ \(default\)} --list-all
|
||||
done
|
||||
|
||||
echo 'Direct Rules:'
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
#compdef flutter
|
||||
#autoload
|
||||
|
||||
local -a _1st_arguments
|
||||
_1st_arguments=(
|
||||
"analyze":"Analyze the project's Dart code."
|
||||
"assemble":"Assemble and build flutter resources."
|
||||
"attach":"Attach to a running application."
|
||||
"build":"Flutter build commands."
|
||||
"channel":"List or switch flutter channels."
|
||||
"clean":"Delete the build/ and .dart_tool/ directories."
|
||||
"config":"Configure Flutter settings."
|
||||
"create":"Create a new Flutter project."
|
||||
"devices":"List all connected devices."
|
||||
"doctor":"Show information about the installed tooling."
|
||||
"drive":"Runs Flutter Driver tests for the current project."
|
||||
"emulators":"List, launch and create emulators."
|
||||
"format":" Format one or more dart files."
|
||||
"help":"Display help information for flutter."
|
||||
"install":"Install a Flutter app on an attached device."
|
||||
"logs":"Show log output for running Flutter apps."
|
||||
"make-host-app-editable":"Moves host apps from generated directories to non-generated directories so that they can be edited by developers."
|
||||
"precache":"Populates the Flutter tool's cache of binary artifacts."
|
||||
"pub":"Commands for managing Flutter packages."
|
||||
"run":"Run your Flutter app on an attached device."
|
||||
"screenshot":"Take a screenshot from a connected device."
|
||||
"test":"Run Flutter unit tests for the current project."
|
||||
"upgrade":"Upgrade your copy of Flutter."
|
||||
"version":"List or switch flutter versions."
|
||||
)
|
||||
|
||||
_arguments -C '*:: :->subcmds'
|
||||
|
||||
if (( CURRENT == 1 )); then
|
||||
_describe -t commands "flutter command" _1st_arguments
|
||||
return
|
||||
fi
|
||||
|
|
@ -12,3 +12,18 @@ alias flrd="flutter run --debug"
|
|||
alias flrp="flutter run --profile"
|
||||
alias flrr="flutter run --release"
|
||||
alias flupgrd="flutter upgrade"
|
||||
|
||||
# COMPLETION FUNCTION
|
||||
if (( ! $+commands[flutter] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `flutter`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_flutter" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _flutter
|
||||
_comps[flutter]=_flutter
|
||||
fi
|
||||
|
||||
flutter zsh-completion >| "$ZSH_CACHE_DIR/completions/_flutter" &|
|
||||
9
plugins/fluxcd/README.md
Normal file
9
plugins/fluxcd/README.md
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# FluxCD plugin
|
||||
|
||||
This plugin adds completion for [FluxCD](https://fluxcd.io), an open and extensible continuous delivery solution for Kubernetes. Powered by GitOps Toolkit.
|
||||
|
||||
To use it, add `fluxcd` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... fluxcd)
|
||||
```
|
||||
14
plugins/fluxcd/fluxcd.plugin.zsh
Normal file
14
plugins/fluxcd/fluxcd.plugin.zsh
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Autocompletion for the FluxCD CLI (flux).
|
||||
if (( ! $+commands[flux] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `flux`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_flux" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _flux
|
||||
_comps[flux]=_flux
|
||||
fi
|
||||
|
||||
flux completion zsh >| "$ZSH_CACHE_DIR/completions/_flux" &|
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
# Author: Adam Strzelecki nanoant.com, modified by Bodo Tasche bitboxer.de
|
||||
# Updated to support ForkLift 2 and ForkLift 3 by Johan Kaving
|
||||
# Updated to support ForkLift from Setapp by Paul Rudkin
|
||||
# Updated to support ForkLift 4 by Michal Szymanski (misiektoja)
|
||||
#
|
||||
# Usage:
|
||||
# fl [<folder>]
|
||||
|
|
@ -58,7 +59,7 @@ function fl {
|
|||
tell application forkLiftSetapp
|
||||
activate
|
||||
set forkLiftVersion to version
|
||||
end tell
|
||||
end tell
|
||||
else if forkLift3 is not null and application forkLift3 is running then
|
||||
tell application forkLift3
|
||||
activate
|
||||
|
|
@ -84,7 +85,7 @@ function fl {
|
|||
else if forkLift is not null then
|
||||
set appName to forkLift
|
||||
end if
|
||||
|
||||
|
||||
tell application appName
|
||||
activate
|
||||
set forkLiftVersion to version
|
||||
|
|
@ -110,6 +111,11 @@ function fl {
|
|||
tell pop over of list of group of splitter group of splitter group of topWindow
|
||||
set value of text field 1 to "$PWD"
|
||||
end tell
|
||||
else if forkLiftVersion starts with "4" then
|
||||
tell pop over of list of group of splitter group of splitter group of topWindow
|
||||
keystroke "$PWD"
|
||||
delay 0.1
|
||||
end tell
|
||||
else
|
||||
tell sheet 1 of topWindow
|
||||
set value of text field 1 to "$PWD"
|
||||
|
|
|
|||
|
|
@ -13,12 +13,11 @@ ZSH_THEME_FOSSIL_PROMPT_DIRTY=" %{$fg_bold[red]%}✖"
|
|||
ZSH_THEME_FOSSIL_PROMPT_CLEAN=" %{$fg_bold[green]%}✔"
|
||||
|
||||
function fossil_prompt_info() {
|
||||
local info=$(fossil branch 2>&1)
|
||||
local branch=$(fossil branch current 2>&1)
|
||||
|
||||
# if we're not in a fossil repo, don't show anything
|
||||
! command grep -q "use --repo" <<< "$info" || return
|
||||
! command grep -q "use --repo" <<< "$branch" || return
|
||||
|
||||
local branch=$(echo $info | grep "* " | sed 's/* //g')
|
||||
local changes=$(fossil changes)
|
||||
local dirty="$ZSH_THEME_FOSSIL_PROMPT_CLEAN"
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue