1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2025-12-12 15:34:50 +08:00

Compare commits

...

6 Commits

Author SHA1 Message Date
Émilia Decaudin
dfafbea653
Merge 73044b4eb7 into f84341c574 2025-12-11 19:47:19 +01:00
tDwtp
f84341c574
fix(git): git_status_prompt should respect spaces in prefixes (#13478) 2025-12-11 15:05:23 +01:00
Tanzim Hossain Romel
92aed2e936
feat(extract): add unar as fallback for RAR extraction (#13472)
Add unar as a fallback when unrar is not available for extracting
RAR files. This addresses the issue where unrar has been removed
from Homebrew due to licensing issues.

The extraction now:
- Prefers unrar if available (backward compatible)
- Falls back to unar if unrar is not found
- Shows helpful error message if neither tool is installed
2025-12-09 20:14:31 +01:00
Émilia Decaudin
73044b4eb7
Display completions from plugin if .plugin.zsh. isn't present. 2025-04-29 14:52:56 -04:00
Émilia Decaudin
be58a5233c
Change from 'cat' to 'view'. 2025-04-29 14:52:56 -04:00
Émilia Decaudin
9fc3bd782f
feat(cli): add plugin cat command 2025-04-29 14:52:56 -04:00
3 changed files with 48 additions and 2 deletions

View File

@ -47,6 +47,7 @@ function _omz {
'info:Get plugin information'
'list:List plugins'
'load:Load plugin(s)'
'view:Show plugin source'
)
_describe 'command' subcmds ;;
pr) subcmds=('clean:Delete all Pull Request branches' 'test:Test a Pull Request')
@ -214,6 +215,7 @@ Available commands:
info <plugin> Get information of a plugin
list [--enabled] List Oh My Zsh plugins
load <plugin> Load plugin(s)
view <plugin> Show the source of a plugin
EOF
return 1
@ -225,6 +227,42 @@ EOF
$0::$command "$@"
}
function _omz::plugin::view {
if [[ -z "$1" ]]; then
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin>"
return 1
fi
local plugin_source
for plugin_source in "$ZSH_CUSTOM/plugins/$1/$1.plugin.zsh" "$ZSH_CUSTOM/plugins/$1/_$1" "$ZSH/plugins/$1/$1.plugin.zsh" "$ZSH/plugins/$1/_$1"; do
if [[ -f "$plugin_source" ]]; then
# If being piped, just cat the source
if [[ ! -t 1 ]]; then
cat "$plugin_source"
return $?
fi
# Enrich the source display depending on the tools we have
# - glow: https://github.com/charmbracelet/glow
# - bat: https://github.com/sharkdp/bat
# - less: typical pager command
case 1 in
${+commands[glow]}) glow -p "$plugin_source" ;;
${+commands[bat]}) bat -l zsh --style plain "$plugin_source" ;;
${+commands[less]}) less "$plugin_source" ;;
*) cat "$readme" ;;
esac
return $?
fi
done
if [[ ! -d "$ZSH_CUSTOM/plugins/$1" && ! -d "$ZSH/plugins/$1" ]]; then
_omz::log error "'$1' plugin not found"
fi
return 1
}
function _omz::plugin::disable {
if [[ -z "$1" ]]; then
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin> [...]"

View File

@ -117,7 +117,7 @@ function _omz_git_prompt_status() {
fi
# For each status prefix, do a regex comparison
for status_prefix in ${(k)prefix_constant_map}; do
for status_prefix in "${(@k)prefix_constant_map}"; do
local status_constant="${prefix_constant_map[$status_prefix]}"
local status_regex=$'(^|\n)'"$status_prefix"

View File

@ -77,7 +77,15 @@ EOF
(*.lzma) unlzma "$full_path" ;;
(*.z) uncompress "$full_path" ;;
(*.zip|*.war|*.jar|*.ear|*.sublime-package|*.ipa|*.ipsw|*.xpi|*.apk|*.aar|*.whl|*.vsix|*.crx|*.pk3|*.pk4) unzip "$full_path" ;;
(*.rar) unrar x -ad "$full_path" ;;
(*.rar)
if (( $+commands[unrar] )); then
unrar x -ad "$full_path"
elif (( $+commands[unar] )); then
unar -o . "$full_path"
else
echo "extract: cannot extract RAR files: install unrar or unar" >&2
success=1
fi ;;
(*.rpm)
rpm2cpio "$full_path" | cpio --quiet -id ;;
(*.7z | *.7z.[0-9]* | *.pk7) 7za x "$full_path" ;;