diff --git a/README.md b/README.md index 86037f199..3ebea91e0 100644 --- a/README.md +++ b/README.md @@ -295,7 +295,7 @@ Thank you so much! We're on social media: - [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter. You should follow it. -- [FaceBook](https://www.facebook.com/Oh-My-Zsh-296616263819290/) poke us. +- [Facebook](https://www.facebook.com/Oh-My-Zsh-296616263819290/) poke us. - [Instagram](https://www.instagram.com/_ohmyzsh/) tag us in your post showing Oh My Zsh! - [Discord](https://discord.gg/ohmyzsh) to chat with us! diff --git a/plugins/cargo/_cargo b/plugins/cargo/_cargo index ffc9fcdc8..ebff99310 100644 --- a/plugins/cargo/_cargo +++ b/plugins/cargo/_cargo @@ -77,7 +77,7 @@ _cargo() { '*:args:_default' ;; - build) + build|b) _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ '--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \ "${command_scope_spec[@]}" \ @@ -86,7 +86,7 @@ _cargo() { '--build-plan[output the build plan in JSON]' \ ;; - check) + check|c) _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ '--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \ "${command_scope_spec[@]}" \ @@ -224,7 +224,7 @@ _cargo() { _arguments -s -S $common $manifest ;; - run) + run|r) _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ '--example=[name of the bin target]:name' \ '--bin=[name of the bin target]:name' \ @@ -259,7 +259,7 @@ _cargo() { '*: :_guard "^-*" "query"' ;; - test) + test|t) _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ '--test=[test name]: :_cargo_test_names' \ '--no-fail-fast[run all tests regardless of failure]' \ diff --git a/plugins/command-not-found/command-not-found.plugin.zsh b/plugins/command-not-found/command-not-found.plugin.zsh index cbf9a0a8e..3ec13429c 100644 --- a/plugins/command-not-found/command-not-found.plugin.zsh +++ b/plugins/command-not-found/command-not-found.plugin.zsh @@ -38,7 +38,7 @@ fi if [[ -x /usr/libexec/pk-command-not-found ]]; then command_not_found_handler() { if [[ -S /var/run/dbus/system_bus_socket && -x /usr/libexec/packagekitd ]]; then - /usr/libexec/pk-command-not-found -- "$@" + /usr/libexec/pk-command-not-found "$@" return $? fi diff --git a/plugins/deno/.gitignore b/plugins/deno/.gitignore new file mode 100644 index 000000000..cba5b03e8 --- /dev/null +++ b/plugins/deno/.gitignore @@ -0,0 +1 @@ +_deno diff --git a/plugins/deno/README.md b/plugins/deno/README.md new file mode 100644 index 000000000..828e6af39 --- /dev/null +++ b/plugins/deno/README.md @@ -0,0 +1,18 @@ +# Deno Plugin + +This plugin sets up completion and aliases for [Deno](https://deno.land). + +## Aliases + +| Alias | Full command | +| ----- | ---------------- | +| db | deno bundle | +| dc | deno compile | +| dca | deno cache | +| dfmt | deno fmt | +| dh | deno help | +| dli | deno lint | +| drn | deno run | +| drw | deno run --watch | +| dts | deno test | +| dup | deno upgrade | diff --git a/plugins/deno/deno.plugin.zsh b/plugins/deno/deno.plugin.zsh new file mode 100644 index 000000000..a37b3bec4 --- /dev/null +++ b/plugins/deno/deno.plugin.zsh @@ -0,0 +1,23 @@ +# ALIASES +alias db='deno bundle' +alias dc='deno compile' +alias dca='deno cache' +alias dfmt='deno fmt' +alias dh='deno help' +alias dli='deno lint' +alias drn='deno run' +alias drw='deno run --watch' +alias dts='deno test' +alias dup='deno upgrade' + +# COMPLETION FUNCTION +if (( $+commands[deno] )); then + if [[ ! -f $ZSH_CACHE_DIR/deno_version ]] \ + || [[ "$(deno --version)" != "$(< "$ZSH_CACHE_DIR/deno_version")" ]] \ + || [[ ! -f $ZSH/plugins/deno/_deno ]]; then + deno completions zsh > $ZSH/plugins/deno/_deno + deno --version > $ZSH_CACHE_DIR/deno_version + fi + autoload -Uz _deno + _comps[deno]=_deno +fi diff --git a/plugins/fzf/fzf.plugin.zsh b/plugins/fzf/fzf.plugin.zsh index 69ec1d411..a979fe222 100644 --- a/plugins/fzf/fzf.plugin.zsh +++ b/plugins/fzf/fzf.plugin.zsh @@ -7,6 +7,7 @@ function setup_using_base_dir() { fzfdirs=( "${HOME}/.fzf" "${HOME}/.nix-profile/share/fzf" + "${XDG_DATA_HOME:-$HOME/.local/share}/fzf" "/usr/local/opt/fzf" "/usr/share/fzf" "/usr/local/share/examples/fzf" diff --git a/plugins/gh/.gitignore b/plugins/gh/.gitignore new file mode 100644 index 000000000..fa1244ab5 --- /dev/null +++ b/plugins/gh/.gitignore @@ -0,0 +1 @@ +_gh diff --git a/plugins/gh/README.md b/plugins/gh/README.md new file mode 100644 index 000000000..54e046a1c --- /dev/null +++ b/plugins/gh/README.md @@ -0,0 +1,23 @@ +# GitHub CLI plugin + +This plugin adds completion for the [GitHub CLI](https://cli.github.com/). + +To use it, add `gh` to the plugins array in your zshrc file: + +```zsh +plugins=(... gh) +``` + +This plugin does not add any aliases. + +## Cache + +This plugin caches the completion script and is automatically updated when the +plugin is loaded, which is usually when you start up a new terminal emulator. + +The cache is stored at: + +- `$ZSH/plugins/gh/_gh` completions script + +- `$ZSH_CACHE_DIR/gh_version` version of GitHub CLI, used to invalidate + the cache. diff --git a/plugins/gh/gh.plugin.zsh b/plugins/gh/gh.plugin.zsh new file mode 100644 index 000000000..8e055ec35 --- /dev/null +++ b/plugins/gh/gh.plugin.zsh @@ -0,0 +1,13 @@ +# Autocompletion for the GitHub CLI (gh). + +if (( $+commands[gh] )); then + if [[ ! -r "$ZSH_CACHE_DIR/gh_version" \ + || "$(gh --version)" != "$(< "$ZSH_CACHE_DIR/gh_version")" + || ! -f "$ZSH/plugins/gh/_gh" ]]; then + gh completion --shell zsh > $ZSH/plugins/gh/_gh + gh --version > $ZSH_CACHE_DIR/gh_version + fi + autoload -Uz _gh + _comps[gh]=_gh +fi + diff --git a/plugins/git/README.md b/plugins/git/README.md index 6ad19543e..4f051db8d 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -41,6 +41,8 @@ plugins=(... git) | gcan! | git commit -v -a --no-edit --amend | | gcans! | git commit -v -a -s --no-edit --amend | | gcam | git commit -a -m | +| gcas | git commit -a -s | +| gcasm | git commit -a -s -m | | gcsm | git commit -s -m | | gcb | git checkout -b | | gcf | git config --list | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index c5be36893..206a1933c 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -81,6 +81,8 @@ alias gcans!='git commit -v -a -s --no-edit --amend' alias gcam='git commit -a -m' alias gcsm='git commit -s -m' alias gck='git checkout' +alias gcas='git commit -a -s' +alias gcasm='git commit -a -s -m' alias gcb='git checkout -b' alias gckb='git checkout -b' alias gcf='git config --list' diff --git a/plugins/kubectl/README.md b/plugins/kubectl/README.md index 7a6cdaa59..8937b2b80 100644 --- a/plugins/kubectl/README.md +++ b/plugins/kubectl/README.md @@ -49,7 +49,7 @@ plugins=(... kubectl) | kdeli | `kubectl delete ingress` | Delete ingress resources matching passed argument | | | | **Namespace management** | | kgns | `kubectl get namespaces` | List the current namespaces in a cluster | -| kcn | `kubectl config set-context ...` | Change current namespace | +| kcn | `kubectl config set-context --current --namespace` | Change current namespace | | kens | `kubectl edit namespace` | Edit namespace resource from the default editor | | kdns | `kubectl describe namespace` | Describe namespace resource in detail | | kdelns | `kubectl delete namespace` | Delete the namespace. WARNING! This deletes everything in the namespace | diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh index d509d8795..56135274f 100644 --- a/plugins/kubectl/kubectl.plugin.zsh +++ b/plugins/kubectl/kubectl.plugin.zsh @@ -71,7 +71,7 @@ alias kgns='kubectl get namespaces' alias kens='kubectl edit namespace' alias kdns='kubectl describe namespace' alias kdelns='kubectl delete namespace' -alias kcn='kubectl config set-context $(kubectl config current-context) --namespace' +alias kcn='kubectl config set-context --current --namespace' # ConfigMap management alias kgcm='kubectl get configmaps' diff --git a/plugins/npm/README.md b/plugins/npm/README.md index 0b1a2280f..47d153619 100644 --- a/plugins/npm/README.md +++ b/plugins/npm/README.md @@ -15,8 +15,10 @@ plugins=(... npm) | `npmg` | `npm i -g` | Install dependencies globally | | `npmS` | `npm i -S` | Install and save to dependencies in your package.json | | `npmD` | `npm i -D` | Install and save to dev-dependencies in your package.json | +| `npmF` | `npm i -f` | Force install from remote registries ignoring local cache | | `npmE` | `PATH="$(npm bin)":"$PATH"` | Run command from node_modules folder based on current directory | | `npmO` | `npm outdated` | Check which npm modules are outdated | +| `npmU` | `npm update` | Update all the packages listed to the latest version | | `npmV` | `npm -v` | Check package versions | | `npmL` | `npm list` | List installed packages | | `npmL0` | `npm ls --depth=0` | List top-level installed packages | @@ -25,3 +27,5 @@ plugins=(... npm) | `npmR` | `npm run` | Run npm scripts | | `npmP` | `npm publish` | Run npm publish | | `npmI` | `npm init` | Run npm init | +| `npmi` | `npm info` | Run npm info | +| `npmSe` | `npm search` | Run npm search | diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index 87c68f3fb..f7d6d3939 100644 --- a/plugins/npm/npm.plugin.zsh +++ b/plugins/npm/npm.plugin.zsh @@ -27,6 +27,9 @@ alias npmS="npm i -S " # npmd is used by https://github.com/dominictarr/npmd alias npmD="npm i -D " +# Force npm to fetch remote resources even if a local copy exists on disk. +alias npmF='npm i -f' + # Execute command from node_modules folder based on current directory # i.e npmE gulp alias npmE='PATH="$(npm bin)":"$PATH"' @@ -34,6 +37,9 @@ alias npmE='PATH="$(npm bin)":"$PATH"' # Check which npm modules are outdated alias npmO="npm outdated" +# Update all the packages listed to the latest version +alias npmU="npm update" + # Check package versions alias npmV="npm -v" @@ -57,3 +63,9 @@ alias npmP="npm publish" # Run npm init alias npmI="npm init" + +# Run npm info +alias npmi="npm info" + +# Run npm search +alias npmSe="npm search" diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh index 08136abda..a77f0069b 100644 --- a/plugins/systemadmin/systemadmin.plugin.zsh +++ b/plugins/systemadmin/systemadmin.plugin.zsh @@ -131,7 +131,8 @@ d0() { # gather external ip address geteip() { - curl -s -S https://icanhazip.com + curl -s -S -4 https://icanhazip.com + curl -s -S -6 https://icanhazip.com } # determine local IP address(es) diff --git a/themes/ys.zsh-theme b/themes/ys.zsh-theme index 89d5355dc..303c898b4 100644 --- a/themes/ys.zsh-theme +++ b/themes/ys.zsh-theme @@ -26,15 +26,26 @@ ys_hg_prompt_info() { if [ -d '.hg' ]; then echo -n "${YS_VCS_PROMPT_PREFIX1}hg${YS_VCS_PROMPT_PREFIX2}" echo -n $(hg branch 2>/dev/null) - if [ -n "$(hg status 2>/dev/null)" ]; then - echo -n "$YS_VCS_PROMPT_DIRTY" - else - echo -n "$YS_VCS_PROMPT_CLEAN" + if [[ "$(hg config oh-my-zsh.hide-dirty 2>/dev/null)" != "1" ]]; then + if [ -n "$(hg status 2>/dev/null)" ]; then + echo -n "$YS_VCS_PROMPT_DIRTY" + else + echo -n "$YS_VCS_PROMPT_CLEAN" + fi fi echo -n "$YS_VCS_PROMPT_SUFFIX" fi } +# Virtualenv +local venv_info='$(virtenv_prompt)' +YS_THEME_VIRTUALENV_PROMPT_PREFIX=" %{$fg[green]%}" +YS_THEME_VIRTUALENV_PROMPT_SUFFIX=" %{$reset_color%}%" +virtenv_prompt() { + [[ -n ${VIRTUAL_ENV} ]] || return + echo "${YS_THEME_VIRTUALENV_PROMPT_PREFIX}${VIRTUAL_ENV:t}${YS_THEME_VIRTUALENV_PROMPT_SUFFIX}" +} + local exit_code="%(?,,C:%{$fg[red]%}%?%{$reset_color%})" # Prompt format: @@ -55,6 +66,7 @@ PROMPT=" %{$terminfo[bold]$fg[yellow]%}%~%{$reset_color%}\ ${hg_info}\ ${git_info}\ +${venv_info}\ \ %{$fg[white]%}[%*] $exit_code %{$terminfo[bold]$fg[red]%}$ %{$reset_color%}"