diff options
-rw-r--r-- | lib/functions.zsh | 9 | ||||
-rw-r--r-- | plugins/flutter/README.md | 21 | ||||
-rw-r--r-- | plugins/flutter/_flutter | 37 | ||||
-rw-r--r-- | plugins/flutter/flutter.plugin.zsh | 7 | ||||
-rw-r--r-- | plugins/gcloud/README.md | 24 | ||||
-rw-r--r-- | plugins/gcloud/gcloud.plugin.zsh | 33 | ||||
-rw-r--r-- | plugins/git/git.plugin.zsh | 2 | ||||
-rw-r--r-- | plugins/sublime/sublime.plugin.zsh | 2 | ||||
-rw-r--r-- | plugins/z/z.sh | 25 | ||||
-rw-r--r-- | themes/robbyrussell.zsh-theme | 2 |
10 files changed, 140 insertions, 22 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/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" 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..c7aebe697 --- /dev/null +++ b/plugins/gcloud/gcloud.plugin.zsh @@ -0,0 +1,33 @@ +##################################################### +# 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/" + "/opt/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 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' 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')" 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 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]%}" |