mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-09-21 18:46:06 +02:00
Compare commits
9
Commits
ee78d3aedd
...
fcf965912c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fcf965912c | ||
|
|
c648271b6b | ||
|
|
53f663f3d8 | ||
|
|
e995678ca8 | ||
|
|
aea374f522 | ||
|
|
6553f90c45 | ||
|
|
9bf43f682c | ||
|
|
1b72d609b4 | ||
|
|
3258baa8b4 |
+21
-10
@@ -12,10 +12,16 @@ function __git_prompt_git() {
|
||||
}
|
||||
|
||||
function _omz_git_prompt_info() {
|
||||
# If we are on a folder not tracked by git, get out.
|
||||
# Otherwise, check for hide-info at global and local repository level
|
||||
if ! __git_prompt_git rev-parse --git-dir &> /dev/null \
|
||||
|| [[ "$(__git_prompt_git config --get oh-my-zsh.hide-info 2>/dev/null)" == 1 ]]; then
|
||||
# Get the git dir and the current branch name in one call. Outside a repo
|
||||
# there is no output. On a detached HEAD the branch is "HEAD". On an unborn
|
||||
# branch git exits non-zero after printing the git dir.
|
||||
local -a info
|
||||
info=("${(@f)$(__git_prompt_git rev-parse --git-dir --abbrev-ref HEAD 2> /dev/null)}")
|
||||
local unborn=$(( $? != 0 ))
|
||||
[[ -n "$info[1]" ]] || return 0
|
||||
|
||||
# Check for hide-info at global and local repository level
|
||||
if [[ "$(__git_prompt_git config --get oh-my-zsh.hide-info 2>/dev/null)" == 1 ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
@@ -23,11 +29,15 @@ function _omz_git_prompt_info() {
|
||||
# - the current branch name
|
||||
# - the tag name if we are on a tag
|
||||
# - the short SHA of the current commit
|
||||
local ref
|
||||
ref=$(__git_prompt_git symbolic-ref --short HEAD 2> /dev/null) \
|
||||
|| ref=$(__git_prompt_git describe --tags --exact-match HEAD 2> /dev/null) \
|
||||
|| ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) \
|
||||
|| return 0
|
||||
# a git dir path may contain newlines, so the branch is the last line
|
||||
local ref="$info[-1]"
|
||||
if (( unborn )); then
|
||||
ref=$(__git_prompt_git symbolic-ref --short HEAD 2> /dev/null) || return 0
|
||||
elif [[ "$ref" == HEAD ]]; then
|
||||
ref=$(__git_prompt_git describe --tags --exact-match HEAD 2> /dev/null) \
|
||||
|| ref=$(__git_prompt_git rev-parse --short HEAD 2> /dev/null) \
|
||||
|| return 0
|
||||
fi
|
||||
|
||||
# Use global ZSH_THEME_GIT_SHOW_UPSTREAM=1 for including upstream remote info
|
||||
local upstream
|
||||
@@ -244,7 +254,8 @@ function parse_git_dirty() {
|
||||
FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}"
|
||||
;;
|
||||
esac
|
||||
STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n 1)
|
||||
# only non-emptiness matters, so keep one line instead of the whole list
|
||||
__git_prompt_git status ${FLAGS} 2> /dev/null | read -r STATUS
|
||||
fi
|
||||
if [[ -n $STATUS ]]; then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
|
||||
|
||||
+2
-1
@@ -22,7 +22,8 @@ function title {
|
||||
print -Pn "\e]1;${1:q}\a" # set tab name
|
||||
;;
|
||||
screen*|tmux*)
|
||||
print -Pn "\ek${1:q}\e\\" # set screen hardstatus
|
||||
print -Pn "\e]2;${2:q}\e\\" # set tmux pane title
|
||||
print -Pn "\ek${1:q}\e\\" # set screen hardstatus/tmux window name if `allow-rename` is on
|
||||
;;
|
||||
*)
|
||||
if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
# AppSignal CLI plugin
|
||||
|
||||
This plugin adds aliases, guard rails and completion for the
|
||||
[AppSignal CLI](https://docs.appsignal.com/cli).
|
||||
|
||||
To use it, add `appsignal-cli` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... appsignal-cli)
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
[AppSignal CLI](https://docs.appsignal.com/cli) 2.1 or newer, installed and on
|
||||
your `PATH`. The plugin does nothing if it is not:
|
||||
|
||||
```zsh
|
||||
brew install appsignal/appsignal-cli/appsignal-cli
|
||||
# or
|
||||
curl -sSL https://github.com/appsignal/appsignal-cli/releases/latest/download/install.sh | sudo sh
|
||||
```
|
||||
|
||||
Most commands need `appsignal-cli auth login` first.
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
| :------ | :----------------------------- | :--------------------------------- |
|
||||
| `asig` | `appsignal-cli` | The AppSignal CLI itself |
|
||||
| `aslog` | `appsignal-cli logs tail` | Stream log lines as they arrive |
|
||||
| `asinc` | `appsignal-cli incidents list` | List incidents for an application |
|
||||
|
||||
`aslog` and `asinc` complete like the commands they stand in for, so
|
||||
`aslog --<TAB>` offers the flags of `appsignal-cli logs tail`.
|
||||
|
||||
## Functions
|
||||
|
||||
| Function | Description |
|
||||
| :-------------- | :----------------------------------------------------------------- |
|
||||
| `appsignal-cli` | Wraps the CLI to confirm before irreversible commands. See Settings |
|
||||
|
||||
## Completion
|
||||
|
||||
Every command completes with a description of what it does, at every level, and
|
||||
so do their flags and allowed values: incident states and severities, sort
|
||||
orders, log severities, trigger fields and comparison operators, output formats
|
||||
and skill targets. `samples` and `sample` complete like `traces`, as they do in
|
||||
the CLI itself.
|
||||
|
||||
`--org` completes offline from the `org` key of your project's
|
||||
`.appsignal.toml` and of the global config.
|
||||
|
||||
The AppSignal CLI ships no completion generator of its own, so `_appsignal-cli`
|
||||
is written from its command definitions and kept in this repository. It targets
|
||||
AppSignal CLI 2.1.x.
|
||||
|
||||
## Settings
|
||||
|
||||
Set these with `zstyle` in your zshrc, before Oh My Zsh is sourced.
|
||||
|
||||
### Confirming destructive commands
|
||||
|
||||
```zsh
|
||||
zstyle ':omz:plugins:appsignal-cli' confirm-destructive no
|
||||
```
|
||||
|
||||
By default the plugin asks for confirmation before four operations that the CLI
|
||||
itself performs without a prompt:
|
||||
|
||||
- `appsignal-cli logs metrics delete`
|
||||
- `appsignal-cli logs triggers delete`
|
||||
- `appsignal-cli triggers archive`, which also closes the trigger's alerts and
|
||||
incidents
|
||||
- `appsignal-cli incidents update --state CLOSED` when it names more than one
|
||||
incident, since that flag accepts a comma-separated list
|
||||
|
||||
Nothing else is intercepted, and the prompt is skipped when stdin is not a
|
||||
terminal, so scripts, pipelines and CI are unaffected. Set the style to `no` to
|
||||
turn the prompt off entirely, or run `command appsignal-cli` for a single
|
||||
invocation.
|
||||
|
||||
### Completing applications
|
||||
|
||||
```zsh
|
||||
zstyle ':omz:plugins:appsignal-cli' dynamic-app-completion yes
|
||||
```
|
||||
|
||||
Off by default. When enabled, `--app`, `--app-id` and `--environment` are
|
||||
completed from `appsignal-cli apps list --output json`, showing each
|
||||
application's name and environment next to its ID instead of making you copy
|
||||
IDs by hand. It is opt-in because it runs the CLI and makes a network call when
|
||||
you press <kbd>Tab</kbd>, and because it needs you to be authenticated. Results
|
||||
are cached for five minutes.
|
||||
|
||||
### Disabling the aliases
|
||||
|
||||
This works for every Oh My Zsh plugin:
|
||||
|
||||
```zsh
|
||||
zstyle ':omz:plugins:appsignal-cli' aliases no
|
||||
```
|
||||
|
||||
## Caveats
|
||||
|
||||
- `appsignal-cli` and the AppSignal Ruby gem's `appsignal` command are different
|
||||
tools. The gem's command installs and diagnoses the agent inside your app;
|
||||
this one queries your data. The plugin deliberately leaves `appsignal` alone,
|
||||
so it keeps working in projects that use the gem.
|
||||
- `appsignal-cli` is a shell function here. Run `command appsignal-cli` to reach
|
||||
the binary directly.
|
||||
- Most commands need exactly one of `--app-id` or `--app`. `--environment` only
|
||||
narrows `--app`; it does nothing next to `--app-id`.
|
||||
- `appsignal-cli project init` writes `.appsignal.toml`, and `auth login` then
|
||||
stores OAuth tokens in it. Do not commit that file.
|
||||
- `incidents delete-note`, `auth logout` and the `--clear-*` flags of
|
||||
`logs metrics update` and `logs triggers update` are destructive too, but are
|
||||
not prompted for: each affects a single note, login or field.
|
||||
- `triggers create` and `triggers update` have their own `--format`, for the
|
||||
format of the metric value. Everywhere else `--format` is a synonym for
|
||||
`--output`.
|
||||
- The CLI sends usage telemetry by default. `APPSIGNAL_CLI_TELEMETRY=0` turns it
|
||||
off, and `APPSIGNAL_CLI_DEBUG=1` shows internal errors.
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,108 @@
|
||||
# AppSignal CLI: completion, aliases and guard rails.
|
||||
# https://docs.appsignal.com/cli
|
||||
|
||||
if (( ! $+commands[appsignal-cli] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# Does this invocation need confirming? Sets REPLY to the reason.
|
||||
#
|
||||
# The command path is collected from the leading bare words. Only the global
|
||||
# flags may precede a subcommand, so the first other flag ends the path: that
|
||||
# way an option value such as `--app "My App"` is never mistaken for one.
|
||||
function _appsignal_cli_is_destructive() {
|
||||
zstyle -T ':omz:plugins:appsignal-cli' confirm-destructive || return 1
|
||||
|
||||
# Nobody to answer: CI and pipelines are unaffected.
|
||||
[[ -t 0 ]] || return 1
|
||||
|
||||
local -a args=("$@") path numbers
|
||||
local arg state=""
|
||||
integer i=1 n=$# path_done=0
|
||||
|
||||
while (( i <= n )); do
|
||||
arg="$args[i]"
|
||||
case "$arg" in
|
||||
--) break ;;
|
||||
--state=*) state="${arg#--state=}"; path_done=1 ;;
|
||||
--state) state="$args[i+1]"; (( i++ )); path_done=1 ;;
|
||||
--number=*) numbers+=(${(s:,:)${arg#--number=}}); path_done=1 ;;
|
||||
# --number takes one or more values, comma-separated or repeated.
|
||||
--number)
|
||||
path_done=1
|
||||
while (( i < n )) && [[ "$args[i+1]" != -* ]]; do
|
||||
(( i++ ))
|
||||
numbers+=(${(s:,:)args[i]})
|
||||
done
|
||||
;;
|
||||
# The output flag is global, so it can appear before the subcommand.
|
||||
-o|--output|--format) (( i++ )) ;;
|
||||
-o*|--output=*|--format=*) ;;
|
||||
-*) path_done=1 ;;
|
||||
*) (( path_done )) || path+=("$arg") ;;
|
||||
esac
|
||||
(( i++ ))
|
||||
done
|
||||
|
||||
case "${(j: :)path[1,3]}" in
|
||||
"logs metrics delete")
|
||||
REPLY="deleting a log-derived metric cannot be undone."
|
||||
return 0
|
||||
;;
|
||||
"logs triggers delete")
|
||||
REPLY="deleting a log-based trigger cannot be undone."
|
||||
return 0
|
||||
;;
|
||||
"triggers archive")
|
||||
REPLY="archiving a trigger also closes its alerts and incidents."
|
||||
return 0
|
||||
;;
|
||||
"incidents update")
|
||||
if [[ "${(U)state}" == CLOSED ]] && (( $#numbers > 1 )); then
|
||||
REPLY="this closes $#numbers incidents at once."
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# Adds a confirmation prompt before irreversible operations. Everything else
|
||||
# passes straight through, so `logs tail` keeps streaming and pipes stay clean.
|
||||
function appsignal-cli() {
|
||||
local REPLY
|
||||
if _appsignal_cli_is_destructive "$@"; then
|
||||
print -u2 -- "appsignal-cli: $REPLY"
|
||||
if ! read -q "?Continue? [y/N] "; then
|
||||
print -u2 -- ""
|
||||
return 130
|
||||
fi
|
||||
print -u2 -- ""
|
||||
fi
|
||||
|
||||
command appsignal-cli "$@"
|
||||
}
|
||||
|
||||
# Complete the aliases like the commands they stand in for.
|
||||
if (( $+functions[compdef] )); then
|
||||
_aslog() {
|
||||
words=(appsignal-cli logs tail ${words[2,-1]})
|
||||
(( CURRENT += 2 ))
|
||||
_appsignal-cli
|
||||
}
|
||||
|
||||
_asinc() {
|
||||
words=(appsignal-cli incidents list ${words[2,-1]})
|
||||
(( CURRENT += 2 ))
|
||||
_appsignal-cli
|
||||
}
|
||||
|
||||
compdef _appsignal-cli asig
|
||||
compdef _aslog aslog
|
||||
compdef _asinc asinc
|
||||
fi
|
||||
|
||||
alias asig='appsignal-cli'
|
||||
alias aslog='appsignal-cli logs tail'
|
||||
alias asinc='appsignal-cli incidents list'
|
||||
@@ -103,6 +103,7 @@ plugins=(... git)
|
||||
| `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` |
|
||||
| `glolm` | `git log $(git_main_branch) --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` |
|
||||
| `glo` | `git log --oneline --decorate` |
|
||||
| `glog` | `git log --oneline --decorate --graph` |
|
||||
|
||||
@@ -239,6 +239,7 @@ alias glod='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgre
|
||||
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 glolm='git log $(git_main_branch) --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'
|
||||
|
||||
@@ -34,6 +34,8 @@ if [[ "$TERM" == screen* ]]; then
|
||||
# tell GNU screen what the tab window title ($1) and the hardstatus($2) should be
|
||||
function screen_set()
|
||||
{
|
||||
[[ "${DISABLE_AUTO_TITLE:-}" != true ]] || return 0
|
||||
|
||||
# set the tab window title (%t) for screen
|
||||
print -nR $'\033k'$1$'\033'\\\
|
||||
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
# Shopify CLI plugin
|
||||
|
||||
This plugin adds aliases, helper functions and completion for the
|
||||
[Shopify CLI](https://shopify.dev/docs/api/shopify-cli).
|
||||
|
||||
To use it, add `shopify` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... shopify)
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
[Shopify CLI](https://shopify.dev/docs/api/shopify-cli) 4.0 or newer, installed
|
||||
and on your `PATH`. The plugin does nothing if it is not:
|
||||
|
||||
```zsh
|
||||
npm install -g @shopify/cli
|
||||
# or
|
||||
brew tap shopify/shopify && brew install shopify-cli
|
||||
```
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
| :----- | :-------- | :--------------------- |
|
||||
| `shop` | `shopify` | The Shopify CLI itself |
|
||||
|
||||
## Functions
|
||||
|
||||
| Function | Description |
|
||||
| :------------- | :--------------------------------------------------------------------------------- |
|
||||
| `shopd` | Runs `theme dev`, `app dev` or `hydrogen dev`, whichever fits the current project |
|
||||
| `shopi` | Shows what the current project is connected to |
|
||||
| `shopify_here` | Prints the kind of Shopify project you are in and the commands worth running in it |
|
||||
| `shopify` | Wraps the CLI to confirm before irreversible commands. See Settings |
|
||||
|
||||
`shopd` and `shopi` work out which topic applies by looking at the project you
|
||||
are standing in, so you do not have to remember whether this directory is a
|
||||
theme, an app or a Hydrogen storefront. They complete like the command they
|
||||
stand in for, so in a theme `shopd --<TAB>` offers the flags of
|
||||
`shopify theme dev`.
|
||||
|
||||
## Completion
|
||||
|
||||
Every command completes with a description of what it does, at every level, and
|
||||
so do their flags, short forms and allowed values. `--environment` completes
|
||||
from the `[environments.*]` sections of your local `shopify.theme.toml` or
|
||||
`shopify.app.toml`.
|
||||
|
||||
The Shopify CLI ships no completion generator of its own, so `_shopify` is
|
||||
generated from `shopify commands --json` and kept in this repository. It targets
|
||||
Shopify CLI 4.x.
|
||||
|
||||
## Settings
|
||||
|
||||
Set these with `zstyle` in your zshrc, before Oh My Zsh is sourced.
|
||||
|
||||
### Confirming destructive commands
|
||||
|
||||
```zsh
|
||||
zstyle ':omz:plugins:shopify' confirm-destructive no
|
||||
```
|
||||
|
||||
By default the plugin asks for confirmation before three irreversible
|
||||
operations:
|
||||
|
||||
- `shopify theme push` with `--live`/`-l` or `--publish`/`-p`, which overwrites
|
||||
or publishes the live storefront
|
||||
- `shopify theme delete`, which the CLI's own help describes as impossible to
|
||||
undo
|
||||
- `shopify app deploy --allow-deletes`, which can permanently remove extensions
|
||||
|
||||
Nothing else is intercepted, and the prompt is skipped when the command already
|
||||
carries `--force`/`-f` or when stdin is not a terminal, so scripts, pipelines
|
||||
and CI are unaffected. Set the style to `no` to turn the prompt off entirely.
|
||||
|
||||
### Completing theme IDs
|
||||
|
||||
```zsh
|
||||
zstyle ':omz:plugins:shopify' dynamic-theme-completion yes
|
||||
```
|
||||
|
||||
Off by default. When enabled, `--theme` is completed from
|
||||
`shopify theme list --json`, showing each theme's name and role next to its ID
|
||||
instead of making you copy IDs by hand. It is opt-in because it runs the CLI and
|
||||
makes a network call when you press <kbd>Tab</kbd>, and because it needs you to
|
||||
be authenticated. Results are cached for five minutes.
|
||||
|
||||
### Disabling the aliases
|
||||
|
||||
This works for every Oh My Zsh plugin:
|
||||
|
||||
```zsh
|
||||
zstyle ':omz:plugins:shopify' aliases no
|
||||
```
|
||||
|
||||
## Caveats
|
||||
|
||||
- `shopify` is a shell function here. Run `command shopify` to reach the binary
|
||||
directly.
|
||||
- When a project has its own copy of the CLI in `node_modules/.bin/shopify`,
|
||||
that one is used in preference to the global install. App and Hydrogen
|
||||
projects normally pin the CLI in `package.json`, and running a different
|
||||
global version against them is a common source of confusing errors.
|
||||
- `--password` and `--store-password` are unrelated, and you often need both.
|
||||
`--password` is the CLI's own authentication token, from the Theme Access app
|
||||
or the Admin API. `--store-password` is the password for a
|
||||
password-protected storefront.
|
||||
- `shopify theme push` deletes remote files that are missing locally, and
|
||||
`shopify theme pull` deletes local files that are missing remotely, unless you
|
||||
pass `--nodelete`/`-n`. The plugin does not prompt for these.
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,203 @@
|
||||
# Shopify CLI: completion, aliases and guard rails.
|
||||
# https://shopify.dev/docs/api/shopify-cli
|
||||
|
||||
if (( ! $+commands[shopify] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# Prefer a project-local CLI: app and Hydrogen projects pin their own version.
|
||||
# The walk stops at $HOME so a stray ~/node_modules cannot hijack every project.
|
||||
# $commands avoids resolving back to the wrapper function below.
|
||||
function _shopify_bin() {
|
||||
local dir="$PWD"
|
||||
while [[ -n "$dir" && "$dir" != "/" && "$dir" != "$HOME" ]]; do
|
||||
if [[ -x "$dir/node_modules/.bin/shopify" ]]; then
|
||||
print -r -- "$dir/node_modules/.bin/shopify"
|
||||
return 0
|
||||
fi
|
||||
dir="${dir:h}"
|
||||
done
|
||||
print -r -- "$commands[shopify]"
|
||||
}
|
||||
|
||||
# Print the project type in $PWD: hydrogen, app or theme.
|
||||
# Hydrogen is tested first because those projects usually carry a
|
||||
# shopify.app.toml too. shopify.theme.toml is not a theme marker: it only
|
||||
# exists once environments are configured.
|
||||
function _shopify_project_type() {
|
||||
local dir="$PWD"
|
||||
local -a app_config
|
||||
|
||||
while [[ -n "$dir" && "$dir" != "/" && "$dir" != "$HOME" ]]; do
|
||||
if [[ -x "$dir/node_modules/.bin/h2" ]] ||
|
||||
[[ -r "$dir/package.json" && "$(<"$dir/package.json")" == *'"@shopify/hydrogen"'* ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
app_config=("$dir"/shopify.app*.toml(N))
|
||||
if (( $#app_config )); then
|
||||
print -r -- app
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -f "$dir/config/settings_schema.json" && -f "$dir/layout/theme.liquid" ]]; then
|
||||
print -r -- theme
|
||||
return 0
|
||||
fi
|
||||
|
||||
dir="${dir:h}"
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# Does this invocation need confirming? Sets REPLY to the reason.
|
||||
function _shopify_is_destructive() {
|
||||
zstyle -T ':omz:plugins:shopify' confirm-destructive || return 1
|
||||
|
||||
# Nobody to answer: CI and pipelines are unaffected.
|
||||
[[ -t 0 ]] || return 1
|
||||
|
||||
local topic="$1" subcommand="$2" arg
|
||||
local -a long
|
||||
local short=""
|
||||
|
||||
# Short flags can be bundled, so collect them as characters: -al counts as l.
|
||||
for arg in "${@[3,-1]}"; do
|
||||
[[ "$arg" == "--" ]] && break
|
||||
case "$arg" in
|
||||
--*) long+=("${arg%%=*}") ;;
|
||||
-?*) short+="${${arg%%=*}#-}" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# An explicit force flag states the intent already.
|
||||
if (( long[(I)--force] )) || [[ "$short" == *f* ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
case "$topic $subcommand" in
|
||||
"theme push")
|
||||
if (( long[(I)--live] || long[(I)--publish] )) || [[ "$short" == *[lp]* ]]; then
|
||||
REPLY="this overwrites or publishes the live theme on the storefront."
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
"theme delete")
|
||||
REPLY="deleting a theme cannot be undone."
|
||||
return 0
|
||||
;;
|
||||
"app deploy")
|
||||
if (( long[(I)--allow-deletes] )); then
|
||||
REPLY="this can permanently remove app extensions."
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# Adds a confirmation prompt before irreversible operations. Everything else
|
||||
# passes straight through, so `theme dev` stays interactive and pipes stay clean.
|
||||
function shopify() {
|
||||
local REPLY
|
||||
if _shopify_is_destructive "$@"; then
|
||||
print -u2 -- "shopify: $REPLY"
|
||||
if ! read -q "?Continue? [y/N] "; then
|
||||
print -u2 -- ""
|
||||
return 130
|
||||
fi
|
||||
print -u2 -- ""
|
||||
fi
|
||||
|
||||
"$(_shopify_bin)" "$@"
|
||||
}
|
||||
|
||||
# Print the commands worth running in the current directory.
|
||||
function shopify_here() {
|
||||
local project_type
|
||||
project_type="$(_shopify_project_type)"
|
||||
|
||||
case "$project_type" in
|
||||
theme)
|
||||
print -- "Shopify theme project."
|
||||
print -- " shopify theme dev Preview locally with live reload"
|
||||
print -- " shopify theme check Lint the theme"
|
||||
print -- " shopify theme list List the themes on the store"
|
||||
print -- " shopify theme pull Download a remote theme into this folder"
|
||||
print -- " shopify theme push Upload this folder to a remote theme"
|
||||
;;
|
||||
app)
|
||||
print -- "Shopify app project."
|
||||
print -- " shopify app dev Run the app against a development store"
|
||||
print -- " shopify app info Show how the app is configured"
|
||||
print -- " shopify app deploy Deploy the app and its extensions"
|
||||
print -- " shopify app logs Stream app logs"
|
||||
;;
|
||||
hydrogen)
|
||||
print -- "Hydrogen storefront."
|
||||
print -- " shopify hydrogen dev Run the storefront locally"
|
||||
print -- " shopify hydrogen build Build for production"
|
||||
print -- " shopify hydrogen deploy Deploy to Oxygen"
|
||||
print -- " shopify hydrogen link Link this project to a storefront"
|
||||
;;
|
||||
*)
|
||||
print -- "No Shopify project found here."
|
||||
print -- " shopify theme init Start a new theme"
|
||||
print -- " shopify app init Start a new app"
|
||||
print -- " shopify hydrogen init Start a new Hydrogen storefront"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Run the dev server for whichever kind of project this is.
|
||||
function shopd() {
|
||||
local project_type
|
||||
if ! project_type="$(_shopify_project_type)"; then
|
||||
print -u2 -- "shopd: not inside a Shopify theme, app or Hydrogen project."
|
||||
return 1
|
||||
fi
|
||||
shopify "$project_type" dev "$@"
|
||||
}
|
||||
|
||||
# Show what the current project is connected to.
|
||||
function shopi() {
|
||||
local project_type
|
||||
if ! project_type="$(_shopify_project_type)"; then
|
||||
print -u2 -- "shopi: not inside a Shopify theme, app or Hydrogen project."
|
||||
return 1
|
||||
fi
|
||||
case "$project_type" in
|
||||
hydrogen) shopify hydrogen list "$@" ;;
|
||||
*) shopify "$project_type" info "$@" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Complete the helpers like the commands they stand in for.
|
||||
if (( $+functions[compdef] )); then
|
||||
_shopd() {
|
||||
local project_type
|
||||
project_type="$(_shopify_project_type)" || return 1
|
||||
words=(shopify "$project_type" dev ${words[2,-1]})
|
||||
(( CURRENT += 2 ))
|
||||
_shopify
|
||||
}
|
||||
|
||||
_shopi() {
|
||||
local project_type
|
||||
project_type="$(_shopify_project_type)" || return 1
|
||||
if [[ "$project_type" == hydrogen ]]; then
|
||||
words=(shopify hydrogen list ${words[2,-1]})
|
||||
else
|
||||
words=(shopify "$project_type" info ${words[2,-1]})
|
||||
fi
|
||||
(( CURRENT += 2 ))
|
||||
_shopify
|
||||
}
|
||||
|
||||
compdef _shopd shopd
|
||||
compdef _shopi shopi
|
||||
fi
|
||||
|
||||
alias shop='shopify'
|
||||
@@ -19,6 +19,7 @@ plugins=(... systemadmin)
|
||||
| mkdir | `mkdir -pv` | Automatically create parent directories and display verbose output |
|
||||
| psmem | `ps -e -orss=,args= \| sort -b -k1 -nr` | Display the processes using the most memory |
|
||||
| psmem10 | `ps -e -orss=,args= \| sort -b -k1 -nr \| head -n 10` | Display the top 10 processes using the most memory |
|
||||
| pszombie| `ps -eo user,pid,ppid,state,comm \| awk '$4=="Z"'` | List zombie processes with ownership and parent process details |
|
||||
| pscpu | `ps -e -o pcpu,cpu,nice,state,cputime,args \|sort -k1 -nr` | Display the top processes using the most CPU |
|
||||
| pscpu10 | `ps -e -o pcpu,cpu,nice,state,cputime,args \|sort -k1 -nr \| head -n 10` | Display the top 10 processes using the most CPU |
|
||||
| hist10 | `print -l ${(o)history%% *} \| uniq -c \| sort -nr \| head -n 10` | Display the top 10 most used commands in the history |
|
||||
@@ -48,5 +49,4 @@ plugins=(... systemadmin)
|
||||
| d0 | Delete 0 byte files recursively in the current directory or another if specified |
|
||||
| geteip | Gather information regarding an external IP address using [icanhazip.com](https://icanhazip.com) |
|
||||
| getip | Determine the local IP Address with `ip addr` or `ifconfig` |
|
||||
| clrz | Clear zombie processes |
|
||||
| conssec | Show number of concurrent connections per second based on nginx/access.log file or another log file if specified |
|
||||
|
||||
@@ -28,6 +28,8 @@ alias mkdir='mkdir -pv'
|
||||
# get top process eating memory
|
||||
alias psmem='ps -e -orss=,args= | sort -b -k1 -nr'
|
||||
alias psmem10='ps -e -orss=,args= | sort -b -k1 -nr | head -n 10'
|
||||
# list all zombie processes with ownership and parent process details
|
||||
alias pszombie="ps -eo user,pid,ppid,state,comm | awk '\$4==\"Z\"'"
|
||||
# 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'
|
||||
@@ -177,11 +179,6 @@ function getip() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Clear zombie processes
|
||||
function clrz() {
|
||||
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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# term_tab plugin
|
||||
|
||||
This plugin only works for Solaris and linux.
|
||||
This plugin works on Linux, macOS and Solaris.
|
||||
|
||||
term_tab - `cwd` for all open zsh sessions
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ function has_typed_input() {
|
||||
# Consider that no input can be typed if stty fails
|
||||
# (this might happen if stdin is not a terminal)
|
||||
local termios
|
||||
termios=$(stty --save 2>/dev/null) || return 1
|
||||
termios=$(stty -g 2>/dev/null) || return 1
|
||||
{
|
||||
# Disable canonical mode so that typed input counts
|
||||
# regardless of whether Enter was pressed
|
||||
|
||||
Reference in New Issue
Block a user