diff options
author | Tuowen Zhao <ztuowen@gmail.com> | 2020-02-27 14:43:29 -0800 |
---|---|---|
committer | Tuowen Zhao <ztuowen@gmail.com> | 2020-02-27 14:43:29 -0800 |
commit | 0b67340fd2fe9330d8487491e1983ad1a111fb2b (patch) | |
tree | fe9cdff80e98deced5c63e79110593d430802adb /plugins | |
parent | 93a2003db7738e2255a4589ef2073df1be34fe02 (diff) | |
parent | 2b499e1a9e8788d607768ecef67851e8234b72b3 (diff) | |
download | zsh-0b67340fd2fe9330d8487491e1983ad1a111fb2b.tar.gz zsh-0b67340fd2fe9330d8487491e1983ad1a111fb2b.tar.bz2 zsh-0b67340fd2fe9330d8487491e1983ad1a111fb2b.zip |
Merge branch 'master' of https://github.com/ohmyzsh/ohmyzsh
Diffstat (limited to 'plugins')
34 files changed, 540 insertions, 417 deletions
diff --git a/plugins/arcanist/README.md b/plugins/arcanist/README.md index f2ca8cf55..9c15f09b5 100644 --- a/plugins/arcanist/README.md +++ b/plugins/arcanist/README.md @@ -1,5 +1,29 @@ ## arcanist -**Maintainer:** [@emzar](https://github.com/emzar) - This plugin adds many useful aliases for [arcanist](https://github.com/phacility/arcanist). + +To use it, add `arcanist` to the plugins array of your zshrc file: + +```zsh +plugins=(... arcanist) +``` + +## Aliases + +| Alias | Command | +|---------|------------------------------------| +| ara | `arc amend` | +| arb | `arc branch` | +| arco | `arc cover` | +| arci | `arc commit` | +| ard | `arc diff` | +| ardc | `arc diff --create` | +| ardnu | `arc diff --nounit` | +| ardnupc | `arc diff --nounit --plan-changes` | +| ardpc | `arc diff --plan-changes` | +| are | `arc export` | +| arh | `arc help` | +| arl | `arc land` | +| arli | `arc lint` | +| arls | `arc list` | +| arpa | `arc patch` | diff --git a/plugins/arcanist/arcanist.plugin.zsh b/plugins/arcanist/arcanist.plugin.zsh index 3f4eb07f4..8918bffdd 100644 --- a/plugins/arcanist/arcanist.plugin.zsh +++ b/plugins/arcanist/arcanist.plugin.zsh @@ -9,6 +9,7 @@ alias arco='arc cover' alias arci='arc commit' alias ard='arc diff' +alias ardc='arc diff --create' alias ardnu='arc diff --nounit' alias ardnupc='arc diff --nounit --plan-changes' alias ardpc='arc diff --plan-changes' diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index 6fe801c9f..4c4d0d4fc 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -18,10 +18,10 @@ if [[ "$OSTYPE" = darwin* ]]; then } function battery_pct() { - local smart_battery_status="$(ioreg -rc AppleSmartBattery)" - local -F maxcapacity=$(command grep '^.*"MaxCapacity"\ =\ ' <<< $smart_battery_status | sed -e 's/^.*"MaxCapacity"\ =\ //') - local -F currentcapacity=$(command grep '^.*"CurrentCapacity"\ =\ ' <<< $smart_battery_status | sed -e 's/^.*CurrentCapacity"\ =\ //') - echo $(( (currentcapacity/maxcapacity) * 100 )) + local battery_status="$(ioreg -rc AppleSmartBattery)" + local -i capacity=$(sed -n -e '/MaxCapacity/s/^.*"MaxCapacity"\ =\ //p' <<< $battery_status) + local -i current=$(sed -n -e '/CurrentCapacity/s/^.*"CurrentCapacity"\ =\ //p' <<< $battery_status) + echo $(( current * 100 / capacity )) } function battery_pct_remaining() { @@ -47,16 +47,17 @@ if [[ "$OSTYPE" = darwin* ]]; then } function battery_pct_prompt () { + local battery_pct color if ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ No'; then - b=$(battery_pct_remaining) - if [[ $b -gt 50 ]]; then + battery_pct=$(battery_pct_remaining) + if [[ $battery_pct -gt 50 ]]; then color='green' - elif [[ $b -gt 20 ]]; then + elif [[ $battery_pct -gt 20 ]]; then color='yellow' else color='red' fi - echo "%{$fg[$color]%}[$(battery_pct_remaining)%%]%{$reset_color%}" + echo "%{$fg[$color]%}[${battery_pct}%%]%{$reset_color%}" else echo "∞" fi @@ -93,19 +94,19 @@ elif [[ "$OSTYPE" = freebsd* ]]; then } function battery_pct_prompt() { - local b color - b=$(battery_pct_remaining) + local battery_pct color + battery_pct=$(battery_pct_remaining) if battery_is_charging; then echo "∞" else - if [[ $b -gt 50 ]]; then + if [[ $battery_pct -gt 50 ]]; then color='green' - elif [[ $b -gt 20 ]]; then + elif [[ $battery_pct -gt 20 ]]; then color='yellow' else color='red' fi - echo "%{$fg[$color]%}$(battery_pct_remaining)%%%{$reset_color%}" + echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}" fi } @@ -136,19 +137,19 @@ elif [[ "$OSTYPE" = linux* ]]; then } function battery_pct_prompt() { - local b color - b=$(battery_pct_remaining) + local battery_pct color + battery_pct=$(battery_pct_remaining) if battery_is_charging; then echo "∞" else - if [[ $b -gt 50 ]]; then + if [[ $battery_pct -gt 50 ]]; then color='green' - elif [[ $b -gt 20 ]]; then + elif [[ $battery_pct -gt 20 ]]; then color='yellow' else color='red' fi - echo "%{$fg[$color]%}$(battery_pct_remaining)%%%{$reset_color%}" + echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}" fi } diff --git a/plugins/cloudapp/README.md b/plugins/cloudapp/README.md index 62975a631..6c7f9bc6c 100644 --- a/plugins/cloudapp/README.md +++ b/plugins/cloudapp/README.md @@ -5,7 +5,7 @@ To use it, add `cloudapp` to the plugins array of your `~/.zshrc` file: ``` -plugins=(... dash) +plugins=(... cloudapp) ``` ## Requirements diff --git a/plugins/copybuffer/copybuffer.plugin.zsh b/plugins/copybuffer/copybuffer.plugin.zsh index cc205d40f..483ed5a5f 100644 --- a/plugins/copybuffer/copybuffer.plugin.zsh +++ b/plugins/copybuffer/copybuffer.plugin.zsh @@ -1,9 +1,9 @@ # copy the active line from the command line buffer -# onto the system clipboard (requires clipcopy plugin) +# onto the system clipboard copybuffer () { if which clipcopy &>/dev/null; then - echo $BUFFER | clipcopy + printf "%s" "$BUFFER" | clipcopy else echo "clipcopy function not found. Please make sure you have Oh My Zsh installed correctly." fi diff --git a/plugins/dotenv/README.md b/plugins/dotenv/README.md index cac552485..dbc02bf61 100644 --- a/plugins/dotenv/README.md +++ b/plugins/dotenv/README.md @@ -32,6 +32,8 @@ PORT=3001 ``` You can even mix both formats, although it's probably a bad idea. +## Plugin options + ### ZSH_DOTENV_FILE You can also modify the name of the file to be loaded with the variable `ZSH_DOTENV_FILE`. @@ -43,6 +45,10 @@ For example, this will make the plugin look for files named `.dotenv` and load t ZSH_DOTENV_FILE=.dotenv ``` +### ZSH_DOTENV_PROMPT + +Set `ZSH_DOTENV_PROMPT=false` in your zshrc file if you don't want the confirmation message. + ## Version Control **It's strongly recommended to add `.env` file to `.gitignore`**, because usually it contains sensitive information such as your credentials, secret keys, passwords etc. You don't want to commit this file, it's supposed to be local only. diff --git a/plugins/dotenv/dotenv.plugin.zsh b/plugins/dotenv/dotenv.plugin.zsh index d4a6db8f8..54036bee3 100644 --- a/plugins/dotenv/dotenv.plugin.zsh +++ b/plugins/dotenv/dotenv.plugin.zsh @@ -1,10 +1,15 @@ source_env() { if [[ -f $ZSH_DOTENV_FILE ]]; then - # confirm before sourcing .env file - local confirmation - echo -n "dotenv: source '$ZSH_DOTENV_FILE' file in the directory? (Y/n) " - if read -k 1 confirmation && [[ $confirmation = [nN] ]]; then - return + if [ "$ZSH_DOTENV_PROMPT" != "false" ]; then + # confirm before sourcing file + local confirmation + # print same-line prompt and output newline character if necessary + echo -n "dotenv: source '$ZSH_DOTENV_FILE' file in the directory? (Y/n) " + read -k 1 confirmation; [[ "$confirmation" != $'\n' ]] && echo + # only bail out if confirmation character is n + if [[ "$confirmation" = [nN] ]]; then + return + fi fi # test .env syntax diff --git a/plugins/dotnet/README.md b/plugins/dotnet/README.md index a663fc88d..7554b4e3c 100644 --- a/plugins/dotnet/README.md +++ b/plugins/dotnet/README.md @@ -20,4 +20,4 @@ plugins=(... dotnet) | 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. | -| dng | dotnet nuget | Provides additional NuGet commands. |
\ No newline at end of file +| dng | dotnet nuget | Provides additional NuGet commands. | diff --git a/plugins/dotnet/dotnet.plugin.zsh b/plugins/dotnet/dotnet.plugin.zsh index ed6c68e5d..6bd4b7af8 100644 --- a/plugins/dotnet/dotnet.plugin.zsh +++ b/plugins/dotnet/dotnet.plugin.zsh @@ -1,114 +1,27 @@ -# --------------------------------------------------------------------- # -# Aliases and Completions for .NET Core (https://dotnet.microsoft.com/) # -# Author: Shaun Tabone (https://github.com/xontab) # -# --------------------------------------------------------------------- # +# This scripts is copied from (MIT License): +# https://github.com/dotnet/toolset/blob/master/scripts/register-completions.zsh -# Helper function to cache and load completions -local cache_base_path="${ZSH_CACHE_DIR}/dotnet_" -_dotnet_cache_completion() { - local cache="${cache_base_path}$(echo $1)_completion" - if [[ ! -f $cache ]]; then - $2 $cache - fi +_dotnet_zsh_complete() +{ + local completions=("$(dotnet complete "$words")") - [[ -f $cache ]] && cat $cache -} + # If the completion list is empty, just continue with filename selection + if [ -z "$completions" ] + then + _arguments '*::arguments: _normal' + return + fi -_dotnet_cache_completion_cleanup() { - local cache="${cache_base_path}$(echo $1)_completion" - rm -f $cache + # This is not a variable assigment, don't remove spaces! + _values = "${(ps:\n:)completions}" } -# --------------------------------------------------------------------- # -# dotnet new # -# ALIAS: dn # -# --------------------------------------------------------------------- # -_dotnet_new_completion() { - if [ $commands[dotnet] ]; then - dotnet new -l | tail -n +21 | sed 's/ \+/:/g' | cut -d : -f 2 >$1 - fi -} +compdef _dotnet_zsh_complete dotnet -_dotnet_new_completion_cached() { - _dotnet_cache_completion 'new' _dotnet_new_completion -} - -_dotnet_cache_completion_cleanup 'new' +# Aliases bellow are here for backwards compatibility +# added by Shaun Tabone (https://github.com/xontab) alias dn='dotnet new' - -# --------------------------------------------------------------------- # -# dotnet # -# --------------------------------------------------------------------- # -_dotnet() { - if [ $CURRENT -eq 2 ]; then - _arguments \ - '--diagnostics[Enable diagnostic output.]' \ - '--help[Show command line help.]' \ - '--info[Display .NET Core information.]' \ - '--list-runtimes[Display the installed runtimes.]' \ - '--list-sdks[Display the installed SDKs.]' \ - '--version[Display .NET Core SDK version in use.]' - - _values \ - 'add[Add a package or reference to a .NET project.]' \ - 'build[Build a .NET project.]' \ - 'build-server[Interact with servers started by a build.]' \ - 'clean[Clean build outputs of a .NET project.]' \ - 'help[Show command line help.]' \ - 'list[List project references of a .NET project.]' \ - 'msbuild[Run Microsoft Build Engine (MSBuild) commands.]' \ - 'new[Create a new .NET project or file.]' \ - 'nuget[Provides additional NuGet commands.]' \ - 'pack[Create a NuGet package.]' \ - 'publish[Publish a .NET project for deployment.]' \ - 'remove[Remove a package or reference from a .NET project.]' \ - 'restore[Restore dependencies specified in a .NET project.]' \ - 'run[Build and run a .NET project output.]' \ - 'sln[Modify Visual Studio solution files.]' \ - 'store[Store the specified assemblies in the runtime package store.]' \ - 'test[Run unit tests using the test runner specified in a .NET project.]' \ - 'tool[Install or manage tools that extend the .NET experience.]' \ - 'vstest[Run Microsoft Test Engine (VSTest) commands.]' \ - 'dev-certs[Create and manage development certificates.]' \ - 'fsi[Start F# Interactive / execute F# scripts.]' \ - 'sql-cache[SQL Server cache command-line tools.]' \ - 'user-secrets[Manage development user secrets.]' \ - 'watch[Start a file watcher that runs a command when files change.]' - return - fi - - if [ $CURRENT -eq 3 ]; then - case ${words[2]} in - "new") - compadd -X ".NET Installed Templates" $(_dotnet_new_completion_cached) - return - ;; - "sln") - _values \ - 'add[Add one or more projects to a solution file.]' \ - 'list[List all projects in a solution file.]' \ - 'remove[Remove one or more projects from a solution file.]' - return - ;; - "nuget") - _values \ - 'delete[Deletes a package from the server.]' \ - 'locals[Clears or lists local NuGet resources such as http requests cache, packages folder, plugin operations cache or machine-wide global packages folder.]' \ - 'push[Pushes a package to the server and publishes it.]' - return - ;; - esac - fi - - _arguments '*::arguments: _normal' -} - -compdef _dotnet dotnet - -# --------------------------------------------------------------------- # -# Other Aliases # -# --------------------------------------------------------------------- # alias dr='dotnet run' alias dt='dotnet test' alias dw='dotnet watch' diff --git a/plugins/fzf/fzf.plugin.zsh b/plugins/fzf/fzf.plugin.zsh index c8aefd7ab..53bdcbc97 100644 --- a/plugins/fzf/fzf.plugin.zsh +++ b/plugins/fzf/fzf.plugin.zsh @@ -10,6 +10,7 @@ function setup_using_base_dir() { if [[ -z "${fzf_base}" ]]; then fzfdirs=( "${HOME}/.fzf" + "${HOME}/.nix-profile/share/fzf" "/usr/local/opt/fzf" "/usr/share/fzf" "/usr/local/share/examples/fzf" @@ -31,8 +32,8 @@ function setup_using_base_dir() { fi if [[ -d "${fzf_base}" ]]; then - # Fix fzf shell directory for Archlinux package - if [[ ! -d "${fzf_base}/shell" ]] && [[ -f /etc/arch-release ]]; then + # Fix fzf shell directory for Arch Linux, NixOS or Void Linux packages + if [[ ! -d "${fzf_base}/shell" ]]; then fzf_shell="${fzf_base}" else fzf_shell="${fzf_base}/shell" diff --git a/plugins/git/README.md b/plugins/git/README.md index 7878f747b..009a74016 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -10,194 +10,196 @@ plugins=(... git) ## Aliases -| Alias | Command | -|:---------------------|:------------------------------------------------------------------------------------------------------------------------------| -| g | git | -| ga | git add | -| gaa | git add --all | -| gapa | git add --patch | -| gau | git add --update | -| gav | git add --verbose | -| gap | git apply | -| gb | git branch | -| gba | git branch -a | -| gbd | git branch -d | +| Alias | Command | +|:---------------------|:---------------------------------------------------------------------------------------------------------------------------------| +| g | git | +| ga | git add | +| gaa | git add --all | +| gapa | git add --patch | +| gau | git add --update | +| gav | git add --verbose | +| gap | git apply | +| gb | git branch | +| gba | git branch -a | +| gbd | git branch -d | | gbda | git branch --no-color --merged \| command grep -vE "^(\+|\*\|\s*(master\|develop\|dev)\s*$)" \| command xargs -n 1 git branch -d | -| gbD | git branch -D | -| gbl | git blame -b -w | -| gbnm | git branch --no-merged | -| gbr | git branch --remote | -| gbs | git bisect | -| gbsb | git bisect bad | -| gbsg | git bisect good | -| gbsr | git bisect reset | -| gbss | git bisect start | -| gc | git commit -v | -| gc! | git commit -v --amend | -| gcn! | git commit -v --no-edit --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 | -| gcam | git commit -a -m | -| gcsm | git commit -s -m | -| gcb | git checkout -b | -| gcf | git config --list | -| gcl | git clone --recurse-submodules | -| gclean | git clean -id | -| gpristine | git reset --hard && git clean -dfx | -| gcm | git checkout master | -| gcd | git checkout develop | -| gcmsg | git commit -m | -| gco | git checkout | -| gcount | git shortlog -sn | -| gcp | git cherry-pick | -| gcpa | git cherry-pick --abort | -| gcpc | git cherry-pick --continue | -| gcs | git commit -S | -| gd | git diff | -| gdca | git diff --cached | -| gdcw | git diff --cached --word-diff | -| gdct | git describe --tags $(git rev-list --tags --max-count=1) | -| gds | git diff --staged | -| gdt | git diff-tree --no-commit-id --name-only -r | -| gdv | git diff -w $@ \| view - | -| gdw | git diff --word-diff | -| gf | git fetch | -| gfa | git fetch --all --prune | -| gfg | git ls-files \| grep | -| gfo | git fetch origin | -| gg | git gui citool | -| gga | git gui citool --amend | -| ggf | git push --force origin $(current_branch) | -| ggfl | git push --force-with-lease origin $(current_branch) | -| ggl | git pull origin $(current_branch) | -| ggp | git push origin $(current_branch) | -| ggpnp | ggl && ggp | -| ggpull | git pull origin "$(git_current_branch)" | -| ggpur | ggu | -| ggpush | git push origin "$(git_current_branch)" | -| ggsup | git branch --set-upstream-to=origin/$(git_current_branch) | -| ggu | git pull --rebase origin $(current_branch) | -| gpsup | git push --set-upstream origin $(git_current_branch) | -| ghh | git help | -| gignore | git update-index --assume-unchanged | -| gignored | git ls-files -v \| grep "^[[:lower:]]" | -| git-svn-dcommit-push | git svn dcommit && git push github master:svntrunk | -| gk | gitk --all --branches | -| gke | gitk --all $(git log -g --pretty=%h) | -| gl | git pull | -| glg | git log --stat | -| glgp | git log --stat -p | -| glgg | git log --graph | -| glgga | git log --graph --decorate --all | -| glgm | git log --graph --max-count=10 | -| glo | git log --oneline --decorate | -| glol | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' | -| glols | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --stat | -| glod | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' | -| glods | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short | -| glola | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all | -| glog | git log --oneline --decorate --graph | -| gloga | git log --oneline --decorate --graph --all | -| glp | `_git_log_prettily` | -| gm | git merge | -| gmom | git merge origin/master | -| gmt | git mergetool --no-prompt | -| gmtvim | git mergetool --no-prompt --tool=vimdiff | -| gmum | git merge upstream/master | -| gma | git merge --abort | -| gp | git push | -| gpd | git push --dry-run | -| gpf | git push --force-with-lease | -| gpf! | git push --force | -| gpoat | git push origin --all && git push origin --tags | -| gpu | git push upstream | -| gpv | git push -v | -| gr | git remote | -| gra | git remote add | -| grb | git rebase | -| grba | git rebase --abort | -| grbc | git rebase --continue | -| grbd | git rebase develop | -| grbi | git rebase -i | -| grbm | git rebase master | -| grbs | git rebase --skip | -| grev | git revert | -| grh | git reset | -| grhh | git reset --hard | -| groh | git reset origin/$(git_current_branch) --hard | -| grm | git rm | -| grmc | git rm --cached | -| grmv | git remote rename | -| grrm | git remote remove | -| grs | git restore | -| grset | git remote set-url | -| grss | git restore --source | -| grt | cd "$(git rev-parse --show-toplevel \|\| echo .)" | -| gru | git reset -- | -| grup | git remote update | -| grv | git remote -v | -| gsb | git status -sb | -| gsd | git svn dcommit | -| gsh | git show | -| gsi | git submodule init | -| gsps | git show --pretty=short --show-signature | -| gsr | git svn rebase | -| gss | git status -s | -| gst | git status | -| gsta | git stash push | -| gsta | git stash save | -| gstaa | git stash apply | -| gstc | git stash clear | -| gstd | git stash drop | -| gstl | git stash list | -| gstp | git stash pop | -| gsts | git stash show --text | -| gstall | git stash --all | -| gsu | git submodule update | -| gsw | git switch | -| gswc | git switch -c | -| gts | git tag -s | -| gtv | git tag \| sort -V | -| gtl | gtl(){ git tag --sort=-v:refname -n -l ${1}* }; noglob gtl | -| gunignore | git update-index --no-assume-unchanged | -| gunwip | git log -n 1 \| grep -q -c "\-\-wip\-\-" && git reset HEAD~1 | -| gup | git pull --rebase | -| gupv | git pull --rebase -v | -| gupa | git pull --rebase --autostash | -| gupav | git pull --rebase --autostash -v | -| glum | git pull upstream master | -| gwch | git whatchanged -p --abbrev-commit --pretty=medium | -| gwip | git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]" | +| gbD | git branch -D | +| gbl | git blame -b -w | +| gbnm | git branch --no-merged | +| gbr | git branch --remote | +| gbs | git bisect | +| gbsb | git bisect bad | +| gbsg | git bisect good | +| gbsr | git bisect reset | +| gbss | git bisect start | +| gc | git commit -v | +| gc! | git commit -v --amend | +| gcn! | git commit -v --no-edit --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 | +| gcam | git commit -a -m | +| gcsm | git commit -s -m | +| gcb | git checkout -b | +| gcf | git config --list | +| gcl | git clone --recurse-submodules | +| gclean | git clean -id | +| gpristine | git reset --hard && git clean -dfx | +| gcm | git checkout master | +| gcd | git checkout develop | +| gcmsg | git commit -m | +| gco | git checkout | +| gcount | git shortlog -sn | +| gcp | git cherry-pick | +| gcpa | git cherry-pick --abort | +| gcpc | git cherry-pick --continue | +| gcs | git commit -S | +| gd | git diff | +| gdca | git diff --cached | +| gdcw | git diff --cached --word-diff | +| gdct | git describe --tags $(git rev-list --tags --max-count=1) | +| gds | git diff --staged | +| gdt | git diff-tree --no-commit-id --name-only -r | +| gdv | git diff -w $@ \| view - | +| gdw | git diff --word-diff | +| gf | git fetch | +| gfa | git fetch --all --prune | +| gfg | git ls-files \| grep | +| gfo | git fetch origin | +| gg | git gui citool | +| gga | git gui citool --amend | +| ggf | git push --force origin $(current_branch) | +| ggfl | git push --force-with-lease origin $(current_branch) | +| ggl | git pull origin $(current_branch) | +| ggp | git push origin $(current_branch) | +| ggpnp | ggl && ggp | +| ggpull | git pull origin "$(git_current_branch)" | +| ggpur | ggu | +| ggpush | git push origin "$(git_current_branch)" | +| ggsup | git branch --set-upstream-to=origin/$(git_current_branch) | +| ggu | git pull --rebase origin $(current_branch) | +| gpsup | git push --set-upstream origin $(git_current_branch) | +| ghh | git help | +| gignore | git update-index --assume-unchanged | +| gignored | git ls-files -v \| grep "^[[:lower:]]" | +| git-svn-dcommit-push | git svn dcommit && git push github master:svntrunk | +| gk | gitk --all --branches | +| gke | gitk --all $(git log -g --pretty=%h) | +| gl | git pull | +| glg | git log --stat | +| glgp | git log --stat -p | +| glgg | git log --graph | +| glgga | git log --graph --decorate --all | +| glgm | git log --graph --max-count=10 | +| glo | git log --oneline --decorate | +| glol | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' | +| glols | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --stat | +| glod | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' | +| glods | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short | +| glola | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all | +| glog | git log --oneline --decorate --graph | +| gloga | git log --oneline --decorate --graph --all | +| glp | `_git_log_prettily` | +| gm | git merge | +| gmom | git merge origin/master | +| gmt | git mergetool --no-prompt | +| gmtvim | git mergetool --no-prompt --tool=vimdiff | +| gmum | git merge upstream/master | +| gma | git merge --abort | +| gp | git push | +| gpd | git push --dry-run | +| gpf | git push --force-with-lease | +| gpf! | git push --force | +| gpoat | git push origin --all && git push origin --tags | +| gpu | git push upstream | +| gpv | git push -v | +| gr | git remote | +| gra | git remote add | +| grb | git rebase | +| grba | git rebase --abort | +| grbc | git rebase --continue | +| grbd | git rebase develop | +| grbi | git rebase -i | +| grbm | git rebase master | +| grbs | git rebase --skip | +| grev | git revert | +| grh | git reset | +| grhh | git reset --hard | +| groh | git reset origin/$(git_current_branch) --hard | +| grm | git rm | +| grmc | git rm --cached | +| grmv | git remote rename | +| grrm | git remote remove | +| grs | git restore | +| grset | git remote set-url | +| grss | git restore --source | +| grt | cd "$(git rev-parse --show-toplevel \|\| echo .)" | +| gru | git reset -- | +| grup | git remote update | +| grv | git remote -v | +| gsb | git status -sb | +| gsd | git svn dcommit | +| gsh | git show | +| gsi | git submodule init | +| gsps | git show --pretty=short --show-signature | +| gsr | git svn rebase | +| gss | git status -s | +| gst | git status | +| gsta | git stash push | +| gsta | git stash save | +| gstaa | git stash apply | +| gstc | git stash clear | +| gstd | git stash drop | +| gstl | git stash list | +| gstp | git stash pop | +| gsts | git stash show --text | +| gstu | git stash --include-untracked | +| gstall | git stash --all | +| gsu | git submodule update | +| gsw | git switch | +| gswc | git switch -c | +| gts | git tag -s | +| gtv | git tag \| sort -V | +| gtl | gtl(){ git tag --sort=-v:refname -n -l ${1}* }; noglob gtl | +| gunignore | git update-index --no-assume-unchanged | +| gunwip | git log -n 1 \| grep -q -c "\-\-wip\-\-" && git reset HEAD~1 | +| gup | git pull --rebase | +| gupv | git pull --rebase -v | +| gupa | git pull --rebase --autostash | +| gupav | git pull --rebase --autostash -v | +| glum | git pull upstream master | +| gwch | git whatchanged -p --abbrev-commit --pretty=medium | +| gwip | git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]" | ### Deprecated These are aliases that have been removed, renamed, or otherwise modified in a way that may, or may not, receive further support. -| Alias | Command | Modification | -| :----- | :----------------------------------------------------------------------------------| --------------------------------------------------------------------------------------------------- | -| gap | git add --patch | new alias `gapa` | -| gcl | git config --list | new alias `gcf` | -| gdc | git diff --cached | new alias `gdca` | -| gdt | git difftool | no replacement | -| ggpull | git pull origin $(current_branch) | new alias `ggl` (`ggpull` still exists for now though) | -| ggpur | git pull --rebase origin $(current_branch) | new alias `ggu` (`ggpur` still exists for now though) | -| ggpush | git push origin $(current_branch) | new alias `ggp` (`ggpush` still exists for now though) | -| gk | gitk --all --branches | now aliased to `gitk --all --branches` | -| glg | git log --stat --max-count = 10 | now aliased to `git log --stat --color` | -| glgg | git log --graph --max-count = 10 | now aliased to `git log --graph --color` | -| gwc | git whatchanged -p --abbrev-commit --pretty = medium | new alias `gwch` | +| Alias | Command | Modification | +| :----- | :----------------------------------------------------- | :----------------------------------------------------- | +| gap | `git add --patch` | new alias `gapa` | +| gcl | `git config --list` | new alias `gcf` | +| gdc | `git diff --cached` | new alias `gdca` | +| gdt | `git difftool` | no replacement | +| ggpull | `git pull origin $(current_branch)` | new alias `ggl` (`ggpull` still exists for now though) | +| ggpur | `git pull --rebase origin $(current_branch)` | new alias `ggu` (`ggpur` still exists for now though) | +| ggpush | `git push origin $(current_branch)` | new alias `ggp` (`ggpush` still exists for now though) | +| gk | `gitk --all --branches` | now aliased to `gitk --all --branches` | +| glg | `git log --stat --max-count = 10` | now aliased to `git log --stat --color` | +| glgg | `git log --graph --max-count = 10` | now aliased to `git log --graph --color` | +| gwc | `git whatchanged -p --abbrev-commit --pretty = medium` | new alias `gwch` | ## Functions ### Current -| Command | Description | -|:-----------------------|:----------------------------------------| -| current_branch | Return the name of the current branch | -| git_current_user_name | Returns the `user.name` config value | -| git_current_user_email | Returns the `user.email` config value | +| Command | Description | +|:-----------------------|:---------------------------------------------------------| +| `grename <old> <new>` | Rename `old` branch to `new`, including in origin remote | +| current_branch | Return the name of the current branch | +| git_current_user_name | Returns the `user.name` config value | +| git_current_user_email | Returns the `user.email` config value | ### Work in Progress (WIP) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index d8c4cffd1..ffb3e506a 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -236,6 +236,7 @@ alias gstd='git stash drop' alias gstl='git stash list' alias gstp='git stash pop' alias gsts='git stash show --text' +alias gstu='git stash --include-untracked' alias gstall='git stash --all' alias gsu='git submodule update' alias gsw='git switch' @@ -255,3 +256,17 @@ alias glum='git pull upstream master' alias gwch='git whatchanged -p --abbrev-commit --pretty=medium' alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]"' + +function grename() { + if [[ -z "$1" || -z "$2" ]]; then + echo "Usage: $0 old_branch new_branch" + return 1 + fi + + # Rename branch locally + git branch -m "$1" "$2" + # Rename branch in origin remote + if git push origin :"$1"; then + git push --set-upstream origin "$2" + fi +} diff --git a/plugins/jfrog/README.md b/plugins/jfrog/README.md new file mode 100644 index 000000000..1d858620b --- /dev/null +++ b/plugins/jfrog/README.md @@ -0,0 +1,11 @@ +# JFrog CLI + +This plugin provides completion for [JFrog CLI](https://github.com/jfrog/jfrog-cli). + +JFrog CLI provides a simple interface that automates access to [Artifactory](https://jfrog.com/artifactory), [Xray](https://jfrog.com/xray), [Bintray](https://jfrog.com/bintray) and [Mission Control](https://jfrog.com/mission-control) through their respective REST APIs. + +To use it, add `jfrog` to the plugins array in your zshrc file: + +```zsh +plugins=(... jfrog) +``` diff --git a/plugins/jfrog/jfrog.plugin.zsh b/plugins/jfrog/jfrog.plugin.zsh new file mode 100644 index 000000000..064ffa2db --- /dev/null +++ b/plugins/jfrog/jfrog.plugin.zsh @@ -0,0 +1,10 @@ +_jfrog() { + local -a opts + opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}") + _describe 'values' opts + if [[ $compstate[nmatches] -eq 0 && $words[$CURRENT] != -* ]]; then + _files + fi +} + +compdef _jfrog jfrog
\ No newline at end of file diff --git a/plugins/jhbuild/README.md b/plugins/jhbuild/README.md index 910526966..3220e0daf 100644 --- a/plugins/jhbuild/README.md +++ b/plugins/jhbuild/README.md @@ -1,4 +1,34 @@ -## JHBuild +# JHBuild + +This plugin adds some [JHBuild](https://developer.gnome.org/jhbuild/) aliases. + +To use it, add `jhbuild` to the plugins array of your zshrc file: + +```zsh +plugins=(... jhbuild) +``` + **Maintainer:** [Miguel Vaello](https://github.com/miguxbe) -This plugin adds some jhbuild aliases and increase the completion function provided by zsh. +## Aliases + +| Alias | Command | +|---------|---------------------------| +| `jh` | `jhbuild` | +| `jhb` | `jhbuild build` | +| `jhbo` | `jhbuild buildone` | +| `jhckb` | `jhbuild checkbranches` | +| `jhckm` | `jhbuild checkmodulesets` | +| `jhi` | `jhbuild info` | +| `jhl` | `jhbuild list` | +| `jhc` | `jhbuild clean` | +| `jhco` | `jhbuild cleanone` | +| `jhm` | `jhbuild make` | +| `jhr` | `jhbuild run` | +| `jhrd` | `jhbuild rdepends` | +| `jhsd` | `jhbuild sysdeps` | +| `jhu` | `jhbuild update` | +| `jhuo` | `jhbuild updateone` | +| `jhun` | `jhbuild uninstall` | +| `jhsh` | `jhbuild shell` | +| `jht` | `jhbuild tinderbox` | diff --git a/plugins/jhbuild/jhbuild.plugin.zsh b/plugins/jhbuild/jhbuild.plugin.zsh index fed1bc9fc..416745d27 100644 --- a/plugins/jhbuild/jhbuild.plugin.zsh +++ b/plugins/jhbuild/jhbuild.plugin.zsh @@ -1,5 +1,6 @@ -# Aliases -# +# JHBuild Aliases + +# Base alias jh='jhbuild' # Build alias jhb='jhbuild build' @@ -7,12 +8,14 @@ alias jhbo='jhbuild buildone' # Checks alias jhckb='jhbuild checkbranches' alias jhckm='jhbuild checkmodulesets' -# Info & list +# Info & List alias jhi='jhbuild info' alias jhl='jhbuild list' # Clean alias jhc='jhbuild clean' alias jhco='jhbuild cleanone' +# Make +alias jhm='jhbuild make' # Run alias jhr='jhbuild run' # Depends @@ -23,6 +26,7 @@ alias jhu='jhbuild update' alias jhuo='jhbuild updateone' # Uninstall alias jhun='jhbuild uninstall' - - - +# Shell +alias jhsh='jhbuild shell' +# Tinderbox +alias jht='jhbuild tinderbox' diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh index cc447b87e..92688c53c 100644 --- a/plugins/kubectl/kubectl.plugin.zsh +++ b/plugins/kubectl/kubectl.plugin.zsh @@ -14,7 +14,7 @@ fi alias k=kubectl # Execute a kubectl command against all namespaces -alias kca='f(){ kubectl "$@" --all-namespaces; unset -f f; }; f' +alias kca='_kca(){ kubectl "$@" --all-namespaces; unset -f _kca; }; _kca' # Apply a YML file alias kaf='kubectl apply -f' diff --git a/plugins/macports/_port b/plugins/macports/_port index 06d7fb426..6a9ebe0c6 100644 --- a/plugins/macports/_port +++ b/plugins/macports/_port @@ -41,6 +41,8 @@ subcmds=( 'patch' 'pkg' 'provides' +'rdependents' +'rdeps' 'rpmpackage' 'search' 'selfupdate' diff --git a/plugins/ng/README.md b/plugins/ng/README.md index 94a450c18..29ac15aa4 100644 --- a/plugins/ng/README.md +++ b/plugins/ng/README.md @@ -1,37 +1,10 @@ -## NG Plugin +# ng plugin -This [ng plugin](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/ng) - adds completion support for Angular's CLI (named ng). +This plugin adds autocompletion support for [Angular's CLI](https://github.com/angular/angular-cli) +(named `ng`). -Ng is hosted on [ng home](https://github.com/catull/angular-cli) - -It is used to generate Angular 2 app "stubs", build those apps, configure them, -test them, lint them etc. - -Ahem, "stubs" is not what Angular engineers refer to the items ng can generate -for you. - -"Stubs" can be any one of: -- class -- component -- directive -- enum -- module -- pipe -- route -- service - -At the moment, `ng completion` creates a very rough completion for Zsh and -Bash. - -It is missing most of the options and a few arguments. -In future, this plugin may be shortened to simply being +To use it, add `ng` to the plugins array of your zshrc file: ```zsh -eval `ng completion` +plugins=(... ng) ``` - -There is hope this materialises in the 21st century. - -### CONTRIBUTOR - - Carlo Dapor ([catull](https://github.com/catull)) diff --git a/plugins/nmap/README.md b/plugins/nmap/README.md index 5cd646277..0a60068c2 100644 --- a/plugins/nmap/README.md +++ b/plugins/nmap/README.md @@ -1,37 +1,27 @@ -# Nmap aliases plugin +# Nmap plugin -Adds some useful aliases for nmap similar to the profiles in zenmap. +Adds some useful aliases for [Nmap](https://nmap.org/) similar to the profiles in zenmap. -Nmap options are: - * -sS - TCP SYN scan - * -v - verbose - * -T1 - timing of scan. Options are paranoid (0), sneaky (1), polite (2), normal (3), aggressive (4), and insane (5) - * -sF - FIN scan (can sneak through non-stateful firewalls) - * -PE - ICMP echo discovery probe - * -PP - timestamp discovery probe - * -PY - SCTP init ping - * -g - use given number as source port - * -A - enable OS detection, version detection, script scanning, and traceroute (aggressive) - * -O - enable OS detection - * -sA - TCP ACK scan - * -F - fast scan - * --script=vulscan - also access vulnerabilities in target +To use it, add `nmap` to the plugins array in your zshrc file: -## Aliases explained +```zsh +plugins=(... nmap) +``` - * nmap_open_ports - Scan for open ports on target - * nmap_list_interfaces - List all network interfaces on host where the command runs - * nmap_slow - Slow scan that avoids to spam the targets logs - * nmap_fin - Scan to see if hosts are up with TCP FIN scan - * nmap_full - Aggressive full scan that scans all ports, tries to determine OS and service versions - * nmap_check_for_firewall - TCP ACK scan to check for firewall existence - * nmap_ping_through_firewall - Host discovery with SYN and ACK probes instead of just pings to avoid firewall - restrictions - * nmap_fast - Fast scan of the top 300 popular ports - * nmap_detect_versions - Detects versions of services and OS, runs on all ports - * nmap_check_for_vulns - Uses vulscan script to check target services for vulnerabilities - * nmap_full_udp - Same as full but via UDP - * nmap_traceroute - Try to traceroute using the most common ports - * nmap_full_with_scripts - Same as nmap_full but also runs all the scripts - * nmap_web_safe_osscan - Little "safer" scan for OS version as connecting to only HTTP and HTTPS ports doesn't look so attacking. +## Aliases +- `nmap_open_ports`: scan for open ports on target. +- `nmap_list_interfaces`: list all network interfaces on host where the command runs. +- `nmap_slow`: slow scan that avoids to spam the targets logs. +- `nmap_fin`: scan to see if hosts are up with TCP FIN scan. +- `nmap_full`: aggressive full scan that scans all ports, tries to determine OS and service versions. +- `nmap_check_for_firewall`: TCP ACK scan to check for firewall existence. +- `nmap_ping_through_firewall`: host discovery with SYN and ACK probes instead of just pings to avoid firewall restrictions. +- `nmap_fast`: fast scan of the top 300 popular ports. +- `nmap_detect_versions`: detects versions of services and OS, runs on all ports. +- `nmap_check_for_vulns`: uses vulscan script to check target services for vulnerabilities. +- `nmap_full_udp`: same as full but via UDP. +- `nmap_traceroute`: try to traceroute using the most common ports. +- `nmap_full_with_scripts`: same as nmap_full but also runs all the scripts. +- `nmap_web_safe_osscan`: little "safer" scan for OS version as connecting to only HTTP and HTTPS ports doesn't look so attacking. +- `nmap_ping_scan`: ICMP scan for active hosts. diff --git a/plugins/nmap/nmap.plugin.zsh b/plugins/nmap/nmap.plugin.zsh index 8c691bdaa..406870f00 100644 --- a/plugins/nmap/nmap.plugin.zsh +++ b/plugins/nmap/nmap.plugin.zsh @@ -29,4 +29,4 @@ alias nmap_full_udp="sudo nmap -sS -sU -T4 -A -v -PE -PS22,25,80 -PA21,23,80,443 alias nmap_traceroute="sudo nmap -sP -PE -PS22,25,80 -PA21,23,80,3389 -PU -PO --traceroute " alias nmap_full_with_scripts="sudo nmap -sS -sU -T4 -A -v -PE -PP -PS21,22,23,25,80,113,31339 -PA80,113,443,10042 -PO --script all " alias nmap_web_safe_osscan="sudo nmap -p 80,443 -O -v --osscan-guess --fuzzy " - +alias nmap_ping_scan="nmap -n -sP" diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index f62174a4f..87c68f3fb 100644 --- a/plugins/npm/npm.plugin.zsh +++ b/plugins/npm/npm.plugin.zsh @@ -1,14 +1,16 @@ (( $+commands[npm] )) && { - __NPM_COMPLETION_FILE="${ZSH_CACHE_DIR:-$ZSH/cache}/npm_completion" - - if [[ ! -f $__NPM_COMPLETION_FILE ]]; then - npm completion >! $__NPM_COMPLETION_FILE 2>/dev/null - [[ $? -ne 0 ]] && rm -f $__NPM_COMPLETION_FILE - fi - - [[ -f $__NPM_COMPLETION_FILE ]] && source $__NPM_COMPLETION_FILE - - unset __NPM_COMPLETION_FILE + rm -f "${ZSH_CACHE_DIR:-$ZSH/cache}/npm_completion" + + _npm_completion() { + local si=$IFS + compadd -- $(COMP_CWORD=$((CURRENT-1)) \ + COMP_LINE=$BUFFER \ + COMP_POINT=0 \ + npm completion -- "${words[@]}" \ + 2>/dev/null) + IFS=$si + } + compdef _npm_completion npm } # Install dependencies globally diff --git a/plugins/python/README.md b/plugins/python/README.md index 2d955c5cb..e391bcfd4 100644 --- a/plugins/python/README.md +++ b/plugins/python/README.md @@ -14,3 +14,4 @@ plugins=(... python) | `pyfind` | Finds .py files recursively in the current directory | | `pyclean [dirs]` | Deletes byte-code and cache files from a list of directories or the current one | | `pygrep <text>` | Looks for `text` in .py files | +| `ipython` | Runs the appropriate `ipython` version according to the activated virtualenv | diff --git a/plugins/python/python.plugin.zsh b/plugins/python/python.plugin.zsh index f39cd80b7..62855fca2 100644 --- a/plugins/python/python.plugin.zsh +++ b/plugins/python/python.plugin.zsh @@ -14,3 +14,5 @@ function pyclean() { # Grep among .py files alias pygrep='grep -r --include="*.py"' +# Run proper IPython regarding current virtualenv (if any) +alias ipython="python -c 'import IPython; IPython.terminal.ipapp.launch_new_instance()'" diff --git a/plugins/systemd/README.md b/plugins/systemd/README.md index d91329290..3fa1d2118 100644 --- a/plugins/systemd/README.md +++ b/plugins/systemd/README.md @@ -51,3 +51,44 @@ plugins=(... systemd) You can use the above aliases as `--user` by using the prefix `scu` instead of `sc`. For example: `scu-list-units` will be aliased to `systemctl --user list-units`. + +### Unit Status Prompt + +You can add a token to your prompt in a similar way to the gitfast plugin. To add the token +to your prompt, drop `$(systemd_prompt_info [unit]...)` into your prompt (more than one unit +may be specified). + +The plugin will add the following to your prompt for each `$unit`. +``` +<prefix><unit>:<active|notactive><suffix> +``` +You can control these parts with the following variables: + +- `<prefix>`: Set `$ZSH_THEME_SYSTEMD_PROMPT_PREFIX`. + +- `<suffix>`: Set `$ZSH_THEME_SYSTEMD_PROMPT_SUFFIX`. + +- `<unit>`: name passed as parameter to the function. If you want it to be in ALL CAPS, + you can set the variable `$ZSH_THEME_SYSTEMD_PROMPT_CAPS` to a non-empty string. + +- `<active>`: shown if the systemd unit is active. + Set `$ZSH_THEME_SYSTEMD_PROMPT_ACTIVE`. + +- `<notactive>`: shown if the systemd unit is *not* active. + Set `$ZSH_THEME_SYSTEMD_PROMPT_NOTACTIVE`. + +For example, if your prompt contains `PROMPT='$(systemd_prompt_info dhcpd httpd)'` and you set the following variables: + +``` +ZSH_THEME_SYSTEMD_PROMPT_PREFIX="[" +ZSH_THEME_SYSTEMD_PROMPT_SUFFIX="]" +ZSH_THEME_SYSTEMD_PROMPT_ACTIVE="+" +ZSH_THEME_SYSTEMD_PROMPT_NOTACTIVE="X" +ZSH_THEME_SYSTEMD_PROMPT_CAPS=1 +``` + +If `dhcpd` is running, and `httpd` is not, then your prompt will look like this: + +``` +[DHCPD: +][HTTPD: X] +``` diff --git a/plugins/systemd/systemd.plugin.zsh b/plugins/systemd/systemd.plugin.zsh index 201ffd998..f2d1d6f1c 100644 --- a/plugins/systemd/systemd.plugin.zsh +++ b/plugins/systemd/systemd.plugin.zsh @@ -73,3 +73,18 @@ alias sc-mask-now="sc-mask --now" alias scu-enable-now="scu-enable --now" alias scu-disable-now="scu-disable --now" alias scu-mask-now="scu-mask --now" + +function systemd_prompt_info { + local unit + for unit in $@; do + echo -n "$ZSH_THEME_SYSTEMD_PROMPT_PREFIX" + [[ -n "$ZSH_THEME_SYSTEMD_PROMPT_CAPS" ]] && echo "${(U)unit}:" || echo "$unit:" + if systemctl is-active $unit &>/dev/null; then + echo -n "$ZSH_THEME_SYSTEMD_PROMPT_ACTIVE" + else + echo -n "$ZSH_THEME_SYSTEMD_PROMPT_NOTACTIVE" + fi + echo -n "$ZSH_THEME_SYSTEMD_PROMPT_SUFFIX" + done +} + diff --git a/plugins/themes/_theme b/plugins/themes/_theme deleted file mode 100644 index 8214ddb0d..000000000 --- a/plugins/themes/_theme +++ /dev/null @@ -1,3 +0,0 @@ -#compdef theme - -_arguments "1: :($(lstheme | tr "\n" " "))" diff --git a/plugins/themes/themes.plugin.zsh b/plugins/themes/themes.plugin.zsh index 2cd0ee327..1fbde5b64 100644 --- a/plugins/themes/themes.plugin.zsh +++ b/plugins/themes/themes.plugin.zsh @@ -1,26 +1,27 @@ -function theme -{ - if [ -z "$1" ] || [ "$1" = "random" ]; then - themes=($ZSH/themes/*zsh-theme) - N=${#themes[@]} - ((N=(RANDOM%N)+1)) - RANDOM_THEME=${themes[$N]} - source "$RANDOM_THEME" - echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..." +function theme { + : ${1:=random} # Use random theme if none provided + + if [[ -f "$ZSH_CUSTOM/$1.zsh-theme" ]]; then + source "$ZSH_CUSTOM/$1.zsh-theme" + elif [[ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]]; then + source "$ZSH_CUSTOM/themes/$1.zsh-theme" + elif [[ -f "$ZSH/themes/$1.zsh-theme" ]]; then + source "$ZSH/themes/$1.zsh-theme" else - if [ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ] - then - source "$ZSH_CUSTOM/themes/$1.zsh-theme" - else - source "$ZSH/themes/$1.zsh-theme" - fi + echo "$0: Theme '$1' not found" + return 1 fi } -function lstheme -{ +function _theme { + _arguments "1: :($(lstheme))" +} + +compdef _theme theme + +function lstheme { # Resources: # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Modifiers # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Glob-Qualifiers - print -l {$ZSH,$ZSH_CUSTOM}/themes/*.zsh-theme(N:t:r) + print "$ZSH_CUSTOM"/*.zsh-theme(N:t:r) {"$ZSH_CUSTOM","$ZSH"}/themes/*.zsh-theme(N:t:r) } diff --git a/plugins/vagrant/README.md b/plugins/vagrant/README.md index f6ea87b0e..331bfa143 100644 --- a/plugins/vagrant/README.md +++ b/plugins/vagrant/README.md @@ -8,3 +8,33 @@ To use it, add `vagrant` to the plugins array in your zshrc file: plugins=(... vagrant) ``` +## Aliases + +| Alias | Command | +|---------|------------------------------| +| `vgi` | `vagrant init` | +| `vup` | `vagrant up` | +| `vd` | `vagrant destroy` | +| `vdf` | `vagrant destroy -f` | +| `vssh` | `vagrant ssh` | +| `vsshc` | `vagrant ssh-config` | +| `vrdp` | `vagrant rdp` | +| `vh` | `vagrant halt` | +| `vssp` | `vagrant suspend` | +| `vst` | `vagrant status` | +| `vre` | `vagrant resume` | +| `vgs` | `vagrant global-status` | +| `vpr` | `vagrant provision` | +| `vr` | `vagrant reload` | +| `vrp` | `vagrant reload --provision` | +| `vp` | `vagrant push` | +| `vsh` | `vagrant share` | +| `vba` | `vagrant box add` | +| `vbr` | `vagrant box remove` | +| `vbl` | `vagrant box list` | +| `vbo` | `vagrant box outdated` | +| `vbu` | `vagrant box update` | +| `vpli` | `vagrant plugin install` | +| `vpll` | `vagrant plugin list` | +| `vplun` | `vagrant plugin uninstall` | +| `vplu` | `vagrant plugin update` | diff --git a/plugins/vagrant/vagrant.plugin.zsh b/plugins/vagrant/vagrant.plugin.zsh new file mode 100644 index 000000000..a4e9b06c2 --- /dev/null +++ b/plugins/vagrant/vagrant.plugin.zsh @@ -0,0 +1,33 @@ +alias vgi="vagrant init" + +alias vup="vagrant up" +alias vd="vagrant destroy" +alias vdf="vagrant destroy -f" + +alias vssh="vagrant ssh" +alias vsshc="vagrant ssh-config" +alias vrdp="vagrant rdp" + +alias vh="vagrant halt" +alias vssp="vagrant suspend" +alias vst="vagrant status" +alias vre="vagrant resume" +alias vgs="vagrant global-status" + +alias vpr="vagrant provision" +alias vr="vagrant reload" +alias vrp="vagrant reload --provision" + +alias vp="vagrant push" +alias vsh="vagrant share" + +alias vba="vagrant box add" +alias vbr="vagrant box remove" +alias vbl="vagrant box list" +alias vbo="vagrant box outdated" +alias vbu="vagrant box update" + +alias vpli="vagrant plugin install" +alias vpll="vagrant plugin list" +alias vplun="vagrant plugin uninstall" +alias vplu="vagrant plugin update" diff --git a/plugins/vscode/README.md b/plugins/vscode/README.md index 2c6530650..469c57ea8 100644 --- a/plugins/vscode/README.md +++ b/plugins/vscode/README.md @@ -8,6 +8,15 @@ To start using it, add the `vscode` plugin to your `plugins` array in `~/.zshrc` plugins=(... vscode) ``` +## Requirements + +To use VS Code in the terminal **in macOS**, first you need to install the `code` command in the PATH, +otherwise you might receive this message: `zsh: command not found: code`. + +[As the docs say](https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line), open +the Command Palette via (F1 or ⇧⌘P) and type shell command to find the Shell Command: +> Install 'code' command in PATH + ## VS Code Insiders 🍏 **If you are only using [VS Code Insiders](https://code.visualstudio.com/insiders/), the plugin will automatically bind to your Insiders installation.** diff --git a/plugins/web-search/README.md b/plugins/web-search/README.md index d04042506..9c01f0724 100644 --- a/plugins/web-search/README.md +++ b/plugins/web-search/README.md @@ -39,6 +39,7 @@ Available search contexts are: | `qwant` | `https://www.qwant.com/?q=` | | `givero` | `https://www.givero.com/search?q=` | | `stackoverflow` | `https://stackoverflow.com/search?q=` | +| `wolframalpha` | `https://wolframalpha.com/input?i=` | Also there are aliases for bang-searching DuckDuckGo: diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh index 5b76eeae2..f975bad7a 100644 --- a/plugins/web-search/web-search.plugin.zsh +++ b/plugins/web-search/web-search.plugin.zsh @@ -19,6 +19,7 @@ function web_search() { qwant "https://www.qwant.com/?q=" givero "https://www.givero.com/search?q=" stackoverflow "https://stackoverflow.com/search?q=" + wolframalpha "https://www.wolframalpha.com/input/?i=" ) # check whether the search engine is supported @@ -55,6 +56,7 @@ alias goodreads='web_search goodreads' alias qwant='web_search qwant' alias givero='web_search givero' alias stackoverflow='web_search stackoverflow' +alias wolframalpha='web_search wolframalpha' #add your own !bang searches here alias wiki='web_search duckduckgo \!w' diff --git a/plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh b/plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh index 0f15aeef0..b0520c239 100644 --- a/plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh +++ b/plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh @@ -144,4 +144,5 @@ zic-completion() { } zle -N zic-completion -bindkey '^I' zic-completion +bindkey -M emacs '^I' zic-completion +bindkey -M viins '^I' zic-completion |