Move the commands near the bottom of the script to a function called main
This commit is contained in:
parent
2511511174
commit
7a774dd48d
39
neofetch
39
neofetch
|
@ -2532,14 +2532,11 @@ getdefaultconfig () {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Source config file
|
|
||||||
getdefaultconfig 2>/dev/null
|
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# Source Config {{{
|
# Source Config {{{
|
||||||
|
|
||||||
getconfig () {
|
getuserconfig () {
|
||||||
# Check $config_file
|
# Check $config_file
|
||||||
if [ -f "$config_file" ]; then
|
if [ -f "$config_file" ]; then
|
||||||
source "$config_file"
|
source "$config_file"
|
||||||
|
@ -2579,7 +2576,9 @@ case "$@" in
|
||||||
config="off"
|
config="off"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
[ "${config:-on}" == "on" ] && getconfig 2>/dev/null
|
|
||||||
|
getdefaultconfig 2>/dev/null
|
||||||
|
[ "${config:-on}" == "on" ] && getuserconfig 2>/dev/null
|
||||||
|
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
@ -2925,7 +2924,7 @@ while [ "$1" ]; do
|
||||||
--config)
|
--config)
|
||||||
case "$2" in
|
case "$2" in
|
||||||
"none" | "off") config="off" ;;
|
"none" | "off") config="off" ;;
|
||||||
*) config_file="$2"; config="on"; getconfig 2>/dev/null ;;
|
*) config_file="$2"; config="on"; getuserconfig 2>/dev/null ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
--test)
|
--test)
|
||||||
|
@ -2973,9 +2972,13 @@ done
|
||||||
|
|
||||||
# Call Functions and Finish Up {{{
|
# Call Functions and Finish Up {{{
|
||||||
|
|
||||||
|
main () {
|
||||||
# Restore cursor and clear screen on ctrl+c
|
# Restore cursor and clear screen on ctrl+c
|
||||||
trap 'printf "\033[?25h"; clear; exit' 2
|
trap 'printf "\033[?25h"; clear; exit' 2
|
||||||
|
|
||||||
|
# If the script exits for any reason, unhide the cursor.
|
||||||
|
trap 'printf "\033[?25h"' EXIT
|
||||||
|
|
||||||
# Distro detection
|
# Distro detection
|
||||||
getdistro
|
getdistro
|
||||||
case "${ascii_distro:-auto}" in
|
case "${ascii_distro:-auto}" in
|
||||||
|
@ -2986,17 +2989,17 @@ esac
|
||||||
bold
|
bold
|
||||||
colors
|
colors
|
||||||
|
|
||||||
# If the script exits for any reason, unhide the cursor.
|
|
||||||
trap 'printf "\033[?25h"' EXIT
|
|
||||||
|
|
||||||
# Clear the scren
|
# Clear the scren
|
||||||
clear
|
clear
|
||||||
|
|
||||||
# Hide the cursor
|
# Hide the cursor
|
||||||
printf "\033[?25l"
|
printf "\033[?25l"
|
||||||
|
|
||||||
|
# Images {{{
|
||||||
|
|
||||||
|
# Get the image src
|
||||||
if [ "$image" != "off" ]; then
|
if [ "$image" != "off" ]; then
|
||||||
# If iterm2 is detected use iterm2 backend.
|
# Set the image backend
|
||||||
if [ -n "$ITERM_PROFILE" ]; then
|
if [ -n "$ITERM_PROFILE" ]; then
|
||||||
image_backend="iterm2"
|
image_backend="iterm2"
|
||||||
|
|
||||||
|
@ -3034,6 +3037,8 @@ if [ "$image" != "off" ] && [ "$image" != "ascii" ]; then
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# }}}
|
||||||
|
|
||||||
# Disable line wrap
|
# Disable line wrap
|
||||||
printf "\033[?7l"
|
printf "\033[?7l"
|
||||||
|
|
||||||
|
@ -3066,13 +3071,15 @@ info_height="$(stty -echo; IFS=';' read -rdR -t 1 -d c -p $'\033[6n\033[c' ROW C
|
||||||
printf "%b%s" "\033[?7h"
|
printf "%b%s" "\033[?7h"
|
||||||
|
|
||||||
# If enabled take a screenshot
|
# If enabled take a screenshot
|
||||||
if [ "$scrot" == "on" ]; then
|
[ "$scrot" == "on" ] && takescrot
|
||||||
takescrot
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Show error messages
|
# Show error messages
|
||||||
if [ "$verbose" == "on" ]; then
|
[ "$verbose" == "on" ] && printf "%s" "$err"
|
||||||
printf "%s" "$err"
|
|
||||||
fi
|
# Reset exit status of the tests above.
|
||||||
|
printf "%s"
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
Reference in New Issue