From c840594c6ffdcecc241c9ccb130daeb630831ef7 Mon Sep 17 00:00:00 2001 From: Robert McLeod Date: Fri, 10 Apr 2015 15:07:29 +1200 Subject: added aliases for vagrant --- plugins/vagrant/vagrant.plugin.zsh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 plugins/vagrant/vagrant.plugin.zsh diff --git a/plugins/vagrant/vagrant.plugin.zsh b/plugins/vagrant/vagrant.plugin.zsh new file mode 100644 index 000000000..a238d9ffe --- /dev/null +++ b/plugins/vagrant/vagrant.plugin.zsh @@ -0,0 +1,31 @@ +alias vgi="vagrant init" + +alias vup="vagrant up" +alias vd="vagrant destroy" +alias vdf="vagrant destroy -f" + +alias vssh="vagrant ssh" +alias vrdp="vagrant rdp" + +alias vh="vagrant halt" +alias vssp="vagrant suspend" +alias vst="vagrant status" +alias vre="vagrant resume" + +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" -- cgit v1.2.3-70-g09d2 From b6ed2e7ac378438689d3348b4be00b2bce4fd9a8 Mon Sep 17 00:00:00 2001 From: Robert McLeod Date: Wed, 8 Jul 2015 07:54:42 +1200 Subject: added aliases for ssh-config and global-status So the following aliases call the respective commands: vgs = vagrant global-status vsshc = vagrant ssh-config --- plugins/vagrant/vagrant.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/vagrant/vagrant.plugin.zsh b/plugins/vagrant/vagrant.plugin.zsh index a238d9ffe..a4e9b06c2 100644 --- a/plugins/vagrant/vagrant.plugin.zsh +++ b/plugins/vagrant/vagrant.plugin.zsh @@ -5,12 +5,14 @@ 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" -- cgit v1.2.3-70-g09d2 From d855547661ee4173bd01ab89ad18418d4dbf508a Mon Sep 17 00:00:00 2001 From: Robert Estelle Date: Fri, 12 Jul 2019 17:01:10 -0400 Subject: clipboard: Reduce unnecessary special-casing on stdin Ideally the parameter would just be removed-users could always just do "clipcopy < some-file". but removing the parameter would break backwards compatibility. In any case, this simplifies the logic considerably. --- lib/clipboard.zsh | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh index 2c93d1bb5..15ad6d916 100644 --- a/lib/clipboard.zsh +++ b/lib/clipboard.zsh @@ -17,32 +17,17 @@ # function clipcopy() { emulate -L zsh - local file=$1 + local file="${1:-/dev/stdin}" + if [[ $OSTYPE == darwin* ]]; then - if [[ -z $file ]]; then - pbcopy - else - cat $file | pbcopy - fi + pbcopy < "${file}" elif [[ $OSTYPE == cygwin* ]]; then - if [[ -z $file ]]; then - cat > /dev/clipboard - else - cat $file > /dev/clipboard - fi + cat "${file}" > /dev/clipboard else if (( $+commands[xclip] )); then - if [[ -z $file ]]; then - xclip -in -selection clipboard - else - xclip -in -selection clipboard $file - fi + xclip -in -selection clipboard < "${file}" elif (( $+commands[xsel] )); then - if [[ -z $file ]]; then - xsel --clipboard --input - else - cat "$file" | xsel --clipboard --input - fi + xsel --clipboard --input < "${file}" else print "clipcopy: Platform $OSTYPE not supported or xclip/xsel not installed" >&2 return 1 -- cgit v1.2.3-70-g09d2 From 956ca639bba5780dc6272e76b0507c67e93c098b Mon Sep 17 00:00:00 2001 From: Robert Estelle Date: Fri, 12 Jul 2019 17:16:01 -0400 Subject: clipboard: Avoid unnecessary re-detection each time Previously, OS detection would happen on each invocation. This makes it happen once (unless it fails, in which case it will try again on the next invocation). This has the additional benefit of localizing the platform-specific checks and commands, too, versus spreading them out in separate functions. --- lib/clipboard.zsh | 65 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh index 15ad6d916..512a5a248 100644 --- a/lib/clipboard.zsh +++ b/lib/clipboard.zsh @@ -15,26 +15,9 @@ # # clipcopy - copies a file's contents to clipboard # -function clipcopy() { - emulate -L zsh - local file="${1:-/dev/stdin}" - - if [[ $OSTYPE == darwin* ]]; then - pbcopy < "${file}" - elif [[ $OSTYPE == cygwin* ]]; then - cat "${file}" > /dev/clipboard - else - if (( $+commands[xclip] )); then - xclip -in -selection clipboard < "${file}" - elif (( $+commands[xsel] )); then - xsel --clipboard --input < "${file}" - else - print "clipcopy: Platform $OSTYPE not supported or xclip/xsel not installed" >&2 - return 1 - fi - fi -} - +# +## +# # clippaste - "Paste" data from clipboard to stdout # # Usage: @@ -52,20 +35,40 @@ function clipcopy() { # # # Paste to a file # clippaste > file.txt -function clippaste() { +# +function detect-clipboard() { emulate -L zsh + if [[ $OSTYPE == darwin* ]]; then - pbpaste + function clipcopy() { pbcopy < "${1:-/dev/stdin}"; } + function clippaste() { pbpaste; } elif [[ $OSTYPE == cygwin* ]]; then - cat /dev/clipboard + function clipcopy() { cat "${1:-/dev/stdin}" > /dev/clipboard; } + function clippaste() { cat /dev/clipboard; } + elif (( $+commands[xclip] )); then + function clipcopy() { xclip -in -selection clipboard < "${1:-/dev/stdin}"; } + function clippaste() { xclip -out -selection clipboard; } + elif (( $+commands[xsel] )); then + function clipcopy() { xsel --clipboard --input < "${1:-/dev/stdin}"; } + function clippaste() { xsel --clipboard --output; } else - if (( $+commands[xclip] )); then - xclip -out -selection clipboard - elif (( $+commands[xsel] )); then - xsel --clipboard --output - else - print "clipcopy: Platform $OSTYPE not supported or xclip/xsel not installed" >&2 - return 1 - fi + function _retry_clipboard_detection_or_fail() { + local clipcmd="${1}"; shift + if detect-clipboard; then + "${clipcmd}" "$@" + else + print "${clipcmd}: Platform $OSTYPE not supported or xclip/xsel not installed" >&2 + return 1 + fi + } + function clipcopy() { _retry_clipboard_detection_or_fail clipcopy "$@"; } + function cilppaste() { _retry_clipboard_detection_or_fail clippaste "$@"; } + return 1 fi } + +# Detect at startup. A non-zero exit here indicates that the dummy clipboards were set, +# which is not really an error. If the user calls them, they will attempt to redetect +# (for example, perhaps the user has now installed xclip) and then either print an error +# or proceed successfully. +detect-clipboard || true -- cgit v1.2.3-70-g09d2 From 01e934d6346a93acd6b4343de3256d5ba82c5961 Mon Sep 17 00:00:00 2001 From: Robert Estelle Date: Fri, 12 Jul 2019 17:39:16 -0400 Subject: clipboard: Add support for several more clipboards This implements essentially the same heuristic as neovim, with the additional (existing) special support for Cygwin. See: https://github.com/neovim/neovim/blob/e682d799fa3cf2e80a02d00c6ea874599d58f0e7/runtime/autoload/provider/clipboard.vim#L55-L121 - pbcopy, pbpaste (macOS) - cygwin (Windows running Cygwin) - wl-copy, wl-paste (if $WAYLAND_DISPLAY is set) - xclip (if $DISPLAY is set) - xsel (if $DISPLAY is set) - lemonade (for SSH) https://github.com/pocke/lemonade - doitclient (for SSH) http://www.chiark.greenend.org.uk/~sgtatham/doit/ - win32yank (Windows) - tmux (if $TMUX is set) --- lib/clipboard.zsh | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh index 512a5a248..17d8d1aaf 100644 --- a/lib/clipboard.zsh +++ b/lib/clipboard.zsh @@ -3,10 +3,23 @@ # This file has support for doing system clipboard copy and paste operations # from the command line in a generic cross-platform fashion. # -# On OS X and Windows, the main system clipboard or "pasteboard" is used. On other -# Unix-like OSes, this considers the X Windows CLIPBOARD selection to be the -# "system clipboard", and the X Windows `xclip` command must be installed. - +# This is uses essentially the same heuristic as neovim, with the additional +# special support for Cygwin. +# See: https://github.com/neovim/neovim/blob/e682d799fa3cf2e80a02d00c6ea874599d58f0e7/runtime/autoload/provider/clipboard.vim#L55-L121 +# +# - pbcopy, pbpaste (macOS) +# - cygwin (Windows running Cygwin) +# - wl-copy, wl-paste (if $WAYLAND_DISPLAY is set) +# - xclip (if $DISPLAY is set) +# - xsel (if $DISPLAY is set) +# - lemonade (for SSH) https://github.com/pocke/lemonade +# - doitclient (for SSH) http://www.chiark.greenend.org.uk/~sgtatham/doit/ +# - win32yank (Windows) +# - tmux (if $TMUX is set) +# +# Defines two functions, clipcopy and clippaste, based on the detected platform. +## +# # clipcopy - Copy data to clipboard # # Usage: @@ -15,7 +28,6 @@ # # clipcopy - copies a file's contents to clipboard # -# ## # # clippaste - "Paste" data from clipboard to stdout @@ -39,18 +51,33 @@ function detect-clipboard() { emulate -L zsh - if [[ $OSTYPE == darwin* ]]; then + if [[ "${OSTYPE}" == darwin* ]] && (( ${+commands[pbcopy]} )) && (( ${+commands[pbpaste]} )); then function clipcopy() { pbcopy < "${1:-/dev/stdin}"; } function clippaste() { pbpaste; } - elif [[ $OSTYPE == cygwin* ]]; then + elif [[ "${OSTYPE}" == cygwin* ]]; then function clipcopy() { cat "${1:-/dev/stdin}" > /dev/clipboard; } function clippaste() { cat /dev/clipboard; } - elif (( $+commands[xclip] )); then + elif [ -n "${WAYLAND_DISPLAY:-}" ] && (( ${+commands[wl-copy]} )) && (( ${+commands[wl-paste]} )); then + function clipcopy() { wl-copy < "${1:-/dev/stdin}"; } + function clippaste() { wl-paste; } + elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xclip]} )); then function clipcopy() { xclip -in -selection clipboard < "${1:-/dev/stdin}"; } function clippaste() { xclip -out -selection clipboard; } - elif (( $+commands[xsel] )); then - function clipcopy() { xsel --clipboard --input < "${1:-/dev/stdin}"; } + elif [ -n "${DISPLAY:-}" ] && $(( ${+commands[xsel]} )); then + function clipcopy() { xsel --clipboard --input < "${1:-/dev/stdin}"; } function clippaste() { xsel --clipboard --output; } + elif (( ${+commands[lemonade]} )); then + function clipcopy() { lemonade copy < "${1:-/dev/stdin}"; } + function clippaste() { lemonade paste; } + elif (( ${+commands[doitclient]} )); then + function clipcopy() { doitclient wclip < "${1:-/dev/stdin}"; } + function clippaste() { doitclient wclip -r; } + elif (( ${+commands[win32yank]} )); then + function clipcopy() { win32yank -i < "${1:-/dev/stdin}"; } + function clippaste() { win32yank -o; } + elif [ -n "${TMUX:-}" ] && (( ${+commands[tmux]} )); then + function clipcopy() { tmux load-buffer "${1:-/dev/stdin}"; } + function clippaste() { tmux save-buffer -; } else function _retry_clipboard_detection_or_fail() { local clipcmd="${1}"; shift -- cgit v1.2.3-70-g09d2 From d71d3d99050fa2b658f41602b830c971235b9202 Mon Sep 17 00:00:00 2001 From: Robert Estelle Date: Sun, 14 Jul 2019 12:52:47 -0400 Subject: clipboard: Fix "cilppaste" -> "clippaste" typo --- lib/clipboard.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh index 17d8d1aaf..671d33d8e 100644 --- a/lib/clipboard.zsh +++ b/lib/clipboard.zsh @@ -89,7 +89,7 @@ function detect-clipboard() { fi } function clipcopy() { _retry_clipboard_detection_or_fail clipcopy "$@"; } - function cilppaste() { _retry_clipboard_detection_or_fail clippaste "$@"; } + function clippaste() { _retry_clipboard_detection_or_fail clippaste "$@"; } return 1 fi } -- cgit v1.2.3-70-g09d2 From 841008c947d5fbe780111539804945c46dcdfaf4 Mon Sep 17 00:00:00 2001 From: Robert Estelle Date: Sun, 14 Jul 2019 12:53:27 -0400 Subject: clipboard: Fix tmux clipcopy after testing Tmux must have special handling for /dev/stdin since it's managing the terminal itself. This was tested with tmux-2.9a on macOS. --- lib/clipboard.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh index 671d33d8e..5001f4695 100644 --- a/lib/clipboard.zsh +++ b/lib/clipboard.zsh @@ -76,7 +76,7 @@ function detect-clipboard() { function clipcopy() { win32yank -i < "${1:-/dev/stdin}"; } function clippaste() { win32yank -o; } elif [ -n "${TMUX:-}" ] && (( ${+commands[tmux]} )); then - function clipcopy() { tmux load-buffer "${1:-/dev/stdin}"; } + function clipcopy() { tmux load-buffer "${1:--}"; } function clippaste() { tmux save-buffer -; } else function _retry_clipboard_detection_or_fail() { -- cgit v1.2.3-70-g09d2 From d81cd753e0b3a845e8f3549da245dbad102a6e4c Mon Sep 17 00:00:00 2001 From: Robert Estelle Date: Sun, 14 Jul 2019 12:56:48 -0400 Subject: clipboard: Fix bad expansion of exit-code test --- lib/clipboard.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh index 5001f4695..333f58dd8 100644 --- a/lib/clipboard.zsh +++ b/lib/clipboard.zsh @@ -63,7 +63,7 @@ function detect-clipboard() { elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xclip]} )); then function clipcopy() { xclip -in -selection clipboard < "${1:-/dev/stdin}"; } function clippaste() { xclip -out -selection clipboard; } - elif [ -n "${DISPLAY:-}" ] && $(( ${+commands[xsel]} )); then + elif [ -n "${DISPLAY:-}" ] && (( ${+commands[xsel]} )); then function clipcopy() { xsel --clipboard --input < "${1:-/dev/stdin}"; } function clippaste() { xsel --clipboard --output; } elif (( ${+commands[lemonade]} )); then -- cgit v1.2.3-70-g09d2 From 634a50936a28ba3a57a02c92e7fe76da2d60ecf8 Mon Sep 17 00:00:00 2001 From: Maxime Richard Date: Thu, 13 Feb 2020 18:10:59 +0100 Subject: dotenv: add ZSH_DOTENV_PROMPT config (#8624) --- plugins/dotenv/README.md | 6 ++++++ plugins/dotenv/dotenv.plugin.zsh | 13 ++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) 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..84815a416 100644 --- a/plugins/dotenv/dotenv.plugin.zsh +++ b/plugins/dotenv/dotenv.plugin.zsh @@ -1,10 +1,13 @@ 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 + echo -n "dotenv: source '$ZSH_DOTENV_FILE' file in the directory? (Y/n) " + if read -k 1 confirmation && [[ $confirmation = [nN] ]]; then + return + fi fi # test .env syntax -- cgit v1.2.3-70-g09d2 From f17e0219fdd38d9fabce2d96d0d283d98122733f Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 13 Feb 2020 18:33:24 +0100 Subject: dotenv: fix prompt newline --- plugins/dotenv/dotenv.plugin.zsh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/dotenv/dotenv.plugin.zsh b/plugins/dotenv/dotenv.plugin.zsh index 84815a416..54036bee3 100644 --- a/plugins/dotenv/dotenv.plugin.zsh +++ b/plugins/dotenv/dotenv.plugin.zsh @@ -1,11 +1,13 @@ source_env() { if [[ -f $ZSH_DOTENV_FILE ]]; then - 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) " - if read -k 1 confirmation && [[ $confirmation = [nN] ]]; then + read -k 1 confirmation; [[ "$confirmation" != $'\n' ]] && echo + # only bail out if confirmation character is n + if [[ "$confirmation" = [nN] ]]; then return fi fi -- cgit v1.2.3-70-g09d2 From 4fc570b0d4a14638322d904b48f237306ccf3adc Mon Sep 17 00:00:00 2001 From: Marco Seguri Date: Thu, 13 Feb 2020 18:50:56 +0100 Subject: kubectl: avoid conflict with existing f aliases in kca alias (#8625) --- plugins/kubectl/kubectl.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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' -- cgit v1.2.3-70-g09d2 From 52f9238b16ddc8a97690b49c8b395e9fe1169b62 Mon Sep 17 00:00:00 2001 From: Roey Darwish Dror Date: Thu, 13 Feb 2020 19:57:52 +0200 Subject: fzf: support for NixOS and Void Linux (#8618) --- plugins/fzf/fzf.plugin.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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" -- cgit v1.2.3-70-g09d2 From 72168aec3da727c4af715f095d27d429106ea79f Mon Sep 17 00:00:00 2001 From: Manuel Silva Date: Sun, 16 Feb 2020 04:26:20 +1100 Subject: cloudapp: fix copy-paste mistake in README (#8629) --- plugins/cloudapp/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v1.2.3-70-g09d2 From aa4146a9a4b75bc998d74750b4f75131973ccf01 Mon Sep 17 00:00:00 2001 From: Roman Date: Sat, 15 Feb 2020 18:28:02 +0100 Subject: git: add alias for git stash --include-untracked (#8617) --- plugins/git/README.md | 1 + plugins/git/git.plugin.zsh | 1 + 2 files changed, 2 insertions(+) diff --git a/plugins/git/README.md b/plugins/git/README.md index 7878f747b..42a583de8 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -154,6 +154,7 @@ plugins=(... git) | 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 | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index d8c4cffd1..380ab76d8 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' -- cgit v1.2.3-70-g09d2 From 0bcecf2f636b8070639b6db44b8541015f574365 Mon Sep 17 00:00:00 2001 From: Harry Date: Sat, 15 Feb 2020 19:19:57 +0100 Subject: dotnet: use official dotnet completion (#8518) --- plugins/dotnet/README.md | 2 +- plugins/dotnet/dotnet.plugin.zsh | 119 ++++++--------------------------------- 2 files changed, 17 insertions(+), 104 deletions(-) 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' -- cgit v1.2.3-70-g09d2 From fbbfd0f8a89dfca51bee7b36c774c718207c5bb1 Mon Sep 17 00:00:00 2001 From: Alexandre GOMES Date: Mon, 17 Feb 2020 17:44:48 +0100 Subject: arcanist: add `arc diff --create` alias (#8610) --- plugins/arcanist/arcanist.plugin.zsh | 1 + 1 file changed, 1 insertion(+) 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' -- cgit v1.2.3-70-g09d2 From 1381da15a458112eace99a997b961b6e522c4a7c Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 17 Feb 2020 17:47:43 +0100 Subject: arcanist: document aliases --- plugins/arcanist/README.md | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 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` | -- cgit v1.2.3-70-g09d2 From 47eae26bf6fb378c8186602eab4c998916ac5b34 Mon Sep 17 00:00:00 2001 From: Kshitij Nikhal Date: Tue, 18 Feb 2020 03:20:54 -0600 Subject: web-search: add wolframalpha search engine (#8638) --- plugins/web-search/README.md | 1 + plugins/web-search/web-search.plugin.zsh | 2 ++ 2 files changed, 3 insertions(+) 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' -- cgit v1.2.3-70-g09d2 From d49397a01d0cc704008d6f1089ef6a7270d17116 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 18 Feb 2020 19:14:30 +0100 Subject: af-magic: fix dashed separator sizing and refactor Fixes #8081 --- themes/af-magic.zsh-theme | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/themes/af-magic.zsh-theme b/themes/af-magic.zsh-theme index 30e997f8c..4d1a40947 100644 --- a/themes/af-magic.zsh-theme +++ b/themes/af-magic.zsh-theme @@ -2,29 +2,28 @@ # Repo: https://github.com/andyfleming/oh-my-zsh # Direct Link: https://github.com/andyfleming/oh-my-zsh/blob/master/themes/af-magic.zsh-theme -if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="green"; fi -local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" -# primary prompt -PROMPT='$FG[237]${(l.COLUMNS..-.)}%{$reset_color%} -$FG[032]%~\ -$(git_prompt_info)$(hg_prompt_info) \ -$FG[105]%(!.#.»)%{$reset_color%} ' -PROMPT2='%{$fg[red]%}\ %{$reset_color%}' -RPS1='${return_code}' +# settings +typeset +H return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})" +typeset +H my_gray="$FG[237]" +typeset +H my_orange="$FG[214]" +# separator dashes size +function afmagic_dashes { + [[ -n "${VIRTUAL_ENV-}" && -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" && "$PS1" = \(* ]] \ + && echo $(( COLUMNS - ${#VIRTUAL_ENV} - 3 )) \ + || echo $COLUMNS +} -# color vars -eval my_gray='$FG[237]' -eval my_orange='$FG[214]' +# primary prompt +PS1='$FG[237]${(l.$(afmagic_dashes)..-.)}%{$reset_color%} +$FG[032]%~$(git_prompt_info)$(hg_prompt_info) $FG[105]%(!.#.»)%{$reset_color%} ' +PS2='%{$fg[red]%}\ %{$reset_color%}' +RPS1='${return_code}' # right prompt -if type "virtualenv_prompt_info" > /dev/null -then - RPROMPT="${RPROMPT}"'$FG[078]$(virtualenv_prompt_info)%{$reset_color%} $my_gray%n@%m%{$reset_color%}%' -else - RPROMPT="${RPROMPT}"'$my_gray%n@%m%{$reset_color%}%' -fi +(( $+functions[virtualenv_prompt_info] )) && RPS1+='$(virtualenv_prompt_info)' +RPS1+=' $my_gray%n@%m%{$reset_color%}%' # git settings ZSH_THEME_GIT_PROMPT_PREFIX="$FG[075]($FG[078]" @@ -37,3 +36,7 @@ ZSH_THEME_HG_PROMPT_PREFIX="$FG[075]($FG[078]" ZSH_THEME_HG_PROMPT_CLEAN="" ZSH_THEME_HG_PROMPT_DIRTY="$my_orange*%{$reset_color%}" ZSH_THEME_HG_PROMPT_SUFFIX="$FG[075])%{$reset_color%}" + +# virtualenv settings +ZSH_THEME_VIRTUALENV_PREFIX=" $FG[075][" +ZSH_THEME_VIRTUALENV_PREFIX="]%{$reset_color%}" -- cgit v1.2.3-70-g09d2 From e8609b857caf730c626ab27910ece30420bc6693 Mon Sep 17 00:00:00 2001 From: Ujwal Dhakal Date: Wed, 19 Feb 2020 01:50:52 +0545 Subject: git: add `grename` to rename a local branch and in the origin remote (#8622) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà --- plugins/git/README.md | 357 +++++++++++++++++++++++---------------------- plugins/git/git.plugin.zsh | 14 ++ 2 files changed, 193 insertions(+), 178 deletions(-) diff --git a/plugins/git/README.md b/plugins/git/README.md index 42a583de8..009a74016 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -10,195 +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 | -| 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]" | +| 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 ` | 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 380ab76d8..ffb3e506a 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -256,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 +} -- cgit v1.2.3-70-g09d2 From de261bd29cb5920b9ad37e67fe5e29ae3c348cfd Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 18 Feb 2020 22:28:58 +0100 Subject: af-magic: fix virtualenv prompt suffix --- themes/af-magic.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/af-magic.zsh-theme b/themes/af-magic.zsh-theme index 4d1a40947..148991fec 100644 --- a/themes/af-magic.zsh-theme +++ b/themes/af-magic.zsh-theme @@ -39,4 +39,4 @@ ZSH_THEME_HG_PROMPT_SUFFIX="$FG[075])%{$reset_color%}" # virtualenv settings ZSH_THEME_VIRTUALENV_PREFIX=" $FG[075][" -ZSH_THEME_VIRTUALENV_PREFIX="]%{$reset_color%}" +ZSH_THEME_VIRTUALENV_SUFFIX="]%{$reset_color%}" -- cgit v1.2.3-70-g09d2 From eeb49bf5b0b8b700713e5b91464003cc09d1b44d Mon Sep 17 00:00:00 2001 From: Sir Mobus Gochfulshigan Dorphin Esquire XXIII Date: Tue, 18 Feb 2020 17:04:14 -0500 Subject: systemd: add prompt function to show systemd units' status (#7657) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà --- plugins/systemd/README.md | 41 ++++++++++++++++++++++++++++++++++++++ plugins/systemd/systemd.plugin.zsh | 15 ++++++++++++++ 2 files changed, 56 insertions(+) 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`. +``` +: +``` +You can control these parts with the following variables: + +- ``: Set `$ZSH_THEME_SYSTEMD_PROMPT_PREFIX`. + +- ``: Set `$ZSH_THEME_SYSTEMD_PROMPT_SUFFIX`. + +- ``: 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. + +- ``: shown if the systemd unit is active. + Set `$ZSH_THEME_SYSTEMD_PROMPT_ACTIVE`. + +- ``: 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 +} + -- cgit v1.2.3-70-g09d2 From c1b798aff39942b2f23a0a5f2ef206ebc8ce4970 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 19 Feb 2020 00:16:54 +0100 Subject: agnoster: fix bzr prompt with breezy installed (#8646) * Change indentation to 2 spaces in prompt_bzr function * Check if in a bzr repository and optimize bzr calls in prompt_bzr --- themes/agnoster.zsh-theme | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index 518a14a37..8c700d06a 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -140,24 +140,30 @@ prompt_git() { } prompt_bzr() { - (( $+commands[bzr] )) || return - if (bzr status >/dev/null 2>&1); then - status_mod=`bzr status | head -n1 | grep "modified" | wc -m` - status_all=`bzr status | head -n1 | wc -m` - revision=`bzr log | head -n2 | tail -n1 | sed 's/^revno: //'` - if [[ $status_mod -gt 0 ]] ; then - prompt_segment yellow black - echo -n "bzr@"$revision "✚ " - else - if [[ $status_all -gt 0 ]] ; then - prompt_segment yellow black - echo -n "bzr@"$revision - else - prompt_segment green black - echo -n "bzr@"$revision - fi - fi + (( $+commands[bzr] )) || return + + # Test if bzr repository in directory hierarchy + local dir="$PWD" + while [[ ! -d "$dir/.bzr" ]]; do + [[ "$dir" = "/" ]] && return + dir="${dir:h}" + done + + local bzr_status status_mod status_all revision + if bzr_status=$(bzr status 2>&1); then + status_mod=$(echo -n "$bzr_status" | head -n1 | grep "modified" | wc -m) + status_all=$(echo -n "$bzr_status" | head -n1 | wc -m) + revision=$(bzr log -r-1 --log-format line | cut -d: -f1) + if [[ $status_mod -gt 0 ]] ; then + prompt_segment yellow black "bzr@$revision ✚" + else + if [[ $status_all -gt 0 ]] ; then + prompt_segment yellow black "bzr@$revision" + else + prompt_segment green black "bzr@$revision" + fi fi + fi } prompt_hg() { -- cgit v1.2.3-70-g09d2 From 443ad8802415c111e8d59e110337e3fe12e2e698 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 19 Feb 2020 16:53:10 +0100 Subject: avit: replace custom prompt functions with OMZ ones Fixes #8637 --- themes/avit.zsh-theme | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme index aec14e4a6..3179bd837 100644 --- a/themes/avit.zsh-theme +++ b/themes/avit.zsh-theme @@ -1,12 +1,12 @@ # AVIT ZSH Theme PROMPT=' -$(_user_host)${_current_dir} $(git_prompt_info) $(_ruby_version) +$(_user_host)${_current_dir} $(git_prompt_info) $(ruby_prompt_info) %{$fg[$CARETCOLOR]%}▶%{$resetcolor%} ' PROMPT2='%{$fg[$CARETCOLOR]%}◀%{$reset_color%} ' -RPROMPT='$(_vi_status)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}' +RPROMPT='$(vi_mode_prompt_info)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}' local _current_dir="%{$fg_bold[blue]%}%3~%{$reset_color%} " local _return_status="%{$fg_bold[red]%}%(?..⍉)%{$reset_color%}" @@ -32,20 +32,6 @@ function _user_host() { fi } -function _vi_status() { - if {echo $fpath | grep -q "plugins/vi-mode"}; then - echo "$(vi_mode_prompt_info)" - fi -} - -function _ruby_version() { - if {echo $fpath | grep -q "plugins/rvm"}; then - echo "%{$fg[grey]%}$(rvm_prompt_info)%{$reset_color%}" - elif {echo $fpath | grep -q "plugins/rbenv"}; then - echo "%{$fg[grey]%}$(rbenv_prompt_info)%{$reset_color%}" - fi -} - # Determine the time since last commit. If branch is clean, # use a neutral color, otherwise colors will vary according to time. function _git_time_since_commit() { @@ -84,9 +70,9 @@ fi MODE_INDICATOR="%{$fg_bold[yellow]%}❮%{$reset_color%}%{$fg[yellow]%}❮❮%{$reset_color%}" +# Git prompt settings ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" - ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}✗%{$reset_color%}" ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}✔%{$reset_color%}" ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%}✚ " @@ -96,6 +82,10 @@ ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}▴ " ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[cyan]%}§ " ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[white]%}◒ " +# Ruby prompt settings +ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[grey]%}" +ZSH_THEME_RUBY_PROMPT_SUFFIX="%{$reset_color%}" + # Colors vary depending on time lapsed. ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}" ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}" -- cgit v1.2.3-70-g09d2 From 77813a330bbc716503dcc4d8d98b6d8ae6f74d03 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 19 Feb 2020 17:24:20 +0100 Subject: avit: clean up theme code --- themes/avit.zsh-theme | 51 +++++++++++++++++---------------------------------- 1 file changed, 17 insertions(+), 34 deletions(-) diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme index 3179bd837..4f82f3414 100644 --- a/themes/avit.zsh-theme +++ b/themes/avit.zsh-theme @@ -1,27 +1,20 @@ # AVIT ZSH Theme +# settings +typeset +H _current_dir="%{$fg_bold[blue]%}%3~%{$reset_color%} " +typeset +H _return_status="%{$fg_bold[red]%}%(?..⍉)%{$reset_color%}" +typeset +H _hist_no="%{$fg[grey]%}%h%{$reset_color%}" + PROMPT=' $(_user_host)${_current_dir} $(git_prompt_info) $(ruby_prompt_info) -%{$fg[$CARETCOLOR]%}▶%{$resetcolor%} ' +%{%F{%(!.red.white)}%}▶%{$resetcolor%} ' -PROMPT2='%{$fg[$CARETCOLOR]%}◀%{$reset_color%} ' +PROMPT2='%{%F{%(!.red.white)}%}◀%{$reset_color%} ' RPROMPT='$(vi_mode_prompt_info)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}' -local _current_dir="%{$fg_bold[blue]%}%3~%{$reset_color%} " -local _return_status="%{$fg_bold[red]%}%(?..⍉)%{$reset_color%}" -local _hist_no="%{$fg[grey]%}%h%{$reset_color%}" - -function _current_dir() { - local _max_pwd_length="65" - if [[ $(echo -n $PWD | wc -c) -gt ${_max_pwd_length} ]]; then - echo "%{$fg_bold[blue]%}%-2~ ... %3~%{$reset_color%} " - else - echo "%{$fg_bold[blue]%}%~%{$reset_color%} " - fi -} - function _user_host() { + local me if [[ -n $SSH_CONNECTION ]]; then me="%n@%m" elif [[ $LOGNAME != $USER ]]; then @@ -35,39 +28,29 @@ function _user_host() { # Determine the time since last commit. If branch is clean, # use a neutral color, otherwise colors will vary according to time. function _git_time_since_commit() { -# Only proceed if there is actually a commit. + local last_commit now seconds_since_last_commit + local minutes hours commit_age + # Only proceed if there is actually a commit. if last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null); then now=$(date +%s) seconds_since_last_commit=$((now-last_commit)) # Totals minutes=$((seconds_since_last_commit / 60)) - hours=$((seconds_since_last_commit/3600)) - - # Sub-hours and sub-minutes - days=$((seconds_since_last_commit / 86400)) - sub_hours=$((hours % 24)) - sub_minutes=$((minutes % 60)) + hours=$((seconds_since_last_commit / 3600)) - if [ $hours -ge 24 ]; then - commit_age="${days}d" - elif [ $minutes -gt 60 ]; then - commit_age="${sub_hours}h${sub_minutes}m" + if [[ $hours -ge 24 ]]; then + commit_age="$(( hours / 24 ))d" + elif [[ $hours -gt 0 ]]; then + commit_age+="$(( hours % 24 ))h$(( minutes % 60 ))m" else commit_age="${minutes}m" fi - color=$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL - echo "$color$commit_age%{$reset_color%}" + echo "${ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL}${commit_age}%{$reset_color%}" fi } -if [[ $USER == "root" ]]; then - CARETCOLOR="red" -else - CARETCOLOR="white" -fi - MODE_INDICATOR="%{$fg_bold[yellow]%}❮%{$reset_color%}%{$fg[yellow]%}❮❮%{$reset_color%}" # Git prompt settings -- cgit v1.2.3-70-g09d2 From d76258ff554ea58d9865b9864f5fff1dd8d2e4bb Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 19 Feb 2020 18:19:46 +0100 Subject: avit: add years since last commit if appropriate --- themes/avit.zsh-theme | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme index 4f82f3414..51701572b 100644 --- a/themes/avit.zsh-theme +++ b/themes/avit.zsh-theme @@ -29,7 +29,7 @@ function _user_host() { # use a neutral color, otherwise colors will vary according to time. function _git_time_since_commit() { local last_commit now seconds_since_last_commit - local minutes hours commit_age + local minutes hours days years commit_age # Only proceed if there is actually a commit. if last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null); then now=$(date +%s) @@ -37,12 +37,16 @@ function _git_time_since_commit() { # Totals minutes=$((seconds_since_last_commit / 60)) - hours=$((seconds_since_last_commit / 3600)) + hours=$((minutes / 60)) + days=$((hours / 24)) + years=$((days / 365)) - if [[ $hours -ge 24 ]]; then - commit_age="$(( hours / 24 ))d" + if [[ $years -gt 0 ]]; then + commit_age="${years}y$((days % 365 ))d" + elif [[ $days -gt 0 ]]; then + commit_age="${days}d$((hours % 24))h" elif [[ $hours -gt 0 ]]; then - commit_age+="$(( hours % 24 ))h$(( minutes % 60 ))m" + commit_age+="${hours}h$(( minutes % 60 ))m" else commit_age="${minutes}m" fi -- cgit v1.2.3-70-g09d2 From 6adad5c300a6bfde33b593489cc1c3b645b721e8 Mon Sep 17 00:00:00 2001 From: Willy Weiskopf Date: Wed, 16 Jul 2014 22:21:09 -0600 Subject: Move random theme functionality into "random" theme The statements for selecting a random theme in oh-my-zsh.sh and the themes plugin are duplicate. Most people eventually settle on a theme, making those lines in oh-my-zsh.sh superfluous. To address those, it may makes sense to put the random theme functionality into a theme of its own (since themes are just zsh scripts. --- oh-my-zsh.sh | 25 ++++++------------------- plugins/themes/themes.plugin.zsh | 24 +++++++++++------------- themes/random.zsh-theme | 10 ++++++++++ 3 files changed, 27 insertions(+), 32 deletions(-) create mode 100644 themes/random.zsh-theme diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index c3fae6efb..30259372c 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -97,25 +97,12 @@ done unset config_file # Load the theme -if [[ "$ZSH_THEME" == "random" ]]; then - if [[ "${(t)ZSH_THEME_RANDOM_CANDIDATES}" = "array" ]] && [[ "${#ZSH_THEME_RANDOM_CANDIDATES[@]}" -gt 0 ]]; then - themes=($ZSH/themes/${^ZSH_THEME_RANDOM_CANDIDATES}.zsh-theme) +if [ ! "$ZSH_THEME" = "" ]; then + if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then + source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" + elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then + source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" else - themes=($ZSH/themes/*zsh-theme) - fi - N=${#themes[@]} - ((N=(RANDOM%N)+1)) - RANDOM_THEME=${themes[$N]} - source "$RANDOM_THEME" - echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..." -else - if [ ! "$ZSH_THEME" = "" ]; then - if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then - source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" - elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then - source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" - else - source "$ZSH/themes/$ZSH_THEME.zsh-theme" - fi + source "$ZSH/themes/$ZSH_THEME.zsh-theme" fi fi diff --git a/plugins/themes/themes.plugin.zsh b/plugins/themes/themes.plugin.zsh index 2cd0ee327..ac4ccc980 100644 --- a/plugins/themes/themes.plugin.zsh +++ b/plugins/themes/themes.plugin.zsh @@ -1,19 +1,17 @@ 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..." + if [ -z "$1" ]; then + 1="random" + fi + + 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" 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 + source "$ZSH/themes/$1.zsh-theme" fi } diff --git a/themes/random.zsh-theme b/themes/random.zsh-theme new file mode 100644 index 000000000..739567662 --- /dev/null +++ b/themes/random.zsh-theme @@ -0,0 +1,10 @@ +if [[ "${(t)ZSH_THEME_RANDOM_CANDIDATES}" = "array" ]] && [[ "${#ZSH_THEME_RANDOM_CANDIDATES[@]}" -gt 0 ]]; then + themes=($ZSH/themes/${^ZSH_THEME_RANDOM_CANDIDATES}.zsh-theme) +else + themes=($ZSH/themes/*zsh-theme) +fi +N=${#themes[@]} +((N=(RANDOM%N)+1)) +RANDOM_THEME=${themes[$N]} +source "$RANDOM_THEME" +echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..." -- cgit v1.2.3-70-g09d2 From b297bf92964e04e24f960f4e38acdb9b740d2d9f Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 19 Feb 2020 18:42:05 +0100 Subject: Add themes in $ZSH_CUSTOM to the pool of candidates Also add comments and unset leftover variables, and print only the name of the theme loaded. When looking for $ZSH_CUSTOM themes, the chosen algorithm is to add the theme names to the pool disregarding the path, and then source whatever theme is selected with the same logic as the init script, which is to source first custom themes even if there is another default theme of the same name. Co-authored-by: Mihai Serban --- themes/random.zsh-theme | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/themes/random.zsh-theme b/themes/random.zsh-theme index 739567662..92d2a6847 100644 --- a/themes/random.zsh-theme +++ b/themes/random.zsh-theme @@ -1,10 +1,34 @@ -if [[ "${(t)ZSH_THEME_RANDOM_CANDIDATES}" = "array" ]] && [[ "${#ZSH_THEME_RANDOM_CANDIDATES[@]}" -gt 0 ]]; then - themes=($ZSH/themes/${^ZSH_THEME_RANDOM_CANDIDATES}.zsh-theme) +# Make themes a unique array +typeset -Ua themes + +if [[ "${(t)ZSH_THEME_RANDOM_CANDIDATES}" = array && ${#ZSH_THEME_RANDOM_CANDIDATES[@]} -gt 0 ]]; then + # Use ZSH_THEME_RANDOM_CANDIDATES if properly defined + themes=($ZSH_THEME_RANDOM_CANDIDATES) else - themes=($ZSH/themes/*zsh-theme) + # Look for themes in $ZSH_CUSTOM and $ZSH and add only the theme name (:t) + themes=( + "$ZSH_CUSTOM"/*.zsh-theme(N:t:r) + "$ZSH_CUSTOM"/themes/*.zsh-theme(N:t:r) + "$ZSH"/themes/*.zsh-theme(N:t:r) + ) fi + +# Choose a theme out of the pool of candidates N=${#themes[@]} -((N=(RANDOM%N)+1)) -RANDOM_THEME=${themes[$N]} -source "$RANDOM_THEME" -echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..." +(( N = (RANDOM%N) + 1 )) +RANDOM_THEME="${themes[$N]}" +unset N themes + +# Source theme +if [[ -f "$ZSH_CUSTOM/$RANDOM_THEME.zsh-theme" ]]; then + source "$ZSH_CUSTOM/$RANDOM_THEME.zsh-theme" +elif [[ -f "$ZSH_CUSTOM/themes/$RANDOM_THEME.zsh-theme" ]]; then + source "$ZSH_CUSTOM/themes/$RANDOM_THEME.zsh-theme" +elif [[ -f "$ZSH/themes/$RANDOM_THEME.zsh-theme" ]]; then + source "$ZSH/themes/$RANDOM_THEME.zsh-theme" +else + echo "[oh-my-zsh] Random theme '${RANDOM_THEME}' not found" + return 1 +fi + +echo "[oh-my-zsh] Random theme '${RANDOM_THEME}' loaded" -- cgit v1.2.3-70-g09d2 From f4b4a446aca37987bc2612d6115d156417628364 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 19 Feb 2020 19:32:28 +0100 Subject: Polish themes plugin and error out if theme not found --- plugins/themes/_theme | 3 --- plugins/themes/themes.plugin.zsh | 29 ++++++++++++++++------------- 2 files changed, 16 insertions(+), 16 deletions(-) delete mode 100644 plugins/themes/_theme 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 ac4ccc980..1fbde5b64 100644 --- a/plugins/themes/themes.plugin.zsh +++ b/plugins/themes/themes.plugin.zsh @@ -1,24 +1,27 @@ -function theme -{ - if [ -z "$1" ]; then - 1="random" - fi +function theme { + : ${1:=random} # Use random theme if none provided - if [ -f "$ZSH_CUSTOM/$1.zsh-theme" ] - then + if [[ -f "$ZSH_CUSTOM/$1.zsh-theme" ]]; then source "$ZSH_CUSTOM/$1.zsh-theme" - elif [ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ] - then + elif [[ -f "$ZSH_CUSTOM/themes/$1.zsh-theme" ]]; then source "$ZSH_CUSTOM/themes/$1.zsh-theme" - else + elif [[ -f "$ZSH/themes/$1.zsh-theme" ]]; then source "$ZSH/themes/$1.zsh-theme" + else + 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) } -- cgit v1.2.3-70-g09d2 From 3d4890dcc07478e7129de1e79afedafd3f08ffbc Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 19 Feb 2020 19:53:37 +0100 Subject: Add blacklist variable for random theme Co-authored-by: Fran Garcia --- themes/random.zsh-theme | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/themes/random.zsh-theme b/themes/random.zsh-theme index 92d2a6847..43f6cbb60 100644 --- a/themes/random.zsh-theme +++ b/themes/random.zsh-theme @@ -5,19 +5,23 @@ if [[ "${(t)ZSH_THEME_RANDOM_CANDIDATES}" = array && ${#ZSH_THEME_RANDOM_CANDIDA # Use ZSH_THEME_RANDOM_CANDIDATES if properly defined themes=($ZSH_THEME_RANDOM_CANDIDATES) else - # Look for themes in $ZSH_CUSTOM and $ZSH and add only the theme name (:t) + # Look for themes in $ZSH_CUSTOM and $ZSH and add only the theme name themes=( "$ZSH_CUSTOM"/*.zsh-theme(N:t:r) "$ZSH_CUSTOM"/themes/*.zsh-theme(N:t:r) "$ZSH"/themes/*.zsh-theme(N:t:r) ) + # Remove blacklisted themes from the list + for theme in ${ZSH_THEME_RANDOM_BLACKLIST[@]}; do + themes=("${(@)themes:#$theme}") + done fi # Choose a theme out of the pool of candidates N=${#themes[@]} (( N = (RANDOM%N) + 1 )) RANDOM_THEME="${themes[$N]}" -unset N themes +unset N themes theme # Source theme if [[ -f "$ZSH_CUSTOM/$RANDOM_THEME.zsh-theme" ]]; then -- cgit v1.2.3-70-g09d2 From f9a2d8cae39a0fb42e22aa17222c7da7b44b7ede Mon Sep 17 00:00:00 2001 From: Andy Pickle <39109475+pickleat@users.noreply.github.com> Date: Mon, 24 Feb 2020 13:13:16 -0600 Subject: vscode: add documentation for running in macOS (#8674) --- plugins/vscode/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) 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.** -- cgit v1.2.3-70-g09d2 From 40b013f5f119be27bd2fdece431cf4979193bd25 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 24 Feb 2020 20:25:27 +0100 Subject: lib: delete upgrade lock in upgrade_oh_my_zsh Provides a different solution to #8332 and #8333 --- lib/functions.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/functions.zsh b/lib/functions.zsh index 61dfa4780..91e9cf895 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -3,11 +3,12 @@ function zsh_stats() { } function uninstall_oh_my_zsh() { - env ZSH=$ZSH sh $ZSH/tools/uninstall.sh + env ZSH="$ZSH" sh "$ZSH/tools/uninstall.sh" } function upgrade_oh_my_zsh() { - env ZSH=$ZSH sh $ZSH/tools/upgrade.sh + env ZSH="$ZSH" sh "$ZSH/tools/upgrade.sh" + rm -rf "$ZSH/log/update.lock" } function take() { -- cgit v1.2.3-70-g09d2 From 0e57142729656bd0bd81a39704328330f9db4557 Mon Sep 17 00:00:00 2001 From: Jonathan Chang <31893406+cccntu@users.noreply.github.com> Date: Tue, 25 Feb 2020 03:39:10 +0800 Subject: installer: remove redundant cp command (#8668) --- tools/install.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index ae248be89..bdf9f18e9 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -129,10 +129,9 @@ setup_zshrc() { echo "${GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${RESET}" - cp "$ZSH/templates/zshrc.zsh-template" ~/.zshrc sed "/^export ZSH=/ c\\ export ZSH=\"$ZSH\" -" ~/.zshrc > ~/.zshrc-omztemp +" "$ZSH/templates/zshrc.zsh-template" > ~/.zshrc-omztemp mv -f ~/.zshrc-omztemp ~/.zshrc echo -- cgit v1.2.3-70-g09d2 From 7290a08bf6098993b783877c8feab4c33cf49c38 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 25 Feb 2020 11:54:52 +0100 Subject: battery: fix floating point output in macOS Fixes #8676 --- plugins/battery/battery.plugin.zsh | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index 6fe801c9f..857ab6e8c 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -21,7 +21,8 @@ if [[ "$OSTYPE" = darwin* ]]; then 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 -i pct=$(( (currentcapacity/maxcapacity) * 100 )) + echo $pct } function battery_pct_remaining() { @@ -47,16 +48,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 +95,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 +138,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 } -- cgit v1.2.3-70-g09d2 From b72607bc8e83c9ffc02409ae8a7fed6a8866e022 Mon Sep 17 00:00:00 2001 From: Yahav Itzhak Date: Tue, 25 Feb 2020 13:00:25 +0200 Subject: Add JFrog CLI plugin (#8250) --- plugins/jfrog/README.md | 11 +++++++++++ plugins/jfrog/jfrog.plugin.zsh | 10 ++++++++++ 2 files changed, 21 insertions(+) create mode 100644 plugins/jfrog/README.md create mode 100644 plugins/jfrog/jfrog.plugin.zsh 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 -- cgit v1.2.3-70-g09d2 From d959283898f4c969579346a6d3596d9dd8fa3532 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 25 Feb 2020 12:21:06 +0100 Subject: avit: fix prompt sequence (fixes #8678) --- themes/avit.zsh-theme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme index 51701572b..0261f0ff3 100644 --- a/themes/avit.zsh-theme +++ b/themes/avit.zsh-theme @@ -7,9 +7,9 @@ typeset +H _hist_no="%{$fg[grey]%}%h%{$reset_color%}" PROMPT=' $(_user_host)${_current_dir} $(git_prompt_info) $(ruby_prompt_info) -%{%F{%(!.red.white)}%}▶%{$resetcolor%} ' +%{%(!.%F{red}.%F{white})%}▶%{$resetcolor%} ' -PROMPT2='%{%F{%(!.red.white)}%}◀%{$reset_color%} ' +PROMPT2='%{%(!.%F{red}.%F{white})%}◀%{$reset_color%} ' RPROMPT='$(vi_mode_prompt_info)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}' -- cgit v1.2.3-70-g09d2 From 3e9e385d98da148a7ad8e8d99da35ce6b7aae9ca Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 25 Feb 2020 15:41:17 +0100 Subject: battery: remove redundant grep calls in battery_pct function --- plugins/battery/battery.plugin.zsh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index 857ab6e8c..4c4d0d4fc 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -18,11 +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"\ =\ //') - local -i pct=$(( (currentcapacity/maxcapacity) * 100 )) - echo $pct + local battery_status="$(ioreg -rc AppleSmartBattery)" + local -i capacity=$(sed -n -e '/MaxCapacity/s/^.*"MaxCapacity"\ =\ //p' <<< $battery_status) + local -i current=$(sed -n -e '/CurrentCapacity/s/^.*"CurrentCapacity"\ =\ //p' <<< $battery_status) + echo $(( current * 100 / capacity )) } function battery_pct_remaining() { -- cgit v1.2.3-70-g09d2 From 609890847d3e3b222431952ee7be99803bd16ccc Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 25 Feb 2020 22:23:37 +0100 Subject: npm: hardcode completion function and delete cached one (#8679) Fixes #8665 --- plugins/npm/npm.plugin.zsh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) 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 -- cgit v1.2.3-70-g09d2 From 1a880fdb9b88c0c98a23d7b2ed2ddb42caef6662 Mon Sep 17 00:00:00 2001 From: Michael Dorst Date: Tue, 25 Feb 2020 13:42:39 -0800 Subject: installer: add option to install without replacing .zshrc (#8209) * Add option to install OMZ without replacing .zshrc tools/install.sh respects REPLACE_RC environment variable --noreplace-rc flag sets REPLACE_RC='no' * Change REPLACE_RC=no to KEEP_ZSHRC=yes Change --noreplace-rc to --keep-zshrc --- tools/install.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index bdf9f18e9..08f3db1e3 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -20,12 +20,14 @@ # BRANCH - branch to check out immediately after install (default: master) # # Other options: -# CHSH - 'no' means the installer will not change the default shell (default: yes) -# RUNZSH - 'no' means the installer will not run zsh after the install (default: yes) +# CHSH - 'no' means the installer will not change the default shell (default: yes) +# RUNZSH - 'no' means the installer will not run zsh after the install (default: yes) +# KEEP_ZSHRC - 'yes' means the installer will not replace an existing .zshrc (default: no) # # You can also pass some arguments to the install script to set some these options: # --skip-chsh: has the same behavior as setting CHSH to 'no' # --unattended: sets both CHSH and RUNZSH to 'no' +# --keep-zshrc: sets KEEP_ZSHRC to 'yes' # For example: # sh install.sh --unattended # @@ -40,6 +42,7 @@ BRANCH=${BRANCH:-master} # Other options CHSH=${CHSH:-yes} RUNZSH=${RUNZSH:-yes} +KEEP_ZSHRC=${KEEP_ZSHRC:-no} command_exists() { @@ -111,6 +114,11 @@ setup_zshrc() { # Must use this exact name so uninstall.sh can find it OLD_ZSHRC=~/.zshrc.pre-oh-my-zsh if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then + # Skip this if the user doesn't want to replace an existing .zshrc + if [ $KEEP_ZSHRC = yes ]; then + echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Keeping...${RESET}" + return + fi if [ -e "$OLD_ZSHRC" ]; then OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)" if [ -e "$OLD_OLD_ZSHRC" ]; then @@ -227,6 +235,7 @@ main() { case $1 in --unattended) RUNZSH=no; CHSH=no ;; --skip-chsh) CHSH=no ;; + --keep-zshrc) KEEP_ZSHRC=yes ;; esac shift done -- cgit v1.2.3-70-g09d2 From 01bfb57446fdc77e8b4ae696729688284392c0e6 Mon Sep 17 00:00:00 2001 From: wallace11 <11wallace11@gmail.com> Date: Thu, 27 Feb 2020 00:59:59 +0900 Subject: zsh-interactive-cd: add vi-mode support (#8681) --- plugins/zsh-interactive-cd/zsh-interactive-cd.plugin.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3-70-g09d2 From 6cb8ff391d0258434485dbe246f9885ba85cf839 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 27 Feb 2020 15:21:10 +0100 Subject: vagrant: document aliases --- plugins/vagrant/README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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` | -- cgit v1.2.3-70-g09d2 From bccfe1389c97379388a148b3a48a63d7272ec017 Mon Sep 17 00:00:00 2001 From: Mauricio Wolff Date: Fri, 28 Feb 2020 03:06:20 +1100 Subject: updater: add --autostash to git pull (#7172) If I have custom configs (like theme customizations) I have to stash my changes and get them back after the update. By adding the --autostash on upgrade.sh, if I have any changes not commited they'll be reapplied after the upgrade, allowing me to have temporary customizations without any harm to the upgrade process. --- tools/upgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/upgrade.sh b/tools/upgrade.sh index 3005e6542..0dc84e214 100644 --- a/tools/upgrade.sh +++ b/tools/upgrade.sh @@ -38,7 +38,7 @@ if [ -n "$remote" ]; then fi printf "${BLUE}%s${NORMAL}\n" "Updating Oh My Zsh" -if git pull --rebase --stat origin master +if git pull --rebase --autostash --stat origin master then printf '%s' "$GREEN" printf '%s\n' ' __ __ ' -- cgit v1.2.3-70-g09d2 From 6b54302b90720437300967b3506bffe00a3e243c Mon Sep 17 00:00:00 2001 From: Petr Bělohlávek Date: Fri, 20 Jan 2017 11:05:01 +0100 Subject: python: add alias to run the proper IPython based on virtualenv Current state: a user invokes `ipython` and is provided with the IPython instance regarding the `$PATH`. Proposed state: a user invokes `ipython` (which is a new alias in the *python plugin*) and is provided with the proper IPython instance regarding the currently activated virtualenv. Example: the user's default Python is 2.7 with installed IPython 2.7. User activates Python 3.5 virtualenv where he installs IPython 3.5. After activating the environment, one expects `ipython` to run the version 3.5, which does not happen by default. Instead, IPython 2.7 is used, which in counter-intuitive and often causes problem. Closes #5797 --- plugins/python/README.md | 1 + plugins/python/python.plugin.zsh | 2 ++ 2 files changed, 3 insertions(+) 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 ` | 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()'" -- cgit v1.2.3-70-g09d2 From 011c7153d589b52eb1d48fdf22d4f1438449be2b Mon Sep 17 00:00:00 2001 From: Ciacho Date: Wed, 27 Jan 2016 21:39:53 +0100 Subject: nmap: add alias for ICMP scan (#4807) Closes #4807 --- plugins/nmap/README.md | 54 ++++++++++++++++++-------------------------- plugins/nmap/nmap.plugin.zsh | 2 +- 2 files changed, 23 insertions(+), 33 deletions(-) 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" -- cgit v1.2.3-70-g09d2 From dbd2f77bd9c13f017550ee6dae37ff95a2c3d183 Mon Sep 17 00:00:00 2001 From: Julian Parsert Date: Thu, 27 Feb 2020 17:28:08 +0000 Subject: norm: add hg prompt (#6725) --- themes/norm.zsh-theme | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/themes/norm.zsh-theme b/themes/norm.zsh-theme index 13077ccf5..bd7ca568a 100644 --- a/themes/norm.zsh-theme +++ b/themes/norm.zsh-theme @@ -1,4 +1,7 @@ -PROMPT='%{$fg[yellow]%}λ %m %{$fg[green]%}%c %{$fg[yellow]%}→ $(git_prompt_info)%{$reset_color%}' +PROMPT='%{$fg[yellow]%}λ %m %{$fg[green]%}%c %{$fg[yellow]%}→ $(git_prompt_info)$(hg_prompt_info)%{$reset_color%}' ZSH_THEME_GIT_PROMPT_PREFIX="λ %{$fg[blue]%}git %{$fg[red]%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg[yellow]%} → %{$reset_color%}" +ZSH_THEME_HG_PROMPT_PREFIX="λ %{$fg[blue]%}hg %{$fg[red]%}" +ZSH_THEME_HG_PROMPT_SUFFIX="%{$fg[yellow]%} → %{$reset_color%}" + -- cgit v1.2.3-70-g09d2 From 573901dd46d657c4c3d14f6e03a85f1522fb299b Mon Sep 17 00:00:00 2001 From: Adrien Plazas Date: Thu, 27 Feb 2020 18:45:53 +0100 Subject: jhbuild: add shell alias (#3707) This adds "jhsh" as an alias for "jhbuild shell" to the JHBuild plugin. --- plugins/jhbuild/jhbuild.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/jhbuild/jhbuild.plugin.zsh b/plugins/jhbuild/jhbuild.plugin.zsh index fed1bc9fc..05e56039d 100644 --- a/plugins/jhbuild/jhbuild.plugin.zsh +++ b/plugins/jhbuild/jhbuild.plugin.zsh @@ -23,6 +23,8 @@ alias jhu='jhbuild update' alias jhuo='jhbuild updateone' # Uninstall alias jhun='jhbuild uninstall' +# Shell +alias jhsh='jhbuild shell' -- cgit v1.2.3-70-g09d2 From ee7a9f6fe679239f7c21f32df135f9c79b606336 Mon Sep 17 00:00:00 2001 From: Miguel Vaello Martínez Date: Thu, 30 Jun 2016 12:25:00 +0200 Subject: jhbuild: add some missing commands and update README (#5195) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commands: make, tinderbox. Closes #5195 Co-authored-by: Marc Cornellà --- plugins/jhbuild/README.md | 34 ++++++++++++++++++++++++++++++++-- plugins/jhbuild/jhbuild.plugin.zsh | 14 ++++++++------ 2 files changed, 40 insertions(+), 8 deletions(-) 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 05e56039d..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 @@ -25,6 +28,5 @@ alias jhuo='jhbuild updateone' alias jhun='jhbuild uninstall' # Shell alias jhsh='jhbuild shell' - - - +# Tinderbox +alias jht='jhbuild tinderbox' -- cgit v1.2.3-70-g09d2 From 79fff1ee492a2c4d8ab09678bd5e7440cfbf03dd Mon Sep 17 00:00:00 2001 From: Guillermo del Fresno Date: Thu, 27 Feb 2020 14:55:14 -0300 Subject: macports: add rdeps and rdependents completion (#4717) --- plugins/macports/_port | 2 ++ 1 file changed, 2 insertions(+) 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' -- cgit v1.2.3-70-g09d2 From 2c0315dba4297ec2e87d6f503a6d907c33f51958 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 27 Feb 2020 19:26:03 +0100 Subject: ng: refactor README --- plugins/ng/README.md | 37 +++++-------------------------------- 1 file changed, 5 insertions(+), 32 deletions(-) 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)) -- cgit v1.2.3-70-g09d2 From 368198b7616eb69b396de86d9ec4ff0f35bd72f0 Mon Sep 17 00:00:00 2001 From: Chai Feng Date: Fri, 28 Feb 2020 05:47:06 +0800 Subject: Fix an issue with escape characters (#7979) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Francisco de Zuviría --- plugins/copybuffer/copybuffer.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 -- cgit v1.2.3-70-g09d2 From 57739cbcb64fb5d166f35b877ffb10b8120256b7 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 27 Feb 2020 23:24:23 +0100 Subject: lib: add support for clip.exe clipboard copy in WSL --- lib/clipboard.zsh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh index 6102f3324..92959bc03 100644 --- a/lib/clipboard.zsh +++ b/lib/clipboard.zsh @@ -78,6 +78,9 @@ function detect-clipboard() { elif [ -n "${TMUX:-}" ] && (( ${+commands[tmux]} )); then function clipcopy() { tmux load-buffer "${1:--}"; } function clippaste() { tmux save-buffer -; } + elif [[ $(uname -r) = *icrosoft* ]]; then + function clipcopy() { clip.exe < "${1:-/dev/stdin}"; } + function clippaste() { _retry_clipboard_detection_or_fail clippaste "$@"; } else function _retry_clipboard_detection_or_fail() { local clipcmd="${1}"; shift -- cgit v1.2.3-70-g09d2 From 2b499e1a9e8788d607768ecef67851e8234b72b3 Mon Sep 17 00:00:00 2001 From: j <74ef54cf@opayq.com> Date: Sat, 12 Aug 2017 15:31:34 -0700 Subject: lib: add termux commands to clipboard.zsh (#6243) Closes #6243 --- lib/clipboard.zsh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh index 92959bc03..808f2ea2d 100644 --- a/lib/clipboard.zsh +++ b/lib/clipboard.zsh @@ -75,6 +75,9 @@ function detect-clipboard() { elif (( ${+commands[win32yank]} )); then function clipcopy() { win32yank -i < "${1:-/dev/stdin}"; } function clippaste() { win32yank -o; } + elif [[ $OSTYPE == linux-android* ]] && (( $+commands[termux-clipboard-set] )); then + function clipcopy() { termux-clipboard-set "${1:-/dev/stdin}"; } + function clippaste() { termux-clipboard-get; } elif [ -n "${TMUX:-}" ] && (( ${+commands[tmux]} )); then function clipcopy() { tmux load-buffer "${1:--}"; } function clippaste() { tmux save-buffer -; } -- cgit v1.2.3-70-g09d2