chore(lint): linting, tweaks, cleanup

This commit is contained in:
2023-09-25 12:17:14 +03:00
parent 748e5bb561
commit 6f854ddbfd
9 changed files with 44 additions and 48 deletions

View File

@@ -250,10 +250,8 @@ function section_dotfiles
~/.local/share/nvim \
~/.local/state/nvim \
~/.cache/nvim \
~/.config/astronvim \
~/.config/nvim
msg_ok "Deleted old nvim files"
ln -s "$DOTFILES/config/astronvim" ~/.config/astronvim
msg_ok "Deleted old nvim files (share, state and cache + config)"
ln -s "$DOTFILES/config/nvim" ~/.config/nvim
msg_ok "Linked nvim and astronvim"
have npm && $0 install npm

View File

@@ -16,21 +16,22 @@ COLOR_S='\033[0;36m'
RESET='\033[0m'
# Print time-based personalized message, using figlet & lolcat if availible
function welcome_greeting () {
function welcome_greeting()
{
h=$(date +%H)
if [ "$h" -lt 04 ] || [ "$h" -gt 22 ];
then greeting="Good Night"
elif [ "$h" -lt 12 ];
then greeting="Good morning"
elif [ "$h" -lt 18 ];
then greeting="Good afternoon"
elif [ "$h" -lt 22 ];
then greeting="Good evening"
if [ "$h" -lt 04 ] || [ "$h" -gt 22 ]; then
greeting="Good Night"
elif [ "$h" -lt 12 ]; then
greeting="Good morning"
elif [ "$h" -lt 18 ]; then
greeting="Good afternoon"
elif [ "$h" -lt 22 ]; then
greeting="Good evening"
else
greeting="Hello"
fi
WELCOME_MSG="$greeting $USER!"
if hash lolcat 2>/dev/null && hash figlet 2>/dev/null; then
if hash lolcat 2> /dev/null && hash figlet 2> /dev/null; then
echo "${WELCOME_MSG}" | figlet | lolcat
else
echo -e "$COLOR_P${WELCOME_MSG}${RESET}\n"
@@ -38,8 +39,9 @@ function welcome_greeting () {
}
# Print system information with neofetch, if it's installed
function welcome_sysinfo () {
if hash neofetch 2>/dev/null; then
function welcome_sysinfo()
{
if hash neofetch 2> /dev/null; then
neofetch --shell_version off \
--disable kernel distro shell resolution cpu gpu de wm wm_theme theme icons terminal \
--backend off \
@@ -50,7 +52,8 @@ function welcome_sysinfo () {
}
# Print todays info: Date, IP, weather, etc
function welcome_today () {
function welcome_today()
{
timeout=1
echo -e "\033[1;34mToday\n------"
@@ -62,7 +65,7 @@ function welcome_today () {
echo -e "${RESET}"
# Print IP address
if hash ip 2>/dev/null; then
if hash ip 2> /dev/null; then
ip_address=$(ip route get 8.8.8.8 | awk -F"src " 'NR==1{split($2,a," ");print a[1]}')
ip_interface=$(ip route get 8.8.8.8 | awk -F"dev " 'NR==1{split($2,a," ");print a[1]}')
echo -e "${COLOR_S}🌐 IP: $(curl -s -m $timeout 'https://ipinfo.io/ip') (${ip_address} on ${ip_interface})"
@@ -71,23 +74,11 @@ function welcome_today () {
}
# Putting it all together
function welcome() {
function welcome()
{
welcome_greeting
welcome_sysinfo
welcome_today
}
# Determine if file is being run directly or sourced
([[ -n $ZSH_EVAL_CONTEXT && $ZSH_EVAL_CONTEXT =~ :file$ ]] \
|| [[ -n $KSH_VERSION && $(cd "$(dirname -- "$0")" \
&& printf '%s' "${PWD%/}/")$(basename -- "$0") != "${.sh.file}" ]] \
|| [[ -n $BASH_VERSION ]] && (return 0 2>/dev/null)
) && sourced=1 || sourced=0
# If script being called directly run immediately
if [ "$sourced" -eq 0 ]; then
welcome "$@"
fi
# EOF
welcome "$@"