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

Compare commits

...

3 Commits

Author SHA1 Message Date
Kaspar V.
b97c92bfd6
Merge 11cf52e701 into 92aed2e936 2025-12-10 10:44:47 +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
Kaspar Vollenweider
11cf52e701
feat(is_os): functions to test for major OS
All over oh-my-zsh I found plenty of functions and plugins
testing for the current OS or Platform.

For this PR I basically made simple is_[OS] functions that can be
used anywhere in plugins or oh-my-zsh code, instead of repeating these
over and over again.

I basically need such tests often, because my personal custom oh my zsh
additions run on macOS with Intel and M1 chips plus on different
linux's.

Functions:

- is_linux - the CPUTYPE env is linux*
- is_android - the CPUTYPE env is linux-android*
- is_netbsd the CPUTYPE env is netbsd*
- is_openbsd - the CPUTYPE env is openbsd*
- is_freebsd - the CPUTYPE env is freebsd*
- is_mac - the CPUTYPE env is darwin*
- is_mac_arm - it is darwin and has CPUTYPE arm64
- is_mac_intel - it is darwin and has CPUTYPE x86_64
- is_bsd - any BSD like OS - the CPUTYPE env is (darwin|freebsd|openbsd|netbsd)*
- is_solaris - the CPUTYPE env is solaris*
- is_cygwin - the CPUTYPE env is cygwin*
- is_msys - the CPUTYPE env is msys*
- is_windows - the CPUTYPE env is (cygwin|msys)*
2022-10-19 13:50:12 +02:00
2 changed files with 36 additions and 1 deletions

View File

@ -282,3 +282,30 @@ function omz_urldecode {
echo -E "$decoded"
}
# The OS is linux
function is_linux { [[ "$OSTYPE" == linux* ]]; }
# The OS is Android
function is_android { [[ "$OSTYPE" == linux-android* ]]; }
# The OS is NetBSD
function is_netbsd() { [[ "$OSTYPE" == netbsd* ]]; }
# The OS is OpenBSD
function is_openbsd() { [[ "$OSTYPE" == openbsd* ]]; }
# The OS is FreeBSD
function is_freebsd() { [[ "$OSTYPE" == freebsd* ]]; }
# The OS is macOS (darwin)
function is_mac() { [[ "$OSTYPE" == darwin* ]]; }
# The OS is macOS (darwin) running on series of ARM-based systems-on-a-chip designed by Apple Inc
function is_mac_arm() { is_mac && [[ "$CPUTYPE" == arm64 ]]; }
# The OS is macOS (darwin) running on series of Intel (amd64 / x86_64) CPU
function is_mac_intel() { is_mac && [[ "$CPUTYPE" == x86_64 ]]; }
# The OS is a BSD derivate
function is_bsd() { [[ "$OSTYPE" == (darwin|freebsd|openbsd|netbsd|dragonfly)* ]]; }
# The OS is Solaris
function is_solaris { [[ "$OSTYPE" == solaris* ]]; }
# The Platform is Cygwin (Windows)
function is_cygwin { [[ "$OSTYPE" == cygwin* ]]; }
# The platform is MinGW (Windows)
function is_msys { [[ "$OSTYPE" == msys* ]]; }
# The OS is Windows
function is_windows { [[ "$OSTYPE" == (cygwin|msys)* ]]; }

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" ;;