mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-11-28 11:23:03 +01:00
feat(cli): make shellsaver the public command
This commit is contained in:
1 parent
035556d687
commit
b4e1e1083f
3 files changed
+26
-29
No files matched your search
@@ -244,24 +244,24 @@ ZSH_THEME_RANDOM_IGNORED=(pygmalion tjkirch_mod)
|
|||||||
|
|
||||||
### Shellsavers
|
### Shellsavers
|
||||||
|
|
||||||
Give your terminal a little downtime with `omz shellsaver`, a playful alias for
|
Give your terminal a little downtime with `omz shellsaver`—our playful name for
|
||||||
`omz screensaver`. The aquarium is the default; choose another scene to change the mood:
|
terminal screensavers. The aquarium is the default; choose another scene to change the mood:
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
omz screensaver # A quiet aquarium full of sea shells
|
omz shellsaver # A quiet aquarium full of sea shells
|
||||||
omz screensaver logo # The updater's rainbow logo, bouncing around
|
omz shellsaver logo # The updater's rainbow logo, bouncing around
|
||||||
omz screensaver hermit # A slightly lost hermit crab
|
omz shellsaver hermit # A slightly lost hermit crab
|
||||||
omz shellsaver party # A rainbow stage and a dancing crowd
|
omz shellsaver party # A rainbow stage and a dancing crowd
|
||||||
```
|
```
|
||||||
|
|
||||||
Press any key or Ctrl-C to return to your shell. Screensavers run only when invoked
|
Press any key or Ctrl-C to return to your shell. Screensavers run only when invoked
|
||||||
and restore the terminal when they exit. No plugin or configuration change is needed.
|
and restore the terminal when they exit. No plugin or configuration change is needed.
|
||||||
Use `omz help` to discover the commands, and Tab to complete scene names and options.
|
Use `omz help` to discover the command, and Tab to complete scene names and options.
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
omz screensaver aquarium --seconds 30 # Stop automatically after 30 seconds
|
omz shellsaver aquarium --seconds 30 # Stop automatically after 30 seconds
|
||||||
omz screensaver logo --mono # Use the terminal's foreground color
|
omz shellsaver logo --mono # Use the terminal's foreground color
|
||||||
omz screensaver --help # Show all scenes and options
|
omz shellsaver --help # Show all scenes and options
|
||||||
```
|
```
|
||||||
|
|
||||||
Requires Zsh 5.8 or newer, `stty`, and an xterm-compatible terminal with alternate-screen
|
Requires Zsh 5.8 or newer, `stty`, and an xterm-compatible terminal with alternate-screen
|
||||||
|
|||||||
+8
-9
@@ -28,8 +28,7 @@ function _omz {
|
|||||||
'plugin:Manage plugins'
|
'plugin:Manage plugins'
|
||||||
'pr:Manage Oh My Zsh Pull Requests'
|
'pr:Manage Oh My Zsh Pull Requests'
|
||||||
'reload:Reload the current zsh session'
|
'reload:Reload the current zsh session'
|
||||||
'screensaver:Launch a whimsical terminal screensaver'
|
'shellsaver:Launch a whimsical terminal screensaver'
|
||||||
'shellsaver:Alias for screensaver'
|
|
||||||
'shop:Open the Oh My Zsh shop'
|
'shop:Open the Oh My Zsh shop'
|
||||||
'theme:Manage themes'
|
'theme:Manage themes'
|
||||||
'update:Update Oh My Zsh'
|
'update:Update Oh My Zsh'
|
||||||
@@ -38,12 +37,12 @@ function _omz {
|
|||||||
|
|
||||||
if [[ "$words[2]" == (screensaver|shellsaver) ]] && (( CURRENT > 2 )); then
|
if [[ "$words[2]" == (screensaver|shellsaver) ]] && (( CURRENT > 2 )); then
|
||||||
_arguments \
|
_arguments \
|
||||||
'1:command:(screensaver shellsaver)' \
|
'1:command:' \
|
||||||
'2::scene:(aquarium logo hermit party)' \
|
'2::scene:(aquarium logo hermit party)' \
|
||||||
'--mono[Use the default foreground color]' \
|
'--mono[Use the default foreground color]' \
|
||||||
'--seconds[Exit after a number of seconds]:seconds:' \
|
'--seconds[Exit after a number of seconds]:seconds:' \
|
||||||
'--snapshot[Print a plain-text still]::frame:' \
|
'--snapshot[Print a plain-text still]::frame:' \
|
||||||
'--help[Show screensaver help]'
|
'--help[Show Shellsaver help]'
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -187,8 +186,7 @@ Available commands:
|
|||||||
plugin <command> Manage plugins
|
plugin <command> Manage plugins
|
||||||
pr <command> Manage Oh My Zsh Pull Requests
|
pr <command> Manage Oh My Zsh Pull Requests
|
||||||
reload Reload the current zsh session
|
reload Reload the current zsh session
|
||||||
screensaver [scene] Launch a screensaver (aquarium by default)
|
shellsaver [scene] Launch a Shellsaver (aquarium by default)
|
||||||
shellsaver [scene] Alias for screensaver
|
|
||||||
shop Open the Oh My Zsh shop
|
shop Open the Oh My Zsh shop
|
||||||
theme <command> Manage themes
|
theme <command> Manage themes
|
||||||
update Update Oh My Zsh
|
update Update Oh My Zsh
|
||||||
@@ -197,12 +195,13 @@ Available commands:
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
function _omz::screensaver {
|
function _omz::shellsaver {
|
||||||
command zsh -f "$ZSH/tools/screensaver.zsh" "$@"
|
command zsh -f "$ZSH/tools/screensaver.zsh" "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
function _omz::shellsaver {
|
# Hidden alias; only shellsaver is advertised in help and command completion.
|
||||||
_omz::screensaver "$@"
|
function _omz::screensaver {
|
||||||
|
_omz::shellsaver "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
function _omz::changelog {
|
function _omz::changelog {
|
||||||
|
|||||||
+9
-11
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
# Shared on-demand renderer for `omz screensaver <scene>`.
|
# Shared on-demand renderer for `omz shellsaver <scene>`.
|
||||||
# The CLI launches a separate Zsh process, keeping all state out of the caller.
|
# The CLI launches a separate Zsh process, keeping all state out of the caller.
|
||||||
{
|
{
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
@@ -12,12 +12,10 @@
|
|||||||
local -a canvas inks palette
|
local -a canvas inks palette
|
||||||
|
|
||||||
_zshell_usage() {
|
_zshell_usage() {
|
||||||
print -r -- 'Oh My Zsh / experimental screensavers
|
print -r -- 'Oh My Zsh / experimental Shellsavers
|
||||||
|
|
||||||
Usage: omz screensaver [aquarium|logo|hermit|party] [--mono] [--seconds N]
|
Usage: omz shellsaver [aquarium|logo|hermit|party] [--mono] [--seconds N]
|
||||||
omz screensaver [aquarium|logo|hermit|party] --snapshot [FRAME]
|
omz shellsaver [aquarium|logo|hermit|party] --snapshot [FRAME]
|
||||||
|
|
||||||
Alias: omz shellsaver [scene] [options]
|
|
||||||
|
|
||||||
aquarium Sea shells, a ~ hermit crab, and a quiet current (default).
|
aquarium Sea shells, a ~ hermit crab, and a quiet current (default).
|
||||||
logo The Oh My Zsh wordmark takes a bouncing coffee break.
|
logo The Oh My Zsh wordmark takes a bouncing coffee break.
|
||||||
@@ -36,7 +34,7 @@ Nothing is installed or enabled automatically.'
|
|||||||
--help|-h) _zshell_usage; exit 0 ;;
|
--help|-h) _zshell_usage; exit 0 ;;
|
||||||
''|--*) scene=aquarium ;;
|
''|--*) scene=aquarium ;;
|
||||||
aquarium|logo|hermit|party) scene=$1; shift ;;
|
aquarium|logo|hermit|party) scene=$1; shift ;;
|
||||||
*) print -u2 -r -- "omz screensaver: unknown scene: $1 (choose aquarium, logo, hermit, or party)"; exit 2 ;;
|
*) print -u2 -r -- "omz shellsaver: unknown scene: $1 (choose aquarium, logo, hermit, or party)"; exit 2 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
while (( $# )); do
|
while (( $# )); do
|
||||||
@@ -46,14 +44,14 @@ Nothing is installed or enabled automatically.'
|
|||||||
--seconds)
|
--seconds)
|
||||||
shift
|
shift
|
||||||
if [[ $1 != <1-3600> ]]; then
|
if [[ $1 != <1-3600> ]]; then
|
||||||
print -u2 -r -- 'omz screensaver: --seconds requires an integer from 1 to 3600'
|
print -u2 -r -- 'omz shellsaver: --seconds requires an integer from 1 to 3600'
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
seconds_limit=$1 ;;
|
seconds_limit=$1 ;;
|
||||||
--snapshot)
|
--snapshot)
|
||||||
snapshot=1
|
snapshot=1
|
||||||
if [[ ${2-} == <0-100000> ]]; then tick=$2; shift; fi ;;
|
if [[ ${2-} == <0-100000> ]]; then tick=$2; shift; fi ;;
|
||||||
*) print -u2 -r -- "omz screensaver: unknown argument: $1 (try --help)"; exit 2 ;;
|
*) print -u2 -r -- "omz shellsaver: unknown argument: $1 (try --help)"; exit 2 ;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
@@ -534,7 +532,7 @@ Nothing is installed or enabled automatically.'
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
if [[ ! -t 0 || ! -t 1 || -z $TERM || $TERM == dumb ]]; then
|
if [[ ! -t 0 || ! -t 1 || -z $TERM || $TERM == dumb ]]; then
|
||||||
print -u2 -r -- 'omz screensaver: run in an interactive terminal (or use --snapshot)'
|
print -u2 -r -- 'omz shellsaver: run in an interactive terminal (or use --snapshot)'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
zmodload zsh/terminfo || exit 1
|
zmodload zsh/terminfo || exit 1
|
||||||
@@ -542,7 +540,7 @@ Nothing is installed or enabled automatically.'
|
|||||||
local capability
|
local capability
|
||||||
for capability in smcup rmcup home clear civis cnorm sgr0 el; do
|
for capability in smcup rmcup home clear civis cnorm sgr0 el; do
|
||||||
if [[ -z ${terminfo[$capability]} ]]; then
|
if [[ -z ${terminfo[$capability]} ]]; then
|
||||||
print -u2 -r -- "omz screensaver: terminal lacks $capability; try --snapshot"
|
print -u2 -r -- "omz shellsaver: terminal lacks $capability; try --snapshot"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in new issue
Block a user