@@ -1419,6 +1419,17 @@ get_model() {
14191419 model=" Hackintosh (SMBIOS: $( sysctl -n hw.model) )"
14201420 else
14211421 mac_model=$( sysctl -n hw.model)
1422+ # On Mac OS X 10.4/10.5, use system_profiler to get the human-readable model name.
1423+ # The model-identifier case statement below only covers Intel and Apple Silicon
1424+ # Macs; PowerPC-era Macs (G3/G4/G5) would all fall through to the raw identifier.
1425+ # system_profiler knows every model natively and shows e.g. "PowerBook G4 15\"".
1426+ if [[ $osx_version =~ " 10.4" || $osx_version =~ " 10.5" ]]; then
1427+ model=" $( system_profiler SPHardwareDataType | grep -E ' (Model Name|Machine Name):' ) "
1428+ model=" ${model/ Model Name:/ } "
1429+ model=" ${model/ Machine Name:/ } "
1430+ model=" ${model## } "
1431+ model=" $model ($mac_model )"
1432+ else
14221433 case $mac_model in
14231434 Mac14,7): " MacBook Pro (13-inch, M2, 2022)" ;;
14241435 MacBookPro18,[3-4]): " MacBook Pro (14-inch, 2021)" ;;
@@ -1518,6 +1529,7 @@ get_model() {
15181529 esac
15191530
15201531 model=$_
1532+ fi
15211533 fi
15221534 ;;
15231535
@@ -1862,14 +1874,19 @@ get_packages() {
18621874 manager_pattern=$( printf ' /%s$|' " ${manager_candidates[@]} " )
18631875 manager_pattern=${manager_pattern% " |" }
18641876
1865- # Find all matching executables in PATH directories at once
1877+ # Find all matching executables in PATH directories at once.
1878+ # Use a temp file to avoid bash 3+ process substitution (<(…)) that
1879+ # causes a parse error on Tiger's bash 2.05b.
18661880 OLD_PATH=$PATH
18671881 PATH+=:EOF # hack to list last PATH dir
18681882 manager_hits=()
1883+ _pkg_tmp=" ${TMPDIR:-/ tmp} /neofetch_pkgs.$$ "
18691884 # shellcheck disable=SC2086
1885+ printf ' %s\n' ${PATH//:/ \\ /* } 2> /dev/null | grep -Eo " $manager_pattern " 2> /dev/null > " $_pkg_tmp "
18701886 while IFS= read -r hit; do
18711887 manager_hits+=(" $hit " )
1872- done < <( printf ' %s\n' ${PATH//:/ \/ * } 2> /dev/null | grep -Eo " $manager_pattern " 2> /dev/null)
1888+ done < " $_pkg_tmp "
1889+ rm -f " $_pkg_tmp "
18731890 PATH=$OLD_PATH
18741891 fi
18751892
@@ -2720,13 +2737,19 @@ get_cpu() {
27202737
27212738 " Mac OS X" |" macOS" )
27222739 if [[ $osx_version =~ " 10.4" || $osx_version =~ " 10.5" ]]; then
2723- cpu=" $( system_profiler SPHardwareDataType | grep CPU\ Type) "
2724- cpu=" ${cpu/ CPU\ Type\: / } "
2725-
2726- speed=" $( system_profiler SPHardwareDataType | grep CPU\ Speed) "
2727- speed=" ${speed/ CPU\ Speed\: / } "
2728- speed=" ${speed/ MHz/ } "
2729- speed=" ${speed/ GHz/ } "
2740+ # 10.4 uses 'CPU Type' / 'CPU Speed'; 10.5 uses 'Processor Name' / 'Processor Speed'.
2741+ # Grep for both variants to handle either version.
2742+ cpu=" $( system_profiler SPHardwareDataType | grep -E ' (CPU Type|Processor Name)' ) "
2743+ cpu=" ${cpu/ CPU Type:/ } "
2744+ cpu=" ${cpu/ Processor Name:/ } "
2745+ cpu=" ${cpu## } "
2746+
2747+ speed=" $( system_profiler SPHardwareDataType | grep -E ' (CPU Speed|Processor Speed)' ) "
2748+ speed=" ${speed/ CPU Speed:/ } "
2749+ speed=" ${speed/ Processor Speed:/ } "
2750+ speed=" ${speed/ MHz/ } "
2751+ speed=" ${speed/ GHz/ } "
2752+ speed=" ${speed## } "
27302753
27312754 cores=" $( system_profiler SPHardwareDataType | grep Number\ Of\ CPUs) "
27322755 cores=" ${cores/ Number\ Of\ CPUs\: / } "
@@ -2939,7 +2962,9 @@ get_cpu() {
29392962 cpu=" $cpu @ ${speed} MHz"
29402963 else
29412964 [[ " $speed_shorthand " == " on" ]] && speed=" $(( speed / 100 )) "
2942- speed=" ${speed: 0: 1} .${speed: 1} "
2965+ # Only insert a decimal point if the speed doesn't already have one
2966+ # (e.g., system_profiler on 10.4/10.5 returns values like "1.3" GHz).
2967+ [[ " $speed " != * .* ]] && speed=" ${speed: 0: 1} .${speed: 1} "
29432968 cpu=" $cpu @ ${speed} GHz"
29442969 fi
29452970 fi
@@ -3210,14 +3235,25 @@ EOF
32103235 " Mac OS X" | " macOS" | " iPhone OS" )
32113236 mem_total=" $(( $(sysctl - n hw.memsize) / 1024 / 1024 )) "
32123237 # Single vm_stat call instead of 3 separate calls (saves ~300-500ms)
3213- read -r mem_wired mem_active mem_compressed <<< " $(vm_stat | awk '
3214- / wired/ { wired = $4 }
3215- / active/ { active = $3 }
3216- / occupied/ { compressed = $5 }
3217- END { print wired, active, compressed }
3218- ')"
3219- mem_compressed=" ${mem_compressed:- 0} "
3220- mem_used=" $(( (${mem_wired// .} + ${mem_active// .} + ${mem_compressed// .} ) * 4 / 1024 )) "
3238+ if [[ $osx_version =~ " 10.4" || $osx_version =~ " 10.5" ]]; then
3239+ # Tiger/Leopard: vm_stat lacks 'wired' and 'occupied' fields.
3240+ # Use 'inactive' + 'active' instead.
3241+ read -r mem_inactive mem_active <<< " $(vm_stat | awk '
3242+ / inactive/ { inactive = $3 }
3243+ / active/ { active = $3 }
3244+ END { print inactive, active }
3245+ ')"
3246+ mem_used=" $(( (${mem_inactive// .} + ${mem_active// .} ) * 4 / 1024 )) "
3247+ else
3248+ read -r mem_wired mem_active mem_compressed <<< " $(vm_stat | awk '
3249+ / wired/ { wired = $4 }
3250+ / active/ { active = $3 }
3251+ / occupied/ { compressed = $5 }
3252+ END { print wired, active, compressed }
3253+ ')"
3254+ mem_compressed=" ${mem_compressed:- 0} "
3255+ mem_used=" $(( (${mem_wired// .} + ${mem_active// .} + ${mem_compressed// .} ) * 4 / 1024 )) "
3256+ fi
32213257 ;;
32223258
32233259 " BSD" | " MINIX" | " ravynOS" )
0 commit comments