From 093b56a7d769d15bdcc2c5300bc4ebedc9d0a837 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Fri, 13 Sep 2019 11:20:20 +0200 Subject: git: fix gtl alias argument Fixes the error `no matches found` because the argument is not quoted. See https://github.com/robbyrussell/oh-my-zsh/pull/7629#issuecomment-531151821 --- plugins/git/git.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 2edee0298..d8c4cffd1 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -243,7 +243,7 @@ alias gswc='git switch -c' alias gts='git tag -s' alias gtv='git tag | sort -V' -alias gtl='gtl(){ git tag --sort=-v:refname -n -l ${1}* }; noglob gtl' +alias gtl='gtl(){ git tag --sort=-v:refname -n -l "${1}*" }; noglob gtl' alias gunignore='git update-index --no-assume-unchanged' alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1' -- cgit v1.2.3-70-g09d2 From 576e0992cac8a0cc4f824e20c0d60188578dd158 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Fri, 13 Sep 2019 11:41:13 +0200 Subject: z: update to latest version (e77e938) Closes #8145 Co-authored-by: GHPS --- plugins/z/z.sh | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/plugins/z/z.sh b/plugins/z/z.sh index 5fe6d5266..5c5771d62 100644 --- a/plugins/z/z.sh +++ b/plugins/z/z.sh @@ -89,7 +89,7 @@ _z() { if [ $? -ne 0 -a -f "$datafile" ]; then env rm -f "$tempfile" else - [ "$_Z_OWNER" ] && chown $_Z_OWNER:$(id -ng $_Z_OWNER) "$tempfile" + [ "$_Z_OWNER" ] && chown $_Z_OWNER:"$(id -ng $_Z_OWNER)" "$tempfile" env mv -f "$tempfile" "$datafile" || env rm -f "$tempfile" fi @@ -110,20 +110,21 @@ _z() { else # list/go + local echo fnd last list opt typ while [ "$1" ]; do case "$1" in - --) while [ "$1" ]; do shift; local fnd="$fnd${fnd:+ }$1";done;; - -*) local opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in - c) local fnd="^$PWD $fnd";; - e) local echo=1;; + --) while [ "$1" ]; do shift; fnd="$fnd${fnd:+ }$1";done;; + -*) opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in + c) fnd="^$PWD $fnd";; + e) echo=1;; h) echo "${_Z_CMD:-z} [-cehlrtx] args" >&2; return;; - l) local list=1;; - r) local typ="rank";; - t) local typ="recent";; + l) list=1;; + r) typ="rank";; + t) typ="recent";; x) sed -i -e "\:^${PWD}|.*:d" "$datafile";; esac; opt=${opt:1}; done;; - *) local fnd="$fnd${fnd:+ }$1";; - esac; local last=$1; [ "$#" -gt 0 ] && shift; done - [ "$fnd" -a "$fnd" != "^$PWD " ] || local list=1 + *) fnd="$fnd${fnd:+ }$1";; + esac; last=$1; [ "$#" -gt 0 ] && shift; done + [ "$fnd" -a "$fnd" != "^$PWD " ] || list=1 # if we hit enter on a completion just go there case "$last" in @@ -147,7 +148,7 @@ _z() { function output(matches, best_match, common) { # list or return the desired directory if( list ) { - cmd = "sort -n >&2" + cmd = "sort -g >&2" for( x in matches ) { if( matches[x] ) { printf "%-10s %s\n", matches[x], x | cmd -- cgit v1.2.3-70-g09d2 From 32338fd40cae45c775dadc34ae05476811a3834b Mon Sep 17 00:00:00 2001 From: nv035674 <37336037+nv035674@users.noreply.github.com> Date: Fri, 13 Sep 2019 16:30:17 -0500 Subject: robbyrussell: restore prompt spacing (#8148) --- themes/robbyrussell.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/robbyrussell.zsh-theme b/themes/robbyrussell.zsh-theme index 4df8433e3..2fd5f2cdc 100644 --- a/themes/robbyrussell.zsh-theme +++ b/themes/robbyrussell.zsh-theme @@ -1,4 +1,4 @@ -PROMPT="%(?:%{$fg_bold[green]%}➜:%{$fg_bold[red]%}➜)" +PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )" PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)' ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}" -- cgit v1.2.3-70-g09d2 From 095d56b5ea44988c83d0be501e70f37df3d5066b Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 19 Sep 2019 16:20:02 +0200 Subject: Fix WSL check for WSL 2 and simplify nohup in open_command WSL 2 changes the output of `uname -r`. For instance, WSL 1: 4.4.0-18980-Microsoft WSL 2: 4.19.67-microsoft-standard Since WSL 2 lowercases the M, we can match for the rest of the string which remains lowercase throughout both versions. Another option would be to match for both upper- and lower-case Ms, like that: $(uname -r) = *[Mm]icrosoft* Fixed use of nohup in open_command where it was only necessary for xdg-open (and actually harmful for cmd.exe in WSL 2). The current logic is simpler and more future-proof. --- lib/functions.zsh | 9 ++------- plugins/sublime/sublime.plugin.zsh | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/functions.zsh b/lib/functions.zsh index 9f8736bd7..61dfa4780 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -21,7 +21,7 @@ function open_command() { case "$OSTYPE" in darwin*) open_cmd='open' ;; cygwin*) open_cmd='cygstart' ;; - linux*) ! [[ $(uname -a) =~ "Microsoft" ]] && open_cmd='xdg-open' || { + linux*) [[ "$(uname -r)" != *icrosoft* ]] && open_cmd='nohup xdg-open' || { open_cmd='cmd.exe /c start ""' [[ -e "$1" ]] && { 1="$(wslpath -w "${1:a}")" || return 1 } } ;; @@ -31,12 +31,7 @@ function open_command() { ;; esac - # don't use nohup on OSX - if [[ "$OSTYPE" == darwin* ]]; then - ${=open_cmd} "$@" &>/dev/null - else - nohup ${=open_cmd} "$@" &>/dev/null - fi + ${=open_cmd} "$@" &>/dev/null } # diff --git a/plugins/sublime/sublime.plugin.zsh b/plugins/sublime/sublime.plugin.zsh index 3a82d6c7f..69604ab4f 100644 --- a/plugins/sublime/sublime.plugin.zsh +++ b/plugins/sublime/sublime.plugin.zsh @@ -15,7 +15,7 @@ alias stn=create_project declare -a _sublime_paths if [[ "$OSTYPE" == linux* ]]; then - if [[ "$(uname -r)" = *Microsoft* ]]; then + if [[ "$(uname -r)" = *icrosoft* ]]; then _sublime_paths=( "$(wslpath -u 'C:\Program Files\Sublime Text 3\subl.exe')" "$(wslpath -u 'C:\Program Files\Sublime Text 2\subl.exe')" -- cgit v1.2.3-70-g09d2 From 6cfaa076272e08b6a81b6358b78d020e48f8a4a6 Mon Sep 17 00:00:00 2001 From: Ian Chesal Date: Fri, 20 Sep 2019 04:58:35 -0700 Subject: Add gcloud plugin (#8144) * A gcloud plugin This PR addresses issue #6205 This adds support for loading completion for the Google Cloud SDK command line tools. It searches the known paths for an SDK and loads the provided completion if it is found. Users can supply a custom location for the SDK by setting `CLOUDSDK_HOME` in their `zshrc` before loading oh-my-zsh plugins. * Canoncial zsh and some safe guards Based on a PR review from mcornella. All off this has now been tested on the following variants: - macOS 10.14.6 - Homebrew - macOS 10.14.6 - Custom install - Ubuntu 16.04.6 LTS - apt install - Ubuntu 18.04.3 LTS - apt install - Ubuntu 18.04.3 LTS - snap classic install - CentOS 7 - yum install --- plugins/gcloud/README.md | 24 ++++++++++++++++++++++++ plugins/gcloud/gcloud.plugin.zsh | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 plugins/gcloud/README.md create mode 100644 plugins/gcloud/gcloud.plugin.zsh diff --git a/plugins/gcloud/README.md b/plugins/gcloud/README.md new file mode 100644 index 000000000..e7ce0e0f1 --- /dev/null +++ b/plugins/gcloud/README.md @@ -0,0 +1,24 @@ +# gcloud + +This plugin provides completion support for the +[Google Cloud SDK CLI](https://cloud.google.com/sdk/gcloud/). + +To use it, add `gcloud` to the plugins array in your zshrc file. + +```zsh +plugins=(... gcloud) +``` + +It relies on you having installed the SDK using one of the supported options +listed [here](https://cloud.google.com/sdk/install). + +## Plugin Options + +* Set `CLOUDSDK_HOME` in your `zshrc` file before you load oh-my-zsh if you have +your GCloud SDK installed in a non-standard location. The plugin will use this +as the base for your SDK if it finds it set already. + +* If you do not have a `python2` in your `PATH` you'll also need to set the +`CLOUDSDK_PYTHON` environment variable at the end of your `.zshrc`. This is +used by the SDK to call a compatible interpreter when you run one of the +SDK commands. diff --git a/plugins/gcloud/gcloud.plugin.zsh b/plugins/gcloud/gcloud.plugin.zsh new file mode 100644 index 000000000..6433a7252 --- /dev/null +++ b/plugins/gcloud/gcloud.plugin.zsh @@ -0,0 +1,32 @@ +##################################################### +# gcloud plugin for oh-my-zsh # +# Author: Ian Chesal (github.com/ianchesal) # +##################################################### + +if [[ -z "${CLOUDSDK_HOME}" ]]; then + search_locations=( + "$HOME/google-cloud-sdk" + "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk" + "/usr/share/google-cloud-sdk" + "/snap/google-cloud-sdk/current" + "/usr/lib64/google-cloud-sdk/" + ) + + for gcloud_sdk_location in $search_locations; do + if [[ -d "${gcloud_sdk_location}" ]]; then + CLOUDSDK_HOME="${gcloud_sdk_location}" + break + fi + done +fi + +if (( ${+CLOUDSDK_HOME} )); then + if (( ! $+commands[gcloud] )); then + # Only source this if GCloud isn't already on the path + if [[ -f "${CLOUDSDK_HOME}/path.zsh.inc" ]]; then + source "${CLOUDSDK_HOME}/path.zsh.inc" + fi + fi + source "${CLOUDSDK_HOME}/completion.zsh.inc" + export CLOUDSDK_HOME +fi -- cgit v1.2.3-70-g09d2 From be9160ef90bd55bc4f19f94df548b728c64d87bf Mon Sep 17 00:00:00 2001 From: Franco Catena Date: Sat, 21 Sep 2019 18:11:25 -0300 Subject: gcloud: add search path for Arch Linux (#8164) --- plugins/gcloud/gcloud.plugin.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/gcloud/gcloud.plugin.zsh b/plugins/gcloud/gcloud.plugin.zsh index 6433a7252..c7aebe697 100644 --- a/plugins/gcloud/gcloud.plugin.zsh +++ b/plugins/gcloud/gcloud.plugin.zsh @@ -10,6 +10,7 @@ if [[ -z "${CLOUDSDK_HOME}" ]]; then "/usr/share/google-cloud-sdk" "/snap/google-cloud-sdk/current" "/usr/lib64/google-cloud-sdk/" + "/opt/google-cloud-sdk" ) for gcloud_sdk_location in $search_locations; do -- cgit v1.2.3-70-g09d2 From f9e7c45a484723f693a77ab6128a1cc163f3704a Mon Sep 17 00:00:00 2001 From: Andrei Lesnitsky Date: Tue, 24 Sep 2019 15:46:38 +0300 Subject: Add flutter plugin (#8150) --- plugins/flutter/README.md | 21 +++++++++++++++++++++ plugins/flutter/_flutter | 37 +++++++++++++++++++++++++++++++++++++ plugins/flutter/flutter.plugin.zsh | 7 +++++++ 3 files changed, 65 insertions(+) create mode 100644 plugins/flutter/README.md create mode 100644 plugins/flutter/_flutter create mode 100644 plugins/flutter/flutter.plugin.zsh diff --git a/plugins/flutter/README.md b/plugins/flutter/README.md new file mode 100644 index 000000000..be419144f --- /dev/null +++ b/plugins/flutter/README.md @@ -0,0 +1,21 @@ +## Flutter plugin + +The Flutter plugin provides completion and useful aliases + +To use it, add flutter to the plugins array of your zshrc file: + +``` +plugins=(... flutter) +``` + +## Aliases + +| Alias | Command | Description | +| :--------- | :--------------------- | :------------------------------------------------------------------------- | +| `fl` | `flutter` | Shorthand for flutter command | +| `flr` | `flutter run` | Runs flutter app | +| `fldoc` | `flutter doctor` | Runs flutter doctor | +| `flb` | `flutter build` | Build flutter application | +| `flattach` | `flutter attach` | Attaches flutter to a running flutter application with enabled observatory | +| `flget` | `flutter packages get` | Installs dependencies | +| `flc` | `flutter clean` | Cleans flutter porject | diff --git a/plugins/flutter/_flutter b/plugins/flutter/_flutter new file mode 100644 index 000000000..ab6ce4265 --- /dev/null +++ b/plugins/flutter/_flutter @@ -0,0 +1,37 @@ +#compdef flutter +#autoload + +local -a _1st_arguments +_1st_arguments=( + "analyze":"Analyze the project's Dart code." + "assemble":"Assemble and build flutter resources." + "attach":"Attach to a running application." + "build":"Flutter build commands." + "channel":"List or switch flutter channels." + "clean":"Delete the build/ and .dart_tool/ directories." + "config":"Configure Flutter settings." + "create":"Create a new Flutter project." + "devices":"List all connected devices." + "doctor":"Show information about the installed tooling." + "drive":"Runs Flutter Driver tests for the current project." + "emulators":"List, launch and create emulators." + "format":" Format one or more dart files." + "help":"Display help information for flutter." + "install":"Install a Flutter app on an attached device." + "logs":"Show log output for running Flutter apps." + "make-host-app-editable":"Moves host apps from generated directories to non-generated directories so that they can be edited by developers." + "precache":"Populates the Flutter tool's cache of binary artifacts." + "pub":"Commands for managing Flutter packages." + "run":"Run your Flutter app on an attached device." + "screenshot":"Take a screenshot from a connected device." + "test":"Run Flutter unit tests for the current project." + "upgrade":"Upgrade your copy of Flutter." + "version":"List or switch flutter versions." +) + +_arguments -C '*:: :->subcmds' + +if (( CURRENT == 1 )); then + _describe -t commands "flutter command" _1st_arguments + return +fi diff --git a/plugins/flutter/flutter.plugin.zsh b/plugins/flutter/flutter.plugin.zsh new file mode 100644 index 000000000..01c4c9f5f --- /dev/null +++ b/plugins/flutter/flutter.plugin.zsh @@ -0,0 +1,7 @@ +alias fl="flutter" +alias flr="flutter run" +alias fldoc="flutter doctor" +alias flb="flutter build" +alias flattach="flutter attach" +alias flget="flutter packages get" +alias flc="flutter clean" -- cgit v1.2.3-70-g09d2