Compare commits

...

5 Commits

Author SHA1 Message Date
Dylan Araps
942f6cc4a7 os: Use OSTYPE 2018-05-31 14:57:13 +10:00
Dylan Araps
f41607c36c cpu: Use HOSTTYPE 2018-05-31 14:30:48 +10:00
Dylan Araps
077e5fadb7 w3m: Simplify function further. 2018-05-31 08:10:43 +10:00
Dylan Araps
c6fde1ff9a ascii: Simplify function. 2018-05-31 08:04:01 +10:00
Dylan Araps
b93eb5ad30 w3m: Simplify path find. 2018-05-31 07:33:20 +10:00

View File

@@ -781,19 +781,29 @@ EOF
get_os() {
# $kernel_name is set in a function called cache_uname and is
# just the output of "uname -s".
case "$kernel_name" in
"Linux" | "GNU"*) os="Linux" ;;
"Darwin") os="$(sw_vers -productName)" ;;
*"BSD" | "DragonFly" | "Bitrig") os="BSD" ;;
"CYGWIN"* | "MSYS"* | "MINGW"*) os="Windows" ;;
"SunOS") os="Solaris" ;;
"Haiku") os="Haiku" ;;
"MINIX") os="MINIX" ;;
"AIX") os="AIX" ;;
"IRIX"*) os="IRIX" ;;
"FreeMiNT") os="FreeMiNT" ;;
case "$OSTYPE" in
"aix"*) os="AIX" ;;
"darwin"*) os="$(sw_vers -productName)" ;;
"haiku"*) os="Haiku" ;;
"irix"*) os="IRIX" ;;
"minix"*) os="MINIX" ;;
"mint"*) os="FreeMiNT" ;;
"solaris"*) os="Solaris" ;;
"linux"* | "gnu"*)
os="Linux"
;;
*"bsd"* | "dragonfly"* | "bitrig"*)
os="BSD"
;;
"cygwin"* | "msys"* | "mingw"* | "win32"*)
os="Windows"
;;
*)
printf "%s\n" "Unknown OS detected: '$kernel_name', aborting..." >&2
printf "%s\n" "Unknown OS detected: '$OSTYPE', aborting..." >&2
printf "%s\n" "Open an issue on GitHub to add support for your OS." >&2
exit 1
;;
@@ -996,15 +1006,8 @@ get_distro() {
[[ -z "$distro" ]] && distro="$os (Unknown)"
# Get OS architecture.
case "$os" in
"Solaris" | "AIX" | "Haiku" | "IRIX" | "FreeMiNT") machine_arch="$(uname -p)" ;;
*) machine_arch="$(uname -m)" ;;
esac
[[ "$os_arch" == "on" ]] && \
distro+=" ${machine_arch}"
distro+=" $HOSTTYPE"
[[ "${ascii_distro:-auto}" == "auto" ]] && \
ascii_distro="$(trim "$distro")"
@@ -1038,7 +1041,7 @@ get_model() {
;;
"iPhone OS")
case "$machine_arch" in
case "$kernel_machine" in
"iPad1,1") model="iPad" ;;
"iPad2,"[1-4]) model="iPad 2" ;;
"iPad3,"[1-3]) model="iPad 3" ;;
@@ -1739,7 +1742,7 @@ get_cpu() {
# Get CPU name.
cpu_file="/proc/cpuinfo"
case "$machine_arch" in
case "$kernel_machine" in
"frv" | "hppa" | "m68k" | "openrisc" | "or"* | "powerpc" | "ppc"* | "sparc"*)
cpu="$(awk -F':' '/^cpu\t|^CPU/ {printf $2; exit}' "$cpu_file")"
;;
@@ -1808,7 +1811,7 @@ get_cpu() {
;;
"iPhone OS")
case "$machine_arch" in
case "$kernel_machine" in
"iPhone1,"[1-2] | "iPod1,1") cpu="Samsung S5L8900 (1) @ 412MHz" ;;
"iPhone2,1") cpu="Samsung S5PC100 (1) @ 600MHz" ;;
"iPhone3,"[1-3] | "iPod4,1") cpu="Apple A4 (1) @ 800MHz" ;;
@@ -2119,7 +2122,7 @@ get_gpu() {
;;
"iPhone OS")
case "$machine_arch" in
case "$kernel_machine" in
"iPhone1,"[1-2]) gpu="PowerVR MBX Lite 3D" ;;
"iPhone5,"[1-4]) gpu="PowerVR SGX543MP3" ;;
"iPhone8,"[1-4]) gpu="PowerVR GT7600" ;;
@@ -3418,17 +3421,8 @@ image_backend() {
}
get_ascii() {
if [[ ! -f "$image_source" ||
"$image_source" =~ ^(auto|ascii)$ ||
"$image_source" =~ \.(png|jpg|jpe|jpeg|gif)$ ]]; then
# Fallback to distro ascii mode if custom ascii isn't found.
[[ ! "$image_source" =~ ^(auto|ascii)$ ]] && \
err "Ascii: Ascii file not found, using distro ascii."
# Fallback to distro ascii mode if source is an image.
[[ "$image_source" =~ \.(png|jpg|jpe|jpeg|gif)$ ]] && \
err "Image: Source is image file but ascii backend was selected. Using distro ascii."
if [[ ! -f "$image_source" ]]; then
err "Ascii: Ascii file not found, using distro ascii."
else
ascii_data="$(< "$image_source")"
fi
@@ -3458,10 +3452,7 @@ get_ascii() {
print="${print//'${c5}'/$c5}"
print="${print//'${c6}'/$c6}"
# Overwrite padding if ascii_length_force is set.
[[ "$ascii_length_force" ]] && ascii_length="$ascii_length_force"
text_padding="$((ascii_length + gap))"
((text_padding=ascii_length+gap))
printf "%b" "$print"
LC_ALL=C
}
@@ -3571,27 +3562,14 @@ END
get_w3m_img_path() {
# Find w3m-img path.
if [[ -x "/usr/lib/w3m/w3mimgdisplay" ]]; then
w3m_img_path="/usr/lib/w3m/w3mimgdisplay"
shopt -s nullglob
w3m_paths=({/usr/{local/,},~/.nix-profile/}{lib,libexec,lib64,libexec64}/w3m/w3mi*)
shopt -u nullglob
elif [[ -x "/usr/libexec/w3m/w3mimgdisplay" ]]; then
w3m_img_path="/usr/libexec/w3m/w3mimgdisplay"
[[ -x "${w3m_paths[0]}" ]] && \
{ w3m_img_path="${w3m_paths[0]}"; return; }
elif [[ -x "/usr/lib64/w3m/w3mimgdisplay" ]]; then
w3m_img_path="/usr/lib64/w3m/w3mimgdisplay"
elif [[ -x "/usr/libexec64/w3m/w3mimgdisplay" ]]; then
w3m_img_path="/usr/libexec64/w3m/w3mimgdisplay"
elif [[ -x "/usr/local/libexec/w3m/w3mimgdisplay" ]]; then
w3m_img_path="/usr/local/libexec/w3m/w3mimgdisplay"
elif [[ -x "$HOME/.nix-profile/libexec/w3m/w3mimgdisplay" ]]; then
w3m_img_path="$HOME/.nix-profile/libexec/w3m/w3mimgdisplay"
else
err "Image: w3m-img wasn't found on your system"
fi
err "Image: w3m-img wasn't found on your system"
}
get_term_size() {
@@ -4213,10 +4191,11 @@ dynamic_prompt() {
cache_uname() {
# Cache the output of uname so we don't
# have to spawn it multiple times.
IFS=" " read -ra uname <<< "$(uname -sr)"
IFS=" " read -ra uname <<< "$(uname -srm)"
kernel_name="${uname[0]}"
kernel_version="${uname[1]}"
kernel_machine="${uname[2]}"
}
convert_time() {