summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/CODEOWNERS2
-rw-r--r--.github/workflows/installer.yml54
-rw-r--r--.github/workflows/installer/.gitignore1
-rw-r--r--.github/workflows/installer/.vercelignore2
-rw-r--r--.github/workflows/installer/vercel.json23
-rw-r--r--.github/workflows/main.yml8
-rw-r--r--README.md136
-rw-r--r--SECURITY.md5
-rw-r--r--custom/example.zsh18
-rw-r--r--custom/plugins/example/example.plugin.zsh1
-rw-r--r--custom/themes/example.zsh-theme2
-rw-r--r--lib/cli.zsh7
-rw-r--r--lib/clipboard.zsh10
-rw-r--r--lib/directories.zsh6
-rw-r--r--lib/functions.zsh2
-rw-r--r--lib/termsupport.zsh77
-rw-r--r--lib/theme-and-appearance.zsh36
-rw-r--r--oh-my-zsh.sh84
-rw-r--r--plugins/alias-finder/.zunit.yml9
-rw-r--r--plugins/alias-finder/README.md55
-rw-r--r--plugins/alias-finder/alias-finder.plugin.zsh79
-rw-r--r--plugins/alias-finder/tests/_output/.gitkeep0
-rw-r--r--plugins/alias-finder/tests/_support/.gitkeep0
-rw-r--r--plugins/alias-finder/tests/_support/bootstrap2
-rw-r--r--plugins/alias-finder/tests/test_run.sh107
-rw-r--r--plugins/aliases/README.md12
-rw-r--r--plugins/aliases/aliases.plugin.zsh2
-rw-r--r--plugins/aliases/cheatsheet.py2
-rw-r--r--plugins/archlinux/README.md1
-rw-r--r--plugins/archlinux/archlinux.plugin.zsh51
-rw-r--r--plugins/asdf/asdf.plugin.zsh35
-rw-r--r--plugins/autoenv/autoenv.plugin.zsh16
-rw-r--r--plugins/aws/README.md13
-rw-r--r--plugins/aws/aws.plugin.zsh57
-rw-r--r--plugins/azure/azure.plugin.zsh14
-rw-r--r--plugins/battery/battery.plugin.zsh44
-rw-r--r--plugins/bazel/_bazel2
-rw-r--r--plugins/brew/README.md20
-rw-r--r--plugins/brew/brew.plugin.zsh11
-rw-r--r--plugins/bun/README.md20
-rw-r--r--plugins/bun/bun.plugin.zsh14
-rw-r--r--plugins/colored-man-pages/colored-man-pages.plugin.zsh1
-rw-r--r--plugins/command-not-found/command-not-found.plugin.zsh3
-rw-r--r--plugins/dbt/README.md29
-rw-r--r--plugins/dbt/dbt.plugin.zsh23
-rw-r--r--plugins/debian/README.md9
-rw-r--r--plugins/debian/debian.plugin.zsh2
-rw-r--r--plugins/deno/README.md27
-rw-r--r--plugins/deno/deno.plugin.zsh1
-rw-r--r--plugins/direnv/direnv.plugin.zsh2
-rw-r--r--plugins/dirhistory/dirhistory.plugin.zsh8
-rw-r--r--plugins/dnf/README.md3
-rw-r--r--plugins/dnf/dnf.plugin.zsh28
-rw-r--r--plugins/docker/README.md11
-rw-r--r--plugins/docker/completions/_docker (renamed from plugins/docker/_docker)11
-rw-r--r--plugins/docker/docker.plugin.zsh29
-rw-r--r--plugins/extract/README.md3
-rw-r--r--plugins/extract/extract.plugin.zsh116
-rw-r--r--plugins/firewalld/firewalld.plugin.zsh2
-rw-r--r--plugins/gas/README.md2
-rw-r--r--plugins/gcloud/gcloud.plugin.zsh10
-rw-r--r--plugins/git-auto-fetch/git-auto-fetch.plugin.zsh2
-rw-r--r--plugins/git-commit/README.md42
-rw-r--r--plugins/git-commit/git-commit.plugin.zsh31
-rw-r--r--plugins/git-extras/README.md2
-rw-r--r--plugins/git-extras/git-extras.plugin.zsh176
-rw-r--r--plugins/git/README.md477
-rw-r--r--plugins/git/git.plugin.zsh485
-rw-r--r--plugins/gitignore/README.md2
-rw-r--r--plugins/gitignore/gitignore.plugin.zsh4
-rw-r--r--plugins/gnu-utils/gnu-utils.plugin.zsh2
-rw-r--r--plugins/gradle/gradle.plugin.zsh2
-rw-r--r--plugins/grc/grc.plugin.zsh5
-rw-r--r--plugins/history/README.md1
-rw-r--r--plugins/history/history.plugin.zsh1
-rw-r--r--plugins/hitchhiker/fortunes/hitchhiker34
-rw-r--r--plugins/jira/jira.plugin.zsh8
-rw-r--r--plugins/juju/README.md2
-rw-r--r--plugins/juju/juju.plugin.zsh32
-rw-r--r--plugins/jump/jump.plugin.zsh7
-rw-r--r--plugins/kind/README.md22
-rw-r--r--plugins/kind/kind.plugin.zsh23
-rw-r--r--plugins/kubectl/kubectl.plugin.zsh1
-rw-r--r--plugins/lando/README.md24
-rw-r--r--plugins/lando/lando.plugin.zsh35
-rw-r--r--plugins/macos/spotify37
-rw-r--r--plugins/mvn/README.md2
-rw-r--r--plugins/mvn/mvn.plugin.zsh2
-rw-r--r--plugins/npm/README.md2
-rw-r--r--plugins/npm/npm.plugin.zsh6
-rw-r--r--plugins/nvm/README.md12
-rw-r--r--plugins/nvm/nvm.plugin.zsh35
-rw-r--r--plugins/per-directory-history/per-directory-history.zsh1
-rw-r--r--plugins/pipenv/README.md16
-rw-r--r--plugins/pipenv/pipenv.plugin.zsh39
-rw-r--r--plugins/podman/README.md47
-rw-r--r--plugins/podman/podman.plugin.zsh47
-rw-r--r--plugins/poetry-env/README.md10
-rw-r--r--plugins/poetry-env/poetry-env.plugin.zsh27
-rw-r--r--plugins/postgres/README.md2
-rw-r--r--plugins/pyenv/README.md8
-rw-r--r--plugins/qodana/README.md20
-rw-r--r--plugins/qodana/qodana.plugin.zsh14
-rw-r--r--plugins/rails/README.md5
-rw-r--r--plugins/rails/rails.plugin.zsh5
-rw-r--r--plugins/rake-fast/rake-fast.plugin.zsh39
-rw-r--r--plugins/rtx/README.md30
-rw-r--r--plugins/rtx/rtx.plugin.zsh18
-rw-r--r--plugins/ruby/ruby.plugin.zsh2
-rw-r--r--plugins/shell-proxy/README.md5
-rwxr-xr-xplugins/shell-proxy/proxy.py23
-rw-r--r--plugins/shell-proxy/shell-proxy.plugin.zsh2
-rw-r--r--plugins/snap/README.md18
-rw-r--r--plugins/snap/snap.plugin.zsh10
-rw-r--r--plugins/ssh-agent/README.md27
-rw-r--r--plugins/ssh-agent/ssh-agent.plugin.zsh5
-rw-r--r--plugins/starship/README.md21
-rw-r--r--plugins/starship/starship.plugin.zsh8
-rw-r--r--plugins/systemadmin/systemadmin.plugin.zsh116
-rw-r--r--plugins/systemd/README.md1
-rw-r--r--plugins/systemd/systemd.plugin.zsh3
-rw-r--r--plugins/term_tab/term_tab.plugin.zsh1
-rw-r--r--plugins/terraform/README.md13
-rw-r--r--plugins/terraform/terraform.plugin.zsh7
-rw-r--r--plugins/tig/tig.plugin.zsh2
-rw-r--r--plugins/tmux/README.md27
-rw-r--r--plugins/tmux/tmux.plugin.zsh24
-rw-r--r--plugins/toolbox/README.md3
-rw-r--r--plugins/toolbox/toolbox.plugin.zsh3
-rw-r--r--plugins/ubuntu/README.md2
-rw-r--r--plugins/ubuntu/ubuntu.plugin.zsh2
-rw-r--r--plugins/vi-mode/README.md6
-rw-r--r--plugins/vi-mode/vi-mode.plugin.zsh46
-rw-r--r--plugins/vscode/README.md3
-rw-r--r--plugins/vscode/vscode.plugin.zsh9
-rw-r--r--plugins/wd/wd.sh4
-rw-r--r--plugins/web-search/README.md62
-rw-r--r--plugins/web-search/web-search.plugin.zsh3
-rw-r--r--plugins/xcode/xcode.plugin.zsh7
-rw-r--r--plugins/yarn/_yarn2
-rw-r--r--plugins/z/LICENSE2
-rw-r--r--plugins/z/MANUAL.md21
-rw-r--r--plugins/z/_z2
-rw-r--r--plugins/z/img/mit_license.svg1
-rw-r--r--plugins/z/img/zsh_4.3.11_plus.svg1
-rw-r--r--plugins/z/z.plugin.zsh54
-rw-r--r--plugins/zsh-navigation-tools/n-list2
-rw-r--r--themes/agnoster.zsh-theme4
-rw-r--r--themes/avit.zsh-theme7
-rw-r--r--themes/bureau.zsh-theme7
-rw-r--r--themes/fino-time.zsh-theme1
-rw-r--r--themes/gallois.zsh-theme136
-rw-r--r--themes/gnzh.zsh-theme2
-rw-r--r--themes/half-life.zsh-theme6
-rw-r--r--themes/michelebologna.zsh-theme11
-rw-r--r--themes/mortalscumbag.zsh-theme8
-rw-r--r--themes/oldgallois.zsh-theme24
-rw-r--r--themes/robbyrussell.zsh-theme4
-rwxr-xr-xtools/changelog.sh101
-rw-r--r--tools/check_for_upgrade.sh230
-rwxr-xr-xtools/install.sh4
-rw-r--r--tools/uninstall.sh23
-rwxr-xr-xtools/upgrade.sh78
163 files changed, 3079 insertions, 1321 deletions
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 6668cd7ce..0c5f3acee 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -9,3 +9,5 @@ plugins/shell-proxy/ @septs
plugins/universalarchive/ @Konfekt
plugins/wp-cli/ @joshmedeski
plugins/zoxide/ @ajeetdsouza
+plugins/starship/ @axieax
+plugins/dbt/ @msempere
diff --git a/.github/workflows/installer.yml b/.github/workflows/installer.yml
new file mode 100644
index 000000000..a70c483d1
--- /dev/null
+++ b/.github/workflows/installer.yml
@@ -0,0 +1,54 @@
+name: Test and Deploy installer
+on:
+ workflow_dispatch: {}
+ push:
+ paths:
+ - 'tools/install.sh'
+ - '.github/workflows/installer/**'
+ - '.github/workflows/installer.yml'
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
+ cancel-in-progress: false
+
+permissions:
+ contents: read # to checkout
+
+jobs:
+ test:
+ name: Test installer
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ os:
+ - ubuntu-latest
+ - macos-latest
+ steps:
+ - name: Set up git repository
+ uses: actions/checkout@v3
+ - name: Install zsh
+ if: runner.os == 'Linux'
+ run: sudo apt-get update; sudo apt-get install zsh
+ - name: Test installer
+ run: sh ./tools/install.sh
+
+ deploy:
+ name: Deploy installer in install.ohmyz.sh
+ if: github.ref == 'refs/heads/master'
+ runs-on: ubuntu-latest
+ environment: vercel
+ needs:
+ - test
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+ - name: Install Vercel CLI
+ run: npm install -g vercel
+ - name: Setup project and deploy
+ env:
+ VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
+ VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
+ run: |
+ cp tools/install.sh .github/workflows/installer/install.sh
+ cd .github/workflows/installer
+ vc deploy --prod -t ${{ secrets.VERCEL_TOKEN }}
diff --git a/.github/workflows/installer/.gitignore b/.github/workflows/installer/.gitignore
new file mode 100644
index 000000000..f66fce310
--- /dev/null
+++ b/.github/workflows/installer/.gitignore
@@ -0,0 +1 @@
+install.sh
diff --git a/.github/workflows/installer/.vercelignore b/.github/workflows/installer/.vercelignore
new file mode 100644
index 000000000..41b233364
--- /dev/null
+++ b/.github/workflows/installer/.vercelignore
@@ -0,0 +1,2 @@
+/*
+!/install.sh
diff --git a/.github/workflows/installer/vercel.json b/.github/workflows/installer/vercel.json
new file mode 100644
index 000000000..524dc3c0f
--- /dev/null
+++ b/.github/workflows/installer/vercel.json
@@ -0,0 +1,23 @@
+{
+ "headers": [
+ {
+ "source": "/((?!favicon.ico).*)",
+ "headers": [
+ {
+ "key": "Content-Type",
+ "value": "text/plain"
+ },
+ {
+ "key": "Content-Disposition",
+ "value": "inline; filename=\"install.sh\""
+ }
+ ]
+ }
+ ],
+ "rewrites": [
+ {
+ "source": "/((?!favicon.ico|install.sh).*)",
+ "destination": "/install.sh"
+ }
+ ]
+}
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 8ee2df3d8..de7d98262 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -20,19 +20,13 @@ permissions:
jobs:
tests:
name: Run tests
- runs-on: ${{ matrix.os }}
+ runs-on: ubuntu-latest
if: github.repository == 'ohmyzsh/ohmyzsh'
- strategy:
- matrix:
- os: [ubuntu-latest, macos-latest]
steps:
- name: Set up git repository
uses: actions/checkout@v3
- name: Install zsh
- if: runner.os == 'Linux'
run: sudo apt-get update; sudo apt-get install zsh
- - name: Test installer
- run: sh ./tools/install.sh
- name: Check syntax
run: |
for file in ./oh-my-zsh.sh \
diff --git a/README.md b/README.md
index 4042c8c26..499986879 100644
--- a/README.md
+++ b/README.md
@@ -13,38 +13,42 @@ Finally, you'll begin to get the sort of attention that you have always felt you
To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twitter.com/ohmyzsh) on Twitter, and join us on [Discord](https://discord.gg/ohmyzsh).
[![CI](https://github.com/ohmyzsh/ohmyzsh/workflows/CI/badge.svg)](https://github.com/ohmyzsh/ohmyzsh/actions?query=workflow%3ACI)
-[![Follow @ohmyzsh](https://img.shields.io/twitter/follow/ohmyzsh?label=Follow+@ohmyzsh&style=flat)](https://twitter.com/intent/follow?screen_name=ohmyzsh)
+[![X (formerly Twitter) Follow](https://img.shields.io/twitter/follow/ohmyzsh?label=%40ohmyzsh&logo=x&style=flat)](https://twitter.com/intent/follow?screen_name=ohmyzsh)
+[![Mastodon Follow](https://img.shields.io/mastodon/follow/111169632522566717?label=%40ohmyzsh&domain=https%3A%2F%2Fmstdn.social&logo=mastodon&style=flat)](https://mstdn.social/@ohmyzsh)
[![Discord server](https://img.shields.io/discord/642496866407284746)](https://discord.gg/ohmyzsh)
[![Gitpod ready](https://img.shields.io/badge/Gitpod-ready-blue?logo=gitpod)](https://gitpod.io/#https://github.com/ohmyzsh/ohmyzsh)
-[![huntr.dev](https://cdn.huntr.dev/huntr_security_badge_mono.svg)](https://huntr.dev/bounties/disclose/?utm_campaign=ohmyzsh%2Fohmyzsh&utm_medium=social&utm_source=github&target=https%3A%2F%2Fgithub.com%2Fohmyzsh%2Fohmyzsh)
<details>
<summary>Table of Contents</summary>
- [Getting Started](#getting-started)
+ - [Operating System Compatibility](#operating-system-compatibility)
- [Prerequisites](#prerequisites)
- [Basic Installation](#basic-installation)
- - [Manual inspection](#manual-inspection)
+ - [Manual Inspection](#manual-inspection)
- [Using Oh My Zsh](#using-oh-my-zsh)
- [Plugins](#plugins)
- [Enabling Plugins](#enabling-plugins)
- [Using Plugins](#using-plugins)
- [Themes](#themes)
- - [Selecting a Theme](#selecting-a-theme)
+ - [Selecting A Theme](#selecting-a-theme)
- [FAQ](#faq)
- [Advanced Topics](#advanced-topics)
- [Advanced Installation](#advanced-installation)
- [Custom Directory](#custom-directory)
- - [Unattended install](#unattended-install)
- - [Installing from a forked repository](#installing-from-a-forked-repository)
+ - [Unattended Install](#unattended-install)
+ - [Installing From A Forked Repository](#installing-from-a-forked-repository)
- [Manual Installation](#manual-installation)
- [Installation Problems](#installation-problems)
- - [Custom Plugins and Themes](#custom-plugins-and-themes)
+ - [Custom Plugins And Themes](#custom-plugins-and-themes)
+ - [Enable GNU ls In macOS And freeBSD Systems](#enable-gnu-ls-in-macos-and-freebsd-systems)
+ - [Skip Aliases](#skip-aliases)
- [Getting Updates](#getting-updates)
+ - [Updates Verbosity](#updates-verbosity)
- [Manual Updates](#manual-updates)
- [Uninstalling Oh My Zsh](#uninstalling-oh-my-zsh)
-- [How do I contribute to Oh My Zsh?](#how-do-i-contribute-to-oh-my-zsh)
- - [Do NOT send us themes](#do-not-send-us-themes)
+- [How Do I Contribute To Oh My Zsh?](#how-do-i-contribute-to-oh-my-zsh)
+ - [Do Not Send Us Themes](#do-not-send-us-themes)
- [Contributors](#contributors)
- [Follow Us](#follow-us)
- [Merchandise](#merchandise)
@@ -55,9 +59,21 @@ To learn more, visit [ohmyz.sh](https://ohmyz.sh), follow [@ohmyzsh](https://twi
## Getting Started
+### Operating System Compatibility
+
+| O/S | Status |
+| :------------- | :-----: |
+| Android | ✅ |
+| freeBSD | ✅ |
+| LCARS | 🛸 |
+| Linux | ✅ |
+| macOS | ✅ |
+| OS/2 Warp | ❌ |
+| Windows (WSL2) | ✅ |
+
+
### Prerequisites
-- A Unix-like operating system: macOS, Linux, BSD. On Windows: WSL2 is preferred, but cygwin or msys also mostly work.
- [Zsh](https://www.zsh.org) should be installed (v4.3.9 or more recent is fine but we prefer 5.0.8 and newer). If not pre-installed (run `zsh --version` to confirm), check the following wiki instructions here: [Installing ZSH](https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH)
- `curl` or `wget` should be installed
- `git` should be installed (recommended v2.4.11 or higher)
@@ -74,7 +90,7 @@ Oh My Zsh is installed by running one of the following commands in your terminal
_Note that any previous `.zshrc` will be renamed to `.zshrc.pre-oh-my-zsh`. After installation, you can move the configuration you want to preserve into the new `.zshrc`._
-#### Manual inspection
+#### Manual Inspection
It's a good idea to inspect the install script from projects you don't yet know. You can do
that by downloading the install script first, looking through it so everything looks normal,
@@ -123,7 +139,7 @@ Each built-in plugin includes a **README**, documenting it. This README should s
We'll admit it. Early in the Oh My Zsh world, we may have gotten a bit too theme happy. We have over one hundred and fifty themes now bundled. Most of them have [screenshots](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes) on the wiki (We are working on updating this!). Check them out!
-#### Selecting a Theme
+#### Selecting A Theme
_Robby's theme is the default one. It's not the fanciest one. It's not the simplest one. It's just the right one (for him)._
@@ -194,7 +210,7 @@ like this:
ZSH="$HOME/.dotfiles/oh-my-zsh" sh install.sh
```
-#### Unattended install
+#### Unattended Install
If you're running the Oh My Zsh install script as part of an automated install, you can pass the `--unattended`
flag to the `install.sh` script. This will have the effect of not trying to change
@@ -204,7 +220,7 @@ the default shell, and it also won't run `zsh` when the installation has finishe
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
```
-#### Installing from a forked repository
+#### Installing From A Forked Repository
The install script also accepts these variables to allow installation of a different repository:
@@ -229,19 +245,19 @@ REPO=apjanke/oh-my-zsh BRANCH=edge sh install.sh
#### Manual Installation
-##### 1. Clone the repository <!-- omit in toc -->
+##### 1. Clone The Repository <!-- omit in toc -->
```sh
git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
```
-##### 2. _Optionally_, backup your existing `~/.zshrc` file <!-- omit in toc -->
+##### 2. _Optionally_, Backup Your Existing `~/.zshrc` File <!-- omit in toc -->
```sh
cp ~/.zshrc ~/.zshrc.orig
```
-##### 3. Create a new zsh configuration file <!-- omit in toc -->
+##### 3. Create A New Zsh Configuration File <!-- omit in toc -->
You can create a new zsh config file by copying the template that we have included for you.
@@ -249,7 +265,7 @@ You can create a new zsh config file by copying the template that we have includ
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
```
-##### 4. Change your default shell <!-- omit in toc -->
+##### 4. Change Your Default Shell <!-- omit in toc -->
```sh
chsh -s $(which zsh)
@@ -257,7 +273,7 @@ chsh -s $(which zsh)
You must log out from your user session and log back in to see this change.
-##### 5. Initialize your new zsh configuration <!-- omit in toc -->
+##### 5. Initialize Your New Zsh Configuration <!-- omit in toc -->
Once you open up a new terminal window, it should load zsh with Oh My Zsh's configuration.
@@ -268,7 +284,7 @@ If you have any hiccups installing, here are a few common fixes.
- You _might_ need to modify your `PATH` in `~/.zshrc` if you're not able to find some commands after switching to `oh-my-zsh`.
- If you installed manually or changed the install location, check the `ZSH` environment variable in `~/.zshrc`.
-### Custom Plugins and Themes
+### Custom Plugins And Themes
If you want to override any of the default behaviors, just add a new file (ending in `.zsh`) in the `custom/` directory.
@@ -276,16 +292,72 @@ If you have many functions that go well together, you can put them as a `XYZ.plu
If you would like to override the functionality of a plugin distributed with Oh My Zsh, create a plugin of the same name in the `custom/plugins/` directory and it will be loaded instead of the one in `plugins/`.
-### Remove directories aliases
+### Enable GNU ls In macOS And freeBSD Systems
-If you want to skip ohmyzsh default
-[directories aliases](https://github.com/ohmyzsh/ohmyzsh/blob/master/lib/directories.zsh) you can add the
-following snippet to your `zshrc`, before loading `oh-my-zsh.sh` script:
+<a name="enable-gnu-ls"></a>
+
+The default behaviour in Oh My Zsh is to use BSD `ls` in macOS and freeBSD systems. If GNU `ls` is installed
+(as `gls` command), you can choose to use it instead. To do it, you can use zstyle-based config before
+sourcing `oh-my-zsh.sh`:
```zsh
+zstyle ':omz:lib:theme-and-appearance' gnu-ls yes
+```
+
+_Note: this is not compatible with `DISABLE_LS_COLORS=true`_
+
+### Skip Aliases
+
+<a name="remove-directories-aliases"></a>
+
+If you want to skip default Oh My Zsh aliases (those defined in `lib/*` files) or plugin aliases,
+you can use the settings below in your `~/.zshrc` file, **before Oh My Zsh is loaded**. Note that
+there are many different ways to skip aliases, depending on your needs.
+
+```sh
+# Skip all aliases, in lib files and enabled plugins
+zstyle ':omz:*' aliases no
+
+# Skip all aliases in lib files
+zstyle ':omz:lib:*' aliases no
+# Skip only aliases defined in the directories.zsh lib file
+zstyle ':omz:lib:directories' aliases no
+
+# Skip all plugin aliases
+zstyle ':omz:plugins:*' aliases no
+# Skip only the aliases from the git plugin
+zstyle ':omz:plugins:git' aliases no
+```
+
+You can combine these in other ways taking into account that more specific scopes takes precedence:
+
+```sh
+# Skip all plugin aliases, except for the git plugin
+zstyle ':omz:plugins:*' aliases no
+zstyle ':omz:plugins:git' aliases yes
+```
+
+A previous version of this feature was using the setting below, which has been removed:
+
+```sh
zstyle ':omz:directories' aliases no
```
+Instead, you can now use the following:
+
+```sh
+zstyle ':omz:lib:directories' aliases no
+```
+
+#### Notice <!-- omit in toc -->
+
+> This feature is currently in a testing phase and it may be subject to change in the future.
+> It is also not currently compatible with plugin managers such as zpm or zinit, which don't
+> source the init script (`oh-my-zsh.sh`) where this feature is implemented in.
+
+> It is also not currently aware of "aliases" that are defined as functions. Example of such
+> are `gccd`, `ggf`, or `ggl` functions from the git plugin.
+
## Getting Updates
By default, you will be prompted to check for updates every 2 weeks. You can choose other update modes by adding a line to your `~/.zshrc` file, **before Oh My Zsh is loaded**:
@@ -317,6 +389,18 @@ zstyle ':omz:update' frequency 7
zstyle ':omz:update' frequency 0
```
+### Updates Verbosity
+
+You can also limit the update verbosity with the following settings:
+
+```sh
+zstyle ':omz:update' verbose default # default update prompt
+
+zstyle ':omz:update' verbose minimal # only few lines
+
+zstyle ':omz:update' verbose silent # only errors
+```
+
### Manual Updates
If you'd like to update at any point in time (maybe someone just released a new plugin and you don't want to wait a week?) you just need to run:
@@ -333,7 +417,7 @@ Oh My Zsh isn't for everyone. We'll miss you, but we want to make this an easy b
If you want to uninstall `oh-my-zsh`, just run `uninstall_oh_my_zsh` from the command-line. It will remove itself and revert your previous `bash` or `zsh` configuration.
-## How do I contribute to Oh My Zsh?
+## How Do I Contribute To Oh My Zsh?
Before you participate in our delightful community, please read the [code of conduct](CODE_OF_CONDUCT.md).
@@ -343,7 +427,7 @@ We also need people to test out pull requests. So take a look through [the open
See [Contributing](CONTRIBUTING.md) for more details.
-### Do NOT send us themes
+### Do Not Send Us Themes
We have (more than) enough themes for the time being. Please add your theme to the [external themes](https://github.com/ohmyzsh/ohmyzsh/wiki/External-themes) wiki page.
diff --git a/SECURITY.md b/SECURITY.md
index 7e5c8eed0..ae7458ee2 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -17,8 +17,7 @@ In the near future we will introduce versioning, so expect this section to chang
**Do not submit an issue or pull request**: this might reveal the vulnerability.
-Instead, you should email the maintainers directly at: [**security@ohmyz.sh**](mailto:security@ohmyz.sh).
+Instead, you should email the maintainers directly at: [**security@ohmyz.sh**](mailto:security@ohmyz.sh),
+or using the link to [privately report a vulnerability with GitHub](https://github.com/ohmyzsh/ohmyzsh/security/advisories/new).
We will deal with the vulnerability privately and submit a patch as soon as possible.
-
-You can also submit your vulnerability report to [huntr.dev](https://huntr.dev/bounties/disclose/?utm_campaign=ohmyzsh%2Fohmyzsh&utm_medium=social&utm_source=github&target=https%3A%2F%2Fgithub.com%2Fohmyzsh%2Fohmyzsh) and see if you can get a bounty reward.
diff --git a/custom/example.zsh b/custom/example.zsh
index c505a9673..21a8d8be7 100644
--- a/custom/example.zsh
+++ b/custom/example.zsh
@@ -1,10 +1,12 @@
-# You can put files here to add functionality separated per file, which
-# will be ignored by git.
-# Files on the custom/ directory will be automatically loaded by the init
-# script, in alphabetical order.
-
-# For example: add yourself some shortcuts to projects you often work on.
-#
+# Put files in this folder to add your own custom functionality.
+# See: https://github.com/ohmyzsh/ohmyzsh/wiki/Customization
+#
+# Files in the custom/ directory will be:
+# - loaded automatically by the init script, in alphabetical order
+# - loaded last, after all built-ins in the lib/ directory, to override them
+# - ignored by git by default
+#
+# Example: add custom/shortcuts.zsh for shortcuts to your local projects
+#
# brainstormr=~/Projects/development/planetargon/brainstormr
# cd $brainstormr
-#
diff --git a/custom/plugins/example/example.plugin.zsh b/custom/plugins/example/example.plugin.zsh
index 406f27445..83611fe3f 100644
--- a/custom/plugins/example/example.plugin.zsh
+++ b/custom/plugins/example/example.plugin.zsh
@@ -1,2 +1,3 @@
# Add your own custom plugins in the custom/plugins directory. Plugins placed
# here will override ones with the same name in the main plugins directory.
+# See: https://github.com/ohmyzsh/ohmyzsh/wiki/Customization#overriding-and-adding-plugins
diff --git a/custom/themes/example.zsh-theme b/custom/themes/example.zsh-theme
index ef8f1c630..494d029e8 100644
--- a/custom/themes/example.zsh-theme
+++ b/custom/themes/example.zsh-theme
@@ -1,4 +1,6 @@
# Put your custom themes in this folder.
+# See: https://github.com/ohmyzsh/ohmyzsh/wiki/Customization#overriding-and-adding-themes
+#
# Example:
PROMPT="%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m %{$fg[yellow]%}%~ %{$reset_color%}%% "
diff --git a/lib/cli.zsh b/lib/cli.zsh
index fed00d21d..561c1b98b 100644
--- a/lib/cli.zsh
+++ b/lib/cli.zsh
@@ -11,7 +11,7 @@ function omz {
# Subcommand functions start with _ so that they don't
# appear as completion entries when looking for `omz`
- (( $+functions[_omz::$command] )) || {
+ (( ${+functions[_omz::$command]} )) || {
_omz::help
return 1
}
@@ -776,10 +776,11 @@ function _omz::update {
local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD)
# Run update script
+ zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default
if [[ "$1" != --unattended ]]; then
- ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" --interactive || return $?
+ ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode || return $?
else
- ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" || return $?
+ ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" -v $verbose_mode || return $?
fi
# Update last updated file
diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh
index 2f3b6bcad..4b37abc9b 100644
--- a/lib/clipboard.zsh
+++ b/lib/clipboard.zsh
@@ -100,8 +100,8 @@ function detect-clipboard() {
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
+function clipcopy clippaste {
+ unfunction clipcopy clippaste
+ detect-clipboard || true # let one retry
+ "$0" "$@"
+}
diff --git a/lib/directories.zsh b/lib/directories.zsh
index 13b680c19..8927a56ad 100644
--- a/lib/directories.zsh
+++ b/lib/directories.zsh
@@ -4,12 +4,6 @@ setopt auto_pushd
setopt pushd_ignore_dups
setopt pushdminus
-# add (uncommented):
-# zstyle ':omz:directories' aliases no
-# to your `zshrc` before loading `oh-my-zsh.sh`
-# to disable the following aliases and functions
-
-zstyle -T ':omz:directories' aliases || return 0
alias -g ...='../..'
alias -g ....='../../..'
diff --git a/lib/functions.zsh b/lib/functions.zsh
index 1d85ea38a..a252d0a33 100644
--- a/lib/functions.zsh
+++ b/lib/functions.zsh
@@ -5,7 +5,7 @@ function zsh_stats() {
}
function uninstall_oh_my_zsh() {
- env ZSH="$ZSH" sh "$ZSH/tools/uninstall.sh"
+ command env ZSH="$ZSH" sh "$ZSH/tools/uninstall.sh"
}
function upgrade_oh_my_zsh() {
diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
index 80ca7ef78..d170ffcbf 100644
--- a/lib/termsupport.zsh
+++ b/lib/termsupport.zsh
@@ -17,7 +17,7 @@ function title {
: ${2=$1}
case "$TERM" in
- cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*|foot)
+ cygwin|xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|st*|foot*|contour*)
print -Pn "\e]2;${2:q}\a" # set window name
print -Pn "\e]1;${1:q}\a" # set tab name
;;
@@ -109,28 +109,55 @@ if [[ -z "$INSIDE_EMACS" || "$INSIDE_EMACS" = vterm ]]; then
add-zsh-hook preexec omz_termsupport_preexec
fi
-# Keep Apple Terminal.app's current working directory updated
-# Based on this answer: https://superuser.com/a/315029
-# With extra fixes to handle multibyte chars and non-UTF-8 locales
-
-if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
- # Emits the control sequence to notify Terminal.app of the cwd
- # Identifies the directory using a file: URI scheme, including
- # the host name to disambiguate local vs. remote paths.
- function update_terminalapp_cwd() {
- emulate -L zsh
-
- # Percent-encode the host and path names.
- local URL_HOST URL_PATH
- URL_HOST="$(omz_urlencode -P $HOST)" || return 1
- URL_PATH="$(omz_urlencode -P $PWD)" || return 1
-
- # Undocumented Terminal.app-specific control sequence
- printf '\e]7;%s\a' "file://$URL_HOST$URL_PATH"
- }
-
- # Use a precmd hook instead of a chpwd hook to avoid contaminating output
- add-zsh-hook precmd update_terminalapp_cwd
- # Run once to get initial cwd set
- update_terminalapp_cwd
+# Keep terminal emulator's current working directory correct,
+# even if the current working directory path contains symbolic links
+#
+# References:
+# - Apple's Terminal.app: https://superuser.com/a/315029
+# - iTerm2: https://iterm2.com/documentation-escape-codes.html (iTerm2 Extension / CurrentDir+RemoteHost)
+# - Konsole: https://bugs.kde.org/show_bug.cgi?id=327720#c1
+# - libvte (gnome-terminal, mate-terminal, …): https://bugzilla.gnome.org/show_bug.cgi?id=675987#c14
+# Apparently it had a bug before ~2012 were it would display the unknown OSC 7 code
+#
+# As of May 2021 mlterm, PuTTY, rxvt, screen, termux & xterm simply ignore the unknown OSC.
+
+# Don't define the function if we're inside Emacs or in an SSH session (#11696)
+if [[ -n "$INSIDE_EMACS" || -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then
+ return
fi
+
+# Don't define the function if we're in an unsupported terminal
+case "$TERM" in
+ # all of these either process OSC 7 correctly or ignore entirely
+ xterm*|putty*|rxvt*|konsole*|mlterm*|alacritty|screen*|tmux*) ;;
+ contour*|foot*) ;;
+ *)
+ # Terminal.app and iTerm2 process OSC 7 correctly
+ case "$TERM_PROGRAM" in
+ Apple_Terminal|iTerm.app) ;;
+ *) return ;;
+ esac ;;
+esac
+
+# Emits the control sequence to notify many terminal emulators
+# of the cwd
+#
+# Identifies the directory using a file: URI scheme, including
+# the host name to disambiguate local vs. remote paths.
+function omz_termsupport_cwd {
+ # Percent-encode the host and path names.
+ local URL_HOST URL_PATH
+ URL_HOST="$(omz_urlencode -P $HOST)" || return 1
+ URL_PATH="$(omz_urlencode -P $PWD)" || return 1
+
+ # Konsole errors if the HOST is provided
+ [[ -z "$KONSOLE_PROFILE_NAME" && -z "$KONSOLE_DBUS_SESSION" ]] || URL_HOST=""
+
+ # common control sequence (OSC 7) to set current host and path
+ printf "\e]7;file://%s%s\e\\" "${URL_HOST}" "${URL_PATH}"
+}
+
+# Use a precmd hook instead of a chpwd hook to avoid contaminating output
+# i.e. when a script or function changes directory without `cd -q`, chpwd
+# will be called the output may be swallowed by the script or function.
+add-zsh-hook precmd omz_termsupport_cwd
diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh
index d8859b04c..585e969d8 100644
--- a/lib/theme-and-appearance.zsh
+++ b/lib/theme-and-appearance.zsh
@@ -20,10 +20,25 @@ if command diff --color /dev/null{,} &>/dev/null; then
}
fi
-
# Don't set ls coloring if disabled
[[ "$DISABLE_LS_COLORS" != true ]] || return 0
+# Default coloring for BSD-based ls
+export LSCOLORS="Gxfxcxdxbxegedabagacad"
+
+# Default coloring for GNU-based ls
+if [[ -z "$LS_COLORS" ]]; then
+ # Define LS_COLORS via dircolors if available. Otherwise, set a default
+ # equivalent to LSCOLORS (generated via https://geoff.greer.fm/lscolors)
+ if (( $+commands[dircolors] )); then
+ [[ -f "$HOME/.dircolors" ]] \
+ && source <(dircolors -b "$HOME/.dircolors") \
+ || source <(dircolors -b)
+ else
+ export LS_COLORS="di=1;36:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43"
+ fi
+fi
+
function test-ls-args {
local cmd="$1" # ls, gls, colorls, ...
local args="${@[2,-1]}" # arguments except the first one
@@ -50,7 +65,7 @@ case "$OSTYPE" in
test-ls-args ls -G && alias ls='ls -G'
# Only use GNU ls if installed and there are user defaults for $LS_COLORS,
# as the default coloring scheme is not very pretty
- [[ -n "$LS_COLORS" || -f "$HOME/.dircolors" ]] \
+ zstyle -t ':omz:lib:theme-and-appearance' gnu-ls \
&& test-ls-args gls --color \
&& alias ls='gls --color=tty'
;;
@@ -64,20 +79,3 @@ case "$OSTYPE" in
esac
unfunction test-ls-args
-
-
-# Default coloring for BSD-based ls
-export LSCOLORS="Gxfxcxdxbxegedabagacad"
-
-# Default coloring for GNU-based ls
-if [[ -z "$LS_COLORS" ]]; then
- # Define LS_COLORS via dircolors if available. Otherwise, set a default
- # equivalent to LSCOLORS (generated via https://geoff.greer.fm/lscolors)
- if (( $+commands[dircolors] )); then
- [[ -f "$HOME/.dircolors" ]] \
- && source <(dircolors -b "$HOME/.dircolors") \
- || source <(dircolors -b)
- else
- export LS_COLORS="di=1;36:ln=35:so=32:pi=33:ex=31:bd=34;46:cd=34;43:su=30;41:sg=30;46:tw=30;42:ow=30;43"
- fi
-fi
diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh
index 363cfca8b..137ca3b6f 100644
--- a/oh-my-zsh.sh
+++ b/oh-my-zsh.sh
@@ -1,14 +1,14 @@
+# ANSI formatting function (\033[<code>m)
+# 0: reset, 1: bold, 4: underline, 22: no bold, 24: no underline, 31: red, 33: yellow
+omz_f() {
+ [ $# -gt 0 ] || return
+ IFS=";" printf "\033[%sm" $*
+}
+# If stdout is not a terminal ignore all formatting
+[ -t 1 ] || omz_f() { :; }
+
# Protect against non-zsh execution of Oh My Zsh (use POSIX syntax here)
[ -n "$ZSH_VERSION" ] || {
- # ANSI formatting function (\033[<code>m)
- # 0: reset, 1: bold, 4: underline, 22: no bold, 24: no underline, 31: red, 33: yellow
- omz_f() {
- [ $# -gt 0 ] || return
- IFS=";" printf "\033[%sm" $*
- }
- # If stdout is not a terminal ignore all formatting
- [ -t 1 ] || omz_f() { :; }
-
omz_ptree() {
# Get process tree of the current process
pid=$$; pids="$pid"
@@ -38,6 +38,15 @@
return 1
}
+# Check if in emulation mode, if so early return
+# https://github.com/ohmyzsh/ohmyzsh/issues/11686
+[[ "$(emulate)" = zsh ]] || {
+ printf "$(omz_f 1 31)Error:$(omz_f 22) Oh My Zsh can't be loaded in \`$(emulate)\` emulation mode.$(omz_f 0)\n" >&2
+ return 1
+}
+
+unset -f omz_f
+
# If ZSH is not defined, use the current script's directory.
[[ -z "$ZSH" ]] && export ZSH="${${(%):-%x}:a:h}"
@@ -146,22 +155,57 @@ if command mkdir "${ZSH_COMPDUMP}.lock" 2>/dev/null; then
command rm -rf "$ZSH_COMPDUMP.zwc.old" "${ZSH_COMPDUMP}.lock"
fi
-# Load all of the config files in ~/oh-my-zsh that end in .zsh
+_omz_source() {
+ local context filepath="$1"
+
+ # Construct zstyle context based on path
+ case "$filepath" in
+ lib/*) context="lib:${filepath:t:r}" ;; # :t = lib_name.zsh, :r = lib_name
+ plugins/*) context="plugins:${filepath:h:t}" ;; # :h = plugins/plugin_name, :t = plugin_name
+ esac
+
+ local disable_aliases=0
+ zstyle -T ":omz:${context}" aliases || disable_aliases=1
+
+ # Back up alias names prior to sourcing
+ local -A aliases_pre galiases_pre
+ if (( disable_aliases )); then
+ aliases_pre=("${(@kv)aliases}")
+ galiases_pre=("${(@kv)galiases}")
+ fi
+
+ # Source file from $ZSH_CUSTOM if it exists, otherwise from $ZSH
+ if [[ -f "$ZSH_CUSTOM/$filepath" ]]; then
+ source "$ZSH_CUSTOM/$filepath"
+ elif [[ -f "$ZSH/$filepath" ]]; then
+ source "$ZSH/$filepath"
+ fi
+
+ # Unset all aliases that don't appear in the backed up list of aliases
+ if (( disable_aliases )); then
+ if (( #aliases_pre )); then
+ aliases=("${(@kv)aliases_pre}")
+ else
+ (( #aliases )) && unalias "${(@k)aliases}"
+ fi
+ if (( #galiases_pre )); then
+ galiases=("${(@kv)galiases_pre}")
+ else
+ (( #galiases )) && unalias "${(@k)galiases}"
+ fi
+ fi
+}
+
+# Load all of the lib files in ~/oh-my-zsh/lib that end in .zsh
# TIP: Add files you don't want in git to .gitignore
-for config_file ("$ZSH"/lib/*.zsh); do
- custom_config_file="$ZSH_CUSTOM/lib/${config_file:t}"
- [[ -f "$custom_config_file" ]] && config_file="$custom_config_file"
- source "$config_file"
+for lib_file ("$ZSH"/lib/*.zsh); do
+ _omz_source "lib/${lib_file:t}"
done
-unset custom_config_file
+unset lib_file
# Load all of the plugins that were defined in ~/.zshrc
for plugin ($plugins); do
- if [[ -f "$ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh" ]]; then
- source "$ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh"
- elif [[ -f "$ZSH/plugins/$plugin/$plugin.plugin.zsh" ]]; then
- source "$ZSH/plugins/$plugin/$plugin.plugin.zsh"
- fi
+ _omz_source "plugins/$plugin/$plugin.plugin.zsh"
done
unset plugin
diff --git a/plugins/alias-finder/.zunit.yml b/plugins/alias-finder/.zunit.yml
new file mode 100644
index 000000000..ae65f8ef2
--- /dev/null
+++ b/plugins/alias-finder/.zunit.yml
@@ -0,0 +1,9 @@
+tap: false
+directories:
+ tests: tests
+ output: tests/_output
+ support: tests/_support
+time_limit: 0
+fail_fast: false
+allow_risky: false
+verbose: true
diff --git a/plugins/alias-finder/README.md b/plugins/alias-finder/README.md
index 409f4b653..6c87c723a 100644
--- a/plugins/alias-finder/README.md
+++ b/plugins/alias-finder/README.md
@@ -2,45 +2,32 @@
This plugin searches the defined aliases and outputs any that match the command inputted. This makes learning new aliases easier.
+## Usage
+
To use it, add `alias-finder` to the `plugins` array of your zshrc file:
```
plugins=(... alias-finder)
```
-## Usage
-To see if there is an alias defined for the command, pass it as an argument to `alias-finder`. This can also run automatically before each command you input - add `ZSH_ALIAS_FINDER_AUTOMATIC=true` to your zshrc if you want this.
+To enable it for every single command, set zstyle in your `~/.zshrc`.
-## Options
+```zsh
+# ~/.zshrc
-- Use `--longer` or `-l` to allow the aliases to be longer than the input (match aliases if they contain the input).
-- Use `--exact` or `-e` to avoid matching aliases that are shorter than the input.
-
-## Examples
-```
-$ alias-finder "git pull"
-gl='git pull'
-g=git
-```
-```
-$ alias-finder "web_search google oh my zsh"
-google='web_search google'
-```
-```
-$ alias-finder "git commit -v"
-gc="git commit -v"
-g=git
-```
-```
-$ alias-finder -e "git commit -v"
-gc='git commit -v'
-```
-```
-$ alias-finder -l "git commit -v"
-gc='git commit -v'
-'gc!'='git commit -v --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'
-'gcn!'='git commit -v --no-edit --amend'
+zstyle ':omz:plugins:alias-finder' autoload yes # disabled by default
+zstyle ':omz:plugins:alias-finder' longer yes # disabled by default
+zstyle ':omz:plugins:alias-finder' exact yes # disabled by default
+zstyle ':omz:plugins:alias-finder' cheaper yes # disabled by default
```
+
+As you can see, options are also available with zstyle.
+
+### Options
+
+> In order to clarify, let's say `alias a=abc` has source 'abc' and destination 'a'.
+
+- Use `--longer` or `-l` to include aliases where the source is longer than the input (in other words, the source could contain the whole input).
+- Use `--exact` or `-e` to avoid aliases where the source is shorter than the input (in other words, the source must be the same with the input).
+- Use `--cheaper` or `-c` to avoid aliases where the destination is longer than the input (in other words, the destination must be the shorter than the input).
+
+
diff --git a/plugins/alias-finder/alias-finder.plugin.zsh b/plugins/alias-finder/alias-finder.plugin.zsh
index caee9b5a3..5fdfbc835 100644
--- a/plugins/alias-finder/alias-finder.plugin.zsh
+++ b/plugins/alias-finder/alias-finder.plugin.zsh
@@ -1,44 +1,59 @@
alias-finder() {
- local cmd="" exact="" longer="" wordStart="" wordEnd="" multiWordEnd=""
- for i in $@; do
- case $i in
+ local cmd=" " exact="" longer="" cheaper="" wordEnd="'{0,1}$" finder="" filter=""
+
+ # build command and options
+ for c in "$@"; do
+ case $c in
+ # TODO: Remove backward compatibility (other than zstyle form)
+ # set options if exist
-e|--exact) exact=true;;
-l|--longer) longer=true;;
- *)
- if [[ -z $cmd ]]; then
- cmd=$i
- else
- cmd="$cmd $i"
- fi
- ;;
+ -c|--cheaper) cheaper=true;;
+ # concatenate cmd
+ *) cmd="$cmd$c " ;;
esac
done
- cmd=$(sed 's/[].\|$(){}?+*^[]/\\&/g' <<< $cmd) # adds escaping for grep
- if (( $(wc -l <<< $cmd) == 1 )); then
- while [[ $cmd != "" ]]; do
- if [[ $longer = true ]]; then
- wordStart="'{0,1}"
- else
- wordEnd="$"
- multiWordEnd="'$"
- fi
- if [[ $cmd == *" "* ]]; then
- local finder="'$cmd$multiWordEnd"
- else
- local finder=$wordStart$cmd$wordEnd
- fi
- alias | grep -E "=$finder"
- if [[ $exact = true || $longer = true ]]; then
- break
- else
- cmd=$(sed -E 's/ {0,1}[^ ]*$//' <<< $cmd) # removes last word
- fi
- done
+
+ zstyle -t ':omz:plugins:alias-finder' longer && longer=true
+ zstyle -t ':omz:plugins:alias-finder' exact && exact=true
+ zstyle -t ':omz:plugins:alias-finder' cheaper && cheaper=true
+
+ # format cmd for grep
+ ## - replace newlines with spaces
+ ## - trim both ends
+ ## - replace multiple spaces with one space
+ ## - add escaping character to special characters
+ cmd=$(echo -n "$cmd" | tr '\n' ' ' | xargs | tr -s '[:space:]' | sed 's/[].\|$(){}?+*^[]/\\&/g')
+
+ if [[ $longer == true ]]; then
+ wordEnd="" # remove wordEnd to find longer aliases
fi
+
+ # find with alias and grep, removing last word each time until no more words
+ while [[ $cmd != "" ]]; do
+ finder="'{0,1}$cmd$wordEnd"
+
+ # make filter to find only shorter results than current cmd
+ if [[ $cheaper == true ]]; then
+ cmdLen=$(echo -n "$cmd" | wc -c)
+ filter="^'{0,1}.{0,$((cmdLen - 1))}="
+ fi
+
+ alias | grep -E "$filter" | grep -E "=$finder"
+
+ if [[ $exact == true ]]; then
+ break # because exact case is only one
+ elif [[ $longer = true ]]; then
+ break # because above grep command already found every longer aliases during first cycle
+ fi
+
+ cmd=$(sed -E 's/ {0,}[^ ]*$//' <<< "$cmd") # remove last word
+ done
}
preexec_alias-finder() {
- if [[ $ZSH_ALIAS_FINDER_AUTOMATIC = true ]]; then
+ # TODO: Remove backward compatibility (other than zstyle form)
+ zstyle -t ':omz:plugins:alias-finder' autoload && alias-finder $1 || if [[ $ZSH_ALIAS_FINDER_AUTOMATIC = true ]]; then
alias-finder $1
fi
}
diff --git a/plugins/alias-finder/tests/_output/.gitkeep b/plugins/alias-finder/tests/_output/.gitkeep
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/plugins/alias-finder/tests/_output/.gitkeep
diff --git a/plugins/alias-finder/tests/_support/.gitkeep b/plugins/alias-finder/tests/_support/.gitkeep
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/plugins/alias-finder/tests/_support/.gitkeep
diff --git a/plugins/alias-finder/tests/_support/bootstrap b/plugins/alias-finder/tests/_support/bootstrap
new file mode 100644
index 000000000..01076611e
--- /dev/null
+++ b/plugins/alias-finder/tests/_support/bootstrap
@@ -0,0 +1,2 @@
+#!/usr/bin/env zsh
+# Write your bootstrap code here
diff --git a/plugins/alias-finder/tests/test_run.sh b/plugins/alias-finder/tests/test_run.sh
new file mode 100644
index 000000000..6b7abebb6
--- /dev/null
+++ b/plugins/alias-finder/tests/test_run.sh
@@ -0,0 +1,107 @@
+#!/usr/bin/env zunit
+
+@setup {
+ load ../alias-finder.plugin.zsh
+
+ set_git_aliases() {
+ unalias -a # all
+ alias g="git"
+ alias gc="git commit"
+ alias gcv="git commit -v"
+ alias gcvs="git commit -v -S"
+ }
+}
+
+@test 'find aliases that contain input' {
+ set_git_aliases
+
+ run alias-finder "git"
+
+ assert "${#lines[@]}" equals 1
+ assert "${lines[1]}" same_as "g=git"
+}
+
+@test 'find aliases that contain input with whitespaces at ends' {
+ set_git_aliases
+
+ run alias-finder " git "
+
+ assert "${#lines[@]}" equals 1
+ assert "${lines[1]}" same_as "g=git"
+}
+
+@test 'find aliases that contain multiple words' {
+ set_git_aliases
+
+ run alias-finder "git commit -v"
+
+ assert "${#lines[@]}" equals 3
+ assert "${lines[1]}" same_as "gcv='git commit -v'"
+ assert "${lines[2]}" same_as "gc='git commit'"
+ assert "${lines[3]}" same_as "g=git"
+}
+
+@test 'find alias that is the same with input when --exact option is set' {
+ set_git_aliases
+
+ run alias-finder -e "git"
+
+ assert "${#lines[@]}" equals 1
+ assert "${lines[1]}" same_as "g=git"
+}
+
+@test 'find alias that is the same with multiple words input when --exact option is set' {
+ set_git_aliases
+
+ run alias-finder -e "git commit -v"
+
+ assert "${#lines[@]}" equals 1
+ assert "${lines[1]}" same_as "gcv='git commit -v'"
+}
+
+@test 'find alias that is the same with or longer than input when --longer option is set' {
+ set_git_aliases
+
+ run alias-finder -l "git"
+
+ assert "${#lines[@]}" equals 4
+ assert "${lines[1]}" same_as "g=git"
+ assert "${lines[2]}" same_as "gc='git commit'"
+ assert "${lines[3]}" same_as "gcv='git commit -v'"
+ assert "${lines[4]}" same_as "gcvs='git commit -v -S'"
+}
+
+@test 'find alias that is the same with or longer than multiple words input when --longer option is set' {
+ set_git_aliases
+
+ run alias-finder -l "git commit -v"
+
+ assert "${#lines[@]}" equals 2
+ assert "${lines[1]}" same_as "gcv='git commit -v'"
+ assert "${lines[2]}" same_as "gcvs='git commit -v -S'"
+}
+
+@test 'find aliases including expensive (longer) than input' {
+ set_git_aliases
+ alias expensiveCommands="git commit"
+
+ run alias-finder "git commit -v"
+
+ assert "${#lines[@]}" equals 4
+ assert "${lines[1]}" same_as "gcv='git commit -v'"
+ assert "${lines[2]}" same_as "expensiveCommands='git commit'"
+ assert "${lines[3]}" same_as "gc='git commit'"
+ assert "${lines[4]}" same_as "g=git"
+}
+
+@test 'find aliases excluding expensive (longer) than input when --cheap option is set' {
+ set_git_aliases
+ alias expensiveCommands="git commit"
+
+ run alias-finder -c "git commit -v"
+
+ assert "${#lines[@]}" equals 3
+ assert "${lines[1]}" same_as "gcv='git commit -v'"
+ assert "${lines[2]}" same_as "gc='git commit'"
+ assert "${lines[3]}" same_as "g=git"
+}
diff --git a/plugins/aliases/README.md b/plugins/aliases/README.md
index 6a2da3d74..14f9c5c53 100644
--- a/plugins/aliases/README.md
+++ b/plugins/aliases/README.md
@@ -15,14 +15,14 @@ Requirements: Python needs to be installed.
## Usage
-- `acs`: show all aliases by group
+- `als`: show all aliases by group
-- `acs -h/--help`: print help mesage
+- `als -h/--help`: print help message
-- `acs <keyword(s)>`: filter and highlight aliases by `<keyword>`
+- `als <keyword(s)>`: filter and highlight aliases by `<keyword>`
-- `acs -g <group>/--group <group>`: show only aliases for group `<group>`. Multiple uses of the flag show all groups
+- `als -g <group>/--group <group>`: show only aliases for group `<group>`. Multiple uses of the flag show all groups
-- `acs --groups`: show only group names
+- `als --groups`: show only group names
- ![screenshot](https://cloud.githubusercontent.com/assets/3602957/11581913/cb54fb8a-9a82-11e5-846b-5a67f67ad9ad.png)
+ ![screenshot](https://github.com/ohmyzsh/ohmyzsh/assets/66907184/5bfa00ea-5fc3-4e97-8b22-2f74f6b948c7)
diff --git a/plugins/aliases/aliases.plugin.zsh b/plugins/aliases/aliases.plugin.zsh
index 9864de957..7f1ba83b8 100644
--- a/plugins/aliases/aliases.plugin.zsh
+++ b/plugins/aliases/aliases.plugin.zsh
@@ -4,7 +4,7 @@
0="${${(M)0:#/*}:-$PWD/$0}"
eval '
- function acs(){
+ function als(){
(( $+commands[python3] )) || {
echo "[error] No python executable detected"
return
diff --git a/plugins/aliases/cheatsheet.py b/plugins/aliases/cheatsheet.py
index f742fba9e..61bf5f956 100644
--- a/plugins/aliases/cheatsheet.py
+++ b/plugins/aliases/cheatsheet.py
@@ -57,7 +57,7 @@ def pretty_print(cheatsheet, wfilter, group_list=None, groups_only=False):
pretty_print_group(key, [ alias for alias in aliases if alias[0].find(wfilter)>-1 or alias[1].find(wfilter)>-1], wfilter)
if __name__ == '__main__':
- parser = argparse.ArgumentParser(description="Pretty print aliases.", prog="acs")
+ parser = argparse.ArgumentParser(description="Pretty print aliases.", prog="als")
parser.add_argument('filter', nargs="*", metavar="<keyword>", help="search aliases matching keywords")
parser.add_argument('-g', '--group', dest="group_list", action='append', help="only print aliases in given groups")
parser.add_argument('--groups', dest='groups_only', action='store_true', help="only print alias groups")
diff --git a/plugins/archlinux/README.md b/plugins/archlinux/README.md
index fd772c61a..5e015dbaa 100644
--- a/plugins/archlinux/README.md
+++ b/plugins/archlinux/README.md
@@ -181,3 +181,4 @@ whether the package manager is installed, checked in the following order:
- Ybalrid (Arthur Brainville) - ybalrid@ybalrid.info
- Jeff M. Hubbard - jeffmhubbard@gmail.com
- K. Harishankar(harishnkr) - hari2menon1234@gmail.com
+- WH-2099 - wh2099@outlook.com \ No newline at end of file
diff --git a/plugins/archlinux/archlinux.plugin.zsh b/plugins/archlinux/archlinux.plugin.zsh
index 4f1364779..fca6548c0 100644
--- a/plugins/archlinux/archlinux.plugin.zsh
+++ b/plugins/archlinux/archlinux.plugin.zsh
@@ -23,30 +23,27 @@ alias pacfiles='pacman -F'
alias pacls='pacman -Ql'
alias pacown='pacman -Qo'
alias pacupd="sudo pacman -Sy"
-alias upgrade='sudo pacman -Syu'
function paclist() {
- # Based on https://bbs.archlinux.org/viewtopic.php?id=93683
- pacman -Qqe | \
- xargs -I '{}' \
- expac "${bold_color}% 20n ${fg_no_bold[white]}%d${reset_color}" '{}'
+ pacman -Qqe | xargs -I{} -P0 --no-run-if-empty pacman -Qs --color=auto "^{}\$"
}
function pacdisowned() {
- local tmp db fs
- tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$
- db=$tmp/db
- fs=$tmp/fs
+ local tmp_dir db fs
+ tmp_dir=$(mktemp --directory)
+ db=$tmp_dir/db
+ fs=$tmp_dir/fs
- mkdir "$tmp"
- trap 'rm -rf "$tmp"' EXIT
+ trap "rm -rf $tmp_dir" EXIT
pacman -Qlq | sort -u > "$db"
- find /bin /etc /lib /sbin /usr ! -name lost+found \
+ find /etc /usr ! -name lost+found \
\( -type d -printf '%p/\n' -o -print \) | sort > "$fs"
comm -23 "$fs" "$db"
+
+ rm -rf $tmp_dir
}
alias pacmanallkeys='sudo pacman-key --refresh-keys'
@@ -109,7 +106,6 @@ if (( $+commands[aura] )); then
alias auupd="sudo aura -Sy"
alias auupg='sudo sh -c "aura -Syu && aura -Au"'
alias ausu='sudo sh -c "aura -Syu --no-confirm && aura -Au --no-confirm"'
- alias upgrade='sudo aura -Syu'
# extra bonus specially for aura
alias auown="aura -Qqo"
@@ -136,7 +132,6 @@ if (( $+commands[pacaur] )); then
alias painsd='pacaur -S --asdeps'
alias pamir='pacaur -Syy'
alias paupd="pacaur -Sy"
- alias upgrade='pacaur -Syu'
fi
if (( $+commands[trizen] )); then
@@ -158,7 +153,6 @@ if (( $+commands[trizen] )); then
alias trinsd='trizen -S --asdeps'
alias trmir='trizen -Syy'
alias trupd="trizen -Sy"
- alias upgrade='trizen -Syu'
fi
if (( $+commands[yay] )); then
@@ -180,5 +174,30 @@ if (( $+commands[yay] )); then
alias yainsd='yay -S --asdeps'
alias yamir='yay -Syy'
alias yaupd="yay -Sy"
- alias upgrade='yay -Syu'
fi
+
+# Check Arch Linux PGP Keyring before System Upgrade to prevent failure.
+function upgrade() {
+ echo ":: Checking Arch Linux PGP Keyring..."
+ local installedver="$(sudo pacman -Qi archlinux-keyring | grep -Po '(?<=Version : ).*')"
+ local currentver="$(sudo pacman -Si archlinux-keyring | grep -Po '(?<=Version : ).*')"
+ if [ $installedver != $currentver ]; then
+ echo " Arch Linux PGP Keyring is out of date."
+ echo " Updating before full system upgrade."
+ sudo pacman -Sy --needed --noconfirm archlinux-keyring
+ else
+ echo " Arch Linux PGP Keyring is up to date."
+ echo " Proceeding with full system upgrade."
+ fi
+ if (( $+commands[yay] )); then
+ yay -Syu
+ elif (( $+commands[trizen] )); then
+ trizen -Syu
+ elif (( $+commands[pacaur] )); then
+ pacaur -Syu
+ elif (( $+commands[aura] )); then
+ sudo aura -Syu
+ else
+ sudo pacman -Syu
+ fi
+}
diff --git a/plugins/asdf/asdf.plugin.zsh b/plugins/asdf/asdf.plugin.zsh
index 3016282c6..7635d20c3 100644
--- a/plugins/asdf/asdf.plugin.zsh
+++ b/plugins/asdf/asdf.plugin.zsh
@@ -2,26 +2,29 @@
ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
ASDF_COMPLETIONS="$ASDF_DIR/completions"
-# If not found, check for archlinux/AUR package (/opt/asdf-vm/)
-if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/asdf.bash" ]] && [[ -f "/opt/asdf-vm/asdf.sh" ]]; then
- ASDF_DIR="/opt/asdf-vm"
- ASDF_COMPLETIONS="$ASDF_DIR"
-fi
-
-# If not found, check for Homebrew package
-if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/asdf.bash" ]] && (( $+commands[brew] )); then
- brew_prefix="$(brew --prefix asdf)"
- ASDF_DIR="${brew_prefix}/libexec"
- ASDF_COMPLETIONS="${brew_prefix}/etc/bash_completion.d"
- unset brew_prefix
+if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/_asdf" ]]; then
+ # If not found, check for archlinux/AUR package (/opt/asdf-vm/)
+ if [[ -f "/opt/asdf-vm/asdf.sh" ]]; then
+ ASDF_DIR="/opt/asdf-vm"
+ ASDF_COMPLETIONS="$ASDF_DIR"
+ # If not found, check for Homebrew package
+ elif (( $+commands[brew] )); then
+ _ASDF_PREFIX="$(brew --prefix asdf)"
+ ASDF_DIR="${_ASDF_PREFIX}/libexec"
+ ASDF_COMPLETIONS="${_ASDF_PREFIX}/share/zsh/site-functions"
+ unset _ASDF_PREFIX
+ else
+ return
+ fi
fi
# Load command
if [[ -f "$ASDF_DIR/asdf.sh" ]]; then
- . "$ASDF_DIR/asdf.sh"
-
+ source "$ASDF_DIR/asdf.sh"
# Load completions
- if [[ -f "$ASDF_COMPLETIONS/asdf.bash" ]]; then
- . "$ASDF_COMPLETIONS/asdf.bash"
+ if [[ -f "$ASDF_COMPLETIONS/_asdf" ]]; then
+ fpath+=("$ASDF_COMPLETIONS")
+ autoload -Uz _asdf
+ compdef _asdf asdf # compdef is already loaded before loading plugins
fi
fi
diff --git a/plugins/autoenv/autoenv.plugin.zsh b/plugins/autoenv/autoenv.plugin.zsh
index 229a8a834..2f84f0acf 100644
--- a/plugins/autoenv/autoenv.plugin.zsh
+++ b/plugins/autoenv/autoenv.plugin.zsh
@@ -17,9 +17,13 @@ if ! type autoenv_init >/dev/null; then
/usr/local/bin
/usr/share/autoenv-git
~/Library/Python/bin
+ .venv/bin
+ venv/bin
+ env/bin
+ .env/bin
)
for d ( $install_locations ); do
- if [[ -e $d/activate.sh ]]; then
+ if [[ -e $d/activate || -e $d/activate.sh ]]; then
autoenv_dir=$d
break
fi
@@ -29,13 +33,13 @@ if ! type autoenv_init >/dev/null; then
# Look for Homebrew path as a last resort
if [[ -z "$autoenv_dir" ]] && (( $+commands[brew] )); then
d=$(brew --prefix)/opt/autoenv
- if [[ -e $d/activate.sh ]]; then
+ if [[ -e $d/activate || -e $d/activate.sh ]]; then
autoenv_dir=$d
fi
fi
# Complain if autoenv is not installed
- if [[ -z $autoenv_dir ]]; then
+ if [[ -z $autoenv_dir ]]; then
cat <<END >&2
-------- AUTOENV ---------
Could not locate autoenv installation.
@@ -46,7 +50,11 @@ END
return 1
fi
# Load autoenv
- source $autoenv_dir/activate.sh
+ if [[ -e $autoenv_dir/activate ]]; then
+ source $autoenv_dir/activate
+ else
+ source $autoenv_dir/activate.sh
+ fi
fi
}
[[ $? != 0 ]] && return $?
diff --git a/plugins/aws/README.md b/plugins/aws/README.md
index e1e355741..9e1e055b8 100644
--- a/plugins/aws/README.md
+++ b/plugins/aws/README.md
@@ -1,7 +1,8 @@
# aws
-This plugin provides completion support for [awscli](https://docs.aws.amazon.com/cli/latest/reference/index.html)
+This plugin provides completion support for [awscli v2](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/index.html)
and a few utilities to manage AWS profiles/regions and display them in the prompt.
+[awscli v1](https://docs.aws.amazon.com/cli/latest/userguide/cliv2-migration.html) is no longer supported.
To use it, add `aws` to the plugins array in your zshrc file.
@@ -12,9 +13,9 @@ plugins=(... aws)
## Plugin commands
* `asp [<profile>]`: sets `$AWS_PROFILE` and `$AWS_DEFAULT_PROFILE` (legacy) to `<profile>`.
- It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI.
+ It also sets `$AWS_EB_PROFILE` to `<profile>` for the Elastic Beanstalk CLI. It sets `$AWS_PROFILE_REGION` for display in `aws_prompt_info`.
Run `asp` without arguments to clear the profile.
-* `asp [<profile>] login`: If AWS SSO has been configured in your aws profile, it will run the `aws sso login` command following profile selection.
+* `asp [<profile>] login`: If AWS SSO has been configured in your aws profile, it will run the `aws sso login` command following profile selection.
* `asr [<region>]`: sets `$AWS_REGION` and `$AWS_DEFAULT_REGION` (legacy) to `<region>`.
Run `asr` without arguments to clear the profile.
@@ -57,6 +58,8 @@ the current `$AWS_PROFILE` and `$AWS_REGION`. It uses four variables to control
* ZSH_THEME_AWS_REGION_SUFFIX: sets the suffix of the AWS_REGION. Defaults to `>`.
+* ZSH_THEME_AWS_DIVIDER: sets the divider between ZSH_THEME_AWS_PROFILE_SUFFIX and ZSH_THEME_AWS_REGION_PREFIX. Defaults to ` ` (single space).
+
## Configuration
[Configuration and credential file settings](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) by AWS
@@ -65,7 +68,7 @@ the current `$AWS_PROFILE` and `$AWS_REGION`. It uses four variables to control
Source profile credentials in `~/.aws/credentials`:
-```
+```ini
[source-profile-name]
aws_access_key_id = ...
aws_secret_access_key = ...
@@ -73,7 +76,7 @@ aws_secret_access_key = ...
Role configuration in `~/.aws/config`:
-```
+```ini
[profile source-profile-name]
mfa_serial = arn:aws:iam::111111111111:mfa/myuser
region = us-east-1
diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh
index 1c386a3e1..c946515be 100644
--- a/plugins/aws/aws.plugin.zsh
+++ b/plugins/aws/aws.plugin.zsh
@@ -9,7 +9,7 @@ function agr() {
# AWS profile selection
function asp() {
if [[ -z "$1" ]]; then
- unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE
+ unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE AWS_PROFILE_REGION
echo AWS profile cleared.
return
fi
@@ -26,6 +26,8 @@ function asp() {
export AWS_PROFILE=$1
export AWS_EB_PROFILE=$1
+ export AWS_PROFILE_REGION=$(aws configure get region)
+
if [[ "$2" == "login" ]]; then
aws sso login
fi
@@ -158,14 +160,39 @@ function aws_change_access_key() {
return 1
fi
- echo "Insert the credentials when asked."
- asp "$1" || return 1
- AWS_PAGER="" aws iam create-access-key
- AWS_PAGER="" aws configure --profile "$1"
+ local profile="$1"
+ # Get current access key
+ local original_aws_access_key_id="$(aws configure get aws_access_key_id --profile $profile)"
+
+ asp "$profile" || return 1
+ echo "Generating a new access key pair for you now."
+ if aws --no-cli-pager iam create-access-key; then
+ echo "Insert the newly generated credentials when asked."
+ aws --no-cli-pager configure --profile $profile
+ else
+ echo "Current access keys:"
+ aws --no-cli-pager iam list-access-keys
+ echo "Profile \"${profile}\" is currently using the $original_aws_access_key_id key. You can delete an old access key by running \`aws --profile $profile iam delete-access-key --access-key-id AccessKeyId\`"
+ return 1
+ fi
- echo "You can now safely delete the old access key running \`aws iam delete-access-key --access-key-id ID\`"
+ read -q "yn?Would you like to disable your previous access key (${original_aws_access_key_id}) now? "
+ case $yn in
+ [Yy]*)
+ echo -n "\nDisabling access key ${original_aws_access_key_id}..."
+ if aws --no-cli-pager iam update-access-key --access-key-id ${original_aws_access_key_id} --status Inactive; then
+ echo "done."
+ else
+ echo "\nFailed to disable ${original_aws_access_key_id} key."
+ fi
+ ;;
+ *)
+ echo ""
+ ;;
+ esac
+ echo "You can now safely delete the old access key by running \`aws --profile $profile iam delete-access-key --access-key-id ${original_aws_access_key_id}\`"
echo "Your current keys are:"
- AWS_PAGER="" aws iam list-access-keys
+ aws --no-cli-pager iam list-access-keys
}
function aws_regions() {
@@ -194,15 +221,25 @@ compctl -K _aws_profiles asp acp aws_change_access_key
# AWS prompt
function aws_prompt_info() {
- if [[ -z $AWS_REGION && -z $AWS_PROFILE ]];then return; fi
- echo "${ZSH_THEME_AWS_PROFILE_PREFIX:=<aws:}${AWS_PROFILE}${ZSH_THEME_AWS_PROFILE_SUFFIX:=>} ${ZSH_THEME_AWS_REGION_PREFIX:=<region:}${AWS_REGION}${ZSH_THEME_AWS_REGION_SUFFIX:=>}"
+ local _aws_to_show
+ local region="${AWS_REGION:-${AWS_DEFAULT_REGION:-$AWS_PROFILE_REGION}}"
+
+ if [[ -n "$AWS_PROFILE" ]];then
+ _aws_to_show+="${ZSH_THEME_AWS_PROFILE_PREFIX="<aws:"}${AWS_PROFILE}${ZSH_THEME_AWS_PROFILE_SUFFIX=">"}"
+ fi
+
+ if [[ -n "$region" ]]; then
+ [[ -n "$_aws_to_show" ]] && _aws_to_show+="${ZSH_THEME_AWS_DIVIDER=" "}"
+ _aws_to_show+="${ZSH_THEME_AWS_REGION_PREFIX="<region:"}${region}${ZSH_THEME_AWS_REGION_SUFFIX=">"}"
+ fi
+
+ echo "$_aws_to_show"
}
if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; then
RPROMPT='$(aws_prompt_info)'"$RPROMPT"
fi
-
# Load awscli completions
# AWS CLI v2 comes with its own autocompletion. Check if that is there, otherwise fall back
diff --git a/plugins/azure/azure.plugin.zsh b/plugins/azure/azure.plugin.zsh
index 51b54dbc1..b33b0f805 100644
--- a/plugins/azure/azure.plugin.zsh
+++ b/plugins/azure/azure.plugin.zsh
@@ -1,4 +1,4 @@
-# AZ Get Subscritions
+# AZ Get Subscriptions
function azgs() {
az account show --output tsv --query 'name' 2>/dev/null
}
@@ -18,10 +18,10 @@ compctl -K _az_subscriptions azss
# Azure prompt
function azure_prompt_info() {
- [[ ! -f "${AZURE_CONFIG_DIR:-$HOME/.azure/azureProfile.json}" ]] && return
+ [[ ! -f "${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json" ]] && return
# azgs is too expensive, if we have jq, we enable the prompt
(( $+commands[jq] )) || return 1
- azgs=$(jq -r '.subscriptions[] | select(.isDefault==true) .name' ${AZURE_CONFIG_DIR:-$HOME/.azure/azureProfile.json})
+ azgs=$(jq -r '.subscriptions[] | select(.isDefault==true) .name' "${AZURE_CONFIG_DIR:-$HOME/.azure}/azureProfile.json")
echo "${ZSH_THEME_AZURE_PREFIX:=<az:}${azgs}${ZSH_THEME_AZURE_SUFFIX:=>}"
}
@@ -31,11 +31,9 @@ function _az-homebrew-installed() {
# check if Homebrew is installed
(( $+commands[brew] )) || return 1
- # speculatively check default brew prefix
- if [[ -d /usr/local ]]; then
- _brew_prefix=/usr/local
- elif [[ -d /opt/homebrew ]]; then
- _brew_prefix=/opt/homebrew
+ # if so, we assume it's default way to install brew
+ if [[ ${commands[brew]:t2} == bin/brew ]]; then
+ _brew_prefix="${commands[brew]:h:h}" # remove trailing /bin/brew
else
# ok, it is not in the default prefix
# this call to brew is expensive (about 400 ms), so at least let's make it only once
diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh
index db5eeb93a..1d3d529a3 100644
--- a/plugins/battery/battery.plugin.zsh
+++ b/plugins/battery/battery.plugin.zsh
@@ -13,6 +13,10 @@
# Author: Avneet Singh (kalsi-avneet) #
# Modified to add support for Android #
###########################################
+# Author: Not Pua (im-notpua) #
+# Modified to add support for OpenBSD #
+###########################################
+
if [[ "$OSTYPE" = darwin* ]]; then
function battery_is_charging() {
@@ -139,6 +143,46 @@ elif [[ "$OSTYPE" = linux-android ]] && (( ${+commands[termux-battery-status]} )
echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
fi
}
+elif [[ "$OSTYPE" = openbsd* ]]; then
+ function battery_is_charging() {
+ [[ $(apm -b) -eq 3 ]]
+ }
+ function battery_pct() {
+ apm -l
+ }
+ function battery_pct_remaining() {
+ if ! battery_is_charging; then
+ battery_pct
+ else
+ echo "External Power"
+ fi
+ }
+ function battery_time_remaining() {
+ local remaining_time
+ remaining_time=$(apm -m)
+ if [[ $remaining_time -ge 0 ]]; then
+ ((hour = $remaining_time / 60 ))
+ ((minute = $remaining_time % 60 ))
+ printf %02d:%02d $hour $minute
+ fi
+ }
+ function battery_pct_prompt() {
+ local battery_pct color
+ battery_pct=$(battery_pct_remaining)
+ if battery_is_charging; then
+ echo "∞"
+ else
+ if [[ $battery_pct -gt 50 ]]; then
+ color='green'
+ elif [[ $battery_pct -gt 20 ]]; then
+ color='yellow'
+ else
+ color='red'
+ fi
+ echo "%{$fg[$color]%}${battery_pct}%%%{$reset_color%}"
+ fi
+ }
+
elif [[ "$OSTYPE" = linux* ]]; then
function battery_is_charging() {
if (( $+commands[acpitool] )); then
diff --git a/plugins/bazel/_bazel b/plugins/bazel/_bazel
index c34c572b0..ea1f4cace 100644
--- a/plugins/bazel/_bazel
+++ b/plugins/bazel/_bazel
@@ -1,4 +1,4 @@
-#compdef bazel
+#compdef bazel bazelisk
# Copyright 2015 The Bazel Authors. All rights reserved.
#
diff --git a/plugins/brew/README.md b/plugins/brew/README.md
index 412daae63..299393b28 100644
--- a/plugins/brew/README.md
+++ b/plugins/brew/README.md
@@ -10,10 +10,12 @@ plugins=(... brew)
## Shellenv
-If `brew` is not found in the PATH, this plugin will attempt to find it in common
-locations, and execute `brew shellenv` to set the environment appropriately.
-This plugin will also export `HOMEBREW_PREFIX="$(brew --prefix)"` if not previously
-defined for convenience.
+If `brew` is not found in the PATH, this plugin will attempt to find it in common locations, and execute
+`brew shellenv` to set the environment appropriately. This plugin will also export
+`HOMEBREW_PREFIX="$(brew --prefix)"` if not previously defined for convenience.
+
+In case you installed `brew` in a non-common location, you can still set `BREW_LOCATION` variable pointing to
+the `brew` binary before sourcing `oh-my-zsh.sh` and it'll set up the environment.
## Aliases
@@ -33,7 +35,9 @@ defined for convenience.
## Completion
-With the release of Homebrew 1.0, they decided to bundle the zsh completion as part of the
-brew installation, so we no longer ship it with the brew plugin; now it only has brew
-aliases. If you find that brew completion no longer works, make sure you have your Homebrew
-installation fully up to date.
+This plugin configures paths with Homebrew's completion functions automatically, so you don't need to do it
+manually. See: https://docs.brew.sh/Shell-Completion#configuring-completions-in-zsh.
+
+With the release of Homebrew 1.0, they decided to bundle the zsh completion as part of the brew installation,
+so we no longer ship it with the brew plugin; now it only has brew aliases. If you find that brew completion
+no longer works, make sure you have your Homebrew installation fully up to date.
diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh
index f6abe0875..447036376 100644
--- a/plugins/brew/brew.plugin.zsh
+++ b/plugins/brew/brew.plugin.zsh
@@ -1,5 +1,10 @@
if (( ! $+commands[brew] )); then
- if [[ -x /opt/homebrew/bin/brew ]]; then
+ if [[ -n "$BREW_LOCATION" ]]; then
+ if [[ ! -x "$BREW_LOCATION" ]]; then
+ echo "[oh-my-zsh] $BREW_LOCATION is not executable"
+ return
+ fi
+ elif [[ -x /opt/homebrew/bin/brew ]]; then
BREW_LOCATION="/opt/homebrew/bin/brew"
elif [[ -x /usr/local/bin/brew ]]; then
BREW_LOCATION="/usr/local/bin/brew"
@@ -25,6 +30,10 @@ if [[ -z "$HOMEBREW_PREFIX" ]]; then
export HOMEBREW_PREFIX="$(brew --prefix)"
fi
+if [[ -d "$HOMEBREW_PREFIX/share/zsh/site-functions" ]]; then
+ fpath+=("$HOMEBREW_PREFIX/share/zsh/site-functions")
+fi
+
alias bcubc='brew upgrade --cask && brew cleanup'
alias bcubo='brew update && brew outdated --cask'
alias bcubc='brew upgrade --cask && brew cleanup'
diff --git a/plugins/bun/README.md b/plugins/bun/README.md
new file mode 100644
index 000000000..5a312370f
--- /dev/null
+++ b/plugins/bun/README.md
@@ -0,0 +1,20 @@
+# Bun Plugin
+
+This plugin sets up completion for [Bun](https://bun.sh).
+
+To use it, add `bun` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... bun)
+```
+
+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_CACHE_DIR/completions/_bun_` completions script
diff --git a/plugins/bun/bun.plugin.zsh b/plugins/bun/bun.plugin.zsh
new file mode 100644
index 000000000..9924faa84
--- /dev/null
+++ b/plugins/bun/bun.plugin.zsh
@@ -0,0 +1,14 @@
+# If Bun is not found, don't do the rest of the script
+if (( ! $+commands[bun] )); then
+ return
+fi
+
+# If the completion file doesn't exist yet, we need to autoload it and
+# bind it to `bun`. Otherwise, compinit will have already done that.
+if [[ ! -f "$ZSH_CACHE_DIR/completions/_bun" ]]; then
+ typeset -g -A _comps
+ autoload -Uz _bun
+ _comps[bun]=_bun
+fi
+
+bun completions >| "$ZSH_CACHE_DIR/completions/_bun" &|
diff --git a/plugins/colored-man-pages/colored-man-pages.plugin.zsh b/plugins/colored-man-pages/colored-man-pages.plugin.zsh
index 981992d88..57facbb5c 100644
--- a/plugins/colored-man-pages/colored-man-pages.plugin.zsh
+++ b/plugins/colored-man-pages/colored-man-pages.plugin.zsh
@@ -36,6 +36,7 @@ function colored() {
# Prefer `less` whenever available, since we specifically configured
# environment for it.
environment+=( PAGER="${commands[less]:-$PAGER}" )
+ environment+=( GROFF_NO_SGR=1 )
# See ./nroff script.
if [[ "$OSTYPE" = solaris* ]]; then
diff --git a/plugins/command-not-found/command-not-found.plugin.zsh b/plugins/command-not-found/command-not-found.plugin.zsh
index cb8a8989c..c741e18a2 100644
--- a/plugins/command-not-found/command-not-found.plugin.zsh
+++ b/plugins/command-not-found/command-not-found.plugin.zsh
@@ -3,9 +3,10 @@
for file (
# Arch Linux. Must have pkgfile installed: https://wiki.archlinux.org/index.php/Pkgfile#Command_not_found
/usr/share/doc/pkgfile/command-not-found.zsh
- # macOS (M1 and classic Homebrew): https://github.com/Homebrew/homebrew-command-not-found
+ # Homebrew: https://github.com/Homebrew/homebrew-command-not-found
/opt/homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh
+ /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-command-not-found/handler.sh
); do
if [[ -r "$file" ]]; then
source "$file"
diff --git a/plugins/dbt/README.md b/plugins/dbt/README.md
new file mode 100644
index 000000000..e05d79cc3
--- /dev/null
+++ b/plugins/dbt/README.md
@@ -0,0 +1,29 @@
+# dbt plugin
+
+## Introduction
+
+The `dbt plugin` adds several aliases for useful [dbt](https://docs.getdbt.com/) commands and
+[aliases](#aliases).
+
+To use it, add `dbt` to the plugins array of your zshrc file:
+
+```
+plugins=(... dbt)
+```
+
+## Aliases
+
+| Alias | Command | Description |
+| ------ | ------------------------------------------------ | ---------------------------------------------------- |
+| dbtlm | `dbt ls -s state:modified` | List modified models only |
+| dbtrm | `dbt run -s state:modified` | Run modified models only |
+| dbttm | `dbt test -m state:modified` | Test modified models only |
+| dbtrtm | `dbtrm && dbttm` | Run and test modified models only |
+| dbtrs | `dbt clean; dbt deps; dbt seed` | Re-seed data |
+| dbtfrt | `dbtrs; dbt run --full-refresh; dbt test` | Perform a full fresh run with tests |
+| dbtcds | `dbt docs generate; dbt docs serve` | Generate docs without compiling |
+| dbtds | `dbt docs generate --no-compile; dbt docs serve` | Generate and serve docs skipping doc. re-compilation |
+
+## Maintainer
+
+### [msempere](https://github.com/msempere)
diff --git a/plugins/dbt/dbt.plugin.zsh b/plugins/dbt/dbt.plugin.zsh
new file mode 100644
index 000000000..6fcc2eecf
--- /dev/null
+++ b/plugins/dbt/dbt.plugin.zsh
@@ -0,0 +1,23 @@
+# list modified models only
+alias dbtlm="dbt ls -s state:modified"
+
+# run modified models only
+alias dbtrm="dbt run -s state:modified"
+
+# test modified models only
+alias dbttm="dbt test -m state:modified"
+
+# run and test modified models only
+alias dbtrtm="dbtrm && dbttm"
+
+# re-seed data
+alias dbtrs="dbt clean; dbt deps; dbt seed"
+
+# perform a full fresh run with tests
+alias dbtfrt="dbtrs; dbt run --full-refresh; dbt test"
+
+# generate and serve docs
+alias dbtcds="dbt docs generate; dbt docs serve"
+
+# generate and serve docs skipping doc. re-compilation
+alias dbtds="dbt docs generate --no-compile; dbt docs serve"
diff --git a/plugins/debian/README.md b/plugins/debian/README.md
index c1ebe1c50..6835ad65c 100644
--- a/plugins/debian/README.md
+++ b/plugins/debian/README.md
@@ -13,7 +13,12 @@ plugins=(... debian)
- `$apt_pref`: use aptitude or apt if installed, fallback is apt-get.
- `$apt_upgr`: use upgrade or safe-upgrade (for aptitude).
-Set `$apt_pref` and `$apt_upgr` to whatever command you want (before sourcing Oh My Zsh) to override this behavior.
+Set **both** `$apt_pref` and `$apt_upgr` to whatever command you want (before sourcing Oh My Zsh) to override this behavior, e.g.:
+
+```sh
+apt_pref='apt'
+apt_upgr='full-upgrade'
+```
## Common Aliases
@@ -21,7 +26,7 @@ Set `$apt_pref` and `$apt_upgr` to whatever command you want (before sourcing Oh
| ------ | ---------------------------------------------------------------------- | ---------------------------------------------------------- |
| `age` | `apt-get` | Command line tool for handling packages |
| `api` | `aptitude` | Same functionality as `apt-get`, provides extra options |
-| `acse` | `apt-cache search` | Command line tool for searching apt software package cache |
+| `acs` | `apt-cache search` | Command line tool for searching apt software package cache |
| `aps` | `aptitude search` | Searches installed packages using aptitude |
| `as` | `aptitude -F '* %p -> %d \n(%v/%V)' --no-gui --disable-columns search` | Print searched packages using a custom format |
| `afs` | `apt-file search --regexp` | Search file in packages |
diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh
index bab1ae1c6..5ef4cfb67 100644
--- a/plugins/debian/debian.plugin.zsh
+++ b/plugins/debian/debian.plugin.zsh
@@ -26,7 +26,7 @@ alias age='apt-get'
alias api='aptitude'
# Some self-explanatory aliases
-alias acse="apt-cache search"
+alias acs="apt-cache search"
alias aps='aptitude search'
alias as="aptitude -F '* %p -> %d \n(%v/%V)' --no-gui --disable-columns search"
diff --git a/plugins/deno/README.md b/plugins/deno/README.md
index 691318397..38f9f2033 100644
--- a/plugins/deno/README.md
+++ b/plugins/deno/README.md
@@ -4,16 +4,17 @@ 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 |
-| drA | deno run -A |
-| drw | deno run --watch |
-| dts | deno test |
-| dup | deno upgrade |
+| Alias | Full command |
+| ----- | ------------------- |
+| db | deno bundle |
+| dc | deno compile |
+| dca | deno cache |
+| dfmt | deno fmt |
+| dh | deno help |
+| dli | deno lint |
+| drn | deno run |
+| drA | deno run -A |
+| drw | deno run --watch |
+| dru | deno run --unstable |
+| dts | deno test |
+| dup | deno upgrade |
diff --git a/plugins/deno/deno.plugin.zsh b/plugins/deno/deno.plugin.zsh
index 7708f84df..bf97d6f03 100644
--- a/plugins/deno/deno.plugin.zsh
+++ b/plugins/deno/deno.plugin.zsh
@@ -8,6 +8,7 @@ alias dli='deno lint'
alias drn='deno run'
alias drA='deno run -A'
alias drw='deno run --watch'
+alias dru='deno run --unstable'
alias dts='deno test'
alias dup='deno upgrade'
diff --git a/plugins/direnv/direnv.plugin.zsh b/plugins/direnv/direnv.plugin.zsh
index 5e32c4c23..6f8debb62 100644
--- a/plugins/direnv/direnv.plugin.zsh
+++ b/plugins/direnv/direnv.plugin.zsh
@@ -3,7 +3,7 @@ command -v direnv &>/dev/null || return
_direnv_hook() {
trap -- '' SIGINT;
- eval "$(direnv export zsh)";
+ eval "$(direnv hook zsh)";
trap - SIGINT;
}
typeset -ag precmd_functions;
diff --git a/plugins/dirhistory/dirhistory.plugin.zsh b/plugins/dirhistory/dirhistory.plugin.zsh
index 7021fc03a..8d67c6188 100644
--- a/plugins/dirhistory/dirhistory.plugin.zsh
+++ b/plugins/dirhistory/dirhistory.plugin.zsh
@@ -19,15 +19,17 @@ export DIRHISTORY_SIZE=30
# Returns the element if the array was not empty,
# otherwise returns empty string.
function pop_past() {
- typeset -g $1="${dirhistory_past[$#dirhistory_past]}"
+ setopt localoptions no_ksh_arrays
if [[ $#dirhistory_past -gt 0 ]]; then
+ typeset -g $1="${dirhistory_past[$#dirhistory_past]}"
dirhistory_past[$#dirhistory_past]=()
fi
}
function pop_future() {
- typeset -g $1="${dirhistory_future[$#dirhistory_future]}"
+ setopt localoptions no_ksh_arrays
if [[ $#dirhistory_future -gt 0 ]]; then
+ typeset -g $1="${dirhistory_future[$#dirhistory_future]}"
dirhistory_future[$#dirhistory_future]=()
fi
}
@@ -35,6 +37,7 @@ function pop_future() {
# Push a new element onto the end of dirhistory_past. If the size of the array
# is >= DIRHISTORY_SIZE, the array is shifted
function push_past() {
+ setopt localoptions no_ksh_arrays
if [[ $#dirhistory_past -ge $DIRHISTORY_SIZE ]]; then
shift dirhistory_past
fi
@@ -44,6 +47,7 @@ function push_past() {
}
function push_future() {
+ setopt localoptions no_ksh_arrays
if [[ $#dirhistory_future -ge $DIRHISTORY_SIZE ]]; then
shift dirhistory_future
fi
diff --git a/plugins/dnf/README.md b/plugins/dnf/README.md
index dc0d1e0a0..f45c8778c 100644
--- a/plugins/dnf/README.md
+++ b/plugins/dnf/README.md
@@ -10,6 +10,9 @@ To use it, add `dnf` to the plugins array in your zshrc file:
plugins=(... dnf)
```
+Classic `dnf` is getting superseded by `dnf5`; this plugin detects the presence
+of `dnf5` and uses it as drop-in alternative to the slower `dnf`.
+
## Aliases
| Alias | Command | Description |
diff --git a/plugins/dnf/dnf.plugin.zsh b/plugins/dnf/dnf.plugin.zsh
index 653ce7dda..642422fe1 100644
--- a/plugins/dnf/dnf.plugin.zsh
+++ b/plugins/dnf/dnf.plugin.zsh
@@ -1,15 +1,19 @@
## Aliases
+local dnfprog="dnf"
-alias dnfl="dnf list" # List packages
-alias dnfli="dnf list installed" # List installed packages
-alias dnfgl="dnf grouplist" # List package groups
-alias dnfmc="dnf makecache" # Generate metadata cache
-alias dnfp="dnf info" # Show package information
-alias dnfs="dnf search" # Search package
+# Prefer dnf5 if installed
+command -v dnf5 > /dev/null && dnfprog=dnf5
-alias dnfu="sudo dnf upgrade" # Upgrade package
-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 package group
-alias dnfc="sudo dnf clean all" # Clean cache
+alias dnfl="${dnfprog} list" # List packages
+alias dnfli="${dnfprog} list installed" # List installed packages
+alias dnfgl="${dnfprog} grouplist" # List package groups
+alias dnfmc="${dnfprog} makecache" # Generate metadata cache
+alias dnfp="${dnfprog} info" # Show package information
+alias dnfs="${dnfprog} search" # Search package
+
+alias dnfu="sudo ${dnfprog} upgrade" # Upgrade package
+alias dnfi="sudo ${dnfprog} install" # Install package
+alias dnfgi="sudo ${dnfprog} groupinstall" # Install package group
+alias dnfr="sudo ${dnfprog} remove" # Remove package
+alias dnfgr="sudo ${dnfprog} groupremove" # Remove package group
+alias dnfc="sudo ${dnfprog} clean all" # Clean cache
diff --git a/plugins/docker/README.md b/plugins/docker/README.md
index 512b5d17c..0ab2e41fb 100644
--- a/plugins/docker/README.md
+++ b/plugins/docker/README.md
@@ -30,6 +30,15 @@ file**, but be aware of the side effects:
> zstyle ':completion:*:*:docker-*:*' option-stacking yes
> ```
+### Use old-style completion
+
+If the current completion does not work well for you, you can enable legacy completion instead with the
+following setting. See https://github.com/ohmyzsh/ohmyzsh/issues/11789 for more information.
+
+```zsh
+zstyle ':omz:plugins:docker' legacy-completion yes
+```
+
## Aliases
| Alias | Command | Description |
@@ -58,7 +67,7 @@ file**, but be aware of the side effects:
| drm | `docker container rm` | Remove the specified container(s) |
| drm! | `docker container rm -f` | Force the removal of a running container (uses SIGKILL) |
| dst | `docker container start` | Start one or more stopped containers |
-| drs | `docker container restart` | Restart one or more containers
+| drs | `docker container restart` | Restart one or more containers |
| dsta | `docker stop $(docker ps -q)` | Stop all running containers |
| dstp | `docker container stop` | Stop one or more running containers |
| dtop | `docker top` | Display the running processes of a container |
diff --git a/plugins/docker/_docker b/plugins/docker/completions/_docker
index e6a12d774..466b09d94 100644
--- a/plugins/docker/_docker
+++ b/plugins/docker/completions/_docker
@@ -602,6 +602,7 @@ __docker_container_subcommand() {
opts_create_run=(
"($help -a --attach)"{-a=,--attach=}"[Attach to stdin, stdout or stderr]:device:(STDIN STDOUT STDERR)"
"($help)*--add-host=[Add a custom host-to-IP mapping]:host\:ip mapping: "
+ "($help)*--annotation=[Add an annotation to the container (passed through to the OCI runtime)]:annotations: "
"($help)*--blkio-weight-device=[Block IO (relative device weight)]:device:Block IO weight: "
"($help)*--cap-add=[Add Linux capabilities]:capability: "
"($help)*--cap-drop=[Drop Linux capabilities]:capability: "
@@ -662,7 +663,7 @@ __docker_container_subcommand() {
"($help)*--ulimit=[ulimit options]:ulimit: "
"($help)--userns=[Container user namespace]:user namespace:(host)"
"($help)--tmpfs[mount tmpfs]"
- "($help)*-v[Bind mount a volume]:volume: "
+ "($help)*-v[Bind mount a volume]:volume:_directories -W / -P '/' -S '\:' -r '/ '"
"($help)--volume-driver=[Optional volume driver for the container]:volume driver:(local)"
"($help)*--volumes-from=[Mount volumes from the specified container]:volume: "
"($help -w --workdir)"{-w=,--workdir=}"[Working directory inside the container]:directory:_directories"
@@ -2527,6 +2528,8 @@ __docker_volume_subcommand() {
(prune)
_arguments $(__docker_arguments) \
$opts_help \
+ "($help -a --all)"{-a,--all}"[Remove all unused local volumes, not just anonymous ones]" \
+ "($help)*--filter=[Filter values]:filter:__docker_complete_prune_filters" \
"($help -f --force)"{-f,--force}"[Do not prompt for confirmation]" && ret=0
;;
(rm)
@@ -2765,8 +2768,8 @@ __docker_subcommand() {
"($help)--live-restore[Enable live restore of docker when containers are still running]" \
"($help)--log-driver=[Default driver for container logs]:logging driver:__docker_complete_log_drivers" \
"($help)*--log-opt=[Default log driver options for containers]:log driver options:__docker_complete_log_options" \
- "($help)--max-concurrent-downloads[Set the max concurrent downloads for each pull]" \
- "($help)--max-concurrent-uploads[Set the max concurrent uploads for each push]" \
+ "($help)--max-concurrent-downloads[Set the max concurrent downloads]" \
+ "($help)--max-concurrent-uploads[Set the max concurrent uploads]" \
"($help)--max-download-attempts[Set the max download attempts for each pull]" \
"($help)--mtu=[Network MTU]:mtu:(0 576 1420 1500 9000)" \
"($help)--oom-score-adjust=[Set the oom_score_adj for the daemon]:oom-score:(-500)" \
@@ -2774,7 +2777,7 @@ __docker_subcommand() {
"($help)--raw-logs[Full timestamps without ANSI coloring]" \
"($help)*--registry-mirror=[Preferred registry mirror]:registry mirror: " \
"($help)--seccomp-profile=[Path to seccomp profile]:path:_files -g \"*.json\"" \
- "($help -s --storage-driver)"{-s=,--storage-driver=}"[Storage driver to use]:driver:(aufs btrfs devicemapper overlay overlay2 vfs zfs)" \
+ "($help -s --storage-driver)"{-s=,--storage-driver=}"[Storage driver to use]:driver:(btrfs devicemapper overlay2 vfs zfs)" \
"($help)--selinux-enabled[Enable selinux support]" \
"($help)--shutdown-timeout=[Set the shutdown timeout value in seconds]:time: " \
"($help)*--storage-opt=[Storage driver options]:storage driver options: " \
diff --git a/plugins/docker/docker.plugin.zsh b/plugins/docker/docker.plugin.zsh
index 8684a9785..7e657f2df 100644
--- a/plugins/docker/docker.plugin.zsh
+++ b/plugins/docker/docker.plugin.zsh
@@ -31,3 +31,32 @@ alias dvls='docker volume ls'
alias dvprune='docker volume prune'
alias dxc='docker container exec'
alias dxcit='docker container exec -it'
+
+if (( ! $+commands[docker] )); then
+ return
+fi
+
+# Standarized $0 handling
+# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
+0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
+0="${${(M)0:#/*}:-$PWD/$0}"
+
+# If the completion file doesn't exist yet, we need to autoload it and
+# bind it to `docker`. Otherwise, compinit will have already done that.
+if [[ ! -f "$ZSH_CACHE_DIR/completions/_docker" ]]; then
+ typeset -g -A _comps
+ autoload -Uz _docker
+ _comps[docker]=_docker
+fi
+
+{
+ # `docker completion` is only available from 23.0.0 on
+ # docker version returns `Docker version 24.0.2, build cb74dfcd85`
+ # with `s:,:` remove the comma after the version, and select third word of it
+ if zstyle -t ':omz:plugins:docker' legacy-completion || \
+ ! is-at-least 23.0.0 ${${(s:,:z)"$(command docker --version)"}[3]}; then
+ command cp "${0:h}/completions/_docker" "$ZSH_CACHE_DIR/completions/_docker"
+ else
+ command docker completion zsh >| "$ZSH_CACHE_DIR/completions/_docker"
+ fi
+} &|
diff --git a/plugins/extract/README.md b/plugins/extract/README.md
index ac4a8e197..c8d98b229 100644
--- a/plugins/extract/README.md
+++ b/plugins/extract/README.md
@@ -25,6 +25,7 @@ plugins=(... extract)
| `cpio` | Cpio archive |
| `deb` | Debian package |
| `ear` | Enterprise Application aRchive |
+| `exe` | Windows executable file |
| `gz` | Gzip file |
| `ipa` | iOS app package |
| `ipsw` | iOS firmware file |
@@ -52,9 +53,11 @@ plugins=(... extract)
| `txz` | Tarball with lzma2 compression |
| `tzst` | Tarball with zstd compression |
| `war` | Web Application archive (Java-based) |
+| `whl` | Python wheel file |
| `xpi` | Mozilla XPI module file |
| `xz` | LZMA2 archive |
| `zip` | Zip archive |
+| `zlib` | zlib archive |
| `zst` | Zstandard file (zstd) |
| `zpaq` | Zpaq file |
diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh
index 7b7a2fa4f..88d8b0740 100644
--- a/plugins/extract/extract.plugin.zsh
+++ b/plugins/extract/extract.plugin.zsh
@@ -27,63 +27,111 @@ EOF
fi
local success=0
- local extract_dir="${1:t:r}"
local file="$1" full_path="${1:A}"
+ local extract_dir="${1:t:r}"
+
+ # Remove the .tar extension if the file name is .tar.*
+ if [[ $extract_dir =~ '\.tar$' ]]; then
+ extract_dir="${extract_dir:r}"
+ fi
+
+ # If there's a file or directory with the same name as the archive
+ # add a random string to the end of the extract directory
+ if [[ -e "$extract_dir" ]]; then
+ local rnd="${(L)"${$(( [##36]$RANDOM*$RANDOM ))}":1:5}"
+ extract_dir="${extract_dir}-${rnd}"
+ fi
+
+ # Create an extraction directory based on the file name
+ command mkdir -p "$extract_dir"
+ builtin cd -q "$extract_dir"
+ echo "extract: extracting to $extract_dir" >&2
+
case "${file:l}" in
(*.tar.gz|*.tgz)
- (( $+commands[pigz] )) && { tar -I pigz -xvf "$file" } || tar zxvf "$file" ;;
+ (( $+commands[pigz] )) && { tar -I pigz -xvf "$full_path" } || tar zxvf "$full_path" ;;
(*.tar.bz2|*.tbz|*.tbz2)
- (( $+commands[pbzip2] )) && { tar -I pbzip2 -xvf "$file" } || tar xvjf "$file" ;;
+ (( $+commands[pbzip2] )) && { tar -I pbzip2 -xvf "$full_path" } || tar xvjf "$full_path" ;;
(*.tar.xz|*.txz)
- (( $+commands[pixz] )) && { tar -I pixz -xvf "$file" } || {
+ (( $+commands[pixz] )) && { tar -I pixz -xvf "$full_path" } || {
tar --xz --help &> /dev/null \
- && tar --xz -xvf "$file" \
- || xzcat "$file" | tar xvf - } ;;
+ && tar --xz -xvf "$full_path" \
+ || xzcat "$full_path" | tar xvf - } ;;
(*.tar.zma|*.tlz)
tar --lzma --help &> /dev/null \
- && tar --lzma -xvf "$file" \
- || lzcat "$file" | tar xvf - ;;
+ && tar --lzma -xvf "$full_path" \
+ || lzcat "$full_path" | tar xvf - ;;
(*.tar.zst|*.tzst)
tar --zstd --help &> /dev/null \
- && tar --zstd -xvf "$file" \
- || zstdcat "$file" | tar xvf - ;;
- (*.tar) tar xvf "$file" ;;
- (*.tar.lz) (( $+commands[lzip] )) && tar xvf "$file" ;;
- (*.tar.lz4) lz4 -c -d "$file" | tar xvf - ;;
- (*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$file" ;;
- (*.gz) (( $+commands[pigz] )) && pigz -dk "$file" || gunzip -k "$file" ;;
- (*.bz2) bunzip2 "$file" ;;
- (*.xz) unxz "$file" ;;
- (*.lrz) (( $+commands[lrunzip] )) && lrunzip "$file" ;;
- (*.lz4) lz4 -d "$file" ;;
- (*.lzma) unlzma "$file" ;;
- (*.z) uncompress "$file" ;;
- (*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$file" -d "$extract_dir" ;;
- (*.rar) unrar x -ad "$file" ;;
+ && tar --zstd -xvf "$full_path" \
+ || zstdcat "$full_path" | tar xvf - ;;
+ (*.tar) tar xvf "$full_path" ;;
+ (*.tar.lz) (( $+commands[lzip] )) && tar xvf "$full_path" ;;
+ (*.tar.lz4) lz4 -c -d "$full_path" | tar xvf - ;;
+ (*.tar.lrz) (( $+commands[lrzuntar] )) && lrzuntar "$full_path" ;;
+ (*.gz) (( $+commands[pigz] )) && pigz -cdk "$full_path" > "${file:t:r}" || gunzip -ck "$full_path" > "${file:t:r}" ;;
+ (*.bz2) bunzip2 "$full_path" ;;
+ (*.xz) unxz "$full_path" ;;
+ (*.lrz) (( $+commands[lrunzip] )) && lrunzip "$full_path" ;;
+ (*.lz4) lz4 -d "$full_path" ;;
+ (*.lzma) unlzma "$full_path" ;;
+ (*.z) uncompress "$full_path" ;;
+ (*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl) unzip "$full_path" ;;
+ (*.rar) unrar x -ad "$full_path" ;;
(*.rpm)
- command mkdir -p "$extract_dir" && builtin cd -q "$extract_dir" \
- && rpm2cpio "$full_path" | cpio --quiet -id ;;
- (*.7z) 7za x "$file" ;;
+ rpm2cpio "$full_path" | cpio --quiet -id ;;
+ (*.7z) 7za x "$full_path" ;;
(*.deb)
- command mkdir -p "$extract_dir/control" "$extract_dir/data"
- builtin cd -q "$extract_dir"; ar vx "$full_path" > /dev/null
+ command mkdir -p "control" "data"
+ ar vx "$full_path" > /dev/null
builtin cd -q control; extract ../control.tar.*
builtin cd -q ../data; extract ../data.tar.*
builtin cd -q ..; command rm *.tar.* debian-binary ;;
- (*.zst) unzstd "$file" ;;
- (*.cab) cabextract -d "$extract_dir" "$file" ;;
- (*.cpio|*.obscpio) cpio -idmvF "$file" ;;
- (*.zpaq) zpaq x "$file" ;;
+ (*.zst) unzstd "$full_path" ;;
+ (*.cab|*.exe) cabextract "$full_path" ;;
+ (*.cpio|*.obscpio) cpio -idmvF "$full_path" ;;
+ (*.zpaq) zpaq x "$full_path" ;;
+ (*.zlib) zlib-flate -uncompress < "$full_path" > "${file:r}" ;;
(*)
echo "extract: '$file' cannot be extracted" >&2
success=1 ;;
esac
(( success = success > 0 ? success : $? ))
- (( success == 0 && remove_archive == 0 )) && rm "$full_path"
+ (( success == 0 && remove_archive == 0 )) && command rm "$full_path"
shift
- # Go back to original working directory in case we ran cd previously
+ # Go back to original working directory
builtin cd -q "$pwd"
+
+ # If content of extract dir is a single directory, move its contents up
+ # Glob flags:
+ # - D: include files starting with .
+ # - N: no error if directory is empty
+ # - Y2: at most give 2 files
+ local -a content
+ content=("${extract_dir}"/*(DNY2))
+ if [[ ${#content} -eq 1 && -e "${content[1]}" ]]; then
+ # The extracted file/folder (${content[1]}) may have the same name as $extract_dir
+ # If so, we need to rename it to avoid conflicts in a 3-step process
+ #
+ # 1. Move and rename the extracted file/folder to a temporary random name
+ # 2. Delete the empty folder
+ # 3. Rename the extracted file/folder to the original name
+ if [[ "${content[1]:t}" == "$extract_dir" ]]; then
+ # =(:) gives /tmp/zsh<random>, with :t it gives zsh<random>
+ local tmp_name==(:); tmp_name="${tmp_name:t}"
+ command mv "${content[1]}" "$tmp_name" \
+ && command rmdir "$extract_dir" \
+ && command mv "$tmp_name" "$extract_dir"
+ # Otherwise, if the extracted folder name already exists in the current
+ # directory (because of a previous file / folder), keep the extract_dir
+ elif [[ ! -e "${content[1]:t}" ]]; then
+ command mv "${content[1]}" . \
+ && command rmdir "$extract_dir"
+ fi
+ elif [[ ${#content} -eq 0 ]]; then
+ command rmdir "$extract_dir"
+ fi
done
}
diff --git a/plugins/firewalld/firewalld.plugin.zsh b/plugins/firewalld/firewalld.plugin.zsh
index 5b1090636..b2c0f64be 100644
--- a/plugins/firewalld/firewalld.plugin.zsh
+++ b/plugins/firewalld/firewalld.plugin.zsh
@@ -9,7 +9,7 @@ function fwl () {
zones=("${(@f)$(sudo firewall-cmd --get-active-zones | grep -v 'interfaces\|sources')}")
for i in $zones; do
- sudo firewall-cmd --zone $i --list-all
+ sudo firewall-cmd --zone ${i/ \(default\)} --list-all
done
echo 'Direct Rules:'
diff --git a/plugins/gas/README.md b/plugins/gas/README.md
index 47b3fb9df..a0a7a568f 100644
--- a/plugins/gas/README.md
+++ b/plugins/gas/README.md
@@ -1,6 +1,6 @@
# Gas plugin
-This plugin adds autocompletion for the [gas](http://walle.github.com/gas) command,
+This plugin adds autocompletion for the [gas](http://ramblingsby.me/gas/) command,
a utility to manage Git authors.
To use it, add `gas` to the plugins array of your zshrc file:
diff --git a/plugins/gcloud/gcloud.plugin.zsh b/plugins/gcloud/gcloud.plugin.zsh
index 30f1dba8f..9a4213aaf 100644
--- a/plugins/gcloud/gcloud.plugin.zsh
+++ b/plugins/gcloud/gcloud.plugin.zsh
@@ -6,6 +6,7 @@
if [[ -z "${CLOUDSDK_HOME}" ]]; then
search_locations=(
"$HOME/google-cloud-sdk"
+ "/usr/local/share/google-cloud-sdk"
"/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
"/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk"
"/usr/share/google-cloud-sdk"
@@ -14,6 +15,7 @@ if [[ -z "${CLOUDSDK_HOME}" ]]; then
"/usr/lib/google-cloud-sdk"
"/usr/lib64/google-cloud-sdk"
"/opt/google-cloud-sdk"
+ "/opt/google-cloud-cli"
"/opt/local/libexec/google-cloud-sdk"
)
@@ -27,11 +29,9 @@ if [[ -z "${CLOUDSDK_HOME}" ]]; then
fi
if (( ${+CLOUDSDK_HOME} )); then
- # Only source this if gcloud isn't already on the path
- if (( ! $+commands[gcloud] )); then
- if [[ -f "${CLOUDSDK_HOME}/path.zsh.inc" ]]; then
- source "${CLOUDSDK_HOME}/path.zsh.inc"
- fi
+ # Source path file
+ if [[ -f "${CLOUDSDK_HOME}/path.zsh.inc" ]]; then
+ source "${CLOUDSDK_HOME}/path.zsh.inc"
fi
# Look for completion file in different paths
diff --git a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh
index 2df34bb7b..f8dfec759 100644
--- a/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh
+++ b/plugins/git-auto-fetch/git-auto-fetch.plugin.zsh
@@ -29,7 +29,7 @@ function git-fetch-all {
date -R &>! "$gitdir/FETCH_LOG"
GIT_SSH_COMMAND="command ssh -o BatchMode=yes" \
GIT_TERMINAL_PROMPT=0 \
- command git fetch --all 2>/dev/null &>> "$gitdir/FETCH_LOG"
+ command git fetch --all --recurse-submodules=yes 2>/dev/null &>> "$gitdir/FETCH_LOG"
) &|
}
diff --git a/plugins/git-commit/README.md b/plugins/git-commit/README.md
new file mode 100644
index 000000000..91cc73b44
--- /dev/null
+++ b/plugins/git-commit/README.md
@@ -0,0 +1,42 @@
+# git-commit plugin
+
+The git-commit plugin adds several [git aliases](https://www.git-scm.com/docs/git-config#Documentation/git-config.txt-alias) for [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/#summary) messages.
+
+To use it, add `git-commit` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... git-commit)
+```
+
+## Syntax
+
+```zsh
+git <type> [(-s, --scope) "<scope>"] "<message>"
+```
+
+> ⚠️ Single/Double quotes around the scope and message are required
+
+Where `type` is one of the following:
+
+- `build`
+- `chore`
+- `ci`
+- `docs`
+- `feat`
+- `fix`
+- `perf`
+- `refactor`
+- `rev`
+- `style`
+- `test`
+
+> NOTE: the alias for `revert` type is `rev`, as otherwise it conflicts with the git command of the same name.
+> It will still generate a commit message in the format `revert: <message>`
+
+## Examples
+
+| Git alias | Command |
+| --------------------------------------------- | ---------------------------------------------------- |
+| `git style "remove trailing whitespace"` | `git commit -m "style: remove trailing whitespace"` |
+| `git fix -s "router" "correct redirect link"` | `git commit -m "fix(router): correct redirect link"` |
+| `git rev -s "api" "rollback v2"` | `git commit -m "revert(api): rollback v2"` |
diff --git a/plugins/git-commit/git-commit.plugin.zsh b/plugins/git-commit/git-commit.plugin.zsh
new file mode 100644
index 000000000..72cecb1d6
--- /dev/null
+++ b/plugins/git-commit/git-commit.plugin.zsh
@@ -0,0 +1,31 @@
+local -a _git_commit_aliases
+_git_commit_aliases=(
+ 'build'
+ 'chore'
+ 'ci'
+ 'docs'
+ 'feat'
+ 'fix'
+ 'perf'
+ 'refactor'
+ 'revert'
+ 'style'
+ 'test'
+)
+
+local alias type
+for type in "${_git_commit_aliases[@]}"; do
+ # an alias can't be named "revert" because the git command takes precedence
+ # https://stackoverflow.com/a/3538791
+ case "$type" in
+ revert) alias=rev ;;
+ *) alias=$type ;;
+ esac
+
+ local func='!a() { if [ "$1" = "-s" ] || [ "$1" = "--scope" ]; then local scope="$2"; shift 2; git commit -m "'$type'(${scope}): ${@}"; else git commit -m "'$type': ${@}"; fi }; a'
+ if ! git config --global --get-all alias.${alias} >/dev/null 2>&1; then
+ git config --global alias.${alias} "$func"
+ fi
+done
+
+unset _git_commit_aliases alias type func
diff --git a/plugins/git-extras/README.md b/plugins/git-extras/README.md
index 2adc9d477..7eb53fcfd 100644
--- a/plugins/git-extras/README.md
+++ b/plugins/git-extras/README.md
@@ -1,6 +1,6 @@
# git-extras
-This plugin provides completion definitions for some of the commands defined by [git-extras](https://github.com/tj/git-extras).
+This plugin provides completion definitions for some of the commands defined by [git-extras](https://github.com/tj/git-extras), which must already be installed.
To use it, add `git-extras` to the plugins array in your zshrc file:
diff --git a/plugins/git-extras/git-extras.plugin.zsh b/plugins/git-extras/git-extras.plugin.zsh
index 6b96e12af..f5fd387d1 100644
--- a/plugins/git-extras/git-extras.plugin.zsh
+++ b/plugins/git-extras/git-extras.plugin.zsh
@@ -80,22 +80,10 @@ __gitex_specific_branch_names() {
_wanted branch-names expl branch-name compadd - $branch_names
}
-__gitex_chore_branch_names() {
- __gitex_specific_branch_names 'chore'
-}
-
__gitex_feature_branch_names() {
__gitex_specific_branch_names 'feature'
}
-__gitex_refactor_branch_names() {
- __gitex_specific_branch_names 'refactor'
-}
-
-__gitex_bug_branch_names() {
- __gitex_specific_branch_names 'bug'
-}
-
__gitex_submodule_names() {
local expl
declare -a submodule_names
@@ -114,88 +102,29 @@ __gitex_author_names() {
}
# subcommands
+# new subcommand should be added in alphabetical order
_git-authors() {
_arguments -C \
'(--list -l)'{--list,-l}'[show authors]' \
'--no-email[without email]' \
}
-_git-bug() {
- local curcontext=$curcontext state line ret=1
- declare -A opt_args
-
- _arguments -C \
- ': :->command' \
- '*:: :->option-or-argument' && ret=0
-
- case $state in
- (command)
- declare -a commands
- commands=(
- 'finish:merge bug into the current branch'
- )
- _describe -t commands command commands && ret=0
- ;;
- (option-or-argument)
- curcontext=${curcontext%:*}-$line[1]:
- case $line[1] in
- (finish)
- _arguments -C \
- ':branch-name:__gitex_bug_branch_names'
- ;;
- -r|--remote )
- _arguments -C \
- ':remote-name:__gitex_remote_names'
- ;;
- esac
- return 0
- esac
-
- _arguments \
- '(--remote -r)'{--remote,-r}'[setup remote tracking branch]'
-}
-
-
_git-changelog() {
_arguments \
'(-l --list)'{-l,--list}'[list commits]' \
}
-_git-chore() {
- local curcontext=$curcontext state line ret=1
- declare -A opt_args
-
- _arguments -C \
- ': :->command' \
- '*:: :->option-or-argument' && ret=0
-
- case $state in
- (command)
- declare -a commands
- commands=(
- 'finish:merge and delete the chore branch'
- )
- _describe -t commands command commands && ret=0
- ;;
- (option-or-argument)
- curcontext=${curcontext%:*}-$line[1]:
- case $line[1] in
- (finish)
- _arguments -C \
- ':branch-name:__gitex_chore_branch_names'
- ;;
- -r|--remote )
- _arguments -C \
- ':remote-name:__gitex_remote_names'
- ;;
- esac
- return 0
- esac
-
+_git-clear() {
_arguments \
- '(--remote -r)'{--remote,-r}'[setup remote tracking branch]'
+ '(-f --force)'{-f,--force}'[force clear]' \
+ '(-h --help)'{-h,--help}'[help message]' \
}
+_git-coauthor() {
+ _arguments \
+ ':co-author[co-author to add]' \
+ ':co-author-email[email address of co-author to add]'
+}
_git-contrib() {
_arguments \
@@ -235,6 +164,11 @@ _git-delete-branch() {
':branch-name:__gitex_branch_names'
}
+_git-delete-squashed-branches() {
+ _arguments \
+ ':branch-name:__gitex_branch_names'
+}
+
_git-delete-submodule() {
_arguments \
@@ -298,6 +232,7 @@ _git-feature() {
case $line[1] in
(finish)
_arguments -C \
+ '--squash[Use squash merge]' \
':branch-name:__gitex_feature_branch_names'
;;
-r|--remote )
@@ -327,20 +262,17 @@ _git-guilt() {
}
_git-ignore() {
- _arguments -C \
+ _arguments -C \
'(--local -l)'{--local,-l}'[show local gitignore]' \
'(--global -g)'{--global,-g}'[show global gitignore]' \
'(--private -p)'{--private,-p}'[show repo gitignore]'
}
-_git-ignore() {
- _arguments -C \
- '(--append -a)'{--append,-a}'[append .gitignore]' \
- '(--replace -r)'{--replace,-r}'[replace .gitignore]' \
- '(--list-in-table -l)'{--list-in-table,-l}'[print available types in table format]' \
- '(--list-alphabetically -L)'{--list-alphabetically,-L}'[print available types in alphabetical order]' \
- '(--search -s)'{--search,-s}'[search word in available types]'
+_git-info() {
+ _arguments -C \
+ '(--color -c)'{--color,-c}'[use color for information titles]' \
+ '--no-config[do not show list all variables set in config file, along with their values]'
}
@@ -357,50 +289,27 @@ _git-missing() {
':second-branch-name:__gitex_branch_names'
}
-
-_git-refactor() {
- local curcontext=$curcontext state line ret=1
- declare -A opt_args
-
+_git-release() {
_arguments -C \
- ': :->command' \
- '*:: :->option-or-argument' && ret=0
-
- case $state in
- (command)
- declare -a commands
- commands=(
- 'finish:merge refactor into the current branch'
- )
- _describe -t commands command commands && ret=0
- ;;
- (option-or-argument)
- curcontext=${curcontext%:*}-$line[1]:
- case $line[1] in
- (finish)
- _arguments -C \
- ':branch-name:__gitex_refactor_branch_names'
- ;;
- -r|--remote )
- _arguments -C \
- ':remote-name:__gitex_remote_names'
- ;;
- esac
- return 0
- esac
-
- _arguments \
- '(--remote -r)'{--remote,-r}'[setup remote tracking branch]'
+ '-c[Generates/populates the changelog with all commit message since the last tag.]' \
+ '-r[The "remote" repository that is destination of a push operation.]' \
+ '-m[use the custom commit information instead of the default message.]' \
+ '-s[Create a signed and annotated tag.]' \
+ '-u[Create a tag, annotated and signed with the given key.]' \
+ '--semver[If the latest tag in your repo matches the semver format requirement, you could increase part of it as the new release tag.]' \
+ '--prefix[Add a prefix string to semver to allow more complex tags.]' \
+ '--no-empty-commit[Avoid creating empty commit if nothing could be committed.]' \
+ '--[The arguments listed after "--" separator will be passed to pre/post-release hook.]'
}
-
_git-squash() {
+ _arguments '--squash-msg[commit with the squashed commit messages]'
_arguments \
':branch-name:__gitex_branch_names'
}
_git-stamp() {
- _arguments -C \
+ _arguments -C \
'(--replace -r)'{--replace,-r}'[replace stamps with same id]'
}
@@ -413,17 +322,19 @@ _git-standup() {
'-g[Display GPG signed info]' \
'-h[Display help message]' \
'-L[Enable the inclusion of symbolic links]' \
- '-m[The depth of recursive directory search]'
+ '-m[The depth of recursive directory search]' \
+ '-B[Display the commits in branch groups]'
}
_git-summary() {
_arguments '--line[summarize with lines rather than commits]'
+ _arguments '--dedup-by-email[remove duplicate users by the email address]'
+ _arguments '--no-merges[exclude merge commits]'
__gitex_commits
}
-
_git-undo(){
- _arguments -C \
+ _arguments -C \
'(--soft -s)'{--soft,-s}'[only rolls back the commit but changes remain un-staged]' \
'(--hard -h)'{--hard,-h}'[wipes your commit(s)]'
}
@@ -432,21 +343,26 @@ zstyle -g existing_user_commands ':completion:*:*:git:*' user-commands
zstyle ':completion:*:*:git:*' user-commands $existing_user_commands \
alias:'define, search and show aliases' \
+ abort:'abort current revert, merge, rebase, or cherry-pick process' \
archive-file:'export the current head of the git repository to an archive' \
authors:'generate authors report' \
- back:'undo and stage latest commits' \
+ browse:'open repo website in browser' \
+ browse-ci:'open repo CI page in browser' \
bug:'create bug branch' \
bulk:'run bulk commands' \
+ brv:'list branches sorted by their last commit date'\
changelog:'generate a changelog report' \
chore:'create chore branch' \
clear-soft:'soft clean up a repository' \
clear:'rigorously clean up a repository' \
+ coauthor:'add a co-author to the last commit' \
commits-since:'show commit logs since some date' \
contrib:'show user contributions' \
count:'show commit count' \
create-branch:'create branches' \
delete-branch:'delete branches' \
delete-merged-branches:'delete merged branches' \
+ delete-squashed-branches:'delete squashed branches' \
delete-submodule:'delete submodules' \
delete-tag:'delete tags' \
delta:'lists changed files' \
@@ -465,11 +381,13 @@ zstyle ':completion:*:*:git:*' user-commands $existing_user_commands \
local-commits:'list local commits' \
lock:'lock a file excluded from version control' \
locked:'ls files that have been locked' \
+ magic:'commits everything with a generated message' \
merge-into:'merge one branch into another' \
merge-repo:'merge two repo histories' \
missing:'show commits missing from another branch' \
mr:'checks out a merge request locally' \
obliterate:'rewrite past commits to remove some files' \
+ paste:'send patches to pastebin sites' \
pr:'checks out a pull request locally' \
psykorebase:'rebase a branch with a merge commit' \
pull-request:'create pull request to GitHub project' \
@@ -479,6 +397,7 @@ zstyle ':completion:*:*:git:*' user-commands $existing_user_commands \
release:'commit, tag and push changes to the repository' \
rename-branch:'rename a branch' \
rename-tag:'rename a tag' \
+ rename-remote:'rename a remote' \
repl:'git read-eval-print-loop' \
reset-file:'reset one file' \
root:'show path of root' \
@@ -495,4 +414,5 @@ zstyle ':completion:*:*:git:*' user-commands $existing_user_commands \
sync:'sync local branch with remote branch' \
touch:'touch and add file to the index' \
undo:'remove latest commits' \
- unlock:'unlock a file excluded from version control'
+ unlock:'unlock a file excluded from version control' \
+ utimes:'change files modification time to their last commit date'
diff --git a/plugins/git/README.md b/plugins/git/README.md
index 0895ce39c..93dc8ccea 100644
--- a/plugins/git/README.md
+++ b/plugins/git/README.md
@@ -10,252 +10,269 @@ 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 |
-| gapt | git apply --3way |
-| gb | git branch |
-| gba | git branch --all |
-| gbd | git branch --delete |
-| gbda | git branch --no-color --merged \| grep -vE "^([+*]\|\s*(<span>$</span>(git_main_branch)\|<span>$</span>(git_develop_branch))\s*<span>$</span>)" \| xargs git branch --delete 2>/dev/null |
-| gbD | git branch --delete --force |
-| gbg | git branch -vv | grep ": gone\]" |
-| gbgd | local res=$(git branch -vv | grep ": gone\]" | awk '{print $1}') && [[ $res ]] && echo $res | xargs git branch -d |
-| gbgD | local res=$(git branch -vv | grep ": gone\]" | awk '{print $1}') && [[ $res ]] && echo $res | xargs 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 --verbose |
-| gc! | git commit --verbose --amend |
-| gcn! | git commit --verbose --no-edit --amend |
-| gca | git commit --verbose --all |
-| gca! | git commit --verbose --all --amend |
-| gcan! | git commit --verbose --all --no-edit --amend |
-| gcans! | git commit --verbose --all --signoff --no-edit --amend |
-| gcam | git commit --all --message |
-| gcas | git commit --all --signoff |
-| gcasm | git commit --all --signoff --message |
-| gcsm | git commit --signoff --message |
-| gcb | git checkout -b |
-| gcf | git config --list |
-| gcl | git clone --recurse-submodules |
-| gccd | git clone --recurse-submodules "<span>$</span>@" && cd "<span>$</span>(basename <span>$</span>\_ .git)" |
-| gclean | git clean --interactive -d |
-| gpristine | git reset --hard && git clean -dffx |
-| gcm | git checkout $(git_main_branch) |
-| gcd | git checkout $(git_develop_branch) |
-| gcmsg | git commit --message |
-| gco | git checkout |
-| gcor | git checkout --recurse-submodules |
-| gcount | git shortlog --summary -n |
-| gcp | git cherry-pick |
-| gcpa | git cherry-pick --abort |
-| gcpc | git cherry-pick --continue |
-| gcs | git commit -S |
-| gcss | git commit -S -s |
-| gcssm | git commit -S -s -m |
-| 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 |
-| gdnolock | git diff $@ ":(exclude)package-lock.json" ":(exclude)\*.lock" |
-| gdup | git diff @{upstream} |
-| 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) |
-| gpsupf | git push --set-upstream origin $(git_current_branch) --force-with-lease --force-if-includes (git version >= 2.30) |
-| gpsupf | git push --set-upstream origin $(git_current_branch) --force-with-lease (git version < 2.30) |
-| 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 $(git_main_branch):svntrunk |
-| gk | gitk --all --branches &! |
-| gke | gitk --all $(git log --walk-reflogs --pretty=%h) &! |
-| gl | git pull |
-| glg | git log --stat |
-| glgp | git log --stat --patch |
-| 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(%ar) %C(bold blue)<%an>%Creset' |
-| glols | git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %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(%ar) %C(bold blue)<%an>%Creset' --all |
-| glog | git log --oneline --decorate --graph |
-| gloga | git log --oneline --decorate --graph --all |
-| glp | git log --pretty=\<format\> |
-| gm | git merge |
-| gmom | git merge origin/$(git_main_branch) |
-| gmtl | git mergetool --no-prompt |
-| gmtlvim | git mergetool --no-prompt --tool=vimdiff |
-| gmum | git merge upstream/$(git_main_branch) |
-| gma | git merge --abort |
-| gp | git push |
-| gpd | git push --dry-run |
-| gpf | git push --force-with-lease --force-if-includes (git version >= 2.30) |
-| gpf | git push --force-with-lease (git version < 2.30) |
-| gpf! | git push --force |
-| gpoat | git push origin --all && git push origin --tags |
-| gpod | git push origin --delete |
-| gpr | git pull --rebase |
-| gpu | git push upstream |
-| gpv | git push --verbose |
-| gr | git remote |
-| gra | git remote add |
-| grb | git rebase |
-| grba | git rebase --abort |
-| grbc | git rebase --continue |
-| grbd | git rebase $(git_develop_branch) |
-| grbi | git rebase --interactive |
-| grbm | git rebase $(git_main_branch) |
-| grbom | git rebase origin/$(git_main_branch) |
-| grbo | git rebase --onto |
-| 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 |
-| grst | git restore --staged |
-| grt | cd "$(git rev-parse --show-toplevel \|\| echo .)" |
-| gru | git reset -- |
-| grup | git remote update |
-| grv | git remote --verbose |
-| gsb | git status --short -b |
-| 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 --short |
-| gst | git status |
-| gsta | git stash push (git version >= 2.13) |
-| gsta | git stash save (git version < 2.13) |
-| 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 |
-| gswm | git switch $(git_main_branch) |
-| gswd | git switch $(git_develop_branch) |
-| gts | git tag -s |
-| gtv | git tag \| sort -V |
-| gtl | gtl(){ git tag --sort=-v:refname -n --list ${1}\* }; noglob gtl |
-| gunignore | git update-index --no-assume-unchanged |
-| gunwip | git log --max-count=1 \| grep -q -c "\-\-wip\-\-" && git reset HEAD~1 |
-| gup | git pull --rebase |
-| gupv | git pull --rebase --verbose |
-| gupa | git pull --rebase --autostash |
-| gupav | git pull --rebase --autostash --verbose |
-| gupom | git pull --rebase origin $(git_main_branch) |
-| gupomi | git pull --rebase=interactive origin $(git_main_branch) |
-| glum | git pull upstream $(git_main_branch) |
-| gluc | git pull upstream $(git_current_branch) |
-| 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 --message "--wip-- [skip ci]" |
-| gam | git am |
-| gamc | git am --continue |
-| gams | git am --skip |
-| gama | git am --abort |
-| gamscp | git am --show-current-patch |
-| gwt | git worktree |
-| gwtls | git worktree list |
-| gwtmv | git worktree move |
-| gwtrm | git worktree remove |
+| Alias | Command |
+| :--------------------- | :------------------------------------------------------------------------------------------------------------------------------ |
+| `grt` | `cd "$(git rev-parse --show-toplevel \|\| echo .)"` |
+| `ggpnp` | `ggl && ggp` |
+| `ggpur` | `ggu` |
+| `g` | `git` |
+| `ga` | `git add` |
+| `gaa` | `git add --all` |
+| `gapa` | `git add --patch` |
+| `gau` | `git add --update` |
+| `gav` | `git add --verbose` |
+| `gwip` | `git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"` |
+| `gam` | `git am` |
+| `gama` | `git am --abort` |
+| `gamc` | `git am --continue` |
+| `gamscp` | `git am --show-current-patch` |
+| `gams` | `git am --skip` |
+| `gap` | `git apply` |
+| `gapt` | `git apply --3way` |
+| `gbs` | `git bisect` |
+| `gbsb` | `git bisect bad` |
+| `gbsg` | `git bisect good` |
+| `gbsn` | `git bisect new` |
+| `gbso` | `git bisect old` |
+| `gbsr` | `git bisect reset` |
+| `gbss` | `git bisect start` |
+| `gbl` | `git blame -w` |
+| `gb` | `git branch` |
+| `gba` | `git branch --all` |
+| `gbd` | `git branch --delete` |
+| `gbD` | `git branch --delete --force` |
+| `gbgd` | `LANG=C git branch --no-color -vv \| grep ": gone\]" \| awk '"'"'{print $1}'"'"' \| xargs git branch -d` |
+| `gbgD` | `LANG=C git branch --no-color -vv \| grep ": gone\]" \| awk '"'"'{print $1}'"'"' \| xargs git branch -D` |
+| `gbm` | `git branch --move` |
+| `gbnm` | `git branch --no-merged` |
+| `gbr` | `git branch --remote` |
+| `ggsup` | `git branch --set-upstream-to=origin/$(git_current_branch)` |
+| `gbg` | `LANG=C git branch -vv \| grep ": gone\]"` |
+| `gco` | `git checkout` |
+| `gcor` | `git checkout --recurse-submodules` |
+| `gcb` | `git checkout -b` |
+| `gcd` | `git checkout $(git_develop_branch)` |
+| `gcm` | `git checkout $(git_main_branch)` |
+| `gcp` | `git cherry-pick` |
+| `gcpa` | `git cherry-pick --abort` |
+| `gcpc` | `git cherry-pick --continue` |
+| `gclean` | `git clean --interactive -d` |
+| `gcl` | `git clone --recurse-submodules` |
+| `gccd` | `git clone --recurse-submodules "$@" && cd "$(basename $\_ .git)"` |
+| `gcam` | `git commit --all --message` |
+| `gcas` | `git commit --all --signoff` |
+| `gcasm` | `git commit --all --signoff --message` |
+| `gcmsg` | `git commit --message` |
+| `gcsm` | `git commit --signoff --message` |
+| `gc` | `git commit --verbose` |
+| `gca` | `git commit --verbose --all` |
+| `gca!` | `git commit --verbose --all --amend` |
+| `gcan!` | `git commit --verbose --all --no-edit --amend` |
+| `gcans!` | `git commit --verbose --all --signoff --no-edit --amend` |
+| `gc!` | `git commit --verbose --amend` |
+| `gcn!` | `git commit --verbose --no-edit --amend` |
+| `gcs` | `git commit -S` |
+| `gcss` | `git commit -S -s` |
+| `gcssm` | `git commit -S -s -m` |
+| `gcf` | `git config --list` |
+| `gdct` | `git describe --tags $(git rev-list --tags --max-count=1)` |
+| `gd` | `git diff` |
+| `gdca` | `git diff --cached` |
+| `gdcw` | `git diff --cached --word-diff` |
+| `gds` | `git diff --staged` |
+| `gdw` | `git diff --word-diff` |
+| `gdv` | `git diff -w "$@" \| view -` |
+| `gdup` | `git diff @{upstream}` |
+| `gdnolock` | `git diff $@ ":(exclude)package-lock.json" ":(exclude)\*.lock"` |
+| `gdt` | `git diff-tree --no-commit-id --name-only -r` |
+| `gf` | `git fetch` |
+| `gfa` | `git fetch --all --prune` |
+| `gfo` | `git fetch origin` |
+| `gg` | `git gui citool` |
+| `gga` | `git gui citool --amend` |
+| `ghh` | `git help` |
+| `glgg` | `git log --graph` |
+| `glgga` | `git log --graph --decorate --all` |
+| `glgm` | `git log --graph --max-count=10` |
+| `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` |
+| `glol` | `git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset'` |
+| `glola` | `git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --all` |
+| `glols` | `git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat` |
+| `glo` | `git log --oneline --decorate` |
+| `glog` | `git log --oneline --decorate --graph` |
+| `gloga` | `git log --oneline --decorate --graph --all` |
+| `glp` | `git log --pretty=<format>` |
+| `glg` | `git log --stat` |
+| `glgp` | `git log --stat --patch` |
+| `gignored` | `git ls-files -v \| grep "^[[:lower:]]"` |
+| `gfg` | `git ls-files \| grep` |
+| `gm` | `git merge` |
+| `gma` | `git merge --abort` |
+| `gms` | `git merge --squash` |
+| `gmom` | `git merge origin/$(git_main_branch)` |
+| `gmum` | `git merge upstream/$(git_main_branch)` |
+| `gmtl` | `git mergetool --no-prompt` |
+| `gmtlvim` | `git mergetool --no-prompt --tool=vimdiff` |
+| `gl` | `git pull` |
+| `gpr` | `git pull --rebase` |
+| `gprv` | `git pull --rebase -v` |
+| `gpra` | `git pull --rebase --autostash` |
+| `gprav` | `git pull --rebase --autostash -v` |
+| `gprom` | `git pull --rebase origin $(git_main_branch)` |
+| `gpromi` | `git pull --rebase=interactive origin $(git_main_branch)` |
+| `ggpull` | `git pull origin "$(git_current_branch)"` |
+| `ggl` | `git pull origin $(current_branch)` |
+| `gluc` | `git pull upstream $(git_current_branch)` |
+| `glum` | `git pull upstream $(git_main_branch)` |
+| `gp` | `git push` |
+| `gpd` | `git push --dry-run` |
+| `gpf!` | `git push --force` |
+| `ggf` | `git push --force origin $(current_branch)` |
+| `gpf` | On Git >= 2.30: `git push --force-with-lease --force-if-includes` |
+| `gpf` | On Git < 2.30: `git push --force-with-lease` |
+| `ggfl` | `git push --force-with-lease origin $(current_branch)` |
+| `gpsup` | `git push --set-upstream origin $(git_current_branch)` |
+| `gpsupf` | On Git >= 2.30: `git push --set-upstream origin $(git_current_branch) --force-with-lease --force-if-includes` |
+| `gpsupf` | On Git < 2.30: `git push --set-upstream origin $(git_current_branch) --force-with-lease` |
+| `gpv` | `git push --verbose` |
+| `gpoat` | `git push origin --all && git push origin --tags` |
+| `gpod` | `git push origin --delete` |
+| `ggpush` | `git push origin "$(git_current_branch)"` |
+| `ggp` | `git push origin $(current_branch)` |
+| `gpu` | `git push upstream` |
+| `grb` | `git rebase` |
+| `grba` | `git rebase --abort` |
+| `grbc` | `git rebase --continue` |
+| `grbi` | `git rebase --interactive` |
+| `grbo` | `git rebase --onto` |
+| `grbs` | `git rebase --skip` |
+| `grbd` | `git rebase $(git_develop_branch)` |
+| `grbm` | `git rebase $(git_main_branch)` |
+| `grbom` | `git rebase origin/$(git_main_branch)` |
+| `gr` | `git remote` |
+| `grv` | `git remote --verbose` |
+| `gra` | `git remote add` |
+| `grrm` | `git remote remove` |
+| `grmv` | `git remote rename` |
+| `grset` | `git remote set-url` |
+| `grup` | `git remote update` |
+| `grh` | `git reset` |
+| `gru` | `git reset --` |
+| `grhh` | `git reset --hard` |
+| `grhk` | `git reset --keep` |
+| `grhs` | `git reset --soft` |
+| `gpristine` | `git reset --hard && git clean -dffx` |
+| `groh` | `git reset origin/$(git_current_branch) --hard` |
+| `grs` | `git restore` |
+| `grss` | `git restore --source` |
+| `grst` | `git restore --staged` |
+| `gunwip` | `git rev-list --max-count=1 --format="%s" HEAD \| grep -q "--wip--" && git reset HEAD~1` |
+| `grev` | `git revert` |
+| `grm` | `git rm` |
+| `grmc` | `git rm --cached` |
+| `gcount` | `git shortlog --summary -n` |
+| `gsh` | `git show` |
+| `gsps` | `git show --pretty=short --show-signature` |
+| `gstall` | `git stash --all` |
+| `gstu` | `git stash --include-untracked` |
+| `gstaa` | `git stash apply` |
+| `gstc` | `git stash clear` |
+| `gstd` | `git stash drop` |
+| `gstl` | `git stash list` |
+| `gstp` | `git stash pop` |
+| `gsta` | On Git >= 2.13: `git stash push` |
+| `gsta` | On Git < 2.13: `git stash save` |
+| `gsts` | `git stash show --patch` |
+| `gst` | `git status` |
+| `gss` | `git status --short` |
+| `gsb` | `git status --short -b` |
+| `gsi` | `git submodule init` |
+| `gsu` | `git submodule update` |
+| `gsd` | `git svn dcommit` |
+| `git-svn-dcommit-push` | `git svn dcommit && git push github $(git_main_branch):svntrunk` |
+| `gsr` | `git svn rebase` |
+| `gsw` | `git switch` |
+| `gswc` | `git switch -c` |
+| `gswd` | `git switch $(git_develop_branch)` |
+| `gswm` | `git switch $(git_main_branch)` |
+| `gta` | `git tag --annotate` |
+| `gts` | `git tag -s` |
+| `gtv` | `git tag \| sort -V` |
+| `gignore` | `git update-index --assume-unchanged` |
+| `gunignore` | `git update-index --no-assume-unchanged` |
+| `gwch` | `git whatchanged -p --abbrev-commit --pretty=medium` |
+| `gwt` | `git worktree` |
+| `gwtls` | `git worktree list` |
+| `gwtmv` | `git worktree move` |
+| `gwtrm` | `git worktree remove` |
+| `gk` | `gitk --all --branches &!` |
+| `gke` | `gitk --all $(git log --walk-reflogs --pretty=%h) &!` |
+| `gtl` | `gtl(){ git tag --sort=-v:refname -n --list ${1}\* }; noglob gtl` |
### Main branch preference
-Following the recent push for removing racially-charged words from our technical vocabulary, the git plugin favors using
-a branch name other than `master`. In this case, we favor the shorter, neutral and descriptive term `main`. This means
-that any aliases and functions that previously used `master`, will use `main` if that branch exists. We do this via the
-function `git_main_branch`.
+Following the recent push for removing racially-charged words from our technical vocabulary, the git plugin
+favors using a branch name other than `master`. In this case, we favor the shorter, neutral and descriptive
+term `main`. This means that any aliases and functions that previously used `master`, will use `main` if that
+branch exists. We do this via the function `git_main_branch`.
### Deprecated aliases
-These are aliases that have been removed, renamed, or otherwise modified in a way that may, or may not, receive further support.
+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`. |
+| `gup` | `git pull --rebase` | now alias `gpr` |
+| `gupv` | `git pull --rebase -v` | now alias `gprv` |
+| `gupa` | `git pull --rebase --autostash` | now alias `gpra` |
+| `gupav` | `git pull --rebase --autostash -v` | now alias `gprav` |
+| `gupom` | `git pull --rebase origin $(git_main_branch)` | now alias `gprom` |
+| `gupomi` | `git pull --rebase=interactive origin $(git_main_branch)` | now alias `gpromi` |
## Functions
### Current
-| Command | Description |
-| :--------------------- | :------------------------------------------------------------------------------------------------------- |
-| `grename <old> <new>` | 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 |
-| git_main_branch | Returns the name of the main branch: `main` if it exists, `master` otherwise |
-| git_develop_branch | Returns the name of the develop branch: `dev`, `devel`, `development` if they exist, `develop` otherwise |
+| Command | Description |
+| :----------------------- | :-------------------------------------------------------------------------------------------------------------- |
+| `current_branch` | Returns the name of the current branch. |
+| `git_current_user_email` | Returns the `user.email` config value. (Lives in `lib/git.zsh`.) |
+| `git_current_user_name` | Returns the `user.name` config value. (Lives in `lib/git.zsh`.) |
+| `git_develop_branch` | Returns the name of the “development” branch: `dev`, `devel`, `development` if they exist, `develop` otherwise. |
+| `git_main_branch` | Returns the name of the main branch: `main` if it exists, `master` otherwise. |
+| `grename <old> <new>` | Renames branch `<old>` to `<new>`, including on the origin remote. |
+| `gbda` | Deletes all merged branches |
+| `gbds` | Deletes all squash-merged branches (**Note: performance degrades with number of branches**) |
### Work in Progress (WIP)
-These features allow to pause a branch development and switch to another one (_"Work in Progress"_, or wip). When you want to go back to work, just unwip it.
+These features allow you to pause developing one branch and switch to another one (_"Work in Progress"_, or
+“wip”). When you want to go back to work, just “unwip” it.
-| Command | Description |
-| :--------------- | :---------------------------------------------- |
-| work_in_progress | Echoes a warning if the current branch is a wip |
-| gwip | Commit wip branch |
-| gunwip | Uncommit wip branch |
+| Command | Description |
+| :----------------- | :---------------------------------------------- |
+| `gwip` | Commit wip branch |
+| `gunwip` | Uncommit wip branch |
+| `gunwipall` | Uncommit all recent `--wip--` commits |
+| `work_in_progress` | Echoes a warning if the current branch is a wip |
+
+Note that `gwip` and `gunwip` are aliases, but are also documented here to group all related WIP features.
### Deprecated functions
-| Command | Description | Reason |
-| :----------------- | :-------------------------------------- | :-------------------------------------------------------------- |
-| current_repository | Return the names of the current remotes | Didn't work properly. Use `git remote -v` instead (`grv` alias) |
+| Command | Description | Reason |
+| :------------------- | :-------------------------------------- | :--------------------------------------------------------------- |
+| `current_repository` | Return the names of the current remotes | Didn't work properly. Use `git remote -v` instead (`grv` alias). |
diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh
index ed17436e8..6ea1d1177 100644
--- a/plugins/git/git.plugin.zsh
+++ b/plugins/git/git.plugin.zsh
@@ -3,7 +3,9 @@ autoload -Uz is-at-least
git_version="${${(As: :)$(git version 2>/dev/null)}[3]}"
#
-# Functions
+# Functions Current
+# (sorted alphabetically by function name)
+# (order should follow README)
#
# The name of the current branch
@@ -14,152 +16,259 @@ function current_branch() {
git_current_branch
}
-# Pretty log messages
-function _git_log_prettily(){
- if ! [ -z $1 ]; then
- git log --pretty=$1
- fi
-}
-compdef _git _git_log_prettily=git-log
+# Check for develop and similarly named branches
+function git_develop_branch() {
+ command git rev-parse --git-dir &>/dev/null || return
+ local branch
+ for branch in dev devel develop development; do
+ if command git show-ref -q --verify refs/heads/$branch; then
+ echo $branch
+ return 0
+ fi
+ done
-# Warn if the current branch is a WIP
-function work_in_progress() {
- command git -c log.showSignature=false log -n 1 2>/dev/null | grep -q -- "--wip--" && echo "WIP!!"
+ echo develop
+ return 1
}
# Check if main exists and use instead of master
function git_main_branch() {
command git rev-parse --git-dir &>/dev/null || return
local ref
- for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk,mainline,default}; do
+ for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk,mainline,default,master}; do
if command git show-ref -q --verify $ref; then
echo ${ref:t}
- return
+ return 0
fi
done
+
+ # If no main branch was found, fall back to master but return error
echo master
+ return 1
}
-# Check for develop and similarly named branches
-function git_develop_branch() {
- command git rev-parse --git-dir &>/dev/null || return
- local branch
- for branch in dev devel development; do
- if command git show-ref -q --verify refs/heads/$branch; then
- echo $branch
- return
- fi
- done
- echo develop
+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
+}
+
+#
+# Functions Work in Progress (WIP)
+# (sorted alphabetically by function name)
+# (order should follow README)
+#
+
+# Similar to `gunwip` but recursive "Unwips" all recent `--wip--` commits not just the last one
+function gunwipall() {
+ local _commit=$(git log --grep='--wip--' --invert-grep --max-count=1 --format=format:%H)
+
+ # Check if a commit without "--wip--" was found and it's not the same as HEAD
+ if [[ "$_commit" != "$(git rev-parse HEAD)" ]]; then
+ git reset $_commit || return 1
+ fi
+}
+
+# Warn if the current branch is a WIP
+function work_in_progress() {
+ command git -c log.showSignature=false log -n 1 2>/dev/null | grep -q -- "--wip--" && echo "WIP!!"
}
#
# Aliases
-# (sorted alphabetically)
+# (sorted alphabetically by command)
+# (order should follow README)
+# (in some cases force the alisas order to match README, like for example gke and gk)
#
-alias g='git'
+alias grt='cd "$(git rev-parse --show-toplevel || echo .)"'
+
+function ggpnp() {
+ if [[ "$#" == 0 ]]; then
+ ggl && ggp
+ else
+ ggl "${*}" && ggp "${*}"
+ fi
+}
+compdef _git ggpnp=git-checkout
+alias ggpur='ggu'
+alias g='git'
alias ga='git add'
alias gaa='git add --all'
alias gapa='git add --patch'
alias gau='git add --update'
alias gav='git add --verbose'
+alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"'
+alias gam='git am'
+alias gama='git am --abort'
+alias gamc='git am --continue'
+alias gamscp='git am --show-current-patch'
+alias gams='git am --skip'
alias gap='git apply'
alias gapt='git apply --3way'
-
-alias gb='git branch'
-alias gba='git branch --all'
-alias gbd='git branch --delete'
-alias gbda='git branch --no-color --merged | command grep -vE "^([+*]|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs git branch --delete 2>/dev/null'
-alias gbD='git branch --delete --force'
-alias gbg='git branch -vv | grep ": gone\]"'
-alias gbgd='local res=$(gbg | awk '"'"'{print $1}'"'"') && [[ $res ]] && echo $res | xargs git branch -d'
-alias gbgD='local res=$(gbg | awk '"'"'{print $1}'"'"') && [[ $res ]] && echo $res | xargs git branch -D'
-alias gbl='git blame -b -w'
-alias gbnm='git branch --no-merged'
-alias gbr='git branch --remote'
alias gbs='git bisect'
alias gbsb='git bisect bad'
alias gbsg='git bisect good'
+alias gbsn='git bisect new'
+alias gbso='git bisect old'
alias gbsr='git bisect reset'
alias gbss='git bisect start'
+alias gbl='git blame -w'
+alias gb='git branch'
+alias gba='git branch --all'
+alias gbd='git branch --delete'
+alias gbD='git branch --delete --force'
-alias gc='git commit --verbose'
-alias gc!='git commit --verbose --amend'
-alias gcn!='git commit --verbose --no-edit --amend'
-alias gca='git commit --verbose --all'
-alias gca!='git commit --verbose --all --amend'
-alias gcan!='git commit --verbose --all --no-edit --amend'
-alias gcans!='git commit --verbose --all --signoff --no-edit --amend'
-alias gcam='git commit --all --message'
-alias gcsm='git commit --signoff --message'
-alias gcas='git commit --all --signoff'
-alias gcasm='git commit --all --signoff --message'
-alias gcb='git checkout -b'
-alias gcf='git config --list'
+function gbda() {
+ git branch --no-color --merged | command grep -vE "^([+*]|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs git branch --delete 2>/dev/null
+}
-function gccd() {
- command git clone --recurse-submodules "$@"
- [[ -d "$_" ]] && cd "$_" || cd "${${_:t}%.git}"
+# Copied and modified from James Roeder (jmaroeder) under MIT License
+# https://github.com/jmaroeder/plugin-git/blob/216723ef4f9e8dde399661c39c80bdf73f4076c4/functions/gbda.fish
+function gbds() {
+ local default_branch=$(git_main_branch)
+ (( ! $? )) || default_branch=$(git_develop_branch)
+
+ git for-each-ref refs/heads/ "--format=%(refname:short)" | \
+ while read branch; do
+ local merge_base=$(git merge-base $default_branch $branch)
+ if [[ $(git cherry $default_branch $(git commit-tree $(git rev-parse $branch\^{tree}) -p $merge_base -m _)) = -* ]]; then
+ git branch -D $branch
+ fi
+ done
}
-compdef _git gccd=git-clone
-alias gcl='git clone --recurse-submodules'
-alias gclean='git clean --interactive -d'
-alias gpristine='git reset --hard && git clean --force -dfx'
-alias gcm='git checkout $(git_main_branch)'
-alias gcd='git checkout $(git_develop_branch)'
-alias gcmsg='git commit --message'
+alias gbgd='LANG=C git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -d'
+alias gbgD='LANG=C git branch --no-color -vv | grep ": gone\]" | awk '"'"'{print $1}'"'"' | xargs git branch -D'
+alias gbm='git branch --move'
+alias gbnm='git branch --no-merged'
+alias gbr='git branch --remote'
+alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)'
+alias gbg='LANG=C git branch -vv | grep ": gone\]"'
alias gco='git checkout'
alias gcor='git checkout --recurse-submodules'
-alias gcount='git shortlog --summary --numbered'
+alias gcb='git checkout -b'
+alias gcd='git checkout $(git_develop_branch)'
+alias gcm='git checkout $(git_main_branch)'
alias gcp='git cherry-pick'
alias gcpa='git cherry-pick --abort'
alias gcpc='git cherry-pick --continue'
+alias gclean='git clean --interactive -d'
+alias gcl='git clone --recurse-submodules'
+
+function gccd() {
+ # get repo URI from args based on valid formats: https://git-scm.com/docs/git-clone#URLS
+ local repo="${${@[(r)(ssh://*|git://*|ftp(s)#://*|http(s)#://*|*@*)(.git/#)#]}:-$_}"
+
+ # clone repository and exit if it fails
+ command git clone --recurse-submodules "$@" || return
+
+ # if last arg passed was a directory, that's where the repo was cloned
+ # otherwise parse the repo URI and use the last part as the directory
+ [[ -d "$_" ]] && cd "$_" || cd "${${repo:t}%.git/#}"
+}
+compdef _git gccd=git-clone
+
+alias gcam='git commit --all --message'
+alias gcas='git commit --all --signoff'
+alias gcasm='git commit --all --signoff --message'
alias gcs='git commit --gpg-sign'
alias gcss='git commit --gpg-sign --signoff'
alias gcssm='git commit --gpg-sign --signoff --message'
-
+alias gcmsg='git commit --message'
+alias gcsm='git commit --signoff --message'
+alias gc='git commit --verbose'
+alias gca='git commit --verbose --all'
+alias gca!='git commit --verbose --all --amend'
+alias gcan!='git commit --verbose --all --no-edit --amend'
+alias gcans!='git commit --verbose --all --signoff --no-edit --amend'
+alias gc!='git commit --verbose --amend'
+alias gcn!='git commit --verbose --no-edit --amend'
+alias gcf='git config --list'
+alias gdct='git describe --tags $(git rev-list --tags --max-count=1)'
alias gd='git diff'
alias gdca='git diff --cached'
alias gdcw='git diff --cached --word-diff'
-alias gdct='git describe --tags $(git rev-list --tags --max-count=1)'
alias gds='git diff --staged'
-alias gdt='git diff-tree --no-commit-id --name-only -r'
-alias gdup='git diff @{upstream}'
alias gdw='git diff --word-diff'
+function gdv() { git diff -w "$@" | view - }
+compdef _git gdv=git-diff
+
+alias gdup='git diff @{upstream}'
+
function gdnolock() {
git diff "$@" ":(exclude)package-lock.json" ":(exclude)*.lock"
}
compdef _git gdnolock=git-diff
-function gdv() { git diff -w "$@" | view - }
-compdef _git gdv=git-diff
-
+alias gdt='git diff-tree --no-commit-id --name-only -r'
alias gf='git fetch'
# --jobs=<n> was added in git 2.8
is-at-least 2.8 "$git_version" \
&& alias gfa='git fetch --all --prune --jobs=10' \
|| alias gfa='git fetch --all --prune'
alias gfo='git fetch origin'
-
-alias gfg='git ls-files | grep'
-
alias gg='git gui citool'
alias gga='git gui citool --amend'
+alias ghh='git help'
+alias glgg='git log --graph'
+alias glgga='git log --graph --decorate --all'
+alias glgm='git log --graph --max-count=10'
+alias glods='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset" --date=short'
+alias glod='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset"'
+alias glola='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" --all'
+alias glols='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" --stat'
+alias glol='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset"'
+alias glo='git log --oneline --decorate'
+alias glog='git log --oneline --decorate --graph'
+alias gloga='git log --oneline --decorate --graph --all'
-function ggf() {
- [[ "$#" != 1 ]] && local b="$(git_current_branch)"
- git push --force origin "${b:=$1}"
+# Pretty log messages
+function _git_log_prettily(){
+ if ! [ -z $1 ]; then
+ git log --pretty=$1
+ fi
}
-compdef _git ggf=git-checkout
-function ggfl() {
+compdef _git _git_log_prettily=git-log
+
+alias glp='_git_log_prettily'
+alias glg='git log --stat'
+alias glgp='git log --stat --patch'
+alias gignored='git ls-files -v | grep "^[[:lower:]]"'
+alias gfg='git ls-files | grep'
+alias gm='git merge'
+alias gma='git merge --abort'
+alias gms="git merge --squash"
+alias gmom='git merge origin/$(git_main_branch)'
+alias gmum='git merge upstream/$(git_main_branch)'
+alias gmtl='git mergetool --no-prompt'
+alias gmtlvim='git mergetool --no-prompt --tool=vimdiff'
+
+alias gl='git pull'
+alias gpr='git pull --rebase'
+alias gprv='git pull --rebase -v'
+alias gpra='git pull --rebase --autostash'
+alias gprav='git pull --rebase --autostash -v'
+
+function ggu() {
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
- git push --force-with-lease origin "${b:=$1}"
+ git pull --rebase origin "${b:=$1}"
}
-compdef _git ggfl=git-checkout
+compdef _git ggu=git-checkout
+
+alias gprom='git pull --rebase origin $(git_main_branch)'
+alias gpromi='git pull --rebase=interactive origin $(git_main_branch)'
+alias ggpull='git pull origin "$(git_current_branch)"'
function ggl() {
if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
@@ -171,183 +280,135 @@ function ggl() {
}
compdef _git ggl=git-checkout
-function ggp() {
- if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
- git push origin "${*}"
- else
- [[ "$#" == 0 ]] && local b="$(git_current_branch)"
- git push origin "${b:=$1}"
- fi
-}
-compdef _git ggp=git-checkout
+alias gluc='git pull upstream $(git_current_branch)'
+alias glum='git pull upstream $(git_main_branch)'
+alias gp='git push'
+alias gpd='git push --dry-run'
-function ggpnp() {
- if [[ "$#" == 0 ]]; then
- ggl && ggp
- else
- ggl "${*}" && ggp "${*}"
- fi
+function ggf() {
+ [[ "$#" != 1 ]] && local b="$(git_current_branch)"
+ git push --force origin "${b:=$1}"
}
-compdef _git ggpnp=git-checkout
+compdef _git ggf=git-checkout
-function ggu() {
+alias gpf!='git push --force'
+is-at-least 2.30 "$git_version" \
+ && alias gpf='git push --force-with-lease --force-if-includes' \
+ || alias gpf='git push --force-with-lease'
+
+function ggfl() {
[[ "$#" != 1 ]] && local b="$(git_current_branch)"
- git pull --rebase origin "${b:=$1}"
+ git push --force-with-lease origin "${b:=$1}"
}
-compdef _git ggu=git-checkout
-
-alias ggpur='ggu'
-alias ggpull='git pull origin "$(git_current_branch)"'
-alias ggpush='git push origin "$(git_current_branch)"'
+compdef _git ggfl=git-checkout
-alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)'
alias gpsup='git push --set-upstream origin $(git_current_branch)'
is-at-least 2.30 "$git_version" \
&& alias gpsupf='git push --set-upstream origin $(git_current_branch) --force-with-lease --force-if-includes' \
|| alias gpsupf='git push --set-upstream origin $(git_current_branch) --force-with-lease'
-
-alias ghh='git help'
-
-alias gignore='git update-index --assume-unchanged'
-alias gignored='git ls-files -v | grep "^[[:lower:]]"'
-alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk'
-
-alias gk='\gitk --all --branches &!'
-alias gke='\gitk --all $(git log --walk-reflogs --pretty=%h) &!'
-
-alias gl='git pull'
-alias glg='git log --stat'
-alias glgp='git log --stat --patch'
-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(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset'"
-alias glols="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat"
-alias glod="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'"
-alias glods="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short"
-alias glola="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %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"
-
-alias gm='git merge'
-alias gmom='git merge origin/$(git_main_branch)'
-alias gmtl='git mergetool --no-prompt'
-alias gmtlvim='git mergetool --no-prompt --tool=vimdiff'
-alias gmum='git merge upstream/$(git_main_branch)'
-alias gma='git merge --abort'
-
-alias gp='git push'
-alias gpd='git push --dry-run'
-is-at-least 2.30 "$git_version" \
- && alias gpf='git push --force-with-lease --force-if-includes' \
- || alias gpf='git push --force-with-lease'
-alias gpf!='git push --force'
+alias gpv='git push --verbose'
alias gpoat='git push origin --all && git push origin --tags'
alias gpod='git push origin --delete'
-alias gpr='git pull --rebase'
-alias gpu='git push upstream'
-alias gpv='git push --verbose'
+alias ggpush='git push origin "$(git_current_branch)"'
-alias gr='git remote'
-alias gra='git remote add'
+function ggp() {
+ if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
+ git push origin "${*}"
+ else
+ [[ "$#" == 0 ]] && local b="$(git_current_branch)"
+ git push origin "${b:=$1}"
+ fi
+}
+compdef _git ggp=git-checkout
+
+alias gpu='git push upstream'
alias grb='git rebase'
alias grba='git rebase --abort'
alias grbc='git rebase --continue'
-alias grbd='git rebase $(git_develop_branch)'
alias grbi='git rebase --interactive'
-alias grbm='git rebase $(git_main_branch)'
-alias grbom='git rebase origin/$(git_main_branch)'
alias grbo='git rebase --onto'
alias grbs='git rebase --skip'
-alias grev='git revert'
+alias grbd='git rebase $(git_develop_branch)'
+alias grbm='git rebase $(git_main_branch)'
+alias grbom='git rebase origin/$(git_main_branch)'
+alias gr='git remote'
+alias grv='git remote --verbose'
+alias gra='git remote add'
+alias grrm='git remote remove'
+alias grmv='git remote rename'
+alias grset='git remote set-url'
+alias grup='git remote update'
alias grh='git reset'
+alias gru='git reset --'
alias grhh='git reset --hard'
+alias grhk='git reset --keep'
+alias grhs='git reset --soft'
+alias gpristine='git reset --hard && git clean --force -dfx'
alias groh='git reset origin/$(git_current_branch) --hard'
-alias grm='git rm'
-alias grmc='git rm --cached'
-alias grmv='git remote rename'
-alias grrm='git remote remove'
alias grs='git restore'
-alias grset='git remote set-url'
alias grss='git restore --source'
alias grst='git restore --staged'
-alias grt='cd "$(git rev-parse --show-toplevel || echo .)"'
-alias gru='git reset --'
-alias grup='git remote update'
-alias grv='git remote --verbose'
-
-alias gsb='git status --short --branch'
-alias gsd='git svn dcommit'
+alias gunwip='git rev-list --max-count=1 --format="%s" HEAD | grep -q "\--wip--" && git reset HEAD~1'
+alias grev='git revert'
+alias grm='git rm'
+alias grmc='git rm --cached'
+alias gcount='git shortlog --summary --numbered'
alias gsh='git show'
-alias gsi='git submodule init'
alias gsps='git show --pretty=short --show-signature'
-alias gsr='git svn rebase'
-alias gss='git status --short'
-alias gst='git status'
-
-# use the default stash push on git 2.13 and newer
-is-at-least 2.13 "$git_version" \
- && alias gsta='git stash push' \
- || alias gsta='git stash save'
-
+alias gstall='git stash --all'
alias gstaa='git stash apply'
alias gstc='git stash clear'
alias gstd='git stash drop'
alias gstl='git stash list'
alias gstp='git stash pop'
-alias gsts='git stash show --text'
-alias gstu='gsta --include-untracked'
-alias gstall='git stash --all'
+# use the default stash push on git 2.13 and newer
+is-at-least 2.13 "$git_version" \
+ && alias gsta='git stash push' \
+ || alias gsta='git stash save'
+alias gsts='git stash show --patch'
+alias gst='git status'
+alias gss='git status --short'
+alias gsb='git status --short --branch'
+alias gsi='git submodule init'
alias gsu='git submodule update'
+alias gsd='git svn dcommit'
+alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk'
+alias gsr='git svn rebase'
alias gsw='git switch'
alias gswc='git switch --create'
-alias gswm='git switch $(git_main_branch)'
alias gswd='git switch $(git_develop_branch)'
-
+alias gswm='git switch $(git_main_branch)'
+alias gta='git tag --annotate'
alias gts='git tag --sign'
alias gtv='git tag | sort -V'
-alias gtl='gtl(){ git tag --sort=-v:refname -n --list "${1}*" }; noglob gtl'
-
+alias gignore='git update-index --assume-unchanged'
alias gunignore='git update-index --no-assume-unchanged'
-alias gunwip='git log --max-count=1 | grep -q -c "\--wip--" && git reset HEAD~1'
-alias gup='git pull --rebase'
-alias gupv='git pull --rebase --verbose'
-alias gupa='git pull --rebase --autostash'
-alias gupav='git pull --rebase --autostash --verbose'
-alias gupom='git pull --rebase origin $(git_main_branch)'
-alias gupomi='git pull --rebase=interactive origin $(git_main_branch)'
-alias glum='git pull upstream $(git_main_branch)'
-alias gluc='git pull upstream $(git_current_branch)'
-
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 --message "--wip-- [skip ci]"'
-
alias gwt='git worktree'
alias gwta='git worktree add'
alias gwtls='git worktree list'
alias gwtmv='git worktree move'
alias gwtrm='git worktree remove'
-
-alias gam='git am'
-alias gamc='git am --continue'
-alias gams='git am --skip'
-alias gama='git am --abort'
-alias gamscp='git am --show-current-patch'
-
-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
-}
+alias gstu='gsta --include-untracked'
+alias gtl='gtl(){ git tag --sort=-v:refname -n --list "${1}*" }; noglob gtl'
+alias gk='\gitk --all --branches &!'
+alias gke='\gitk --all $(git log --walk-reflogs --pretty=%h) &!'
unset git_version
+
+# Logic for adding warnings on deprecated aliases
+local old_alias new_alias
+for old_alias new_alias (
+ # TODO(2023-10-19): remove deprecated `git pull --rebase` aliases
+ gup gpr
+ gupv gprv
+ gupa gpra
+ gupav gprav
+ gupom gprom
+ gupomi gpromi
+); do
+ aliases[$old_alias]="
+ print -Pu2 \"%F{yellow}[oh-my-zsh] '%F{red}${old_alias}%F{yellow}' is a deprecated alias, using '%F{green}${new_alias}%F{yellow}' instead.%f\"
+ $new_alias"
+done
+unset old_alias new_alias
diff --git a/plugins/gitignore/README.md b/plugins/gitignore/README.md
index 753dd31fd..23c7887cf 100644
--- a/plugins/gitignore/README.md
+++ b/plugins/gitignore/README.md
@@ -1,6 +1,6 @@
# gitignore
-This plugin enables you the use of [gitignore.io](https://www.gitignore.io/) from the command line. You need an active internet connection.
+This plugin enables you the use of [gitignore.io](https://www.toptal.com/developers/gitignore) from the command line. You need an active internet connection.
To use it, add `gitignore` to the plugins array in your zshrc file:
diff --git a/plugins/gitignore/gitignore.plugin.zsh b/plugins/gitignore/gitignore.plugin.zsh
index a687f5cce..3271d61a9 100644
--- a/plugins/gitignore/gitignore.plugin.zsh
+++ b/plugins/gitignore/gitignore.plugin.zsh
@@ -1,7 +1,7 @@
-function gi() { curl -fLw '\n' https://www.gitignore.io/api/"${(j:,:)@}" }
+function gi() { curl -fLw '\n' https://www.toptal.com/developers/gitignore/api/"${(j:,:)@}" }
_gitignoreio_get_command_list() {
- curl -sfL https://www.gitignore.io/api/list | tr "," "\n"
+ curl -sfL https://www.toptal.com/developers/gitignore/api/list | tr "," "\n"
}
_gitignoreio () {
diff --git a/plugins/gnu-utils/gnu-utils.plugin.zsh b/plugins/gnu-utils/gnu-utils.plugin.zsh
index 6bd3e8463..6023bf2b4 100644
--- a/plugins/gnu-utils/gnu-utils.plugin.zsh
+++ b/plugins/gnu-utils/gnu-utils.plugin.zsh
@@ -19,7 +19,7 @@ __gnu_utils() {
'gchown' 'gchroot' 'gcksum' 'gcomm' 'gcp' 'gcsplit' 'gcut' 'gdate'
'gdd' 'gdf' 'gdir' 'gdircolors' 'gdirname' 'gdu' 'gecho' 'genv' 'gexpand'
'gexpr' 'gfactor' 'gfalse' 'gfmt' 'gfold' 'ggroups' 'ghead' 'ghostid'
- 'gid' 'ginstall' 'gjoin' 'gkill' 'glink' 'gln' 'glogname' 'gls' 'gmd5sum'
+ 'gid' 'gindent' 'ginstall' 'gjoin' 'gkill' 'glink' 'gln' 'glogname' 'gls' 'gmd5sum'
'gmkdir' 'gmkfifo' 'gmknod' 'gmktemp' 'gmv' 'gnice' 'gnl' 'gnohup' 'gnproc'
'god' 'gpaste' 'gpathchk' 'gpinky' 'gpr' 'gprintenv' 'gprintf' 'gptx' 'gpwd'
'greadlink' 'grm' 'grmdir' 'gruncon' 'gseq' 'gsha1sum' 'gsha224sum'
diff --git a/plugins/gradle/gradle.plugin.zsh b/plugins/gradle/gradle.plugin.zsh
index 5bca364d1..dacc46478 100644
--- a/plugins/gradle/gradle.plugin.zsh
+++ b/plugins/gradle/gradle.plugin.zsh
@@ -6,7 +6,7 @@ function gradle-or-gradlew() {
# taken from https://github.com/gradle/gradle-completion
local dir="$PWD" project_root="$PWD"
while [[ "$dir" != / ]]; do
- if [[ -f "$dir/settings.gradle" || -f "$dir/settings.gradle.kts" || -f "$dir/gradlew" ]]; then
+ if [[ -x "$dir/gradlew" ]]; then
project_root="$dir"
break
fi
diff --git a/plugins/grc/grc.plugin.zsh b/plugins/grc/grc.plugin.zsh
index b709b9e02..e036b8d89 100644
--- a/plugins/grc/grc.plugin.zsh
+++ b/plugins/grc/grc.plugin.zsh
@@ -2,8 +2,9 @@
# common grc.zsh paths
files=(
- /etc/grc.zsh # default
- /usr/local/etc/grc.zsh # homebrew
+ /etc/grc.zsh # default
+ /usr/local/etc/grc.zsh # homebrew darwin-x64
+ /opt/homebrew/etc/grc.zsh # homebrew darwin-arm64
)
# verify the file is readable and source it
diff --git a/plugins/history/README.md b/plugins/history/README.md
index a9d480f46..73d6a5052 100644
--- a/plugins/history/README.md
+++ b/plugins/history/README.md
@@ -13,5 +13,6 @@ plugins=(... history)
| Alias | Command | Description |
|-------|----------------------|------------------------------------------------------------------|
| `h` | `history` | Prints your command history |
+| `hl` | `history \| less` | Pipe history output to less to search and navigate it easily |
| `hs` | `history \| grep` | Use grep to search your command history |
| `hsi` | `history \| grep -i` | Use grep to do a case-insensitive search of your command history |
diff --git a/plugins/history/history.plugin.zsh b/plugins/history/history.plugin.zsh
index 9cee48fe4..fb3e31389 100644
--- a/plugins/history/history.plugin.zsh
+++ b/plugins/history/history.plugin.zsh
@@ -1,3 +1,4 @@
alias h='history'
+alias hl='history | less'
alias hs='history | grep'
alias hsi='history | grep -i'
diff --git a/plugins/hitchhiker/fortunes/hitchhiker b/plugins/hitchhiker/fortunes/hitchhiker
index 825b86cd6..94cc1c835 100644
--- a/plugins/hitchhiker/fortunes/hitchhiker
+++ b/plugins/hitchhiker/fortunes/hitchhiker
@@ -80,7 +80,7 @@
%
"The fronting for the eighty-yard-long marble-topped bar had been made by stitching together nearly twenty thousand Antarean Mosaic Lizard skins, despite the fact that the twenty thousand lizards concerned had needed them to keep their insides in."
-- The Book decribing Milliways' politically incorrect decor.
+- The Book describing Milliways' politically incorrect decor.
%
"`...and the Universe,' continued the waiter, determined not to be deflected on his home stretch, `will explode later for your pleasure.' Ford's head swivelled slowly towards him. He spoke with feeling. `Wow,' he said, `What sort of drinks do you serve in this place?' The waiter laughed a polite little waiter's laugh. `Ah,' he said, `I think sir has perhaps misunderstood me.' `Oh, I hope not,' breathed Ford."
@@ -104,7 +104,7 @@
%
"`The first ten million years were the worst,' said Marvin, `and the second ten million, they were the worst too. The third ten million I didn't enjoy at all. After that I went into a bit of a decline.'"
-- Marvin reflecting back on his 576,000,003,579 year career as Milliways' car park attendent.
+- Marvin reflecting back on his 576,000,003,579 year career as Milliways' car park attendant.
%
"`Incidentally,' he said, `what does teleport mean?' Another moment passed. Slowly, the others turned to face him. `Probably the wrong moment to ask,' said Arthur, `It's just I remember you use the word a short while ago and I only bring it up because...' `Where,' said Ford quietly, `does it say teleport?' `Well, just over here in fact,' said Arthur, pointing at a dark control box in the rear of the cabin, `Just under the word "emergency", above the word "system" and beside the sign saying "out of order".'"
@@ -122,7 +122,7 @@
- Ford "debating" what to do with fire with a marketing girl.
%
-"The story goes that I first had the idea for THHGTTG while lying drunk in a field in Innsbruck (or `Spain' as the BBC TV publicity department authoritatively has it, probably because it's easier to spell)." - Foreward by DNA.
+"The story goes that I first had the idea for THHGTTG while lying drunk in a field in Innsbruck (or `Spain' as the BBC TV publicity department authoritatively has it, probably because it's easier to spell)." - Foreword by DNA.
FORD Six pints of bitter. And quickly please, the world's about to end. BARMAN Oh yes, sir? Nice weather for it.
%
@@ -162,7 +162,7 @@ ARTHUR It probably seems a terrible thing to say, but you know what I sometimes
- Arthur discovering a way of coping with life on Prehistoric Earth.
%
-"`... then I decided that I was a lemon for a couple of weeks. I kept myself amused all that time jumping in and out of a gin and tonic.' Arthur cleared his throat, and then did it again. `Where,' he said, `did you...?' `Find a gin and tonic?' said Ford brightly. `I found a small lake that thought it was a gin and tonic, and jumped in and out of that. At least, I think it thought it was a gin and tonic.' `I may,' he addded with a grin which would have sent sane men scampering into the trees, `have been imagining it.'"
+"`... then I decided that I was a lemon for a couple of weeks. I kept myself amused all that time jumping in and out of a gin and tonic.' Arthur cleared his throat, and then did it again. `Where,' he said, `did you...?' `Find a gin and tonic?' said Ford brightly. `I found a small lake that thought it was a gin and tonic, and jumped in and out of that. At least, I think it thought it was a gin and tonic.' `I may,' he added with a grin which would have sent sane men scampering into the trees, `have been imagining it.'"
- Ford updating Arthur about what he's been doing for the past four years.
%
@@ -194,31 +194,31 @@ ARTHUR It probably seems a terrible thing to say, but you know what I sometimes
- One of the more preferable pieces of advice contained in the Guide.
%
-"His eyes seemed to be popping out of his head. He wasn't certain if this was because they were trying to see more clearly, or if they simply wanted to leave at this point."QUOTEHERESTRINGMAGIC1234- Arthur trying to see who had diverted him from going to a party.
+"His eyes seemed to be popping out of his head. He wasn't certain if this was because they were trying to see more clearly, or if they simply wanted to leave at this point." - Arthur trying to see who had diverted him from going to a party.
%
-"Arthur yawed wildly as his skin tried to jump one way and his skeleton the other, whilst his brain tried to work out which of his ears it most wanted to crawl out of. `Bet you weren't expecting to see me again,' said the monster, which Arthur couldn't help thinking was a strange remark for it to make, seeing as he had never met the creature before. He could tell that he hadn't met the creature before from the simple fact that he was able to sleep at nights."QUOTEHERESTRINGMAGIC1234- Arthur discovering who had diverted him from going to a party.
+"Arthur yawed wildly as his skin tried to jump one way and his skeleton the other, whilst his brain tried to work out which of his ears it most wanted to crawl out of. `Bet you weren't expecting to see me again,' said the monster, which Arthur couldn't help thinking was a strange remark for it to make, seeing as he had never met the creature before. He could tell that he hadn't met the creature before from the simple fact that he was able to sleep at nights." - Arthur discovering who had diverted him from going to a party.
%
-"`That young girl is one of the least benightedly unintelligent organic life forms it has been my profound lack of pleasure not to be able to avoid meeting.'"QUOTEHERESTRINGMAGIC1234- Marvin's first ever compliment about anybody.
+"`That young girl is one of the least benightedly unintelligent organic life forms it has been my profound lack of pleasure not to be able to avoid meeting.'" - Marvin's first ever compliment about anybody.
%
-"Arthur hoped and prayed that there wasn't an afterlife. Then he realised there was a contradiction there and merely hoped that there wasn't an afterlife."QUOTEHERESTRINGMAGIC1234- Arthur realising that he's in a certain death situation with a supernova bomb that is shaped like a cricket ball.
+"Arthur hoped and prayed that there wasn't an afterlife. Then he realised there was a contradiction there and merely hoped that there wasn't an afterlife." - Arthur realising that he's in a certain death situation with a supernova bomb that is shaped like a cricket ball.
%
-"`Credit?' he said. `Aaaargggh...' These two words are usually coupled together in the Old Pink Dog Bar."QUOTEHERESTRINGMAGIC1234- Ford in a spot of bother.
+"`Credit?' he said. `Aaaargggh...' These two words are usually coupled together in the Old Pink Dog Bar." - Ford in a spot of bother.
%
-"`...we might as well start with where your hand is now.' Arthur said, `So which way do I go?' `Down,' said Fenchurch, `on this occasion.' He moved his hand. `Down,' she said, `is in fact the other way.' `Oh yes.'"QUOTEHERESTRINGMAGIC1234- Arthur trying to discover which part of Fenchurch is wrong.
+"`...we might as well start with where your hand is now.' Arthur said, `So which way do I go?' `Down,' said Fenchurch, `on this occasion.' He moved his hand. `Down,' she said, `is in fact the other way.' `Oh yes.'" - Arthur trying to discover which part of Fenchurch is wrong.
%
-"There was a point to this story, but it has temporarily escaped the chronicler's mind."QUOTEHERESTRINGMAGIC1234- This line perhaps best sums up the whole book.
+"There was a point to this story, but it has temporarily escaped the chronicler's mind." - This line perhaps best sums up the whole book.
%
-"The last time anybody made a list of the top hundred character attributes of New Yorkers, common sense snuck in at number 79. .... When it's fall in New York, the air smells as if someone's been frying goats in it, and if you are keen to breathe the best plan is to open a window and stick your head in a building."QUOTEHERESTRINGMAGIC1234- Nuff said??
+"The last time anybody made a list of the top hundred character attributes of New Yorkers, common sense snuck in at number 79. .... When it's fall in New York, the air smells as if someone's been frying goats in it, and if you are keen to breathe the best plan is to open a window and stick your head in a building." - Nuff said??
%
-"`What's been happening here?' he demanded. `Oh just the nicest things, sir, just the nicest things. can I sit on your lap please?'" "`Colin, I am going to abandon you to your fate.' `I'm so happy.'" "`It will be very, very nasty for you, and that's just too bad. Got it?' `I gurgle with pleasure.'"QUOTEHERESTRINGMAGIC1234- Ford and Colin the robot.
+"`What's been happening here?' he demanded. `Oh just the nicest things, sir, just the nicest things. can I sit on your lap please?'" "`Colin, I am going to abandon you to your fate.' `I'm so happy.'" "`It will be very, very nasty for you, and that's just too bad. Got it?' `I gurgle with pleasure.'" - Ford and Colin the robot.
%
-"What the hell, he thought, you're only young once, and threw himself out of the window. That would at least keep the element of surprise on his side."QUOTEHERESTRINGMAGIC1234- Ford outwitting a Vogon with a rocket launcher by going into another certain death situation.
+"What the hell, he thought, you're only young once, and threw himself out of the window. That would at least keep the element of surprise on his side." - Ford outwitting a Vogon with a rocket launcher by going into another certain death situation.
%
-"The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong it usually turns out to be impossible to get at or repair."QUOTEHERESTRINGMAGIC1234- One of the laws of computers and programming revealed.
+"The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong it usually turns out to be impossible to get at or repair." - One of the laws of computers and programming revealed.
%
-"`You know they've reintroduced the death penalty for insurance company directors?' `Really?' said Arthur. `No I didn't. For what offence?' Trillian frowned. `What do you mean, offence?' `I see.'"QUOTEHERESTRINGMAGIC1234- Evidence that there will be some justice in the Universe eventually.
+"`You know they've reintroduced the death penalty for insurance company directors?' `Really?' said Arthur. `No I didn't. For what offence?' Trillian frowned. `What do you mean, offence?' `I see.'" - Evidence that there will be some justice in the Universe eventually.
%
-"`She hit me on the head with the rock again.' `I think I can confirm that that was my daughter.' `Sweet kid.' `You have to get to know her,' said Arthur. `She eases up does she?' `No,' said Arthur, `but you get a better sense of when to duck.'"QUOTEHERESTRINGMAGIC1234- Ford and Arthur on Random.
+"`She hit me on the head with the rock again.' `I think I can confirm that that was my daughter.' `Sweet kid.' `You have to get to know her,' said Arthur. `She eases up does she?' `No,' said Arthur, `but you get a better sense of when to duck.'" - Ford and Arthur on Random.
%
"Far out in the uncharted backwaters of the unfashionable end of the western spiral arm of the Galaxy lies a small unregarded yellow sun. "
%
diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh
index e789fce92..b6ee9f100 100644
--- a/plugins/jira/jira.plugin.zsh
+++ b/plugins/jira/jira.plugin.zsh
@@ -80,7 +80,13 @@ function jira() {
issue_arg=${issue_arg##*/}
# Strip suffixes starting with _
issue_arg=(${(s:_:)issue_arg})
- issue_arg=${issue_arg[1]}
+ # If there is only one part, it means that there is a different delimiter. Try with -
+ if [[ ${#issue_arg[@]} = 1 && ${issue_arg} == *-* ]]; then
+ issue_arg=(${(s:-:)issue_arg})
+ issue_arg="${issue_arg[1]}-${issue_arg[2]}"
+ else
+ issue_arg=${issue_arg[1]}
+ fi
if [[ "${issue_arg:l}" = ${jira_prefix:l}* ]]; then
issue="${issue_arg}"
else
diff --git a/plugins/juju/README.md b/plugins/juju/README.md
index f0c65309c..6ee333f50 100644
--- a/plugins/juju/README.md
+++ b/plugins/juju/README.md
@@ -126,5 +126,7 @@ Naming convention:
- `jaddr <app_name> [unit_num]`: display app or unit IP address.
- `jreld <relation_name> <app_name> <unit_num>`: display app and unit relation data.
- `jclean`: destroy all controllers
+- `jcontroller`: display the controller your are connected to.
+- `jmodel`: display the model your are connected to.
- `wjst [interval_secs] [args_for_watch]`: watch juju status, with optional interval
(default: 5s); you may pass additional arguments to `watch`.
diff --git a/plugins/juju/juju.plugin.zsh b/plugins/juju/juju.plugin.zsh
index be8a2c7ae..0c60e35ce 100644
--- a/plugins/juju/juju.plugin.zsh
+++ b/plugins/juju/juju.plugin.zsh
@@ -163,10 +163,40 @@ jreld() {
juju run "relation-get -r $relid - $2" --unit $2/$3
}
+# Return Juju current controller
+jcontroller() {
+ local controller="$(awk '/current-controller/ {print $2}' ~/.local/share/juju/controllers.yaml)"
+ if [[ -z "$controller" ]]; then
+ return 1
+ fi
+
+ echo $controller
+ return 0
+}
+
+# Return Juju current model
+jmodel() {
+ local yqbin="$(whereis yq | awk '{print $2}')"
+
+ if [[ -z "$yqbin" ]]; then
+ echo "--"
+ return 1
+ fi
+
+ local model="$(yq e ".controllers.$(jcontroller).current-model" < ~/.local/share/juju/models.yaml | cut -d/ -f2)"
+
+ if [[ -z "$model" ]]; then
+ echo "--"
+ return 1
+ fi
+
+ echo $model
+ return 0
+}
+
# Watch juju status, with optional interval (default: 5 sec)
wjst() {
local interval="${1:-5}"
shift $(( $# > 0 ))
watch -n "$interval" --color juju status --relations --color "$@"
}
-
diff --git a/plugins/jump/jump.plugin.zsh b/plugins/jump/jump.plugin.zsh
index c2da1144e..829c9d9cb 100644
--- a/plugins/jump/jump.plugin.zsh
+++ b/plugins/jump/jump.plugin.zsh
@@ -35,12 +35,11 @@ marks() {
max=${#link:t}
fi
done
- local printf_markname_template="$(printf -- "%%%us " "$max")"
+ local printf_markname_template="$(printf -- "%%%us" "$max")"
for link in $MARKPATH/{,.}*(@N); do
- local markname="$fg[cyan]${link:t}$reset_color"
+ local markname="$fg[cyan]$(printf -- "$printf_markname_template" "${link:t}")$reset_color"
local markpath="$fg[blue]$(readlink $link)$reset_color"
- printf -- "$printf_markname_template" "$markname"
- printf -- "-> %s\n" "$markpath"
+ printf -- "%s -> %s\n" "$markname" "$markpath"
done
}
diff --git a/plugins/kind/README.md b/plugins/kind/README.md
new file mode 100644
index 000000000..49024648d
--- /dev/null
+++ b/plugins/kind/README.md
@@ -0,0 +1,22 @@
+# Kind plugin
+
+This plugin adds completion for the [Kind](https://kind.sigs.k8s.io/) tool, as well
+as a few aliases for easier use.
+
+To use it, add `kind` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... kind)
+```
+
+## Aliases
+
+| Alias | Command |
+| ------- | ---------------------------- |
+| `kicc` | `kind create cluster` |
+| `kiccn` | `kind create cluster --name` |
+| `kigc` | `kind get clusters` |
+| `kidc` | `kind delete cluster` |
+| `kidcn` | `kind delete cluster --name` |
+| `kidca` | `kind delete clusters -A` |
+| `kigk` | `kind get kubeconfig` |
diff --git a/plugins/kind/kind.plugin.zsh b/plugins/kind/kind.plugin.zsh
new file mode 100644
index 000000000..183eb7bd6
--- /dev/null
+++ b/plugins/kind/kind.plugin.zsh
@@ -0,0 +1,23 @@
+if (( ! $+commands[kind] )); then
+ return
+fi
+
+# If the completion file doesn't exist yet, we need to autoload it and
+# bind it to `kind`. Otherwise, compinit will have already done that.
+if [[ ! -f "$ZSH_CACHE_DIR/completions/_kind" ]]; then
+ typeset -g -A _comps
+ autoload -Uz _kind
+ _comps[kind]=_kind
+fi
+
+# Generate and load kind completion
+kind completion zsh >! "$ZSH_CACHE_DIR/completions/_kind" &|
+
+# Register aliases
+alias kicc="kind create cluster"
+alias kiccn="kind create cluster --name"
+alias kigc="kind get clusters"
+alias kidc="kind delete cluster"
+alias kidcn="kind delete cluster --name"
+alias kidca="kind delete clusters -A"
+alias kigk="kind get kubeconfig"
diff --git a/plugins/kubectl/kubectl.plugin.zsh b/plugins/kubectl/kubectl.plugin.zsh
index 315d3ce93..0dd4e691a 100644
--- a/plugins/kubectl/kubectl.plugin.zsh
+++ b/plugins/kubectl/kubectl.plugin.zsh
@@ -162,6 +162,7 @@ alias kdelsa="kubectl delete sa"
# DaemonSet management.
alias kgds='kubectl get daemonset'
+alias kgdsa='kubectl get daemonset --all-namespaces'
alias kgdsw='kgds --watch'
alias keds='kubectl edit daemonset'
alias kdds='kubectl describe daemonset'
diff --git a/plugins/lando/README.md b/plugins/lando/README.md
index 6daeae4e4..2f881cf3d 100644
--- a/plugins/lando/README.md
+++ b/plugins/lando/README.md
@@ -8,7 +8,7 @@ To use it, add `lando` to the plugins array in your zshrc file:
plugins=(... lando)
```
-## ALIASES:
+## Wrapped Commands
| Alias | Description |
|:----------:|:----------------:|
@@ -21,16 +21,34 @@ plugins=(... lando)
| `wp` | `lando wp` |
| `yarn` | `lando yarn` |
+More or different commands can be wrapped by setting the `LANDO_ZSH_WRAPPED_COMMANDS` setting, see [Settings](#settings) below.
+
## How It Works:
This plugin removes the requirement to type `lando` before a command. It utilizes the lando version of supported commands run within directories with the following criteria:
+
- The `.lando.yml` file is found in the current directory or any parent directory within `$LANDO_ZSH_SITES_DIRECTORY`.
- The current directory is within `$LANDO_ZSH_SITES_DIRECTORY` but is not `$LANDO_ZSH_SITES_DIRECTORY` itself.
+- If the command is not a part of the commands available in the lando environment, it will run the command without `lando`.
## Settings:
-- `LANDO_ZSH_SITES_DIRECTORY`: The plugin will stop searching through parents for `CONFIG_FILE` once it hits this directory.
-- `LANDO_ZSH_CONFIG_FILE`: The plugin will check to see if this provided file exists to check for presence of Lando.
+> NOTE: these settings must be set *before* the plugin is loaded, and any changes require a restart of the shell to be applied.
+
+- `LANDO_ZSH_SITES_DIRECTORY`: The plugin will stop searching through parents for `CONFIG_FILE` once it hits this directory:
+ ```sh
+ LANDO_ZSH_SITES_DIRECTORY="$HOME/Code"
+ ```
+
+- `LANDO_ZSH_CONFIG_FILE`: The plugin will check to see if this provided file exists to check for presence of Lando:
+ ```sh
+ LANDO_ZSH_CONFIG_FILE=".lando.dev.yml"
+ ```
+
+- `LANDO_ZSH_WRAPPED_COMMANDS`: The list of commands to wrap, as a string of commands separated by whitespace:
+ ```sh
+ LANDO_ZSH_WRAPPED_COMMANDS="mysql php composer test artisan"
+ ```
## Author:
diff --git a/plugins/lando/lando.plugin.zsh b/plugins/lando/lando.plugin.zsh
index af53e7e5a..ee796d212 100644
--- a/plugins/lando/lando.plugin.zsh
+++ b/plugins/lando/lando.plugin.zsh
@@ -1,25 +1,36 @@
# Settings
: ${LANDO_ZSH_SITES_DIRECTORY:="$HOME/Sites"}
: ${LANDO_ZSH_CONFIG_FILE:=.lando.yml}
+: ${LANDO_ZSH_WRAPPED_COMMANDS:="
+ artisan
+ composer
+ drush
+ gulp
+ npm
+ php
+ wp
+ yarn
+"}
# Enable multiple commands with lando.
-function artisan \
- composer \
- drush \
- gulp \
- npm \
- php \
- wp \
- yarn {
- if checkForLandoFile; then
- lando "$0" "$@"
+function ${=LANDO_ZSH_WRAPPED_COMMANDS} {
+ # If the lando task is available in `lando --help`, then it means:
+ #
+ # 1. `lando` is in a project with a `.lando.yml` file.
+ # 2. The lando task is available for lando, based on the .lando.yml config file.
+ #
+ # This has a penalty of about 250ms, so we still want to check if the lando file
+ # exists before, which is the fast path. If it exists, checking help output is
+ # still faster than running the command and failing.
+ if _lando_file_exists && lando --help 2>&1 | command grep -Eq "^ +lando $0 "; then
+ command lando "$0" "$@"
else
command "$0" "$@"
fi
}
# Check for the file in the current and parent directories.
-checkForLandoFile() {
+_lando_file_exists() {
# Only bother checking for lando within the Sites directory.
if [[ "$PWD/" != "$LANDO_ZSH_SITES_DIRECTORY"/* ]]; then
# Not within $LANDO_ZSH_SITES_DIRECTORY
@@ -38,4 +49,4 @@ checkForLandoFile() {
# Could not find $LANDO_ZSH_CONFIG_FILE in the current directory
# or in any of its parents up to $LANDO_ZSH_SITES_DIRECTORY.
return 1
-} \ No newline at end of file
+}
diff --git a/plugins/macos/spotify b/plugins/macos/spotify
index 491a60686..ae42db425 100644
--- a/plugins/macos/spotify
+++ b/plugins/macos/spotify
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
function spotify() {
-# Copyright (c) 2012--2019 Harish Narayanan <mail@harishnarayanan.org>
+# Copyright (c) 2012--2023 Harish Narayanan <mail@harishnarayanan.org>
#
# Contains numerous helpful contributions from Jorge Colindres, Thomas
# Pritchard, iLan Epstein, Gabriele Bonetti, Sean Heller, Eric Martin
@@ -35,6 +35,9 @@ if ! [[ -f "${USER_CONFIG_FILE}" ]]; then
fi
source "${USER_CONFIG_FILE}";
+# Set the percent change in volume for vol up and vol down
+VOL_INCREMENT=10
+
showAPIHelp() {
echo;
echo "Connecting to Spotify's API:";
@@ -43,7 +46,7 @@ showAPIHelp() {
echo " find music by name. It is very likely you want this feature!";
echo;
echo " To get this to work, you need to sign up (or in) and create an 'Application' at:";
- echo " https://developer.spotify.com/my-applications/#!/applications/create";
+ echo " https://developer.spotify.com/dashboard/create";
echo;
echo " Once you've created an application, find the 'Client ID' and 'Client Secret'";
echo " values, and enter them into your shpotify config file at '${USER_CONFIG_FILE}'";
@@ -170,12 +173,12 @@ while [ $# -gt 0 ]; do
if [ -z "${CLIENT_ID}" ]; then
cecho "Invalid Client ID, please update ${USER_CONFIG_FILE}";
showAPIHelp;
- return 1
+ return 1;
fi
if [ -z "${CLIENT_SECRET}" ]; then
cecho "Invalid Client Secret, please update ${USER_CONFIG_FILE}";
showAPIHelp;
- return 1
+ return 1;
fi
SHPOTIFY_CREDENTIALS=$(printf "${CLIENT_ID}:${CLIENT_SECRET}" | base64 | tr -d "\n"|tr -d '\r');
SPOTIFY_PLAY_URI="";
@@ -198,7 +201,7 @@ while [ $# -gt 0 ]; do
fi
SPOTIFY_ACCESS_TOKEN=$( \
printf "${SPOTIFY_TOKEN_RESPONSE_DATA}" \
- | grep -E -o '"access_token":".*",' \
+ | command grep -E -o '"access_token":".*",' \
| sed 's/"access_token"://g' \
| sed 's/"//g' \
| sed 's/,.*//g' \
@@ -219,9 +222,8 @@ while [ $# -gt 0 ]; do
-H "Accept: application/json" \
--data-urlencode "q=$Q" \
-d "type=$type&limit=1&offset=0" \
- | grep -E -o "spotify:$type:[a-zA-Z0-9]+" -m 1
+ | command grep -E -o "spotify:$type:[a-zA-Z0-9]+" -m 1
)
- echo "play uri: ${SPOTIFY_PLAY_URI}"
}
case $2 in
@@ -235,11 +237,11 @@ while [ $# -gt 0 ]; do
results=$( \
curl -s -G $SPOTIFY_SEARCH_API --data-urlencode "q=$Q" -d "type=playlist&limit=10&offset=0" -H "Accept: application/json" -H "Authorization: Bearer ${SPOTIFY_ACCESS_TOKEN}" \
- | grep -E -o "spotify:playlist:[a-zA-Z0-9]+" -m 10 \
+ | command grep -E -o "spotify:playlist:[a-zA-Z0-9]+" -m 10 \
)
count=$( \
- echo "$results" | grep -c "spotify:playlist" \
+ echo "$results" | command grep -c "spotify:playlist" \
)
if [ "$count" -gt 0 ]; then
@@ -333,16 +335,16 @@ while [ $# -gt 0 ]; do
cecho "Current Spotify volume level is $vol.";
break ;
elif [ "$2" = "up" ]; then
- if [ $vol -le 90 ]; then
- newvol=$(( vol+10 ));
+ if [ $vol -le $(( 100-$VOL_INCREMENT )) ]; then
+ newvol=$(( vol+$VOL_INCREMENT ));
cecho "Increasing Spotify volume to $newvol.";
else
newvol=100;
cecho "Spotify volume level is at max.";
fi
elif [ "$2" = "down" ]; then
- if [ $vol -ge 10 ]; then
- newvol=$(( vol-10 ));
+ if [ $vol -ge $(( $VOL_INCREMENT )) ]; then
+ newvol=$(( vol-$VOL_INCREMENT ));
cecho "Reducing Spotify volume to $newvol.";
else
newvol=0;
@@ -354,11 +356,11 @@ while [ $# -gt 0 ]; do
else
echo "Improper use of 'vol' command"
echo "The 'vol' command should be used as follows:"
- echo " vol up # Increases the volume by 10%.";
- echo " vol down # Decreases the volume by 10%.";
+ echo " vol up # Increases the volume by $VOL_INCREMENT%.";
+ echo " vol down # Decreases the volume by $VOL_INCREMENT%.";
echo " vol [amount] # Sets the volume to an amount between 0 and 100.";
echo " vol # Shows the current Spotify volume.";
- return 1
+ return 1;
fi
osascript -e "tell application \"Spotify\" to set sound volume to $newvol";
@@ -468,10 +470,9 @@ while [ $# -gt 0 ]; do
"help" )
showHelp;
break ;;
-
* )
showHelp;
- return 1 ;;
+ return 1;
esac
done
diff --git a/plugins/mvn/README.md b/plugins/mvn/README.md
index 815dfd57c..4181fedc5 100644
--- a/plugins/mvn/README.md
+++ b/plugins/mvn/README.md
@@ -33,7 +33,7 @@ if it's found, or the mvn command otherwise.
| `mvnct` | `mvn clean test` |
| `mvncv` | `mvn clean verify` |
| `mvncvst` | `mvn clean verify -DskipTests` |
-| `mvnd` | `mvn deploy` |
+| `mvndp` | `mvn deploy` |
| `mvndocs` | `mvn dependency:resolve -Dclassifier=javadoc` |
| `mvndt` | `mvn dependency:tree` |
| `mvne` | `mvn eclipse:eclipse` |
diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh
index da51f74df..a569a87fa 100644
--- a/plugins/mvn/mvn.plugin.zsh
+++ b/plugins/mvn/mvn.plugin.zsh
@@ -62,7 +62,7 @@ alias mvncp='mvn clean package'
alias mvnct='mvn clean test'
alias mvncv='mvn clean verify'
alias mvncvst='mvn clean verify -DskipTests'
-alias mvnd='mvn deploy'
+alias mvndp='mvn deploy'
alias mvndocs='mvn dependency:resolve -Dclassifier=javadoc'
alias mvndt='mvn dependency:tree'
alias mvne='mvn eclipse:eclipse'
diff --git a/plugins/npm/README.md b/plugins/npm/README.md
index 8eafc6d61..7848a1290 100644
--- a/plugins/npm/README.md
+++ b/plugins/npm/README.md
@@ -29,6 +29,8 @@ plugins=(... npm)
| `npmI` | `npm init` | Run npm init |
| `npmi` | `npm info` | Run npm info |
| `npmSe` | `npm search` | Run npm search |
+| `npmrd` | `npm run dev` | Run npm run dev |
+| `npmrb` | `npm run build` | Run npm run build |
## `npm install` / `npm uninstall` toggle
diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh
index e0dcbf142..23377b085 100644
--- a/plugins/npm/npm.plugin.zsh
+++ b/plugins/npm/npm.plugin.zsh
@@ -70,6 +70,12 @@ alias npmi="npm info"
# Run npm search
alias npmSe="npm search"
+# Run npm run dev
+alias npmrd="npm run dev"
+
+# Run npm run build
+alias npmrb="npm run build"
+
npm_toggle_install_uninstall() {
# Look up to the previous 2 history commands
local line
diff --git a/plugins/nvm/README.md b/plugins/nvm/README.md
index d3fd980be..b5ef221d3 100644
--- a/plugins/nvm/README.md
+++ b/plugins/nvm/README.md
@@ -26,7 +26,7 @@ These settings should go in your zshrc file, before Oh My Zsh is sourced:
#### Lazy startup
This option will help you to defer nvm's load until you use it to speed-up your zsh startup. This will source
-nvm script only when using it, and will create a function for `node`, `npm`, `pnpm`, `yarn`, and the
+nvm script only when using it, and will create a function for `node`, `npm`, `npx`, `pnpm`, `yarn`, and the
command(s) specified by `lazy-cmd` option, so when you call either of them, nvm will be loaded and run with
default version. To enable it, you can add this snippet to your zshrc, before Oh My Zsh is sourced:
@@ -43,18 +43,16 @@ zstyle ':omz:plugins:nvm' lazy-cmd eslint prettier typescript ...
#### `.nvmrc` autoload
+Note: _this option cannot be used at the same time as `lazy`. `autoload` will override it and load `nvm` at
+startup._
+
If set, the plugin will automatically load a node version when if finds a
[`.nvmrc` file](https://github.com/nvm-sh/nvm#nvmrc) in the current working directory indicating which node
version to load. This can be done, similar as previous options, adding:
```zsh
zstyle ':omz:plugins:nvm' autoload yes
-```
-
-To remove the output generated by NVM when autoloading, you can set the following option:
-
-```zsh
-zstyle ':omz:plugins:nvm' silent-autoload yes
+zstyle ':omz:plugins:nvm' silent-autoload yes # optionally remove the output generated by NVM when autoloading
```
Note: _this will not remove regular `nvm` output_
diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh
index 20697d67d..1badbeab5 100644
--- a/plugins/nvm/nvm.plugin.zsh
+++ b/plugins/nvm/nvm.plugin.zsh
@@ -16,46 +16,25 @@ fi
# Note: nvm is a function so we need to use `which`
which nvm &>/dev/null && return
-# TODO: 2022-11-11: Remove soft-deprecate options
-if (( ${+NVM_LAZY} + ${+NVM_LAZY_CMD} + ${+NVM_AUTOLOAD} )); then
- # Get list of NVM_* variable settings defined
- local -a used_vars
- used_vars=(${(o)parameters[(I)NVM_(AUTOLOAD|LAZY|LAZY_CMD)]})
- # Nicely print the list in the style `var1, var2 and var3`
- echo "${fg[yellow]}[nvm plugin] Variable-style settings are deprecated. Instead of ${(j:, :)used_vars[1,-2]}${used_vars[-2]+ and }${used_vars[-1]}, use:\n"
- if (( $+NVM_AUTOLOAD )); then
- echo " zstyle ':omz:plugins:nvm' autoload yes"
- zstyle ':omz:plugins:nvm' autoload yes
- fi
- if (( $+NVM_LAZY )); then
- echo " zstyle ':omz:plugins:nvm' lazy yes"
- zstyle ':omz:plugins:nvm' lazy yes
- fi
- if (( $+NVM_LAZY_CMD )); then
- echo " zstyle ':omz:plugins:nvm' lazy-cmd $NVM_LAZY_CMD"
- zstyle ':omz:plugins:nvm' lazy-cmd $NVM_LAZY_CMD
- fi
- echo "$reset_color"
- unset used_vars NVM_AUTOLOAD NVM_LAZY NVM_LAZY_CMD
+if [[ -z "$NVM_DIR" ]] || [[ ! -f "$NVM_DIR/nvm.sh" ]]; then
+ return
fi
-if zstyle -t ':omz:plugins:nvm' lazy; then
+if zstyle -t ':omz:plugins:nvm' lazy && \
+ ! zstyle -t ':omz:plugins:nvm' autoload; then
# Call nvm when first using nvm, node, npm, pnpm, yarn or other commands in lazy-cmd
zstyle -a ':omz:plugins:nvm' lazy-cmd nvm_lazy_cmd
eval "
- function nvm node npm pnpm yarn $nvm_lazy_cmd {
- unfunction nvm node npm pnpm yarn $nvm_lazy_cmd
+ function nvm node npm npx pnpm yarn $nvm_lazy_cmd {
+ unfunction nvm node npm npx pnpm yarn $nvm_lazy_cmd
# Load nvm if it exists in \$NVM_DIR
[[ -f \"\$NVM_DIR/nvm.sh\" ]] && source \"\$NVM_DIR/nvm.sh\"
\"\$0\" \"\$@\"
}
"
unset nvm_lazy_cmd
-elif [[ -f "$NVM_DIR/nvm.sh" ]]; then
- # Load nvm if it exists in $NVM_DIR
- source "$NVM_DIR/nvm.sh"
else
- return
+ source "$NVM_DIR/nvm.sh"
fi
# Autoload nvm when finding a .nvmrc file in the current directory
diff --git a/plugins/per-directory-history/per-directory-history.zsh b/plugins/per-directory-history/per-directory-history.zsh
index 7cd673cdb..acbd64757 100644
--- a/plugins/per-directory-history/per-directory-history.zsh
+++ b/plugins/per-directory-history/per-directory-history.zsh
@@ -81,6 +81,7 @@ function per-directory-history-toggle-history() {
autoload per-directory-history-toggle-history
zle -N per-directory-history-toggle-history
bindkey $PER_DIRECTORY_HISTORY_TOGGLE per-directory-history-toggle-history
+bindkey -M vicmd $PER_DIRECTORY_HISTORY_TOGGLE per-directory-history-toggle-history
#-------------------------------------------------------------------------------
# implementation details
diff --git a/plugins/pipenv/README.md b/plugins/pipenv/README.md
index ab1c1e442..e78ef0e3b 100644
--- a/plugins/pipenv/README.md
+++ b/plugins/pipenv/README.md
@@ -1,6 +1,7 @@
# Pipenv
## Installation
+
In your `.zshrc` file, add `pipenv` to the plugins section
```
@@ -8,7 +9,9 @@ plugins=(... pipenv ...)
```
## Features
-This plugin provides some features to simplify the use of Pipenv while working on ZSH.
+
+This plugin provides some features to simplify the use of Pipenv while working on ZSH.
+
- Adds completion for pipenv
- Auto activates and deactivates pipenv shell
- Adds short aliases for common pipenv commands
@@ -23,6 +26,17 @@ This plugin provides some features to simplify the use of Pipenv while working o
- `psh` is aliased to `pipenv shell`
- `psy` is aliased to `pipenv sync`
- `pu` is aliased to `pipenv uninstall`
+ - `pupd` is aliased to `pipenv update`
- `pwh` is aliased to `pipenv --where`
- `pvenv` is aliased to `pipenv --venv`
- `ppy` is aliased to `pipenv --py`
+
+## Configuration
+
+### Shell activation
+
+If you want to disable the shell activation and deactivation feature, add the following style to your `.zshrc` before sourcing `oh-my-zsh.sh`:
+
+```zsh
+zstyle ':omz:plugins:pipenv' auto-shell no
+```
diff --git a/plugins/pipenv/pipenv.plugin.zsh b/plugins/pipenv/pipenv.plugin.zsh
index 244bd6b7c..f81c266a4 100644
--- a/plugins/pipenv/pipenv.plugin.zsh
+++ b/plugins/pipenv/pipenv.plugin.zsh
@@ -12,28 +12,30 @@ fi
_PIPENV_COMPLETE=zsh_source pipenv >| "$ZSH_CACHE_DIR/completions/_pipenv" &|
-# Automatic pipenv shell activation/deactivation
-_togglePipenvShell() {
- # deactivate shell if Pipfile doesn't exist and not in a subdir
- if [[ ! -f "$PWD/Pipfile" ]]; then
- if [[ "$PIPENV_ACTIVE" == 1 ]]; then
- if [[ "$PWD" != "$pipfile_dir"* ]]; then
- exit
+if zstyle -T ':omz:plugins:pipenv' auto-shell; then
+ # Automatic pipenv shell activation/deactivation
+ _togglePipenvShell() {
+ # deactivate shell if Pipfile doesn't exist and not in a subdir
+ if [[ ! -f "$PWD/Pipfile" ]]; then
+ if [[ "$PIPENV_ACTIVE" == 1 ]]; then
+ if [[ "$PWD" != "$pipfile_dir"* ]]; then
+ exit
+ fi
fi
fi
- fi
- # activate the shell if Pipfile exists
- if [[ "$PIPENV_ACTIVE" != 1 ]]; then
- if [[ -f "$PWD/Pipfile" ]]; then
- export pipfile_dir="$PWD"
- pipenv shell
+ # activate the shell if Pipfile exists
+ if [[ "$PIPENV_ACTIVE" != 1 ]]; then
+ if [[ -f "$PWD/Pipfile" ]]; then
+ export pipfile_dir="$PWD"
+ pipenv shell
+ fi
fi
- fi
-}
-autoload -U add-zsh-hook
-add-zsh-hook chpwd _togglePipenvShell
-_togglePipenvShell
+ }
+ autoload -U add-zsh-hook
+ add-zsh-hook chpwd _togglePipenvShell
+ _togglePipenvShell
+fi
# Aliases
alias pch="pipenv check"
@@ -47,6 +49,7 @@ alias prun="pipenv run"
alias psh="pipenv shell"
alias psy="pipenv sync"
alias pu="pipenv uninstall"
+alias pupd="pipenv update"
alias pwh="pipenv --where"
alias pvenv="pipenv --venv"
alias ppy="pipenv --py"
diff --git a/plugins/podman/README.md b/plugins/podman/README.md
new file mode 100644
index 000000000..99daa28cd
--- /dev/null
+++ b/plugins/podman/README.md
@@ -0,0 +1,47 @@
+# Podman plugin
+
+This plugin adds auto-completion and aliases for [podman](https://podman.io/).
+
+To use it add `podman` to the plugins array in your zshrc file.
+
+```zsh
+plugins=(... podman)
+```
+
+## Aliases
+
+| Alias | Command | Description |
+| :------ | :-------------------------------------------- | :--------------------------------------------------------------------------------------- |
+| pbl | `podman build` | Build an image from a Dockerfile |
+| pcin | `podman container inspect` | Display detailed information on one or more containers |
+| pcls | `podman container ls` | List all the running podman containers |
+| pclsa | `podman container ls --all` | List all running and stopped containers |
+| pib | `podman image build` | Build an image from a Dockerfile (same as podman build) |
+| pii | `podman image inspect` | Display detailed information on one or more images |
+| pils | `podman image ls` | List podman images |
+| pipu | `podman image push` | Push an image or repository to a remote registry |
+| pirm | `podman image rm` | Remove one or more images |
+| pit | `podman image tag` | Add a name and tag to a particular image |
+| plo | `podman container logs` | Fetch the logs of a podman container |
+| pnc | `podman network create` | Create a new network |
+| pncn | `podman network connect` | Connect a container to a network |
+| pndcn | `podman network disconnect` | Disconnect a container from a network |
+| pni | `podman network inspect` | Return information about one or more networks |
+| pnls | `podman network ls` | List all networks the engine daemon knows about, including those spanning multiple hosts |
+| pnrm | `podman network rm` | Remove one or more networks |
+| ppo | `podman container port` | List port mappings or a specific mapping for the container |
+| ppu | `podman pull` | Pull an image or a repository from a registry |
+| pr | `podman container run` | Create a new container and start it using the specified command |
+| prit | `podman container run --interactive --tty` | Create a new container and start it in an interactive shell |
+| prm | `podman container rm` | Remove the specified container(s) |
+| prm! | `podman container rm --force` | Force the removal of a running container (uses SIGKILL) |
+| pst | `podman container start` | Start one or more stopped containers |
+| prs | `podman container restart` | Restart one or more containers |
+| psta | `podman stop $(podman ps -q)` | Stop all running containers |
+| pstp | `podman container stop` | Stop one or more running containers |
+| ptop | `podman top` | Display the running processes of a container |
+| pvi | `podman volume inspect` | Display detailed information about one or more volumes |
+| pvls | `podman volume ls` | List all the volumes known to podman |
+| pvprune | `podman volume prune` | Cleanup dangling volumes |
+| pxc | `podman container exec` | Run a new command in a running container |
+| pxcit | `podman container exec --interactive --tty` | Run a new command in a running container in an interactive shell |
diff --git a/plugins/podman/podman.plugin.zsh b/plugins/podman/podman.plugin.zsh
new file mode 100644
index 000000000..97cf92b2a
--- /dev/null
+++ b/plugins/podman/podman.plugin.zsh
@@ -0,0 +1,47 @@
+if (( ! $+commands[podman] )); then
+ return
+fi
+
+# If the completion file doesn't exist yet, we need to autoload it and
+# bind it to `podman`. Otherwise, compinit will have already done that.
+if [[ ! -f "$ZSH_CACHE_DIR/completions/_podman" ]]; then
+ typeset -g -A _comps
+ autoload -Uz _podman
+ _comps[podman]=_podman
+fi
+
+podman completion zsh 2> /dev/null >| "$ZSH_CACHE_DIR/completions/_podman" &|
+
+alias pbl='podman build'
+alias pcin='podman container inspect'
+alias pcls='podman container ls'
+alias pclsa='podman container ls --all'
+alias pib='podman image build'
+alias pii='podman image inspect'
+alias pils='podman image ls'
+alias pipu='podman image push'
+alias pirm='podman image rm'
+alias pit='podman image tag'
+alias plo='podman container logs'
+alias pnc='podman network create'
+alias pncn='podman network connect'
+alias pndcn='podman network disconnect'
+alias pni='podman network inspect'
+alias pnls='podman network ls'
+alias pnrm='podman network rm'
+alias ppo='podman container port'
+alias ppu='podman pull'
+alias pr='podman container run'
+alias prit='podman container run --interactive --tty'
+alias prm='podman container rm'
+alias 'prm!'='podman container rm --force'
+alias pst='podman container start'
+alias prs='podman container restart'
+alias psta='podman stop $(podman ps --quiet)'
+alias pstp='podman container stop'
+alias ptop='podman top'
+alias pvi='podman volume inspect'
+alias pvls='podman volume ls'
+alias pvprune='podman volume prune'
+alias pxc='podman container exec'
+alias pxcit='podman container exec --interactive --tty'
diff --git a/plugins/poetry-env/README.md b/plugins/poetry-env/README.md
new file mode 100644
index 000000000..a7d16563e
--- /dev/null
+++ b/plugins/poetry-env/README.md
@@ -0,0 +1,10 @@
+# Poetry Environment Plugin
+
+This plugin automatically changes poetry environment when you cd into or out of the project directory.
+Note: Script looks for pyproject.toml file to determine poetry if its a poetry environment
+
+To use it, add `poetry-env` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... poetry-env)
+```
diff --git a/plugins/poetry-env/poetry-env.plugin.zsh b/plugins/poetry-env/poetry-env.plugin.zsh
new file mode 100644
index 000000000..86e5fad4e
--- /dev/null
+++ b/plugins/poetry-env/poetry-env.plugin.zsh
@@ -0,0 +1,27 @@
+# Automatic poetry environment activation/deactivation
+_togglePoetryShell() {
+ # deactivate environment if pyproject.toml doesn't exist and not in a subdir
+ if [[ ! -f "$PWD/pyproject.toml" ]] ; then
+ if [[ "$poetry_active" == 1 ]]; then
+ if [[ "$PWD" != "$poetry_dir"* ]]; then
+ export poetry_active=0
+ deactivate
+ return
+ fi
+ fi
+ fi
+
+ # activate the environment if pyproject.toml exists
+ if [[ "$poetry_active" != 1 ]]; then
+ if [[ -f "$PWD/pyproject.toml" ]]; then
+ if grep -q 'tool.poetry' "$PWD/pyproject.toml"; then
+ export poetry_active=1
+ export poetry_dir="$PWD"
+ source "$(poetry env info --path)/bin/activate"
+ fi
+ fi
+ fi
+}
+autoload -U add-zsh-hook
+add-zsh-hook chpwd _togglePoetryShell
+_togglePoetryShell
diff --git a/plugins/postgres/README.md b/plugins/postgres/README.md
index 59445f31c..3f59a8fe4 100644
--- a/plugins/postgres/README.md
+++ b/plugins/postgres/README.md
@@ -19,4 +19,4 @@ plugins=(... postgres)
| stoppost | `pg_ctl -D /usr/local/var/postgres stop -s -m fast` | Stop postgres server |
| restartpost | `stoppost && sleep 1 && startpost` | Restart (calls stop, then start) |
| reloadpost | `pg_ctl reload -D /usr/local/var/postgres -s` | Reload postgres configuration (some setting require restart)|
-| statuspost | `pg_ctl status -D /usr/local/var/postgres -s` | Check startus of postgres server (running, stopped) |
+| statuspost | `pg_ctl status -D /usr/local/var/postgres -s` | Check status of postgres server (running, stopped) |
diff --git a/plugins/pyenv/README.md b/plugins/pyenv/README.md
index b9ee937b7..f1ca3d288 100644
--- a/plugins/pyenv/README.md
+++ b/plugins/pyenv/README.md
@@ -10,6 +10,14 @@ To use it, add `pyenv` to the plugins array in your zshrc file:
plugins=(... pyenv)
```
+If you receive a `Found pyenv, but it is badly configured.` error on startup, you may need to ensure that `pyenv` is initialized before the oh-my-zsh pyenv plugin is loaded. This can be achived by adding the following earlier in the `.zshrc` file than the `plugins=(...)` line:
+
+```zsh
+export PYENV_ROOT="$HOME/.pyenv"
+export PATH="$PYENV_ROOT/bin:$PATH"
+eval "$(pyenv init --path)"
+```
+
## Settings
- `ZSH_PYENV_QUIET`: if set to `true`, the plugin will not print any messages if it
diff --git a/plugins/qodana/README.md b/plugins/qodana/README.md
new file mode 100644
index 000000000..0b68bdecf
--- /dev/null
+++ b/plugins/qodana/README.md
@@ -0,0 +1,20 @@
+# JetBrains Qodana CLI plugin
+
+This plugin adds completion for the [JetBrains Qodana CLI](https://github.com/JetBrains/qodana-cli).
+
+To use it, add `qodana` to the plugins array in your zshrc file:
+
+```zsh
+plugins=(... qodana)
+```
+
+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_CACHE_DIR/completions/_qodana` completions script
diff --git a/plugins/qodana/qodana.plugin.zsh b/plugins/qodana/qodana.plugin.zsh
new file mode 100644
index 000000000..2b92a8051
--- /dev/null
+++ b/plugins/qodana/qodana.plugin.zsh
@@ -0,0 +1,14 @@
+# Autocompletion for the JetBrains Qodana CLI (qodana).
+if (( ! $+commands[qodana] )); then
+ return
+fi
+
+# If the completion file doesn't exist yet, we need to autoload it and
+# bind it to `qodana`. Otherwise, compinit will have already done that.
+if [[ ! -f "$ZSH_CACHE_DIR/completions/_qodana" ]]; then
+ typeset -g -A _comps
+ autoload -Uz _qodana
+ _comps[qodana]=_qodana
+fi
+
+qodana completion zsh >| "$ZSH_CACHE_DIR/completions/_qodana" &|
diff --git a/plugins/rails/README.md b/plugins/rails/README.md
index b2425aabc..c0c37ff3d 100644
--- a/plugins/rails/README.md
+++ b/plugins/rails/README.md
@@ -40,7 +40,10 @@ plugins=(... rails)
| `rn` | `rails notes` | Search for notes (`FIXME`, `TODO`) in code comments |
| `rp` | `rails plugin` | Run a Rails plugin command |
| `rr` | `rails routes` | List all defined routes |
-| `rrg` | `rails routes \| grep` | List and filter the defined routes |
+| `rrc` | `rails routes --controller` | List and filter routes mapped to specific controller |
+| `rre` | `rails routes --expanded` | List all defined routes in expanded table mode |
+| `rrg` | `rails routes --grep` | List and filter the defined routes |
+| `rru` | `rails routes --unused` | List unused routes |
| `rs` | `rails server` | Launch a web server |
| `rsb` | `rails server --bind` | Launch a web server binding it to a specific IP |
| `rsd` | `rails server --debugger` | Launch a web server with debugger |
diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh
index 015dc9ecb..75dd9b0c6 100644
--- a/plugins/rails/rails.plugin.zsh
+++ b/plugins/rails/rails.plugin.zsh
@@ -68,7 +68,10 @@ alias rmd='rails middleware'
alias rn='rails notes'
alias rp='rails plugin'
alias rr='rails routes'
-alias rrg='rails routes | grep'
+alias rrc='rails routes --controller'
+alias rre='rails routes --expanded'
+alias rrg='rails routes --grep'
+alias rru='rails routes --unused'
alias rs='rails server'
alias rsb='rails server --bind'
alias rsd='rails server --debugger'
diff --git a/plugins/rake-fast/rake-fast.plugin.zsh b/plugins/rake-fast/rake-fast.plugin.zsh
index 19dab154b..86e5ed586 100644
--- a/plugins/rake-fast/rake-fast.plugin.zsh
+++ b/plugins/rake-fast/rake-fast.plugin.zsh
@@ -1,5 +1,28 @@
+# The version of the format of .rake_tasks. If the output of _rake_generate
+# changes, incrementing this number will force it to regenerate
+_rake_tasks_version=2
+
_rake_does_task_list_need_generating () {
- [[ ! -f .rake_tasks ]] || [[ Rakefile -nt .rake_tasks ]] || { _is_rails_app && _tasks_changed }
+ _rake_tasks_missing || _rake_tasks_version_changed || _rakefile_has_changes || { _is_rails_app && _tasks_changed }
+}
+
+_rake_tasks_missing () {
+ [[ ! -f .rake_tasks ]]
+}
+
+_rake_tasks_version_changed () {
+ local -a file_version
+ file_version=`head -n 1 .rake_tasks | sed "s/^version\://"`
+
+ if ! [[ $file_version =~ '^[0-9]*$' ]]; then
+ return true
+ fi
+
+ [[ $file_version -ne $_rake_tasks_version ]]
+}
+
+_rakefile_has_changes () {
+ [[ Rakefile -nt .rake_tasks ]]
}
_is_rails_app () {
@@ -20,7 +43,14 @@ _tasks_changed () {
}
_rake_generate () {
- rake --silent --tasks | cut -d " " -f 2 | sed 's/\[.*\]//g' > .rake_tasks
+ echo "version:$_rake_tasks_version" > .rake_tasks
+
+ rake --silent --tasks --all \
+ | sed "s/^rake //" | sed "s/\:/\\\:/g" \
+ | sed "s/\[[^]]*\]//g" \
+ | sed "s/ *# /\:/" \
+ | sed "s/\:$//" \
+ >> .rake_tasks
}
_rake () {
@@ -29,7 +59,10 @@ _rake () {
echo "\nGenerating .rake_tasks..." >&2
_rake_generate
fi
- compadd $(cat .rake_tasks)
+ local -a rake_options
+ rake_options=("${(@f)$(cat .rake_tasks)}")
+ shift rake_options
+ _describe 'rake tasks' rake_options
fi
}
compdef _rake rake
diff --git a/plugins/rtx/README.md b/plugins/rtx/README.md
new file mode 100644
index 000000000..c6436d3a7
--- /dev/null
+++ b/plugins/rtx/README.md
@@ -0,0 +1,30 @@
+## rtx
+
+
+Adds integration with [rtx](https://github.com/jdx/rtx), a runtime executor compatible with npm, nodenv, pyenv, etc. rtx is written in rust and is very fast. 20x-200x faster than asdf. With that being said, rtx is compatible with asdf plugins and .tool-versions files. It can be used as a drop-in replacement.
+
+### Installation
+
+1. [Download & install rtx](https://github.com/jdx/rtx#installation) by running the following:
+
+ ```
+ curl https://rtx.pub/install.sh | sh
+ ```
+
+
+2. [Enable rtx](https://github.com/jdx/rtx#quickstart) by adding it to your `plugins` definition in `~/.zshrc`.
+
+ ```
+ plugins=(rtx)
+ ```
+
+### Usage
+
+See the [rtx readme](https://github.com/jdx/rtx#table-of-contents) for information on how to use rtx. Here are a few examples:
+
+```
+rtx install node Install the current version specified in .tool-versions/.rtx.toml
+rtx use -g node@system Use system node as global default
+rtx install node@20.0.0 Install a specific version number
+rtx use -g node@20 Use node-20.x as global default
+```
diff --git a/plugins/rtx/rtx.plugin.zsh b/plugins/rtx/rtx.plugin.zsh
new file mode 100644
index 000000000..a01828afd
--- /dev/null
+++ b/plugins/rtx/rtx.plugin.zsh
@@ -0,0 +1,18 @@
+# rtx needs to be in $PATH
+if (( ! ${+commands[rtx]} )); then
+ return
+fi
+
+# Load rtx hooks
+eval "$(rtx activate zsh)"
+
+# If the completion file doesn't exist yet, we need to autoload it and
+# bind it to `rtx`. Otherwise, compinit will have already done that.
+if [[ ! -f "$ZSH_CACHE_DIR/completions/_rtx" ]]; then
+ typeset -g -A _comps
+ autoload -Uz _rtx
+ _comps[rtx]=_rtx
+fi
+
+# Generate and load rtx completion
+rtx completion zsh >! "$ZSH_CACHE_DIR/completions/_rtx" &|
diff --git a/plugins/ruby/ruby.plugin.zsh b/plugins/ruby/ruby.plugin.zsh
index 408512110..e09b22c75 100644
--- a/plugins/ruby/ruby.plugin.zsh
+++ b/plugins/ruby/ruby.plugin.zsh
@@ -23,4 +23,4 @@ alias gel="gem lock"
alias geo="gem open"
alias geoe="gem open -e"
alias rrun="ruby -e"
-alias rserver="ruby -e httpd . -p 8080" # requires webrick
+alias rserver="ruby -run -e httpd . -p 8080" # requires webrick
diff --git a/plugins/shell-proxy/README.md b/plugins/shell-proxy/README.md
index b19888c56..102e46b6b 100644
--- a/plugins/shell-proxy/README.md
+++ b/plugins/shell-proxy/README.md
@@ -23,6 +23,7 @@ Set `SHELLPROXY_URL` environment variable to the URL of the proxy server:
```sh
SHELLPROXY_URL="http://127.0.0.1:8123"
+SHELLPROXY_NO_PROXY="localhost,127.0.0.1"
proxy enable
```
@@ -36,11 +37,15 @@ Example:
```sh
#!/bin/bash
+# HTTP Proxy
if [[ "$(uname)" = Darwin ]]; then
echo "http://127.0.0.1:6152" # Surge Mac
else
echo "http://127.0.0.1:8123" # polipo
fi
+
+# No Proxy
+echo "localhost,127.0.0.1"
```
### Method 3
diff --git a/plugins/shell-proxy/proxy.py b/plugins/shell-proxy/proxy.py
index 14f2944cc..8c2aaf9f3 100755
--- a/plugins/shell-proxy/proxy.py
+++ b/plugins/shell-proxy/proxy.py
@@ -6,6 +6,7 @@ from subprocess import check_output, list2cmdline
cwd = os.path.dirname(__file__)
ssh_agent = os.path.join(cwd, "ssh-agent.py")
proxy_env = "SHELLPROXY_URL"
+no_proxy_env = "SHELLPROXY_NO_PROXY"
proxy_config = os.environ.get("SHELLPROXY_CONFIG") or os.path.expandvars("$HOME/.config/proxy")
usage="""shell-proxy: no proxy configuration found.
@@ -15,18 +16,30 @@ See the plugin README for more information.""".format(env=proxy_env, config=prox
def get_http_proxy():
default_proxy = os.environ.get(proxy_env)
- if default_proxy:
- return default_proxy
+ no_proxy = os.environ.get(no_proxy_env)
+ if default_proxy and no_proxy:
+ return default_proxy, no_proxy
+
if os.path.isfile(proxy_config):
- return check_output(proxy_config).decode("utf-8").strip()
+ proxy_configdata = [line.strip() for line in check_output(proxy_config).decode("utf-8").splitlines()]
+ if len(proxy_configdata) >= 1:
+ if not default_proxy:
+ default_proxy = proxy_configdata[0]
+ if len(proxy_configdata) == 2 and not no_proxy:
+ no_proxy = proxy_configdata[1]
+
+ if default_proxy:
+ return default_proxy, no_proxy
print(usage, file=sys.stderr)
sys.exit(1)
-def make_proxies(url: str):
+def make_proxies(url: str, no_proxy: str):
proxies = {"%s_PROXY" % _: url for _ in ("HTTP", "HTTPS", "FTP", "RSYNC", "ALL")}
proxies.update({name.lower(): value for (name, value) in proxies.items()})
proxies["GIT_SSH"] = ssh_agent
+ if no_proxy:
+ proxies.update({"NO_PROXY": no_proxy, "no_proxy": no_proxy})
return proxies
@@ -35,7 +48,7 @@ def merge(mapping: dict):
class CommandSet:
- proxies = make_proxies(get_http_proxy())
+ proxies = make_proxies(*get_http_proxy())
aliases = {
_: "env __SSH_PROGRAM_NAME__=%s %s" % (_, ssh_agent)
for _ in ("ssh", "sftp", "scp", "slogin", "ssh-copy-id")
diff --git a/plugins/shell-proxy/shell-proxy.plugin.zsh b/plugins/shell-proxy/shell-proxy.plugin.zsh
index 4fdbe9322..f6c31da45 100644
--- a/plugins/shell-proxy/shell-proxy.plugin.zsh
+++ b/plugins/shell-proxy/shell-proxy.plugin.zsh
@@ -27,7 +27,7 @@ eval '
# capture the output of the proxy script and bail out if it fails
local output
- output="$(SHELLPROXY_URL="$SHELLPROXY_URL" SHELLPROXY_CONFIG="$SHELLPROXY_CONFIG" "$proxy" "$1")" ||
+ output="$(SHELLPROXY_URL="$SHELLPROXY_URL" SHELLPROXY_NO_PROXY="$SHELLPROXY_NO_PROXY" SHELLPROXY_CONFIG="$SHELLPROXY_CONFIG" "$proxy" "$1")" ||
return $?
# evaluate the output generated by the proxy script
diff --git a/plugins/snap/README.md b/plugins/snap/README.md
new file mode 100644
index 000000000..75c5ec19a
--- /dev/null
+++ b/plugins/snap/README.md
@@ -0,0 +1,18 @@
+# snap plugin
+
+This plugin sets up aliases for the common [snap](https://snapcraft.io/docs/getting-started) commands
+
+## Aliases
+
+| Alias | Full command |
+| --- | ---|
+| sv | snap version |
+| sf | snap find |
+| si | snap install |
+| sin | snap info |
+| sr | snap remove |
+| sref | snap refresh |
+| srev | snap revert |
+| sl | snap list |
+| sd | snap disable |
+| se | snap enable |
diff --git a/plugins/snap/snap.plugin.zsh b/plugins/snap/snap.plugin.zsh
new file mode 100644
index 000000000..af2346978
--- /dev/null
+++ b/plugins/snap/snap.plugin.zsh
@@ -0,0 +1,10 @@
+alias sv="snap version"
+alias sf="snap find"
+alias si="snap install"
+alias sin="snap info"
+alias sr="snap remove"
+alias sref="snap refresh"
+alias srev="snap revert"
+alias sl="snap list"
+alias sd="snap disable"
+alias se="snap enable"
diff --git a/plugins/ssh-agent/README.md b/plugins/ssh-agent/README.md
index fa6a996d4..8c118e65b 100644
--- a/plugins/ssh-agent/README.md
+++ b/plugins/ssh-agent/README.md
@@ -99,6 +99,33 @@ ssh-add -K -c -a /run/user/1000/ssh-auth <identities>
For valid `ssh-add` arguments run `ssh-add --help` or `man ssh-add`.
+### Powerline 10k specific settings
+
+Powerline10k has an instant prompt setting that doesn't like when this plugin
+writes to the console. Consider using the following settings if you're using
+p10k (documented above):
+
+```
+zstyle :omz:plugins:ssh-agent quiet yes
+zstyle :omz:plugins:ssh-agent lazy yes
+```
+
+### macOS specific settings
+
+macOS supports using passphrases stored in the keychain when adding identities
+to the ssh-agent.
+
+```
+ssh-add --apple-use-keychain ~/.ssh/id_rsa ...
+```
+
+
+This plugin can be configured to use the keychain when loading using the following:
+
+```
+zstyle :omz:plugins:ssh-agent ssh-add-args --apple-load-keychain
+```
+
## Credits
Based on code from Joseph M. Reagle: https://www.cygwin.com/ml/cygwin/2001-06/msg00537.html
diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh
index 78ac46b13..49ad95a11 100644
--- a/plugins/ssh-agent/ssh-agent.plugin.zsh
+++ b/plugins/ssh-agent/ssh-agent.plugin.zsh
@@ -13,6 +13,11 @@ function _start_agent() {
fi
fi
+ if [[ ! -d "$HOME/.ssh" ]]; then
+ echo "[oh-my-zsh] ssh-agent plugin requires ~/.ssh directory"
+ return 1
+ fi
+
# Set a maximum lifetime for identities added to ssh-agent
local lifetime
zstyle -s :omz:plugins:ssh-agent lifetime lifetime
diff --git a/plugins/starship/README.md b/plugins/starship/README.md
new file mode 100644
index 000000000..0e66c5294
--- /dev/null
+++ b/plugins/starship/README.md
@@ -0,0 +1,21 @@
+# starship plugin
+
+Initializes [starship prompt](https://starship.rs) - a minimal, blazing-fast and infinitely customizable cross-shell prompt.
+
+[Demo](https://user-images.githubusercontent.com/62098008/169764279-50b48262-9506-4651-ba89-f6611a88ebf0.mp4)
+
+[External repository](https://github.com/axieax/zsh-starship) for this zsh plugin.
+
+# Installation
+
+**Note:** you have to [install starship](https://starship.rs/guide/#%F0%9F%9A%80-installation) first.
+
+## [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh)
+
+Add `starship` to the plugins array in your `.zshrc` file:
+
+```zsh
+plugins=(... starship)
+```
+
+## ⚠️ ENABLING THIS PLUGIN WILL UNSET YOUR ZSH_THEME VARIABLE
diff --git a/plugins/starship/starship.plugin.zsh b/plugins/starship/starship.plugin.zsh
new file mode 100644
index 000000000..8c5d9135e
--- /dev/null
+++ b/plugins/starship/starship.plugin.zsh
@@ -0,0 +1,8 @@
+# ignore oh-my-zsh theme
+unset ZSH_THEME
+
+if (( $+commands[starship] )); then
+ eval "$(starship init zsh)"
+else
+ echo '[oh-my-zsh] starship not found, please install it from https://starship.rs'
+fi
diff --git a/plugins/systemadmin/systemadmin.plugin.zsh b/plugins/systemadmin/systemadmin.plugin.zsh
index 7ce62bac1..03dd995b6 100644
--- a/plugins/systemadmin/systemadmin.plugin.zsh
+++ b/plugins/systemadmin/systemadmin.plugin.zsh
@@ -13,11 +13,11 @@
# ------------------------------------------------------------------------------
function retlog() {
- if [[ -z $1 ]];then
- echo '/var/log/nginx/access.log'
- else
- echo $1
- fi
+ if [[ -z $1 ]];then
+ echo '/var/log/nginx/access.log'
+ else
+ echo $1
+ fi
}
alias ping='ping -c 5'
@@ -28,142 +28,160 @@ alias mkdir='mkdir -pv'
alias psmem='ps -e -orss=,args= | sort -b -k1 -nr'
alias psmem10='ps -e -orss=,args= | sort -b -k1 -nr | head -n 10'
# get top process eating cpu if not work try execute : export LC_ALL='C'
-alias pscpu='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr'
-alias pscpu10='ps -e -o pcpu,cpu,nice,state,cputime,args|sort -k1,1n -nr | head -n 10'
+alias pscpu='ps -e -o pcpu,cpu,nice,state,cputime,args | sort -k1,1n -nr'
+alias pscpu10='ps -e -o pcpu,cpu,nice,state,cputime,args | sort -k1,1n -nr | head -n 10'
# top10 of the history
alias hist10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
function ip() {
- if [ -t 1 ]; then
- command ip -color "$@"
- else
- command ip "$@"
- fi
+ if [ -t 1 ]; then
+ command ip -color "$@"
+ else
+ command ip "$@"
+ fi
}
# directory LS
function dls() {
- print -l *(/)
+ print -l *(/)
}
function psgrep() {
- ps aux | grep "${1:-.}" | grep -v grep
+ ps aux | grep "${1:-.}" | grep -v grep
}
# Kills any process that matches a regexp passed to it
function killit() {
- ps aux | grep -v "grep" | grep "$@" | awk '{print $2}' | xargs sudo kill
+ ps aux | grep -v "grep" | grep "$@" | awk '{print $2}' | xargs sudo kill
}
# list contents of directories in a tree-like format
if ! (( $+commands[tree] )); then
- function tree() {
- find $@ -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
- }
+ function tree() {
+ find $@ -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
+ }
fi
# Sort connection state
function sortcons() {
- netstat -nat |awk '{print $6}'|sort|uniq -c|sort -rn
+ {
+ LANG= ss -nat | awk 'NR > 1 {print $1}' \
+ || LANG= netstat -nat | awk 'NR > 2 {print $6}'
+ } | sort | uniq -c | sort -rn
}
# View all 80 Port Connections
function con80() {
- netstat -nat|grep -i ":80"|wc -l
+ {
+ LANG= ss -nat || LANG= netstat -nat
+ } | grep -E ":80[^0-9]" | wc -l
}
# On the connected IP sorted by the number of connections
function sortconip() {
- netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
+ {
+ LANG= ss -ntu | awk 'NR > 1 {print $6}' \
+ || LANG= netstat -ntu | awk 'NR > 2 {print $5}'
+ } | cut -d: -f1 | sort | uniq -c | sort -n
}
# top20 of Find the number of requests on 80 port
function req20() {
- netstat -anlp|grep 80|grep tcp|awk '{print $5}'|awk -F: '{print $1}'|sort|uniq -c|sort -nr|head -n20
+ {
+ LANG= ss -tn | awk '$4 ~ /:80$/ {print $5}' \
+ || LANG= netstat -tn | awk '$4 ~ /:80$/ {print $5}'
+ } | awk -F: '{print $1}' | sort | uniq -c | sort -nr | head -n 20
}
# top20 of Using tcpdump port 80 access to view
function http20() {
- sudo tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F"." '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort -nr |head -n 20
+ sudo tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F"." '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort -nr | head -n 20
}
# top20 of Find time_wait connection
function timewait20() {
- netstat -n|grep TIME_WAIT|awk '{print $5}'|sort|uniq -c|sort -rn|head -n20
+ {
+ LANG= ss -nat | awk 'NR > 1 && /TIME-WAIT/ {print $5}' \
+ || LANG= netstat -nat | awk 'NR > 2 && /TIME_WAIT/ {print $5}'
+ } | sort | uniq -c | sort -rn | head -n 20
}
# top20 of Find SYN connection
function syn20() {
- netstat -an | grep SYN | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | sort -nr|head -n20
+ {
+ LANG= ss -an | awk '/SYN/ {print $5}' \
+ || LANG= netstat -an | awk '/SYN/ {print $5}'
+ } | awk -F: '{print $1}' | sort | uniq -c | sort -nr | head -n20
}
# Printing process according to the port number
function port_pro() {
- netstat -ntlp | grep "${1:-.}" | awk '{print $7}' | cut -d/ -f1
+ LANG= ss -ntlp | awk "NR > 1 && /:${1:-}/ {print \$6}" | sed 's/.*pid=\([^,]*\).*/\1/' \
+ || LANG= netstat -ntlp | awk "NR > 2 && /:${1:-}/ {print \$7}" | cut -d/ -f1
}
# top10 of gain access to the ip address
function accessip10() {
- awk '{counts[$(11)]+=1}; END {for(url in counts) print counts[url], url}' "$(retlog)"
+ awk '{counts[$(11)]+=1}; END {for(url in counts) print counts[url], url}' "$(retlog)"
}
# top20 of Most Visited file or page
function visitpage20() {
- awk '{print $11}' "$(retlog)"|sort|uniq -c|sort -nr|head -n 20
+ awk '{print $11}' "$(retlog)" | sort | uniq -c | sort -nr | head -n 20
}
# top100 of Page lists the most time-consuming (more than 60 seconds) as well as the corresponding page number of occurrences
function consume100() {
- awk '($NF > 60 && $7~/\.php/){print $7}' "$(retlog)" |sort -n|uniq -c|sort -nr|head -n 100
- # if django website or other website make by no suffix language
- # awk '{print $7}' "$(retlog)" |sort -n|uniq -c|sort -nr|head -n 100
+ awk '($NF > 60 && $7~/\.php/){print $7}' "$(retlog)" | sort -n | uniq -c | sort -nr | head -n 100
+ # if django website or other website make by no suffix language
+ # awk '{print $7}' "$(retlog)" | sort -n | uniq -c | sort -nr | head -n 100
}
# Website traffic statistics (G)
function webtraffic() {
- awk "{sum+=$10} END {print sum/1024/1024/1024}" "$(retlog)"
+ awk "{sum+=$10} END {print sum/1024/1024/1024}" "$(retlog)"
}
# Statistical connections 404
function c404() {
- awk '($9 ~/404/)' "$(retlog)" | awk '{print $9,$7}' | sort
+ awk '($9 ~ /404/)' "$(retlog)" | awk '{print $9,$7}' | sort
}
# Statistical http status.
function httpstatus() {
- awk '{counts[$(9)]+=1}; END {for(code in counts) print code, counts[code]}' "$(retlog)"
+ awk '{counts[$(9)]+=1}; END {for(code in counts) print code, counts[code]}' "$(retlog)"
}
# Delete 0 byte file
function d0() {
- find "${1:-.}" -type f -size 0 -exec rm -rf {} \;
+ find "${1:-.}" -type f -size 0 -exec rm -rf {} \;
}
# gather external ip address
function geteip() {
- curl -s -S -4 https://icanhazip.com
+ curl -s -S -4 https://icanhazip.com
- # handle case when there is no IPv6 external IP, which shows error
- # curl: (7) Couldn't connect to server
- curl -s -S -6 https://icanhazip.com 2>/dev/null
- local ret=$?
- (( ret == 7 )) && print -P -u2 "%F{red}error: no IPv6 route to host%f"
- return $ret
+ # handle case when there is no IPv6 external IP, which shows error
+ # curl: (7) Couldn't connect to server
+ curl -s -S -6 https://icanhazip.com 2>/dev/null
+ local ret=$?
+ (( ret == 7 )) && print -P -u2 "%F{red}error: no IPv6 route to host%f"
+ return $ret
}
# determine local IP address(es)
function getip() {
- if (( ${+commands[ip]} )); then
- ip addr | awk '/inet /{print $2}' | command grep -v 127.0.0.1
- else
- ifconfig | awk '/inet /{print $2}' | command grep -v 127.0.0.1
- fi
+ if (( ${+commands[ip]} )); then
+ ip addr | awk '/inet /{print $2}' | command grep -v 127.0.0.1
+ else
+ ifconfig | awk '/inet /{print $2}' | command grep -v 127.0.0.1
+ fi
}
# Clear zombie processes
function clrz() {
- ps -eal | awk '{ if ($2 == "Z") {print $4}}' | kill -9
+ ps -eal | awk '{ if ($2 == "Z") {print $4}}' | kill -9
}
# Second concurrent
function conssec() {
- awk '{if($9~/200|30|404/)COUNT[$4]++}END{for( a in COUNT) print a,COUNT[a]}' "$(retlog)"|sort -k 2 -nr|head -n10
+ awk '{if($9~/200|30|404/)COUNT[$4]++}END{for( a in COUNT) print a,COUNT[a]}' "$(retlog)" | sort -k 2 -nr | head -n10
}
diff --git a/plugins/systemd/README.md b/plugins/systemd/README.md
index ffa0567a8..755c649a1 100644
--- a/plugins/systemd/README.md
+++ b/plugins/systemd/README.md
@@ -12,6 +12,7 @@ plugins=(... systemd)
| Alias | Command | Description |
|:-----------------------|:-----------------------------------|:-----------------------------------------------------------------|
+| `sc-failed` | `systemctl --failed` | List failed systemd units |
| `sc-list-units` | `systemctl list-units` | List all units systemd has in memory |
| `sc-is-active` | `systemctl is-active` | Show whether a unit is active |
| `sc-status` | `systemctl status` | Show terse runtime status information about one or more units |
diff --git a/plugins/systemd/systemd.plugin.zsh b/plugins/systemd/systemd.plugin.zsh
index 1270bea0e..382a57b29 100644
--- a/plugins/systemd/systemd.plugin.zsh
+++ b/plugins/systemd/systemd.plugin.zsh
@@ -93,6 +93,9 @@ alias scu-enable-now="scu-enable --now"
alias scu-disable-now="scu-disable --now"
alias scu-mask-now="scu-mask --now"
+# --failed commands
+alias scu-failed='systemctl --user --failed'
+alias sc-failed='systemctl --failed'
function systemd_prompt_info {
local unit
diff --git a/plugins/term_tab/term_tab.plugin.zsh b/plugins/term_tab/term_tab.plugin.zsh
index 1b612df68..89acd9103 100644
--- a/plugins/term_tab/term_tab.plugin.zsh
+++ b/plugins/term_tab/term_tab.plugin.zsh
@@ -28,6 +28,7 @@ function _term_list(){
case $OSTYPE in
solaris*) dirs=( ${(M)${${(f)"$(pgrep -U $UID -x zsh|xargs pwdx)"}:#$$:*}%%/*} ) ;;
linux*) dirs=( /proc/${^$(pidof zsh):#$$}/cwd(N:A) ) ;;
+ darwin*) dirs=( $( lsof -d cwd -c zsh -a -w -Fn | sed -n 's/^n//p' ) ) ;;
esac
dirs=( ${(D)dirs} )
diff --git a/plugins/terraform/README.md b/plugins/terraform/README.md
index c19f2ad1c..fc9a9f005 100644
--- a/plugins/terraform/README.md
+++ b/plugins/terraform/README.md
@@ -1,7 +1,7 @@
# Terraform plugin
-Plugin for Terraform, a tool from Hashicorp for managing infrastructure safely and efficiently.
-It adds completion for `terraform`, as well as aliases and a prompt function.
+Plugin for Terraform, a tool from Hashicorp for managing infrastructure safely and efficiently. It adds
+completion for `terraform`, as well as aliases and a prompt function.
To use it, add `terraform` to the plugins array of your `~/.zshrc` file:
@@ -11,7 +11,7 @@ plugins=(... terraform)
## Requirements
-* [Terraform](https://terraform.io/)
+- [Terraform](https://terraform.io/)
## Aliases
@@ -29,11 +29,12 @@ plugins=(... terraform)
## Prompt function
-You can add the current Terraform workspace in your prompt by adding `$(tf_prompt_info)`
-to your `PROMPT` or `RPROMPT` variable.
+You can add the current Terraform workspace in your prompt by adding `$(tf_prompt_info)`,
+`$(tf_version_prompt_info)` to your `PROMPT` or `RPROMPT` variable.
```sh
RPROMPT='$(tf_prompt_info)'
+RPROMPT='$(tf_version_prompt_info)'
```
You can also specify the PREFIX and SUFFIX for the workspace with the following variables:
@@ -41,4 +42,6 @@ You can also specify the PREFIX and SUFFIX for the workspace with the following
```sh
ZSH_THEME_TF_PROMPT_PREFIX="%{$fg[white]%}"
ZSH_THEME_TF_PROMPT_SUFFIX="%{$reset_color%}"
+ZSH_THEME_TF_VERSION_PROMPT_PREFIX="%{$fg[white]%}"
+ZSH_THEME_TF_VERSION_PROMPT_SUFFIX="%{$reset_color%}"
```
diff --git a/plugins/terraform/terraform.plugin.zsh b/plugins/terraform/terraform.plugin.zsh
index 7006f204b..ccca54684 100644
--- a/plugins/terraform/terraform.plugin.zsh
+++ b/plugins/terraform/terraform.plugin.zsh
@@ -8,6 +8,13 @@ function tf_prompt_info() {
echo "${ZSH_THEME_TF_PROMPT_PREFIX-[}${workspace:gs/%/%%}${ZSH_THEME_TF_PROMPT_SUFFIX-]}"
}
+function tf_version_prompt_info() {
+ local terraform_version
+ terraform_version=$(terraform --version | head -n 1 | cut -d ' ' -f 2)
+ echo "${ZSH_THEME_TF_VERSION_PROMPT_PREFIX-[}${terraform_version:gs/%/%%}${ZSH_THEME_TF_VERSION_PROMPT_SUFFIX-]}"
+}
+
+
alias tf='terraform'
alias tfa='terraform apply'
alias tfc='terraform console'
diff --git a/plugins/tig/tig.plugin.zsh b/plugins/tig/tig.plugin.zsh
index 7e0c530ac..5b7d2550a 100644
--- a/plugins/tig/tig.plugin.zsh
+++ b/plugins/tig/tig.plugin.zsh
@@ -1,3 +1,5 @@
alias tis='tig status'
alias til='tig log'
alias tib='tig blame -C'
+alias tif='tig reflog'
+alias tia='tig --all'
diff --git a/plugins/tmux/README.md b/plugins/tmux/README.md
index 7348f77c9..b4516ef26 100644
--- a/plugins/tmux/README.md
+++ b/plugins/tmux/README.md
@@ -25,19 +25,20 @@ The plugin also supports the following:
| `tkss` | tmux kill-session -t | Terminate named running tmux session |
| `tmux` | `_zsh_tmux_plugin_run` | Start a new tmux session |
| `tmuxconf` | `$EDITOR $ZSH_TMUX_CONFIG` | Open .tmux.conf file with an editor |
+| `tds` | `_tmux_directory_session` | Creates or attaches to a session for the current path |
## Configuration Variables
-| Variable | Description |
-| ----------------------------------- | ----------------------------------------------------------------------------- |
-| `ZSH_TMUX_AUTOSTART` | Automatically starts tmux (default: `false`) |
-| `ZSH_TMUX_AUTOSTART_ONCE` | Autostart only if tmux hasn't been started previously (default: `true`) |
-| `ZSH_TMUX_AUTOCONNECT` | Automatically connect to a previous session if it exits (default: `true`) |
-| `ZSH_TMUX_AUTOQUIT` | Automatically closes terminal once tmux exits (default: `ZSH_TMUX_AUTOSTART`) |
-| `ZSH_TMUX_FIXTERM` | Sets `$TERM` to 256-color term or not based on current terminal support |
-| `ZSH_TMUX_ITERM2` | Sets the `-CC` option for iTerm2 tmux integration (default: `false`) |
-| `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `screen`) |
-| `ZSH_TMUX_FIXTERM_WITH_256COLOR` | `$TERM` to use for 256-color terminals (default: `screen-256color` |
-| `ZSH_TMUX_CONFIG` | Set the configuration path (default: `$HOME/.tmux.conf`) |
-| `ZSH_TMUX_UNICODE` | Set `tmux -u` option to support unicode |
-| `ZSH_TMUX_DEFAULT_SESSION_NAME` | Set tmux default session name when autostart is enabled |
+| Variable | Description |
+| ----------------------------------- | ------------------------------------------------------------------------------------------- |
+| `ZSH_TMUX_AUTOSTART` | Automatically starts tmux (default: `false`) |
+| `ZSH_TMUX_AUTOSTART_ONCE` | Autostart only if tmux hasn't been started previously (default: `true`) |
+| `ZSH_TMUX_AUTOCONNECT` | Automatically connect to a previous session if it exits (default: `true`) |
+| `ZSH_TMUX_AUTOQUIT` | Automatically closes terminal once tmux exits (default: `ZSH_TMUX_AUTOSTART`) |
+| `ZSH_TMUX_FIXTERM` | Sets `$TERM` to 256-color term or not based on current terminal support |
+| `ZSH_TMUX_ITERM2` | Sets the `-CC` option for iTerm2 tmux integration (default: `false`) |
+| `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `screen`) |
+| `ZSH_TMUX_FIXTERM_WITH_256COLOR` | `$TERM` to use for 256-color terminals (default: `screen-256color` |
+| `ZSH_TMUX_CONFIG` | Set the configuration path (default: `$HOME/.tmux.conf`, `$XDG_CONFIG_HOME/tmux/tmux.conf`) |
+| `ZSH_TMUX_UNICODE` | Set `tmux -u` option to support unicode |
+| `ZSH_TMUX_DEFAULT_SESSION_NAME` | Set tmux default session name when autostart is enabled |
diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh
index 311c2e6a9..72cdd4818 100644
--- a/plugins/tmux/tmux.plugin.zsh
+++ b/plugins/tmux/tmux.plugin.zsh
@@ -26,12 +26,17 @@ fi
# systems without the proper terminfo
: ${ZSH_TMUX_FIXTERM_WITH_256COLOR:=screen-256color}
# Set the configuration path
-: ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf}
+if [[ -e $HOME/.tmux.conf ]]; then
+ : ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf}
+elif [[ -e ${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf ]]; then
+ : ${ZSH_TMUX_CONFIG:=${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf}
+else
+ : ${ZSH_TMUX_CONFIG:=$HOME/.tmux.conf}
+fi
# Set -u option to support unicode
: ${ZSH_TMUX_UNICODE:=false}
# ALIASES
-
alias ta='tmux attach -t'
alias tad='tmux attach -d -t'
alias ts='tmux new-session -s'
@@ -103,8 +108,21 @@ compdef _tmux _zsh_tmux_plugin_run
# Alias tmux to our wrapper function.
alias tmux=_zsh_tmux_plugin_run
+function _tmux_directory_session() {
+ # current directory without leading path
+ local dir=${PWD##*/}
+ # md5 hash for the full working directory path
+ local md5=$(printf '%s' "$PWD" | md5sum | cut -d ' ' -f 1)
+ # human friendly unique session name for this directory
+ local session_name="${dir}-${md5:0:6}"
+ # create or attach to the session
+ tmux new -As "$session_name"
+}
+
+alias tds=_tmux_directory_session
+
# Autostart if not already in tmux and enabled.
-if [[ -z "$TMUX" && "$ZSH_TMUX_AUTOSTART" == "true" && -z "$INSIDE_EMACS" && -z "$EMACS" && -z "$VIM" ]]; then
+if [[ -z "$TMUX" && "$ZSH_TMUX_AUTOSTART" == "true" && -z "$INSIDE_EMACS" && -z "$EMACS" && -z "$VIM" && -z "$INTELLIJ_ENVIRONMENT_READER" ]]; then
# Actually don't autostart if we already did and multiple autostarts are disabled.
if [[ "$ZSH_TMUX_AUTOSTART_ONCE" == "false" || "$ZSH_TMUX_AUTOSTARTED" != "true" ]]; then
export ZSH_TMUX_AUTOSTARTED=true
diff --git a/plugins/toolbox/README.md b/plugins/toolbox/README.md
index abaca31f4..bc04a906b 100644
--- a/plugins/toolbox/README.md
+++ b/plugins/toolbox/README.md
@@ -22,4 +22,5 @@ RPROMPT='$(toolbox_prompt_info)'
| Alias | Command | Description |
|-------|----------------------|----------------------------------------|
-| tb | `toolbox enter` | Enters the toolbox environment |
+| tbe | `toolbox enter` | Enters the toolbox environment |
+| tbr | `toolbox run` | Run a command in an existing toolbox |
diff --git a/plugins/toolbox/toolbox.plugin.zsh b/plugins/toolbox/toolbox.plugin.zsh
index d24d6d396..377e498cd 100644
--- a/plugins/toolbox/toolbox.plugin.zsh
+++ b/plugins/toolbox/toolbox.plugin.zsh
@@ -2,4 +2,5 @@ function toolbox_prompt_info() {
[[ -f /run/.toolboxenv ]] && echo "⬢"
}
-alias tb="toolbox enter"
+alias tbe="toolbox enter"
+alias tbr="toolbox run"
diff --git a/plugins/ubuntu/README.md b/plugins/ubuntu/README.md
index 2401c102b..20f5c65ee 100644
--- a/plugins/ubuntu/README.md
+++ b/plugins/ubuntu/README.md
@@ -15,7 +15,7 @@ Commands that use `$APT` will use `apt` if installed or defer to `apt-get` other
| Alias | Command | Description |
|---------|--------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------|
| age | `sudo $APT` | Run apt-get with sudo |
-| acse | `apt-cache search` | Search the apt-cache with the specified criteria |
+| acs | `apt-cache search` | Search the apt-cache with the specified criteria |
| acsp | `apt-cache showpkg` | Shows information about the listed packages |
| acp | `apt-cache policy` | Display the package source priorities |
| afs | `apt-file search --regexp` | Perform a regular expression apt-file search |
diff --git a/plugins/ubuntu/ubuntu.plugin.zsh b/plugins/ubuntu/ubuntu.plugin.zsh
index 4d35da2ac..7b765a406 100644
--- a/plugins/ubuntu/ubuntu.plugin.zsh
+++ b/plugins/ubuntu/ubuntu.plugin.zsh
@@ -1,6 +1,6 @@
(( $+commands[apt] )) && APT=apt || APT=apt-get
-alias acse='apt-cache search'
+alias acs='apt-cache search'
alias afs='apt-file search --regexp'
diff --git a/plugins/vi-mode/README.md b/plugins/vi-mode/README.md
index 0cb516751..821c12adb 100644
--- a/plugins/vi-mode/README.md
+++ b/plugins/vi-mode/README.md
@@ -144,11 +144,17 @@ NOTE: this used to be bound to `v`. That is now the default (`visual-mode`).
- `c{motion}` : Delete {motion} text and start insert
- `cc` : Delete line and start insert
- `C` : Delete to the end of the line and start insert
+- `P` : Insert the contents of the clipboard before the cursor
+- `p` : Insert the contents of the clipboard after the cursor
- `r{char}` : Replace the character under the cursor with {char}
- `R` : Enter replace mode: Each character replaces existing one
- `x` : Delete `count` characters under and after the cursor
- `X` : Delete `count` characters before the cursor
+NOTE: delete/kill commands (`dd`, `D`, `c{motion}`, `C`, `x`,`X`) and yank commands
+(`y`, `Y`) will copy to the clipboard. Contents can then be put back using paste commands
+(`P`, `p`).
+
## Known issues
### Low `$KEYTIMEOUT`
diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh
index 9a410c1fb..8fefaf86c 100644
--- a/plugins/vi-mode/vi-mode.plugin.zsh
+++ b/plugins/vi-mode/vi-mode.plugin.zsh
@@ -43,12 +43,32 @@ function _vi-mode-set-cursor-shape-for-keymap() {
printf $'\e[%d q' "${_shape}"
}
+function _visual-mode {
+ typeset -g VI_KEYMAP=visual
+ _vi-mode-set-cursor-shape-for-keymap "$VI_KEYMAP"
+ zle .visual-mode
+}
+zle -N visual-mode _visual-mode
+
+function _vi-mode-should-reset-prompt() {
+ # If $VI_MODE_RESET_PROMPT_ON_MODE_CHANGE is unset (default), dynamically
+ # check whether we're using the prompt to display vi-mode info
+ if [[ -z "${VI_MODE_RESET_PROMPT_ON_MODE_CHANGE:-}" ]]; then
+ [[ "${PS1} ${RPS1}" = *'$(vi_mode_prompt_info)'* ]]
+ return $?
+ fi
+
+ # If $VI_MODE_RESET_PROMPT_ON_MODE_CHANGE was manually set, let's check
+ # if it was specifically set to true or it was disabled with any other value
+ [[ "${VI_MODE_RESET_PROMPT_ON_MODE_CHANGE}" = true ]]
+}
+
# Updates editor information when the keymap changes.
function zle-keymap-select() {
# update keymap variable for the prompt
typeset -g VI_KEYMAP=$KEYMAP
- if [[ "${VI_MODE_RESET_PROMPT_ON_MODE_CHANGE:-}" = true ]]; then
+ if _vi-mode-should-reset-prompt; then
zle reset-prompt
zle -R
fi
@@ -59,10 +79,9 @@ zle -N zle-keymap-select
# These "echoti" statements were originally set in lib/key-bindings.zsh
# Not sure the best way to extend without overriding.
function zle-line-init() {
- local prev_vi_keymap
- prev_vi_keymap="${VI_KEYMAP:-}"
+ local prev_vi_keymap="${VI_KEYMAP:-}"
typeset -g VI_KEYMAP=main
- [[ "$prev_vi_keymap" != 'main' ]] && [[ "${VI_MODE_RESET_PROMPT_ON_MODE_CHANGE:-}" = true ]] && zle reset-prompt
+ [[ "$prev_vi_keymap" != 'main' ]] && _vi-mode-should-reset-prompt && zle reset-prompt
(( ! ${+terminfo[smkx]} )) || echoti smkx
_vi-mode-set-cursor-shape-for-keymap "${VI_KEYMAP}"
}
@@ -128,8 +147,16 @@ function wrap_clipboard_widgets() {
done
}
-wrap_clipboard_widgets copy vi-yank vi-yank-eol vi-backward-kill-word vi-change-whole-line vi-delete vi-delete-char
-wrap_clipboard_widgets paste vi-put-{before,after}
+wrap_clipboard_widgets copy \
+ vi-yank vi-yank-eol vi-yank-whole-line \
+ vi-change vi-change-eol vi-change-whole-line \
+ vi-kill-line vi-kill-eol vi-backward-kill-word \
+ vi-delete vi-delete-char vi-backward-delete-char
+
+wrap_clipboard_widgets paste \
+ vi-put-{before,after} \
+ put-replace-selection
+
unfunction wrap_clipboard_widgets
# if mode indicator wasn't setup by theme, define default, we'll leave INSERT_MODE_INDICATOR empty by default
@@ -138,13 +165,6 @@ if [[ -z "$MODE_INDICATOR" ]]; then
fi
function vi_mode_prompt_info() {
- # If we're using the prompt to display mode info, and we haven't explicitly
- # disabled "reset prompt on mode change", then set it here.
- #
- # We do that here instead of the `if` statement below because the user may
- # set RPS1/RPROMPT to something else in their custom config.
- : "${VI_MODE_RESET_PROMPT_ON_MODE_CHANGE:=true}"
-
echo "${${VI_KEYMAP/vicmd/$MODE_INDICATOR}/(main|viins)/$INSERT_MODE_INDICATOR}"
}
diff --git a/plugins/vscode/README.md b/plugins/vscode/README.md
index e95ed5d4f..726b23d35 100644
--- a/plugins/vscode/README.md
+++ b/plugins/vscode/README.md
@@ -31,7 +31,7 @@ the Command Palette via (F1 or ⇧⌘P) and type shell command to find the Shell
## Using multiple flavours
-If for any reason, you ever require to use multiple flavours of VS Code i.e. VS Code (stable) and VS Code Insiders, you can
+If for any reason, you ever require to use multiple flavours of VS Code i.e. VS Code (stable) and VS Code Insiders, you can
manually specify the flavour's executable. Add the following line to the .zshrc file (between the `ZSH_THEME` and the `plugins=()` lines).
This will make the plugin use your manually defined executable.
@@ -53,6 +53,7 @@ source $ZSH/oh-my-zsh.sh
| Alias | Command | Description |
| ----------------------- | ------------------------------ | ----------------------------------------------------------------------------------------------------------- |
| vsc | code . | Open the current folder in VS code |
+| vsc `dir` | code `dir` | Open passed folder in VS code |
| vsca `dir` | code --add `dir` | Add folder(s) to the last active window |
| vscd `file` `file` | code --diff `file` `file` | Compare two files with each other. |
| vscg `file:line[:char]` | code --goto `file:line[:char]` | Open a file at the path on the specified line and character position. |
diff --git a/plugins/vscode/vscode.plugin.zsh b/plugins/vscode/vscode.plugin.zsh
index 48d904377..356c62360 100644
--- a/plugins/vscode/vscode.plugin.zsh
+++ b/plugins/vscode/vscode.plugin.zsh
@@ -23,7 +23,14 @@ if [[ -z "$VSCODE" ]]; then
fi
fi
-alias vsc="$VSCODE ."
+function vsc {
+ if (( $# )); then
+ $VSCODE $@
+ else
+ $VSCODE .
+ fi
+}
+
alias vsca="$VSCODE --add"
alias vscd="$VSCODE --diff"
alias vscg="$VSCODE --goto"
diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh
index e51cf906a..840e92d61 100644
--- a/plugins/wd/wd.sh
+++ b/plugins/wd/wd.sh
@@ -396,7 +396,7 @@ fi
# disable extendedglob for the complete wd execution time
setopt | grep -q extendedglob
wd_extglob_is_set=$?
-[[ $wd_extglob_is_set ]] && setopt noextendedglob
+(( ! $wd_extglob_is_set )) && setopt noextendedglob
# load warp points
typeset -A points
@@ -484,7 +484,7 @@ fi
# if not, next time warp will pick up variables from this run
# remember, there's no sub shell
-[[ $wd_extglob_is_set ]] && setopt extendedglob
+(( ! $wd_extglob_is_set )) && setopt extendedglob
unset wd_extglob_is_set
unset wd_warp
diff --git a/plugins/web-search/README.md b/plugins/web-search/README.md
index 0bf9f26ad..6e4b4d7b8 100644
--- a/plugins/web-search/README.md
+++ b/plugins/web-search/README.md
@@ -12,8 +12,8 @@ plugins=( ... web-search)
You can use the `web-search` plugin in these two forms:
-* `web_search <context> <term> [more terms if you want]`
-* `<context> <term> [more terms if you want]`
+- `web_search <context> <term> [more terms if you want]`
+- `<context> <term> [more terms if you want]`
For example, these two are equivalent:
@@ -24,43 +24,42 @@ $ google oh-my-zsh
Available search contexts are:
-| Context | URL |
-| --------------------- | ---------------------------------------- |
-| `bing` | `https://www.bing.com/search?q=` |
-| `google` | `https://www.google.com/search?q=` |
-| `brs` or `brave` | `https://search.brave.com/search?q=` |
-| `yahoo` | `https://search.yahoo.com/search?p=` |
-| `ddg` or `duckduckgo` | `https://www.duckduckgo.com/?q=` |
-| `sp` or `startpage` | `https://www.startpage.com/do/search?q=` |
-| `yandex` | `https://yandex.ru/yandsearch?text=` |
-| `github` | `https://github.com/search?q=` |
-| `baidu` | `https://www.baidu.com/s?wd=` |
-| `ecosia` | `https://www.ecosia.org/search?q=` |
-| `goodreads` | `https://www.goodreads.com/search?q=` |
-| `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=` |
-| `archive` | `https://web.archive.org/web/*/` |
-| `scholar` | `https://scholar.google.com/scholar?q=` |
-| `ask` | `https://www.ask.com/web?q=` |
+| Context | URL |
+| --------------------- | ----------------------------------------------- |
+| `bing` | `https://www.bing.com/search?q=` |
+| `google` | `https://www.google.com/search?q=` |
+| `brs` or `brave` | `https://search.brave.com/search?q=` |
+| `yahoo` | `https://search.yahoo.com/search?p=` |
+| `ddg` or `duckduckgo` | `https://www.duckduckgo.com/?q=` |
+| `sp` or `startpage` | `https://www.startpage.com/do/search?q=` |
+| `yandex` | `https://yandex.ru/yandsearch?text=` |
+| `github` | `https://github.com/search?q=` |
+| `baidu` | `https://www.baidu.com/s?wd=` |
+| `ecosia` | `https://www.ecosia.org/search?q=` |
+| `goodreads` | `https://www.goodreads.com/search?q=` |
+| `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=` |
+| `archive` | `https://web.archive.org/web/*/` |
+| `scholar` | `https://scholar.google.com/scholar?q=` |
+| `ask` | `https://www.ask.com/web?q=` |
+| `youtube` | `https://www.youtube.com/results?search_query=` |
Also there are aliases for bang-searching DuckDuckGo:
| Context | Bang |
-|-----------|-------|
+| --------- | ----- |
| `wiki` | `!w` |
| `news` | `!n` |
-| `youtube` | `!yt` |
| `map` | `!m` |
| `image` | `!i` |
| `ducky` | `!` |
### Custom search engines
-If you want to add other search contexts to the plugin, you can use the
-`$ZSH_WEB_SEARCH_ENGINES` variable. Set it before Oh My Zsh is sourced,
-with the following format:
+If you want to add other search contexts to the plugin, you can use the `$ZSH_WEB_SEARCH_ENGINES` variable.
+Set it before Oh My Zsh is sourced, with the following format:
```zsh
ZSH_WEB_SEARCH_ENGINES=(
@@ -69,13 +68,12 @@ ZSH_WEB_SEARCH_ENGINES=(
)
```
-where `<context>` is the name of the search context, and `<URL>` a URL of
-the same type as the search contexts above. For example, to add `reddit`,
-you'd do:
+where `<context>` is the name of the search context, and `<URL>` a URL of the same type as the search contexts
+above. For example, to add `reddit`, you'd do:
```zsh
ZSH_WEB_SEARCH_ENGINES=(reddit "https://www.reddit.com/search/?q=")
```
-These custom search engines will also be turned to aliases, so you can
-both do `web_search reddit <query>` or `reddit <query>`.
+These custom search engines will also be turned to aliases, so you can both do `web_search reddit <query>` or
+`reddit <query>`.
diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh
index ec176dd68..a8848fd95 100644
--- a/plugins/web-search/web-search.plugin.zsh
+++ b/plugins/web-search/web-search.plugin.zsh
@@ -25,6 +25,7 @@ function web_search() {
archive "https://web.archive.org/web/*/"
scholar "https://scholar.google.com/scholar?q="
ask "https://www.ask.com/web?q="
+ youtube "https://www.youtube.com/results?search_query="
)
# check whether the search engine is supported
@@ -66,11 +67,11 @@ alias wolframalpha='web_search wolframalpha'
alias archive='web_search archive'
alias scholar='web_search scholar'
alias ask='web_search ask'
+alias youtube='web_search youtube'
#add your own !bang searches here
alias wiki='web_search duckduckgo \!w'
alias news='web_search duckduckgo \!n'
-alias youtube='web_search duckduckgo \!yt'
alias map='web_search duckduckgo \!m'
alias image='web_search duckduckgo \!i'
alias ducky='web_search duckduckgo \!'
diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh
index 5d1f901a3..f09434e69 100644
--- a/plugins/xcode/xcode.plugin.zsh
+++ b/plugins/xcode/xcode.plugin.zsh
@@ -17,6 +17,13 @@ function xc {
local active_path
active_path=${"$(xcode-select -p)"%%/Contents/Developer*}
echo "Found ${xcode_files[1]}. Opening with ${active_path}"
+
+ # If Xcode is already opened in another Desk, we need this double call
+ # with -g to open the project window in the current Desk and focus it.
+ # See https://github.com/ohmyzsh/ohmyzsh/issues/10384
+ if command pgrep -q "^Xcode"; then
+ open -g -a "$active_path" "${xcode_files[1]}"
+ fi
open -a "$active_path" "${xcode_files[1]}"
}
diff --git a/plugins/yarn/_yarn b/plugins/yarn/_yarn
index 1237ba672..f15756ff4 100644
--- a/plugins/yarn/_yarn
+++ b/plugins/yarn/_yarn
@@ -144,7 +144,7 @@ _yarn_scripts() {
fi
if [[ -n $packageJson ]]; then
- scripts=("${(@f)$(cat ${packageJson} | perl -0777 -MJSON::PP -n -E '%r=%{decode_json($_)->{scripts}}; do{$k=$_;($e=$k)=~s/:/\\:/g; printf "$e:$r{$k}\n"} for sort keys %r')}")
+ scripts=("${(@f)$(cat ${packageJson} | perl -0777 -MJSON::PP -n -E 'binmode(STDOUT, ":encoding(UTF-8)"); %r=%{decode_json($_)->{scripts}}; do{$k=$_;($e=$k)=~s/:/\\:/g; printf "$e:$r{$k}\n"} for sort keys %r')}")
fi
commands=('env' $scripts $binaries)
diff --git a/plugins/z/LICENSE b/plugins/z/LICENSE
index d1cca7ae5..6af13b9e0 100644
--- a/plugins/z/LICENSE
+++ b/plugins/z/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2018-2022 Alexandros Kozak
+Copyright (c) 2018-2023 Alexandros Kozak
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/plugins/z/MANUAL.md b/plugins/z/MANUAL.md
index dcca3c452..d367c3026 100644
--- a/plugins/z/MANUAL.md
+++ b/plugins/z/MANUAL.md
@@ -1,5 +1,9 @@
# Zsh-z
+[![MIT License](img/mit_license.svg)](https://opensource.org/licenses/MIT)
+![Zsh version 4.3.11 and higher](img/zsh_4.3.11_plus.svg)
+[![GitHub stars](https://img.shields.io/github/stars/agkozak/zsh-z.svg)](https://github.com/agkozak/zsh-z/stargazers)
+
Zsh-z is a command line tool that allows you to jump quickly to directories that you have visited frequently in the past, or recently -- but most often a combination of the two (a concept known as ["frecency"](https://en.wikipedia.org/wiki/Frecency)). It works by keeping track of when you go to directories and how much time you spend in them. It is then in the position to guess where you want to go when you type a partial string, e.g., `z src` might take you to `~/src/zsh`. `z zsh` might also get you there, and `z c/z` might prove to be even more specific -- it all depends on your habits and how much time you have been using Zsh-z to build up a database. After using Zsh-z for a little while, you will get to where you want to be by typing considerably less than you would need if you were using `cd`.
Zsh-z is a native Zsh port of [rupa/z](https://github.com/rupa/z), a tool written for `bash` and Zsh that uses embedded `awk` scripts to do the heavy lifting. It was quite possibly my most used command line tool for a couple of years. I decided to translate it, `awk` parts and all, into pure Zsh script, to see if by eliminating calls to external tools (`awk`, `sort`, `date`, `sed`, `mv`, `rm`, and `chown`) and reducing forking through subshells I could make it faster. The performance increase is impressive, particularly on systems where forking is slow, such as Cygwin, MSYS2, and WSL. I have found that, in those environments, switching directories using Zsh-z can be over 100% faster than it is using `rupa/z`.
@@ -28,6 +32,10 @@ Zsh-z is a drop-in replacement for `rupa/z` and will, by default, use the same d
<details>
<summary>Here are the latest features and updates.</summary>
+- April 27, 2023
+ + Zsh-z now allows the user to specify the directory-changing command using the `ZSHZ_CD` environment variable (default: `builtin cd`; props @basnijholt).
+- January 27, 2023
+ + If the datafile directory specified by `ZSHZ_DATA` or `_Z_DATA` does not already exist, create it (props @mattmc3).
- June 29, 2022
+ Zsh-z is less likely to leave temporary files sitting around (props @mafredri).
- June 27, 2022
@@ -118,13 +126,19 @@ Add the line
to your `.zshrc`, somewhere above the line that says `antigen apply`.
-### For [oh-my-zsh](http://ohmyz.sh/) users
+### For [Oh My Zsh](http://ohmyz.sh/) users
-Execute the following command:
+Zsh-z is now included as part of Oh My Zsh! As long as you are using an up-to-date installation of Oh My Zsh, you can activate Zsh-z simply by adding `z` to your `plugins` array in your `.zshrc`, e.g.,
+
+ plugins=( git z )
+
+It is as simple as that.
+
+If, however, you prefer always to use the latest version of Zsh-z from the `agkozak/zsh-z` repo, you may install it thus:
git clone https://github.com/agkozak/zsh-z ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-z
-and add `zsh-z` to the line of your `.zshrc` that specifies `plugins=()`, e.g., `plugins=( git zsh-z )`.
+and activate it by adding `zsh-z` to the line of your `.zshrc` that specifies `plugins=()`, e.g., `plugins=( git zsh-z )`.
### For [prezto](https://github.com/sorin-ionescu/prezto) users
@@ -246,6 +260,7 @@ to install `zsh-z`.
Zsh-z has environment variables (they all begin with `ZSHZ_`) that change its behavior if you set them; you can also keep your old ones if you have been using `rupa/z` (they begin with `_Z_`).
* `ZSHZ_CMD` changes the command name (default: `z`)
+* `ZSHZ_CD` specifies the default directory-changing command (default: `builtin cd`)
* `ZSHZ_COMPLETION` can be `'frecent'` (default) or `'legacy'`, depending on whether you want your completion results sorted according to frecency or simply sorted alphabetically
* `ZSHZ_DATA` changes the database file (default: `~/.z`)
* `ZSHZ_ECHO` displays the new path name when changing directories (default: `0`)
diff --git a/plugins/z/_z b/plugins/z/_z
index 9891a52ed..a493f35ba 100644
--- a/plugins/z/_z
+++ b/plugins/z/_z
@@ -5,7 +5,7 @@
#
# https://github.com/agkozak/zsh-z
#
-# Copyright (c) 2018-2022 Alexandros Kozak
+# Copyright (c) 2018-2023 Alexandros Kozak
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
diff --git a/plugins/z/img/mit_license.svg b/plugins/z/img/mit_license.svg
new file mode 100644
index 000000000..1c02079d7
--- /dev/null
+++ b/plugins/z/img/mit_license.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="78" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="78" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h47v20H0z"/><path fill="#97CA00" d="M47 0h31v20H47z"/><path fill="url(#b)" d="M0 0h78v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110"><text x="245" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="370">license</text><text x="245" y="140" transform="scale(.1)" textLength="370">license</text><text x="615" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="210">MIT</text><text x="615" y="140" transform="scale(.1)" textLength="210">MIT</text></g> </svg> \ No newline at end of file
diff --git a/plugins/z/img/zsh_4.3.11_plus.svg b/plugins/z/img/zsh_4.3.11_plus.svg
new file mode 100644
index 000000000..f46d947d0
--- /dev/null
+++ b/plugins/z/img/zsh_4.3.11_plus.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="84" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="84" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h29v20H0z"/><path fill="#e05d44" d="M29 0h55v20H29z"/><path fill="url(#b)" d="M0 0h84v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110"><text x="155" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="190">zsh</text><text x="155" y="140" transform="scale(.1)" textLength="190">zsh</text><text x="555" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="450">4.3.11+</text><text x="555" y="140" transform="scale(.1)" textLength="450">4.3.11+</text></g> </svg> \ No newline at end of file
diff --git a/plugins/z/z.plugin.zsh b/plugins/z/z.plugin.zsh
index 209edfea7..60a630624 100644
--- a/plugins/z/z.plugin.zsh
+++ b/plugins/z/z.plugin.zsh
@@ -4,7 +4,7 @@
#
# https://github.com/agkozak/zsh-z
#
-# Copyright (c) 2018-2022 Alexandros Kozak
+# Copyright (c) 2018-2023 Alexandros Kozak
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -52,6 +52,7 @@
# ZSHZ_CASE -> if `ignore', pattern matching is case-insensitive; if `smart',
# pattern matching is case-insensitive only when the pattern is all
# lowercase
+# ZSHZ_CD -> the directory-changing command that is used (default: builtin cd)
# ZSHZ_CMD -> name of command (default: z)
# ZSHZ_COMPLETION -> completion method (default: 'frecent'; 'legacy' for
# alphabetic sorting)
@@ -129,6 +130,7 @@ is-at-least 5.3.0 && ZSHZ[PRINTV]=1
# Globals:
# ZSHZ
# ZSHZ_CASE
+# ZSHZ_CD
# ZSHZ_COMPLETION
# ZSHZ_DATA
# ZSHZ_DEBUG
@@ -149,9 +151,19 @@ zshz() {
local REPLY
local -a lines
- # Allow the user to specify the datafile name in $ZSHZ_DATA (default: ~/.z)
+ # Allow the user to specify a custom datafile in $ZSHZ_DATA (or legacy $_Z_DATA)
+ local custom_datafile="${ZSHZ_DATA:-$_Z_DATA}"
+
+ # If a datafile was provided as a standalone file without a directory path
+ # print a warning and exit
+ if [[ -n ${custom_datafile} && ${custom_datafile} != */* ]]; then
+ print "ERROR: You configured a custom Zsh-z datafile (${custom_datafile}), but have not specified its directory." >&2
+ exit
+ fi
+
+ # If the user specified a datafile, use that or default to ~/.z
# If the datafile is a symlink, it gets dereferenced
- local datafile=${${ZSHZ_DATA:-${_Z_DATA:-${HOME}/.z}}:A}
+ local datafile=${${custom_datafile:-$HOME/.z}:A}
# If the datafile is a directory, print a warning and exit
if [[ -d $datafile ]]; then
@@ -161,7 +173,7 @@ zshz() {
# Make sure that the datafile exists before attempting to read it or lock it
# for writing
- [[ -f $datafile ]] || touch "$datafile"
+ [[ -f $datafile ]] || { mkdir -p "${datafile:h}" && touch "$datafile" }
# Bail if we don't own the datafile and $ZSHZ_OWNER is not set
[[ -z ${ZSHZ_OWNER:-${_Z_OWNER}} && -f $datafile && ! -O $datafile ]] &&
@@ -620,7 +632,7 @@ zshz() {
*)
# Frecency routine
(( dx = EPOCHSECONDS - time_field ))
- rank=$(( 10000 * rank_field * (3.75/((0.0001 * dx + 1) + 0.25)) ))
+ rank=$(( 10000 * rank_field * (3.75/( (0.0001 * dx + 1) + 0.25)) ))
;;
esac
@@ -757,6 +769,26 @@ zshz() {
}
#########################################################
+ # Allow the user to specify directory-changing command
+ # using $ZSHZ_CD (default: builtin cd).
+ #
+ # Globals:
+ # ZSHZ_CD
+ #
+ # Arguments:
+ # $* Path
+ #########################################################
+ zshz_cd() {
+ setopt LOCAL_OPTIONS NO_WARN_CREATE_GLOBAL
+
+ if [[ -z $ZSHZ_CD ]]; then
+ builtin cd "$*"
+ else
+ ${=ZSHZ_CD} "$*"
+ fi
+ }
+
+ #########################################################
# If $ZSHZ_ECHO == 1, display paths as you jump to them.
# If it is also the case that $ZSHZ_TILDE == 1, display
# the home directory as a tilde.
@@ -773,7 +805,7 @@ zshz() {
if [[ ${@: -1} == /* ]] && (( ! $+opts[-e] && ! $+opts[-l] )); then
# cd if possible; echo the new path if $ZSHZ_ECHO == 1
- [[ -d ${@: -1} ]] && builtin cd ${@: -1} && _zshz_echo && return
+ [[ -d ${@: -1} ]] && zshz_cd ${@: -1} && _zshz_echo && return
fi
# With option -c, make sure query string matches beginning of matches;
@@ -830,12 +862,12 @@ zshz() {
print -- "$cd"
else
# cd if possible; echo the new path if $ZSHZ_ECHO == 1
- [[ -d $cd ]] && builtin cd "$cd" && _zshz_echo
+ [[ -d $cd ]] && zshz_cd "$cd" && _zshz_echo
fi
else
# if $req is a valid path, cd to it; echo the new path if $ZSHZ_ECHO == 1
if ! (( $+opts[-e] || $+opts[-l] )) && [[ -d $req ]]; then
- builtin cd "$req" && _zshz_echo
+ zshz_cd "$req" && _zshz_echo
else
return $ret2
fi
@@ -900,9 +932,9 @@ add-zsh-hook chpwd _zshz_chpwd
############################################################
# Standarized $0 handling
-# (See https://github.com/agkozak/Zsh-100-Commits-Club/blob/master/Zsh-Plugin-Standard.adoc)
-0=${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}
-0=${${(M)0:#/*}:-$PWD/$0}
+# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
+0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
+0="${${(M)0:#/*}:-$PWD/$0}"
(( ${fpath[(ie)${0:A:h}]} <= ${#fpath} )) || fpath=( "${0:A:h}" "${fpath[@]}" )
diff --git a/plugins/zsh-navigation-tools/n-list b/plugins/zsh-navigation-tools/n-list
index f25db8f60..a852b083a 100644
--- a/plugins/zsh-navigation-tools/n-list
+++ b/plugins/zsh-navigation-tools/n-list
@@ -467,7 +467,7 @@ while (( 1 )); do
elif [ -n "$keypad" ]; then
final_key="$keypad"
else
- _nlist_status_msg "Inproper input detected"
+ _nlist_status_msg "Improper input detected"
zcurses refresh main inner
fi
diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme
index 3abd9f799..af0c33754 100644
--- a/themes/agnoster.zsh-theme
+++ b/themes/agnoster.zsh-theme
@@ -109,7 +109,9 @@ prompt_git() {
if [[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]]; then
repo_path=$(git rev-parse --git-dir 2>/dev/null)
dirty=$(parse_git_dirty)
- ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)"
+ ref=$(git symbolic-ref HEAD 2> /dev/null) || \
+ ref="◈ $(git describe --exact-match --tags HEAD 2> /dev/null)" || \
+ ref="➦ $(git rev-parse --short HEAD 2> /dev/null)"
if [[ -n $dirty ]]; then
prompt_segment yellow black
else
diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme
index 1279ea919..206274462 100644
--- a/themes/avit.zsh-theme
+++ b/themes/avit.zsh-theme
@@ -11,7 +11,12 @@ $(_user_host)${_current_dir} $(git_prompt_info) $(ruby_prompt_info)
PROMPT2='%{%(!.${fg[red]}.${fg[white]})%}◀%{$reset_color%} '
-RPROMPT='$(vi_mode_prompt_info)%{$(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)%}'
+if [[ -z $RPROMPT ]]; then
+ RPROMPT=$__RPROMPT
+else
+ RPROMPT="${RPROMPT} ${__RPROMPT}"
+fi
function _user_host() {
local me
diff --git a/themes/bureau.zsh-theme b/themes/bureau.zsh-theme
index 698aa2ff8..e87a594cd 100644
--- a/themes/bureau.zsh-theme
+++ b/themes/bureau.zsh-theme
@@ -15,6 +15,7 @@ ZSH_THEME_GIT_PROMPT_BEHIND="%{$fg[magenta]%}▾%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_STAGED="%{$fg_bold[green]%}●%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg_bold[yellow]%}●%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}●%{$reset_color%}"
+ZSH_THEME_GIT_PROMPT_STASHED="(%{$fg_bold[blue]%}✹%{$reset_color%})"
bureau_git_info () {
local ref
@@ -67,6 +68,12 @@ bureau_git_status() {
}
bureau_git_prompt() {
+ # ignore non git folders and hidden repos (adapted from lib/git.zsh)
+ if ! command git rev-parse --git-dir &> /dev/null \
+ || [[ "$(command git config --get oh-my-zsh.hide-info 2>/dev/null)" == 1 ]]; then
+ return
+ fi
+
# check git information
local gitinfo=$(bureau_git_info)
if [[ -z "$gitinfo" ]]; then
diff --git a/themes/fino-time.zsh-theme b/themes/fino-time.zsh-theme
index c7e2d965e..3f9360ac5 100644
--- a/themes/fino-time.zsh-theme
+++ b/themes/fino-time.zsh-theme
@@ -12,6 +12,7 @@
# Also borrowing from http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/
function virtualenv_info {
+ [ $CONDA_DEFAULT_ENV ] && echo "($CONDA_DEFAULT_ENV) "
[ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') '
}
diff --git a/themes/gallois.zsh-theme b/themes/gallois.zsh-theme
index bb97bfb17..3fc349072 100644
--- a/themes/gallois.zsh-theme
+++ b/themes/gallois.zsh-theme
@@ -1,24 +1,140 @@
# Depends on the git plugin for work_in_progress()
(( $+functions[work_in_progress] )) || work_in_progress() {}
-ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}["
-ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}"
-ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}"
+ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[cyan]%}[%{$fg[green]%}"
+ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg[cyan]%}]"
+ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_CLEAN=""
# Customized git status, oh-my-zsh currently does not allow render dirty status before branch
git_custom_status() {
local branch=$(git_current_branch)
[[ -n "$branch" ]] || return 0
- echo "$(parse_git_dirty)\
-%{${fg_bold[yellow]}%}$(work_in_progress)%{$reset_color%}\
-${ZSH_THEME_GIT_PROMPT_PREFIX}${branch}${ZSH_THEME_GIT_PROMPT_SUFFIX}"
+ print "%{${fg_bold[yellow]}%}$(work_in_progress)%{$reset_color%}\
+${ZSH_THEME_GIT_PROMPT_PREFIX}$(parse_git_dirty)${branch}\
+${ZSH_THEME_GIT_PROMPT_SUFFIX}"
+}
+autoload -U colors && colors
+
+#export VCS_PROMPT=hg_prompt_info
+export VCS_PROMPT=git_custom_status
+
+base_prompt="%{$fg[cyan]%}[%~% ]%(?.%{$fg[green]%}.%{$fg[red]%})%B$%b "
+custom_prompt=""
+last_run_time=""
+last_vcs_info=""
+
+
+function pipestatus_parse {
+ PIPESTATUS="$pipestatus"
+ ERROR=0
+ for i in "${(z)PIPESTATUS}"; do
+ if [[ "$i" -ne 0 ]]; then
+ ERROR=1
+ fi
+ done
+
+ if [[ "$ERROR" -ne 0 ]]; then
+ print "[%{$fg[red]%}$PIPESTATUS%{$fg[cyan]%}]"
+ fi
}
-# RVM component of prompt
-ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[red]%}["
-ZSH_THEME_RUBY_PROMPT_SUFFIX="]%{$reset_color%}"
# Combine it all into a final right-side prompt
-RPS1="\$(git_custom_status)\$(ruby_prompt_info)${RPS1:+ $RPS1}"
PROMPT='%{$fg[cyan]%}[%~% ]%(?.%{$fg[green]%}.%{$fg[red]%})%B$%b '
+function preexec() {
+ last_run_time=$(perl -MTime::HiRes=time -e 'printf "%.9f\n", time')
+}
+
+function duration() {
+ local duration
+ local now=$(perl -MTime::HiRes=time -e 'printf "%.9f\n", time')
+ local last=$1
+ local last_split=("${(@s/./)last}")
+ local now_split=("${(@s/./)now}")
+ local T=$((now_split[1] - last_split[1]))
+ local D=$((T/60/60/24))
+ local H=$((T/60/60%24))
+ local M=$((T/60%60))
+ local S=$((T%60))
+ local s=$(((now_split[2] - last_split[2]) / 1000000000.))
+ local m=$(((now_split[2] - last_split[2]) / 1000000.))
+
+ (( $D > 0 )) && duration+="${D}d"
+ (( $H > 0 )) && duration+="${H}h"
+ (( $M > 0 )) && duration+="${M}m"
+
+ if [[ $S -le 0 ]]; then
+ printf "%ims" "$m"
+ else
+ if ! [[ -z $duration ]] && printf "%s" "$duration"
+ local sec_milli=$((S + s))
+ printf "%.3fs" "$sec_milli"
+ fi
+}
+
+function precmd() {
+ RETVAL=$(pipestatus_parse)
+ local info=""
+
+ if [ ! -z "$last_run_time" ]; then
+ local elapsed=$(duration $last_run_time)
+ last_run_time=$(print $last_run_time | tr -d ".")
+ if [ $(( $(perl -MTime::HiRes=time -e 'printf "%.9f\n", time' | tr -d ".") - $last_run_time )) -gt $(( 120 * 1000 * 1000 * 1000 )) ]; then
+ local elapsed_color="%{$fg[magenta]%}"
+ elif [ $(( $(perl -MTime::HiRes=time -e 'printf "%.9f\n", time' | tr -d ".") - $last_run_time )) -gt $(( 60 * 1000 * 1000 * 1000 )) ]; then
+ local elapsed_color="%{$fg[red]%}"
+ elif [ $(( $(perl -MTime::HiRes=time -e 'printf "%.9f\n", time' | tr -d ".") - $last_run_time )) -gt $(( 10 * 1000 * 1000 * 1000 )) ]; then
+ local elapsed_color="%{$fg[yellow]%}"
+ else
+ local elapsed_color="%{$fg[green]%}"
+ fi
+ info=$(printf "%s%s%s%s%s" "%{$fg[cyan]%}[" "$elapsed_color" "$elapsed" "%{$fg[cyan]%}]" "$RETVAL")
+ unset last_run_time
+ fi
+
+ if [ -z "$info" -a ! -z "$last_vcs_info" ]; then
+ custom_prompt="$last_vcs_info$base_prompt"
+ return;
+ fi
+
+ if (( ${+VCS_PROMPT} )); then
+ last_vcs_info=$($VCS_PROMPT)
+ if [ ! -z "$last_vcs_info" ]; then
+ [ -z "$info" ] && info=$last_vcs_info || info="$info$last_vcs_info"
+ fi
+ fi
+
+ [ -z "$info" ] && custom_prompt="$base_prompt" || custom_prompt="$info$base_prompt"
+}
+
+function hg_prompt_info() {
+ unset output info parts branch_parts branch
+
+ local output=""
+ if ! output="$(hg status 2> /dev/null)"; then
+ return
+ fi
+
+ local info=$(hg log -l1 --template '{author}:{node|short}:{remotenames}:{phabdiff}')
+ local parts=(${(@s/:/)info})
+ local branch_parts=(${(@s,/,)parts[3]})
+ local branch=${branch_parts[-1]}
+ [ ! -z "${parts[3]}" ] && [[ "${parts[1]}" =~ "$USER@" ]] && branch=${parts[3]}
+ [ -z "${parts[3]}" ] && branch=${parts[2]}
+
+ if [[ ! -z "$output" ]]; then
+ local color="%{$fg[red]%}"
+ elif [[ "${branch}" == "master" || "${branch}" == "warm" ]]; then
+ local color="%{$fg[yellow]%}"
+ else
+ local color="%{$fg[green]%}"
+ fi
+
+ print "%{$fg[cyan]%}[${color}${branch}%{$fg[cyan]%}]"
+}
+
+setopt PROMPT_SUBST
+PROMPT='$custom_prompt'
+
+
diff --git a/themes/gnzh.zsh-theme b/themes/gnzh.zsh-theme
index 1e6c4e93b..ca62320e2 100644
--- a/themes/gnzh.zsh-theme
+++ b/themes/gnzh.zsh-theme
@@ -21,7 +21,7 @@ fi
if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then
PR_HOST='%F{red}%M%f' # SSH
else
- PR_HOST='%F{green}%M%f' # no SSH
+ PR_HOST='%F{green}%m%f' # no SSH
fi
diff --git a/themes/half-life.zsh-theme b/themes/half-life.zsh-theme
index c4d785126..2ad84ac83 100644
--- a/themes/half-life.zsh-theme
+++ b/themes/half-life.zsh-theme
@@ -89,5 +89,9 @@ ZSH_THEME_RUBY_PROMPT_PREFIX="with%F{red} "
ZSH_THEME_RUBY_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_RVM_PROMPT_OPTIONS="v g"
+# virtualenv prompt settings
+ZSH_THEME_VIRTUALENV_PREFIX=" with%F{red} "
+ZSH_THEME_VIRTUALENV_SUFFIX="%{$reset_color%}"
+
setopt prompt_subst
-PROMPT="${purple}%n%{$reset_color%} in ${limegreen}%~%{$reset_color%}\$(ruby_prompt_info)\$vcs_info_msg_0_${orange} λ%{$reset_color%} "
+PROMPT="${purple}%n%{$reset_color%} in ${limegreen}%~%{$reset_color%}\$(virtualenv_prompt_info)\$(ruby_prompt_info)\$vcs_info_msg_0_${orange} λ%{$reset_color%} "
diff --git a/themes/michelebologna.zsh-theme b/themes/michelebologna.zsh-theme
index bb86d68db..b13b2caf1 100644
--- a/themes/michelebologna.zsh-theme
+++ b/themes/michelebologna.zsh-theme
@@ -29,14 +29,13 @@ local cyan="%{$fg_bold[cyan]%}"
local yellow="%{$fg_bold[yellow]%}"
local blue="%{$fg_bold[blue]%}"
local magenta="%{$fg_bold[magenta]%}"
-local white="%{$fg_bold[white]%}"
local reset="%{$reset_color%}"
local -a color_array
-color_array=($green $red $cyan $yellow $blue $magenta $white)
+color_array=($green $red $cyan $yellow $blue $magenta)
-local username_color=$white
-local hostname_color=$color_array[$[((#HOST))%7+1]] # choose hostname color based on first character
+local username_color=$blue
+local hostname_color=$color_array[$[((#HOST))%6+1]] # choose hostname color based on first character
local current_dir_color=$blue
local username="%n"
@@ -66,10 +65,10 @@ function michelebologna_git_prompt {
local out=$(git_prompt_info)$(git_prompt_status)$(git_remote_status)
[[ -n $out ]] || return
printf " %s(%s%s%s)%s" \
- "%{$fg_bold[white]%}" \
+ "%{$fg_bold[blue]%}" \
"%{$fg_bold[green]%}" \
"$out" \
- "%{$fg_bold[white]%}" \
+ "%{$fg_bold[blue]%}" \
"%{$reset_color%}"
}
diff --git a/themes/mortalscumbag.zsh-theme b/themes/mortalscumbag.zsh-theme
index d81a7ca06..36301cb76 100644
--- a/themes/mortalscumbag.zsh-theme
+++ b/themes/mortalscumbag.zsh-theme
@@ -51,8 +51,14 @@ function ssh_connection() {
fi
}
+function _toolbox_prompt_info() {
+ if typeset -f toolbox_prompt_info > /dev/null; then
+ toolbox_prompt_info
+ fi
+}
+
local ret_status="%(?:%{$fg_bold[green]%}:%{$fg_bold[red]%})%?%{$reset_color%}"
-PROMPT=$'\n$(ssh_connection)%{$fg_bold[green]%}%n@%m%{$reset_color%}$(my_git_prompt) : %~\n[${ret_status}] %# '
+PROMPT=$'\n$(_toolbox_prompt_info)$(ssh_connection)%{$fg_bold[green]%}%n@%m%{$reset_color%}$(my_git_prompt) : %~\n[${ret_status}] %# '
ZSH_THEME_PROMPT_RETURNCODE_PREFIX="%{$fg_bold[red]%}"
ZSH_THEME_GIT_PROMPT_PREFIX=" $fg[white]‹ %{$fg_bold[yellow]%}"
diff --git a/themes/oldgallois.zsh-theme b/themes/oldgallois.zsh-theme
new file mode 100644
index 000000000..bb97bfb17
--- /dev/null
+++ b/themes/oldgallois.zsh-theme
@@ -0,0 +1,24 @@
+# Depends on the git plugin for work_in_progress()
+(( $+functions[work_in_progress] )) || work_in_progress() {}
+
+ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}["
+ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}"
+ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}"
+ZSH_THEME_GIT_PROMPT_CLEAN=""
+
+# Customized git status, oh-my-zsh currently does not allow render dirty status before branch
+git_custom_status() {
+ local branch=$(git_current_branch)
+ [[ -n "$branch" ]] || return 0
+ echo "$(parse_git_dirty)\
+%{${fg_bold[yellow]}%}$(work_in_progress)%{$reset_color%}\
+${ZSH_THEME_GIT_PROMPT_PREFIX}${branch}${ZSH_THEME_GIT_PROMPT_SUFFIX}"
+}
+
+# RVM component of prompt
+ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[red]%}["
+ZSH_THEME_RUBY_PROMPT_SUFFIX="]%{$reset_color%}"
+
+# Combine it all into a final right-side prompt
+RPS1="\$(git_custom_status)\$(ruby_prompt_info)${RPS1:+ $RPS1}"
+PROMPT='%{$fg[cyan]%}[%~% ]%(?.%{$fg[green]%}.%{$fg[red]%})%B$%b '
diff --git a/themes/robbyrussell.zsh-theme b/themes/robbyrussell.zsh-theme
index 2fd5f2cdc..173e6d579 100644
--- a/themes/robbyrussell.zsh-theme
+++ b/themes/robbyrussell.zsh-theme
@@ -1,5 +1,5 @@
-PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
-PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
+PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ ) %{$fg[cyan]%}%c%{$reset_color%}"
+PROMPT+=' $(git_prompt_info)'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
diff --git a/tools/changelog.sh b/tools/changelog.sh
index a5cc468f2..6d768963e 100755
--- a/tools/changelog.sh
+++ b/tools/changelog.sh
@@ -106,6 +106,9 @@ function parse-commit {
message="${match[1]}"
# remove CR characters (might be inserted in GitHub UI commit description form)
message="${message//$'\r'/}"
+ # remove lines containing only whitespace
+ local nlnl=$'\n\n'
+ message="${message//$'\n'[[:space:]]##$'\n'/$nlnl}"
# skip next paragraphs (separated by two newlines or more)
message="${message%%$'\n\n'*}"
# ... and replace newlines with spaces
@@ -157,6 +160,89 @@ function parse-commit {
fi
}
+################################
+# SUPPORTS HYPERLINKS FUNCTION #
+################################
+
+# The code for checking if a terminal supports hyperlinks is copied from install.sh
+
+# The [ -t 1 ] check only works when the function is not called from
+# a subshell (like in `$(...)` or `(...)`, so this hack redefines the
+# function at the top level to always return false when stdout is not
+# a tty.
+if [ -t 1 ]; then
+ is_tty() {
+ true
+ }
+else
+ is_tty() {
+ false
+ }
+fi
+
+# This function uses the logic from supports-hyperlinks[1][2], which is
+# made by Kat Marchán (@zkat) and licensed under the Apache License 2.0.
+# [1] https://github.com/zkat/supports-hyperlinks
+# [2] https://crates.io/crates/supports-hyperlinks
+#
+# Copyright (c) 2021 Kat Marchán
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+supports_hyperlinks() {
+ # $FORCE_HYPERLINK must be set and be non-zero (this acts as a logic bypass)
+ if [ -n "$FORCE_HYPERLINK" ]; then
+ [ "$FORCE_HYPERLINK" != 0 ]
+ return $?
+ fi
+
+ # If stdout is not a tty, it doesn't support hyperlinks
+ is_tty || return 1
+
+ # DomTerm terminal emulator (domterm.org)
+ if [ -n "$DOMTERM" ]; then
+ return 0
+ fi
+
+ # VTE-based terminals above v0.50 (Gnome Terminal, Guake, ROXTerm, etc)
+ if [ -n "$VTE_VERSION" ]; then
+ [ $VTE_VERSION -ge 5000 ]
+ return $?
+ fi
+
+ # If $TERM_PROGRAM is set, these terminals support hyperlinks
+ case "$TERM_PROGRAM" in
+ Hyper|iTerm.app|terminology|WezTerm) return 0 ;;
+ esac
+
+ # kitty supports hyperlinks
+ if [ "$TERM" = xterm-kitty ]; then
+ return 0
+ fi
+
+ # Windows Terminal also supports hyperlinks
+ if [ -n "$WT_SESSION" ]; then
+ return 0
+ fi
+
+ # Konsole supports hyperlinks, but it's an opt-in setting that can't be detected
+ # https://github.com/ohmyzsh/ohmyzsh/issues/10964
+ # if [ -n "$KONSOLE_VERSION" ]; then
+ # return 0
+ # fi
+
+ return 1
+}
+
#############################
# RELEASE CHANGELOG DISPLAY #
#############################
@@ -208,7 +294,13 @@ function display-release {
local hash="${1:-$hash}"
case "$output" in
raw) printf '%s' "$hash" ;;
- text) printf '\e[33m%s\e[0m' "$hash" ;; # red
+ text)
+ local text="\e[33m$hash\e[0m"; # red
+ if supports_hyperlinks; then
+ printf "\e]8;;%s\a%s\e]8;;\a" "https://github.com/ohmyzsh/ohmyzsh/commit/$hash" $text;
+ else
+ echo $text;
+ fi ;;
md) printf '[`%s`](https://github.com/ohmyzsh/ohmyzsh/commit/%s)' "$hash" "$hash" ;;
esac
}
@@ -272,7 +364,12 @@ function display-release {
case "$output" in
raw) printf '%s' "$subject" ;;
# In text mode, highlight (#<issue>) and dim text between `backticks`
- text) sed -E $'s|#([0-9]+)|\e[32m#\\1\e[0m|g;s|`([^`]+)`|`\e[2m\\1\e[0m`|g' <<< "$subject" ;;
+ text)
+ if supports_hyperlinks; then
+ sed -E $'s|#([0-9]+)|\e]8;;https://github.com/ohmyzsh/ohmyzsh/issues/\\1\a\e[32m#\\1\e[0m\e]8;;\a|g;s|`([^`]+)`|`\e[2m\\1\e[0m`|g' <<< "$subject"
+ else
+ sed -E $'s|#([0-9]+)|\e[32m#\\1\e[0m|g;s|`([^`]+)`|`\e[2m\\1\e[0m`|g' <<< "$subject"
+ fi ;;
# In markdown mode, link to (#<issue>) issues
md) sed -E 's|#([0-9]+)|[#\1](https://github.com/ohmyzsh/ohmyzsh/issues/\1)|g' <<< "$subject" ;;
esac
diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh
index 734714c94..1cc193bde 100644
--- a/tools/check_for_upgrade.sh
+++ b/tools/check_for_upgrade.sh
@@ -9,6 +9,7 @@ fi
# - prompt (default): the user is asked before updating when it's time to update
# - auto: the update is performed automatically when it's time
# - reminder: a reminder is shown to the user when it's time to update
+# - background-alpha: an experimental update-on-the-background option
# - disabled: automatic update is turned off
zstyle -s ':omz:update' mode update_mode || {
update_mode=prompt
@@ -91,12 +92,37 @@ function is_update_available() {
}
function update_last_updated_file() {
- echo "LAST_EPOCH=$(current_epoch)" >! "${ZSH_CACHE_DIR}/.zsh-update"
+ local exit_status="$1" error="$2"
+
+ if [[ -z "${1}${2}" ]]; then
+ echo "LAST_EPOCH=$(current_epoch)" >! "${ZSH_CACHE_DIR}/.zsh-update"
+ return
+ fi
+
+ cat >! "${ZSH_CACHE_DIR}/.zsh-update" <<EOD
+LAST_EPOCH=$(current_epoch)
+EXIT_STATUS=${exit_status}
+ERROR='${error//\'/’}'
+EOD
}
function update_ohmyzsh() {
- if ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" --interactive; then
+ local verbose_mode
+ zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default
+
+ if [[ "$update_mode" != background-alpha ]] \
+ && LANG= ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" -i -v $verbose_mode; then
update_last_updated_file
+ return $?
+ fi
+
+ local exit_status error
+ if error=$(LANG= ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" -i -v silent 2>&1); then
+ update_last_updated_file 0 "Update successful"
+ else
+ exit_status=$?
+ update_last_updated_file $exit_status "$error"
+ return $exit_status
fi
}
@@ -125,87 +151,145 @@ function has_typed_input() {
}
}
-() {
- emulate -L zsh
+function handle_update() {
+ () {
+ emulate -L zsh
- local epoch_target mtime option LAST_EPOCH
+ local epoch_target mtime option LAST_EPOCH
- # Remove lock directory if older than a day
- zmodload zsh/datetime
- zmodload -F zsh/stat b:zstat
- if mtime=$(zstat +mtime "$ZSH/log/update.lock" 2>/dev/null); then
- if (( (mtime + 3600 * 24) < EPOCHSECONDS )); then
- command rm -rf "$ZSH/log/update.lock"
+ # Remove lock directory if older than a day
+ zmodload zsh/datetime
+ zmodload -F zsh/stat b:zstat
+ if mtime=$(zstat +mtime "$ZSH/log/update.lock" 2>/dev/null); then
+ if (( (mtime + 3600 * 24) < EPOCHSECONDS )); then
+ command rm -rf "$ZSH/log/update.lock"
+ fi
fi
- fi
- # Check for lock directory
- if ! command mkdir "$ZSH/log/update.lock" 2>/dev/null; then
- return
- fi
+ # Check for lock directory
+ if ! command mkdir "$ZSH/log/update.lock" 2>/dev/null; then
+ return
+ fi
- # Remove lock directory on exit. `return $ret` is important for when trapping a SIGINT:
- # The return status from the function is handled specially. If it is zero, the signal is
- # assumed to have been handled, and execution continues normally. Otherwise, the shell
- # will behave as interrupted except that the return status of the trap is retained.
- # This means that for a CTRL+C, the trap needs to return the same exit status so that
- # the shell actually exits what it's running.
- trap "
- ret=\$?
- unset update_mode
- unset -f current_epoch is_update_available update_last_updated_file update_ohmyzsh 2>/dev/null
- command rm -rf '$ZSH/log/update.lock'
- return \$ret
- " EXIT INT QUIT
-
- # Create or update .zsh-update file if missing or malformed
- if ! source "${ZSH_CACHE_DIR}/.zsh-update" 2>/dev/null || [[ -z "$LAST_EPOCH" ]]; then
- update_last_updated_file
- return
- fi
+ # Remove lock directory on exit. `return $ret` is important for when trapping a SIGINT:
+ # The return status from the function is handled specially. If it is zero, the signal is
+ # assumed to have been handled, and execution continues normally. Otherwise, the shell
+ # will behave as interrupted except that the return status of the trap is retained.
+ # This means that for a CTRL+C, the trap needs to return the same exit status so that
+ # the shell actually exits what it's running.
+ trap "
+ ret=\$?
+ unset update_mode
+ unset -f current_epoch is_update_available update_last_updated_file update_ohmyzsh handle_update 2>/dev/null
+ command rm -rf '$ZSH/log/update.lock'
+ return \$ret
+ " EXIT INT QUIT
- # Number of days before trying to update again
- zstyle -s ':omz:update' frequency epoch_target || epoch_target=${UPDATE_ZSH_DAYS:-13}
- # Test if enough time has passed until the next update
- if (( ( $(current_epoch) - $LAST_EPOCH ) < $epoch_target )); then
- return
- fi
+ # Create or update .zsh-update file if missing or malformed
+ if ! source "${ZSH_CACHE_DIR}/.zsh-update" 2>/dev/null || [[ -z "$LAST_EPOCH" ]]; then
+ update_last_updated_file
+ return
+ fi
- # Test if Oh My Zsh directory is a git repository
- if ! (builtin cd -q "$ZSH" && LANG= git rev-parse &>/dev/null); then
- echo >&2 "[oh-my-zsh] Can't update: not a git repository."
- return
- fi
+ # Number of days before trying to update again
+ zstyle -s ':omz:update' frequency epoch_target || epoch_target=${UPDATE_ZSH_DAYS:-13}
+ # Test if enough time has passed until the next update
+ if (( ( $(current_epoch) - $LAST_EPOCH ) < $epoch_target )); then
+ return
+ fi
- # Check if there are updates available before proceeding
- if ! is_update_available; then
- return
- fi
+ # Test if Oh My Zsh directory is a git repository
+ if ! (builtin cd -q "$ZSH" && LANG= git rev-parse &>/dev/null); then
+ echo >&2 "[oh-my-zsh] Can't update: not a git repository."
+ return
+ fi
- # If in reminder mode or user has typed input, show reminder and exit
- if [[ "$update_mode" = reminder ]] || has_typed_input; then
- printf '\r\e[0K' # move cursor to first column and clear whole line
- echo "[oh-my-zsh] It's time to update! You can do that by running \`omz update\`"
- return 0
- fi
+ # Check if there are updates available before proceeding
+ if ! is_update_available; then
+ update_last_updated_file
+ return
+ fi
- # Don't ask for confirmation before updating if in auto mode
- if [[ "$update_mode" = auto ]]; then
- update_ohmyzsh
- return $?
- fi
+ # If in reminder mode or user has typed input, show reminder and exit
+ if [[ "$update_mode" = reminder ]] || { [[ "$update_mode" != background-alpha ]] && has_typed_input }; then
+ printf '\r\e[0K' # move cursor to first column and clear whole line
+ echo "[oh-my-zsh] It's time to update! You can do that by running \`omz update\`"
+ return 0
+ fi
- # Ask for confirmation and only update on 'y', 'Y' or Enter
- # Otherwise just show a reminder for how to update
- echo -n "[oh-my-zsh] Would you like to update? [Y/n] "
- read -r -k 1 option
- [[ "$option" = $'\n' ]] || echo
- case "$option" in
- [yY$'\n']) update_ohmyzsh ;;
- [nN]) update_last_updated_file ;&
- *) echo "[oh-my-zsh] You can update manually by running \`omz update\`" ;;
- esac
+ # Don't ask for confirmation before updating if in auto mode
+ if [[ "$update_mode" = (auto|background-alpha) ]]; then
+ update_ohmyzsh
+ return $?
+ fi
+
+ # Ask for confirmation and only update on 'y', 'Y' or Enter
+ # Otherwise just show a reminder for how to update
+ echo -n "[oh-my-zsh] Would you like to update? [Y/n] "
+ read -r -k 1 option
+ [[ "$option" = $'\n' ]] || echo
+ case "$option" in
+ [yY$'\n']) update_ohmyzsh ;;
+ [nN]) update_last_updated_file ;&
+ *) echo "[oh-my-zsh] You can update manually by running \`omz update\`" ;;
+ esac
+ }
+
+ unset update_mode
+ unset -f current_epoch is_update_available update_last_updated_file update_ohmyzsh handle_update
}
-unset update_mode
-unset -f current_epoch is_update_available update_last_updated_file update_ohmyzsh
+case "$update_mode" in
+ background-alpha)
+ autoload -Uz add-zsh-hook
+
+ _omz_bg_update() {
+ # do the update in a subshell
+ (handle_update) &|
+
+ # register update results function
+ add-zsh-hook precmd _omz_bg_update_status
+
+ # deregister background function
+ add-zsh-hook -d precmd _omz_bg_update
+ unset -f _omz_bg_update
+ }
+
+ _omz_bg_update_status() {
+ {
+ local LAST_EPOCH EXIT_STATUS ERROR
+ if [[ ! -f "$ZSH_CACHE_DIR"/.zsh-update ]]; then
+ return 1
+ fi
+
+ # check update results until timeout is reached
+ . "$ZSH_CACHE_DIR/.zsh-update"
+ if [[ -z "$EXIT_STATUS" || -z "$ERROR" ]]; then
+ return 1
+ fi
+
+ if [[ "$EXIT_STATUS" -eq 0 ]]; then
+ print -P "\n%F{green}[oh-my-zsh] Update successful.%f"
+ return 0
+ elif [[ "$EXIT_STATUS" -ne 0 ]]; then
+ print -P "\n%F{red}[oh-my-zsh] There was an error updating:%f"
+ printf "\n${fg[yellow]}%s${reset_color}" "$ERROR"
+ return 0
+ fi
+ } always {
+ if (( TRY_BLOCK_ERROR == 0 )); then
+ # if last update results have been handled, remove them from the status file
+ update_last_updated_file
+
+ # deregister background function
+ add-zsh-hook -d precmd _omz_bg_update_status
+ unset -f _omz_bg_update_status
+ fi
+ }
+ }
+
+ add-zsh-hook precmd _omz_bg_update
+ ;;
+ *)
+ handle_update ;;
+esac
diff --git a/tools/install.sh b/tools/install.sh
index f4ef16a0c..fcfbcf778 100755
--- a/tools/install.sh
+++ b/tools/install.sh
@@ -84,6 +84,10 @@ command_exists() {
user_can_sudo() {
# Check if sudo is installed
command_exists sudo || return 1
+ # Termux can't run sudo, so we can detect it and exit the function early.
+ case "$PREFIX" in
+ *com.termux*) return 1 ;;
+ esac
# The following command has 3 parts:
#
# 1. Run `sudo` with `-v`. Does the following:
diff --git a/tools/uninstall.sh b/tools/uninstall.sh
index 6a0e7b4c7..6e3df7aca 100644
--- a/tools/uninstall.sh
+++ b/tools/uninstall.sh
@@ -1,3 +1,15 @@
+if hash chsh >/dev/null 2>&1 && [ -f ~/.shell.pre-oh-my-zsh ]; then
+ old_shell=$(cat ~/.shell.pre-oh-my-zsh)
+ echo "Switching your shell back to '$old_shell':"
+ if chsh -s "$old_shell"; then
+ rm -f ~/.shell.pre-oh-my-zsh
+ else
+ echo "Could not change default shell. Change it manually by running chsh"
+ echo "or editing the /etc/passwd file."
+ exit
+ fi
+fi
+
read -r -p "Are you sure you want to remove Oh My Zsh? [y/N] " confirmation
if [ "$confirmation" != y ] && [ "$confirmation" != Y ]; then
echo "Uninstall cancelled"
@@ -25,16 +37,5 @@ else
echo "No original zsh config found"
fi
-if hash chsh >/dev/null 2>&1 && [ -f ~/.shell.pre-oh-my-zsh ]; then
- old_shell=$(cat ~/.shell.pre-oh-my-zsh)
- echo "Switching your shell back to '$old_shell':"
- if chsh -s "$old_shell"; then
- rm -f ~/.shell.pre-oh-my-zsh
- else
- echo "Could not change default shell. Change it manually by running chsh"
- echo "or editing the /etc/passwd file."
- fi
-fi
-
echo "Thanks for trying out Oh My Zsh. It's been uninstalled."
echo "Don't forget to restart your terminal!"
diff --git a/tools/upgrade.sh b/tools/upgrade.sh
index 596a59302..f7a263d66 100755
--- a/tools/upgrade.sh
+++ b/tools/upgrade.sh
@@ -1,4 +1,7 @@
#!/usr/bin/env zsh
+set +u # disable nounset
+
+local ret=0 # exit code
# Protect against running with shells other than zsh
if [ -z "$ZSH_VERSION" ]; then
@@ -12,6 +15,23 @@ esac
cd "$ZSH"
+verbose_mode="default"
+interactive=false
+
+while getopts "v:i" opt; do
+ case $opt in
+ v)
+ if [[ $OPTARG == default || $OPTARG == minimal || $OPTARG == silent ]]; then
+ verbose_mode=$OPTARG
+ else
+ echo "[oh-my-zsh] update verbosity '$OPTARG' is not valid"
+ echo "[oh-my-zsh] valid options are 'default', 'minimal' and 'silent'"
+ fi
+ ;;
+ i) interactive=true ;;
+ esac
+done
+
# Use colors, but only if connected to a terminal
# and that terminal supports them.
@@ -164,17 +184,23 @@ fi
# Update upstream remote to ohmyzsh org
git remote -v | while read remote url extra; do
case "$url" in
+ git://github.com/robbyrussell/oh-my-zsh(|.git))
+ # Update out-of-date "unauthenticated git protocol on port 9418" to https
+ git remote set-url "$remote" "https://github.com/ohmyzsh/ohmyzsh.git" ;;
https://github.com/robbyrussell/oh-my-zsh(|.git))
- git remote set-url "$remote" "https://github.com/ohmyzsh/ohmyzsh.git"
- break ;;
+ git remote set-url "$remote" "https://github.com/ohmyzsh/ohmyzsh.git" ;;
git@github.com:robbyrussell/oh-my-zsh(|.git))
- git remote set-url "$remote" "git@github.com:ohmyzsh/ohmyzsh.git"
- break ;;
- # Update out-of-date "unauthenticated git protocol on port 9418" to https
- git://github.com/robbyrussell/oh-my-zsh(|.git))
- git remote set-url "$remote" "https://github.com/ohmyzsh/ohmyzsh.git"
- break ;;
+ git remote set-url "$remote" "git@github.com:ohmyzsh/ohmyzsh.git" ;;
+ https://github.com/ohmyzsh/ohmyzsh(|.git)) ;;
+ git@github.com:ohmyzsh/ohmyzsh(|.git)) ;;
+ *) continue ;;
esac
+
+ # If we reach this point we have found the proper ohmyzsh upstream remote. If we don't,
+ # we'll only update from the set remote if `oh-my-zsh.remote` has been set to a remote,
+ # as when installing from a fork.
+ git config --local oh-my-zsh.remote "$remote"
+ break
done
# Set git-config values known to fix git errors
@@ -203,7 +229,9 @@ git checkout -q "$branch" -- || exit 1
last_commit=$(git rev-parse "$branch")
# Update Oh My Zsh
-printf "${BLUE}%s${RESET}\n" "Updating Oh My Zsh"
+if [[ $verbose_mode != silent ]]; then
+ printf "${BLUE}%s${RESET}\n" "Updating Oh My Zsh"
+fi
if LANG= git pull --quiet --rebase $remote $branch; then
# Check if it was really updated or not
if [[ "$(git rev-parse HEAD)" = "$last_commit" ]]; then
@@ -215,24 +243,30 @@ if LANG= git pull --quiet --rebase $remote $branch; then
git config oh-my-zsh.lastVersion "$last_commit"
# Print changelog to the terminal
- if [[ "$1" = --interactive ]]; then
+ if [[ $interactive == true && $verbose_mode == default ]]; then
"$ZSH/tools/changelog.sh" HEAD "$last_commit"
fi
- printf "${BLUE}%s \`${BOLD}%s${RESET}${BLUE}\`${RESET}\n" "You can see the changelog with" "omz changelog"
+ if [[ $verbose_mode != silent ]]; then
+ printf "${BLUE}%s \`${BOLD}%s${RESET}${BLUE}\`${RESET}\n" "You can see the changelog with" "omz changelog"
+ fi
fi
- printf '%s %s__ %s %s %s %s %s__ %s\n' $RAINBOW $RESET
- printf '%s ____ %s/ /_ %s ____ ___ %s__ __ %s ____ %s_____%s/ /_ %s\n' $RAINBOW $RESET
- printf '%s / __ \\%s/ __ \\ %s / __ `__ \\%s/ / / / %s /_ / %s/ ___/%s __ \\ %s\n' $RAINBOW $RESET
- printf '%s/ /_/ /%s / / / %s / / / / / /%s /_/ / %s / /_%s(__ )%s / / / %s\n' $RAINBOW $RESET
- printf '%s\\____/%s_/ /_/ %s /_/ /_/ /_/%s\\__, / %s /___/%s____/%s_/ /_/ %s\n' $RAINBOW $RESET
- printf '%s %s %s %s /____/ %s %s %s %s\n' $RAINBOW $RESET
- printf '\n'
- printf "${BLUE}%s${RESET}\n\n" "$message"
- printf "${BLUE}${BOLD}%s %s${RESET}\n" "To keep up with the latest news and updates, follow us on Twitter:" "$(fmt_link @ohmyzsh https://twitter.com/ohmyzsh)"
- printf "${BLUE}${BOLD}%s %s${RESET}\n" "Want to get involved in the community? Join our Discord:" "$(fmt_link "Discord server" https://discord.gg/ohmyzsh)"
- printf "${BLUE}${BOLD}%s %s${RESET}\n" "Get your Oh My Zsh swag at:" "$(fmt_link "Planet Argon Shop" https://shop.planetargon.com/collections/oh-my-zsh)"
+ if [[ $verbose_mode == default ]]; then
+ printf '%s %s__ %s %s %s %s %s__ %s\n' $RAINBOW $RESET
+ printf '%s ____ %s/ /_ %s ____ ___ %s__ __ %s ____ %s_____%s/ /_ %s\n' $RAINBOW $RESET
+ printf '%s / __ \\%s/ __ \\ %s / __ `__ \\%s/ / / / %s /_ / %s/ ___/%s __ \\ %s\n' $RAINBOW $RESET
+ printf '%s/ /_/ /%s / / / %s / / / / / /%s /_/ / %s / /_%s(__ )%s / / / %s\n' $RAINBOW $RESET
+ printf '%s\\____/%s_/ /_/ %s /_/ /_/ /_/%s\\__, / %s /___/%s____/%s_/ /_/ %s\n' $RAINBOW $RESET
+ printf '%s %s %s %s /____/ %s %s %s %s\n' $RAINBOW $RESET
+ printf '\n'
+ printf "${BLUE}%s${RESET}\n\n" "$message"
+ printf "${BLUE}${BOLD}%s %s${RESET}\n" "To keep up with the latest news and updates, follow us on Twitter:" "$(fmt_link @ohmyzsh https://twitter.com/ohmyzsh)"
+ printf "${BLUE}${BOLD}%s %s${RESET}\n" "Want to get involved in the community? Join our Discord:" "$(fmt_link "Discord server" https://discord.gg/ohmyzsh)"
+ printf "${BLUE}${BOLD}%s %s${RESET}\n" "Get your Oh My Zsh swag at:" "$(fmt_link "Planet Argon Shop" https://shop.planetargon.com/collections/oh-my-zsh)"
+ elif [[ $verbose_mode == minimal ]]; then
+ printf "${BLUE}%s${RESET}\n" "$message"
+ fi
else
ret=$?
printf "${RED}%s${RESET}\n" 'There was an error updating. Try again later?'