[zsh] Use the darwin- system info functions in init_profile_darwin_say_hello
This commit is contained in:
		
							parent
							
								
									6276b5f40e
								
							
						
					
					
						commit
						6f6129f071
					
				
					 1 changed files with 16 additions and 13 deletions
				
			
		| 
						 | 
					@ -1,31 +1,34 @@
 | 
				
			||||||
#!/usr/bin/env zsh
 | 
					 | 
				
			||||||
# Eryn Wells <eryn@erynwells.me>
 | 
					# Eryn Wells <eryn@erynwells.me>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
autoload -Uz binary_exists
 | 
					autoload -Uz binary_exists
 | 
				
			||||||
 | 
					autoload -Uz darwin-os-version
 | 
				
			||||||
 | 
					autoload -Uz darwin-os-build
 | 
				
			||||||
 | 
					autoload -Uz darwin-hardware-model
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if binary_exists sw_vers && [[ -n "$HWMODEL" && -n "$OSVERSION" && -n "$OSBUILD" ]]; then
 | 
					init_profile_darwin_say_hello() {
 | 
				
			||||||
    cat_program=cat
 | 
					    local cat_program=cat
 | 
				
			||||||
    if binary_exists lolcat; then
 | 
					    if binary_exists lolcat; then
 | 
				
			||||||
        cat_program=lolcat
 | 
					        cat_program=lolcat
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    local hello_message="It's `date +'%H:%M on %A, %B %d'`."
 | 
					    local hello_message="It's `date +'%H:%M on %A, %B %d'`."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ -n "$HWMODEL" ]]; then
 | 
					    local hardware_model=`darwin-hardware-model`
 | 
				
			||||||
        hello_message+="\nThis machine is a $HWMODEL."
 | 
					    if [[ -n "$hardware_model" ]]; then
 | 
				
			||||||
 | 
					        hello_message+="\nThis machine is a $hardware_model."
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if [[ -n "$OSVERSION" ]]; then
 | 
					    local os_version=`darwin-os-version`
 | 
				
			||||||
        if [[ -n "$OSBUILD" ]]; then
 | 
					    if [[ -n "$os_version" ]]; then
 | 
				
			||||||
            hello_message+="\nYou're running macOS $OSVERSION ($OSBUILD)."
 | 
					        local os_build=`darwin-os-build`
 | 
				
			||||||
 | 
					        if [[ -n "$os_build" ]]; then
 | 
				
			||||||
 | 
					            hello_message+="\nYou're running macOS $os_version ($os_build)."
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
            hello_message+="\nYou're running macOS $OSVERSION."
 | 
					            hello_message+="\nYou're running macOS $os_version."
 | 
				
			||||||
        fi
 | 
					        fi
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    print "$hello_message\n" | $cat_program
 | 
					    print "$hello_message\n" | $cat_program
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return 0
 | 
					init_profile_darwin_say_hello "$@"
 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
return 1
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue