diff options
26 files changed, 95 insertions, 57 deletions
diff --git a/lib/completion.zsh b/lib/completion.zsh index a1e934315..c7db2eb7b 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -25,6 +25,9 @@ else fi unset CASE_SENSITIVE HYPHEN_INSENSITIVE +# Complete . and .. special directories +zstyle ':completion:*' special-dirs true + zstyle ':completion:*' list-colors '' zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' diff --git a/lib/functions.zsh b/lib/functions.zsh index f30653784..7410ae645 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -25,7 +25,9 @@ function open_command() { case "$OSTYPE" in darwin*) open_cmd='open' ;; cygwin*) open_cmd='cygstart' ;; - linux*) open_cmd='xdg-open' ;; + linux*) [[ $(uname -a) =~ "Microsoft" ]] && \ + open_cmd='cmd.exe /c start' || \ + open_cmd='xdg-open' ;; msys*) open_cmd='start ""' ;; *) echo "Platform $OSTYPE not supported" return 1 diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index 6a0e04add..a326e2e01 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -42,11 +42,11 @@ function aws_profiles { compctl -K aws_profiles asp -if _homebrew-installed && _awscli-homebrew-installed ; then +if which aws_zsh_completer.sh &>/dev/null; then + _aws_zsh_completer_path=$(which aws_zsh_completer.sh 2>/dev/null) +elif _homebrew-installed && _awscli-homebrew-installed; then _aws_zsh_completer_path=$_brew_prefix/libexec/bin/aws_zsh_completer.sh -else - _aws_zsh_completer_path=$(which aws_zsh_completer.sh) fi -[ -x $_aws_zsh_completer_path ] && source $_aws_zsh_completer_path +[ -n "$_aws_zsh_completer_path" ] && [ -x $_aws_zsh_completer_path ] && source $_aws_zsh_completer_path unset _aws_zsh_completer_path diff --git a/plugins/copydir/README.md b/plugins/copydir/README.md new file mode 100644 index 000000000..594bf1065 --- /dev/null +++ b/plugins/copydir/README.md @@ -0,0 +1,10 @@ +# copydir plugin + +Copies the path of your current folder to the system clipboard. + +To use, add `copydir` to your plugins array: +``` +plugins=(... copydir) +``` + +Then use the command `copydir` to copy the $PWD. diff --git a/plugins/copyfile/README.md b/plugins/copyfile/README.md new file mode 100644 index 000000000..53138ad06 --- /dev/null +++ b/plugins/copyfile/README.md @@ -0,0 +1,10 @@ +# copyfile plugin + +Puts the contents of a file in your system clipboard so you can paste it anywhere. + +To use, add `copyfile` to your plugins array: +``` +plugins=(... copyfile) +``` + +Then you can run the command `copyfile <filename>` to copy the file named `filename`. diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh index 6867086ca..239915e48 100644 --- a/plugins/dirhistory/dirhistory.plugin.zsh +++ b/plugins/dirhistory/dirhistory.plugin.zsh @@ -124,7 +124,9 @@ zle -N dirhistory_zle_dirhistory_back bindkey "\e[3D" dirhistory_zle_dirhistory_back bindkey "\e[1;3D" dirhistory_zle_dirhistory_back # Mac teminal (alt+left/right) -bindkey "^[b" dirhistory_zle_dirhistory_back +if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then + bindkey "^[b" dirhistory_zle_dirhistory_back +fi # Putty: bindkey "\e\e[D" dirhistory_zle_dirhistory_back # GNU screen: @@ -133,7 +135,9 @@ bindkey "\eO3D" dirhistory_zle_dirhistory_back zle -N dirhistory_zle_dirhistory_future bindkey "\e[3C" dirhistory_zle_dirhistory_future bindkey "\e[1;3C" dirhistory_zle_dirhistory_future -bindkey "^[f" dirhistory_zle_dirhistory_future +if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]]; then + bindkey "^[f" dirhistory_zle_dirhistory_future +fi bindkey "\e\e[C" dirhistory_zle_dirhistory_future bindkey "\eO3C" dirhistory_zle_dirhistory_future diff --git a/plugins/fedora/README.md b/plugins/fedora/README.md deleted file mode 100644 index f384b0ffd..000000000 --- a/plugins/fedora/README.md +++ /dev/null @@ -1,3 +0,0 @@ -This is a plugin based on yum plugin, but using dnf as main frontend -(from Fedora 22 onwards, yum is deprecated in favor of dnf). - diff --git a/plugins/fedora/fedora.plugin.zsh b/plugins/fedora/fedora.plugin.zsh index eddc3627b..16a214313 100644..120000 --- a/plugins/fedora/fedora.plugin.zsh +++ b/plugins/fedora/fedora.plugin.zsh @@ -1,16 +1 @@ -## Aliases - -alias dnfs="dnf search" # search package -alias dnfp="dnf info" # show package info -alias dnfl="dnf list" # list packages -alias dnfgl="dnf grouplist" # list package groups -alias dnfli="dnf list installed" # print all installed packages -alias dnfmc="dnf makecache" # rebuilds the dnf package list - -alias dnfu="sudo dnf upgrade" # upgrade packages -alias dnfi="sudo dnf install" # install package -alias dnfgi="sudo dnf groupinstall" # install package group -alias dnfr="sudo dnf remove" # remove package -alias dnfgr="sudo dnf groupremove" # remove pagage group -alias dnfrl="sudo dnf remove --remove-leaves" # remove package and leaves -alias dnfc="sudo dnf clean all" # clean cache +../dnf/dnf.plugin.zsh
\ No newline at end of file diff --git a/plugins/git-prompt/gitstatus.py b/plugins/git-prompt/gitstatus.py index a8eb8284b..14d875973 100644 --- a/plugins/git-prompt/gitstatus.py +++ b/plugins/git-prompt/gitstatus.py @@ -41,7 +41,7 @@ ahead, behind = 0, 0 status = [(line[0], line[1], line[2:]) for line in stdout.decode('utf-8').splitlines()] for st in status: if st[0] == '#' and st[1] == '#': - if re.search('Initial commit on', st[2]): + if re.search('Initial commit on', st[2]) or re.search('No commits yet on', st[2]): branch = st[2].split(' ')[-1] elif re.search('no branch', st[2]): # detached status branch = get_tagname_or_hash() diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index fa0c06500..fd55be138 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -180,8 +180,8 @@ alias glgg='git log --graph' alias glgga='git log --graph --decorate --all' alias glgm='git log --graph --max-count=10' alias glo='git log --oneline --decorate' -alias glol="git log --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" -alias glola="git log --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all" +alias glol="git log --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'" +alias glola="git log --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all" alias glog='git log --oneline --decorate --graph' alias gloga='git log --oneline --decorate --graph --all' alias glp="_git_log_prettily" diff --git a/plugins/github/_hub b/plugins/github/_hub index 3a6493878..1833a9c09 100644 --- a/plugins/github/_hub +++ b/plugins/github/_hub @@ -89,6 +89,7 @@ __hub_setup_zsh_fns () { browse:'browse the project on GitHub' compare:'open GitHub compare view' ci-status:'lookup commit in GitHub Status API' + sync:'update local branches from upstream' ) _describe -t hub-commands 'hub command' hub_commands && ret=0 @@ -115,6 +116,7 @@ create browse compare ci-status +sync EOF __git_list_all_commands_without_hub } diff --git a/plugins/github/github.plugin.zsh b/plugins/github/github.plugin.zsh index 0ab399c97..077f07bd4 100644 --- a/plugins/github/github.plugin.zsh +++ b/plugins/github/github.plugin.zsh @@ -1,8 +1,6 @@ # Set up hub wrapper for git, if it is available; http://github.com/github/hub -if [ "$commands[(I)hub]" ]; then - if hub --version &>/dev/null; then - eval $(hub alias -s zsh) - fi +if (( $+commands[hub] )); then + alias git=hub fi # Functions ################################################################# diff --git a/plugins/gitignore/gitignore.plugin.zsh b/plugins/gitignore/gitignore.plugin.zsh index ba1b38711..f242169e4 100644 --- a/plugins/gitignore/gitignore.plugin.zsh +++ b/plugins/gitignore/gitignore.plugin.zsh @@ -1,7 +1,7 @@ -function gi() { curl -sL https://www.gitignore.io/api/${(j:,:)@} } +function gi() { curl -fL https://www.gitignore.io/api/${(j:,:)@} } _gitignoreio_get_command_list() { - curl -sL https://www.gitignore.io/api/list | tr "," "\n" + curl -fL https://www.gitignore.io/api/list | tr "," "\n" } _gitignoreio () { diff --git a/plugins/gpg-agent/gpg-agent.plugin.zsh b/plugins/gpg-agent/gpg-agent.plugin.zsh index 6a94f598f..3e24c2527 100644 --- a/plugins/gpg-agent/gpg-agent.plugin.zsh +++ b/plugins/gpg-agent/gpg-agent.plugin.zsh @@ -1,16 +1,16 @@ # Enable gpg-agent if it is not running- # --use-standard-socket will work from version 2 upwards -AGENT_SOCK=`gpgconf --list-dirs | grep agent-socket | cut -d : -f 2` +AGENT_SOCK=$(gpgconf --list-dirs | grep agent-socket | cut -d : -f 2) -if [ ! -S ${AGENT_SOCK} ]; then - gpg-agent --daemon --use-standard-socket >/dev/null 2>&1 +if [[ ! -S $AGENT_SOCK ]]; then + gpg-agent --daemon --use-standard-socket &>/dev/null fi -export GPG_TTY=$(tty) +export GPG_TTY=$TTY # Set SSH to use gpg-agent if it's enabled -if [ -S "${AGENT_SOCK}.ssh" ]; then - export SSH_AUTH_SOCK="${AGENT_SOCK}.ssh" +GNUPGCONFIG="${GNUPGHOME:-"$HOME/.gnupg"}/gpg-agent.conf" +if [[ -r $GNUPGCONFIG ]] && command grep -q enable-ssh-support "$GNUPGCONFIG"; then + export SSH_AUTH_SOCK="$AGENT_SOCK.ssh" unset SSH_AGENT_PID fi - diff --git a/plugins/gradle/gradle.plugin.zsh b/plugins/gradle/gradle.plugin.zsh index 0adc04a13..c7047552d 100644 --- a/plugins/gradle/gradle.plugin.zsh +++ b/plugins/gradle/gradle.plugin.zsh @@ -88,7 +88,7 @@ function _gradle_arguments() { # and if so, regenerate the .gradle_tasks cache file ############################################################################ _gradle_does_task_list_need_generating () { - [[ ! -f .gradletasknamecache ]] || [[ build.gradle -nt .gradletasknamecache ]] + [[ ! -f .gradletasknamecache ]] || [[ build.gradle -nt .gradletasknamecache || build.gradle.kts -nt .gradletasknamecache ]] } ############## @@ -144,7 +144,7 @@ _gradle_parse_and_extract_tasks () { # Discover the gradle tasks by running "gradle tasks --all" ############################################################################ _gradle_tasks () { - if [[ -f build.gradle ]]; then + if [[ -f build.gradle || -f build.gradle.kts ]]; then _gradle_arguments if _gradle_does_task_list_need_generating; then _gradle_parse_and_extract_tasks "$(gradle tasks --all)" > .gradletasknamecache @@ -154,7 +154,7 @@ _gradle_tasks () { } _gradlew_tasks () { - if [[ -f build.gradle ]]; then + if [[ -f build.gradle || -f build.gradle.kts ]]; then _gradle_arguments if _gradle_does_task_list_need_generating; then _gradle_parse_and_extract_tasks "$(./gradlew tasks --all)" > .gradletasknamecache diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh index 97e429aac..ec1321d8b 100644 --- a/plugins/kubectl/kubectl.plugin.zsh +++ b/plugins/kubectl/kubectl.plugin.zsh @@ -33,6 +33,12 @@ alias kes='k edit svc' alias kds='k describe svc' alias kdels='k delete svc' +# Ingress management +alias kgi='k get ingress' +alias kei='k edit ingress' +alias kdi='k describe ingress' +alias kdeli='k delete ingress' + # Secret management alias kgsec='k get secret' alias kdsec='k describe secret' diff --git a/plugins/last-working-dir/last-working-dir.plugin.zsh b/plugins/last-working-dir/last-working-dir.plugin.zsh index e882b288f..53bb19e46 100644 --- a/plugins/last-working-dir/last-working-dir.plugin.zsh +++ b/plugins/last-working-dir/last-working-dir.plugin.zsh @@ -4,8 +4,10 @@ typeset -g ZSH_LAST_WORKING_DIRECTORY # Updates the last directory once directory is changed chpwd_functions+=(chpwd_last_working_dir) chpwd_last_working_dir() { - local cache_file="$ZSH_CACHE_DIR/last-working-dir" - pwd >| "$cache_file" + if [ "$ZSH_SUBSHELL" = 0 ]; then + local cache_file="$ZSH_CACHE_DIR/last-working-dir" + pwd >| "$cache_file" + fi } # Changes directory to the last working directory diff --git a/plugins/minikube/minikube.plugin.zsh b/plugins/minikube/minikube.plugin.zsh new file mode 100644 index 000000000..d8ebe79af --- /dev/null +++ b/plugins/minikube/minikube.plugin.zsh @@ -0,0 +1,6 @@ +# Autocompletion for Minikube. +# + +if [ $commands[minikube] ]; then + source <(minikube completion zsh) +fi diff --git a/plugins/mix-fast/mix-fast.plugin.zsh b/plugins/mix-fast/mix-fast.plugin.zsh index 3719c3525..e27e30d64 100644 --- a/plugins/mix-fast/mix-fast.plugin.zsh +++ b/plugins/mix-fast/mix-fast.plugin.zsh @@ -12,7 +12,7 @@ _mix_does_task_list_need_generating () { } _mix_generate () { - mix --help | grep -v 'iex -S' | tail -n +2 | cut -d " " -f 2 > .mix_tasks + mix help | grep -v 'iex -S' | tail -n +2 | cut -d " " -f 2 > .mix_tasks } _mix () { diff --git a/plugins/mix/_mix b/plugins/mix/_mix index 025572a4d..ecbe7e2d3 100644 --- a/plugins/mix/_mix +++ b/plugins/mix/_mix @@ -21,6 +21,15 @@ _1st_arguments=( 'deps.unlock:Unlock the given dependencies' 'deps.update:Update the given dependencies' 'do:Executes the tasks separated by comma' + 'ecto.create:Create Ecto database' + 'ecto.drop:Drop the storage for the given repository' + 'ecto.dump:Dumps the current environment’s database structure' + 'ecto.gen.migration:Generates a migration' + 'ecto.gen.repo:Generates a new repository' + 'ecto.load:Loads the current environment’s database structure' + 'ecto.migrate:Runs Ecto migration' + 'ecto.migrations:Displays the up / down migration status' + 'ecto.rollback:Reverts applied migrations' 'escript.build:Builds an escript for the project' 'help:Print help information for tasks' 'hex:Print hex help information' diff --git a/plugins/rails/_rails b/plugins/rails/_rails index 96f57ce64..ad7505506 100644 --- a/plugins/rails/_rails +++ b/plugins/rails/_rails @@ -51,6 +51,9 @@ _arguments \ if (( CURRENT == 1 )); then _describe -t commands "rails subcommand" _1st_arguments return +else + _files + return fi case "$words[1]" in diff --git a/plugins/rust/_rust b/plugins/rust/_rust index ac6aee160..6e3f344cd 100644 --- a/plugins/rust/_rust +++ b/plugins/rust/_rust @@ -88,14 +88,14 @@ _rustc_opts_vals=( --pretty='[Pretty-print the input instead of compiling]::TYPE:_values "TYPES" "$_rustc_pretty_types[@]"' --unpretty='[Present the input source, unstable (and less-pretty)]::TYPE:_values "TYPES" "$_rustc_unpretty_types[@]"' --color='[Configure coloring of output]:CONF:_values "COLORS" "$_rustc_color_types[@]"' - {-v,--version}'[Print version info and exit]::VERBOSE:(verbose)' ) _rustc_opts_switches=( -g'[Equivalent to --debuginfo=2]' -O'[Equivalent to --opt-level=2]' --test'[Build a test harness]' - --verbose'[Use verbose output]' + {-v,--verbose}'[Use verbose output]' + {-V,--version}'[Print version info and exit]' {-h,--help}'[Display this message]' --no-analysis'[Parse and expand the output, but run no analysis or produce output]' --no-trans'[Run all passes except translation; no output]' diff --git a/plugins/sublime/sublime.plugin.zsh b/plugins/sublime/sublime.plugin.zsh index 8934783c9..f5bb070ab 100644 --- a/plugins/sublime/sublime.plugin.zsh +++ b/plugins/sublime/sublime.plugin.zsh @@ -3,7 +3,7 @@ () { if [[ "$OSTYPE" == linux* ]]; then - local _sublime_linux_paths _sublime_path + local _sublime_linux_paths _sublime_linux_paths=( "$HOME/bin/sublime_text" "/opt/sublime_text/sublime_text" @@ -24,7 +24,7 @@ if [[ "$OSTYPE" == linux* ]]; then fi done elif [[ "$OSTYPE" = darwin* ]]; then - local _sublime_darwin_paths _sublime_path + local _sublime_darwin_paths _sublime_darwin_paths=( "/usr/local/bin/subl" "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" @@ -42,7 +42,7 @@ elif [[ "$OSTYPE" = darwin* ]]; then fi done elif [[ "$OSTYPE" = 'cygwin' ]]; then - local sublime_cygwin_paths _sublime_path + local sublime_cygwin_paths sublime_cygwin_paths=( "$(cygpath $ProgramW6432/Sublime\ Text\ 2)/sublime_text.exe" "$(cygpath $ProgramW6432/Sublime\ Text\ 3)/sublime_text.exe" diff --git a/themes/half-life.zsh-theme b/themes/half-life.zsh-theme index 5f987099d..8b458cde9 100644 --- a/themes/half-life.zsh-theme +++ b/themes/half-life.zsh-theme @@ -60,7 +60,7 @@ zstyle ':vcs_info:*:prompt:*' nvcsformats "" function steeef_preexec { - case "$(history $HISTCMD)" in + case "$2" in *git*) PR_GIT_UPDATE=1 ;; diff --git a/themes/steeef.zsh-theme b/themes/steeef.zsh-theme index 88ef1ca1b..622c90465 100644 --- a/themes/steeef.zsh-theme +++ b/themes/steeef.zsh-theme @@ -66,6 +66,9 @@ function steeef_preexec { *git*) PR_GIT_UPDATE=1 ;; + *hub*) + PR_GIT_UPDATE=1 + ;; *svn*) PR_GIT_UPDATE=1 ;; diff --git a/tools/install.sh b/tools/install.sh index 840a0d7d8..ad47df785 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -24,12 +24,10 @@ main() { # which may fail on systems lacking tput or terminfo set -e - CHECK_ZSH_INSTALLED=$(grep /zsh$ /etc/shells | wc -l) - if [ ! $CHECK_ZSH_INSTALLED -ge 1 ]; then + if ! command -v zsh >/dev/null 2>&1; then printf "${YELLOW}Zsh is not installed!${NORMAL} Please install zsh first!\n" exit fi - unset CHECK_ZSH_INSTALLED if [ ! -n "$ZSH" ]; then ZSH=~/.oh-my-zsh |