2024-02-22 18:37:43 +01:00
|
|
|
#!/bin/zsh
|
|
|
|
#
|
|
|
|
|
2024-06-19 18:26:45 +02:00
|
|
|
# zsh colors
|
|
|
|
#
|
|
|
|
autoload colors && colors
|
|
|
|
|
|
|
|
# Proxy
|
|
|
|
#
|
|
|
|
proxy=$(systemctl list-sockets --quiet "*proxy*" | head -1 | cut -d' ' -f1)
|
|
|
|
if [ -n "${proxy}" ]; then
|
|
|
|
echo "${bg[yellow]}${fg[black]} Using proxy ${fg_bold[black]}${proxy} \n"
|
|
|
|
export ALL_PROXY="${proxy}"
|
|
|
|
fi
|
|
|
|
|
2024-02-22 18:37:43 +01:00
|
|
|
# asdf, direnv, python & lastversion
|
|
|
|
#
|
|
|
|
# - https://github.com/dvershinin/lastversion
|
|
|
|
#
|
|
|
|
cd $(dirname $0)
|
|
|
|
eval $(asdf exec direnv export zsh)
|
|
|
|
|
2024-06-19 19:16:15 +02:00
|
|
|
# Print Age
|
|
|
|
#
|
|
|
|
function print_age
|
|
|
|
{
|
|
|
|
program=$1
|
|
|
|
|
|
|
|
echo "\n${bg[red]}${fg[black]}>>>> ${program} ${reset_color}"
|
|
|
|
|
|
|
|
# Already installed
|
|
|
|
#
|
|
|
|
if (( ${+commands[$program]} )); then
|
2024-06-20 13:00:06 +02:00
|
|
|
echo "\n${bg[cyan]} Installation Age ${reset_color}"
|
2024-06-19 19:16:15 +02:00
|
|
|
|
|
|
|
prog_out=$(${program} -V)
|
|
|
|
|
|
|
|
# Extract version from program's output
|
|
|
|
current_version=$(lastversion format "${prog_out}")
|
|
|
|
|
|
|
|
# Highlight program's version
|
|
|
|
echo ${prog_out} | grep --colour=always -F "${current_version}"
|
|
|
|
lsd -lh --date=relative =${program}
|
|
|
|
fi
|
2024-06-20 13:00:06 +02:00
|
|
|
|
|
|
|
echo
|
2024-06-19 19:16:15 +02:00
|
|
|
}
|
|
|
|
|
2024-06-19 18:26:45 +02:00
|
|
|
# Debian Package
|
2024-02-22 18:37:43 +01:00
|
|
|
#
|
|
|
|
function debian
|
|
|
|
{
|
|
|
|
program=$1
|
|
|
|
repository=$2
|
2024-06-19 18:26:45 +02:00
|
|
|
apt_name=${3:-$1}
|
|
|
|
current_version="0.0.0"
|
2024-02-22 18:37:43 +01:00
|
|
|
|
2024-06-19 18:26:45 +02:00
|
|
|
echo "\n${bg[red]}${fg[black]}>>>> ${program} ${reset_color}"
|
|
|
|
|
|
|
|
# Already installed
|
|
|
|
#
|
|
|
|
if (( ${+commands[$program]} )); then
|
|
|
|
echo "\n${bg[cyan]} Installed ${reset_color}"
|
2024-02-22 18:37:43 +01:00
|
|
|
|
2024-06-19 18:26:45 +02:00
|
|
|
prog_out=$(${program} --version)
|
2024-02-22 18:37:43 +01:00
|
|
|
|
2024-06-19 18:26:45 +02:00
|
|
|
# Extract version from program's output
|
|
|
|
current_version=$(lastversion format "${prog_out}")
|
2024-02-22 18:37:43 +01:00
|
|
|
|
2024-06-19 18:26:45 +02:00
|
|
|
# Highlight program's version
|
|
|
|
echo ${prog_out} | grep --colour=always -F "${current_version}"
|
2024-02-22 18:37:43 +01:00
|
|
|
\ls -lh =${program}
|
2024-06-19 18:26:45 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Repository
|
|
|
|
#
|
|
|
|
echo "\n${bg[cyan]} ${repository} ${reset_color}"
|
|
|
|
|
|
|
|
# Retrieve latest repository version
|
|
|
|
repo_version=$(lastversion ${repository} --newer-than ${current_version})
|
|
|
|
|
|
|
|
# Check last result code
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "${fg[red]}${repo_version}${fg[cyan]} > ${current_version}${reset_color}\n"
|
|
|
|
|
2024-06-20 13:00:06 +02:00
|
|
|
echo "${fg[cyan]}${repository}/releases/latest${reset_color}"
|
|
|
|
lastversion ${repository} --assets --filter="." \
|
|
|
|
| rg --color=always --passthru --regexp="${filter}"
|
2024-06-19 18:26:45 +02:00
|
|
|
|
|
|
|
else
|
|
|
|
echo "${fg[green]}${repo_version}"
|
|
|
|
fi
|
|
|
|
echo -n ${reset_color}
|
2024-02-22 18:37:43 +01:00
|
|
|
|
|
|
|
|
2024-06-19 18:26:45 +02:00
|
|
|
# Debian Package
|
|
|
|
apt_list=$(apt list ${apt_name} 2>/dev/null)
|
|
|
|
deb_version=$(lastversion format "${apt_list}" 2>/dev/null)
|
2024-02-22 18:37:43 +01:00
|
|
|
|
2024-06-19 18:26:45 +02:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "\n${bg[cyan]} Debian package ${reset_color}"
|
|
|
|
|
|
|
|
deb_version=$(lastversion "${deb_version}" --newer-than ${current_version})
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "${fg[red]}${deb_version} ${fg[cyan]} > ${current_version}${reset_color}\n"
|
2024-02-22 18:37:43 +01:00
|
|
|
else
|
2024-06-19 18:26:45 +02:00
|
|
|
echo "${fg[green]}${deb_version}"
|
2024-02-22 18:37:43 +01:00
|
|
|
fi
|
2024-06-19 18:26:45 +02:00
|
|
|
echo -n ${reset_color}
|
|
|
|
fi
|
2024-02-22 18:37:43 +01:00
|
|
|
|
2024-06-19 18:26:45 +02:00
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
# Archive
|
|
|
|
#
|
|
|
|
function archive
|
|
|
|
{
|
|
|
|
program=$1
|
|
|
|
repository=$2
|
2024-06-19 19:06:32 +02:00
|
|
|
current_version=${3:-"0.0.0"}
|
2024-06-19 18:26:45 +02:00
|
|
|
|
|
|
|
echo "\n${bg[red]}${fg[black]}>>>> ${program} ${reset_color}"
|
|
|
|
|
|
|
|
# Already installed
|
|
|
|
#
|
|
|
|
if (( ${+commands[$program]} )); then
|
|
|
|
echo "\n${bg[cyan]} Installed ${reset_color}"
|
|
|
|
|
|
|
|
prog_out=$(${program} --version)
|
|
|
|
|
|
|
|
# Extract version from program's output
|
|
|
|
current_version=$(lastversion format "${prog_out} | head -1 )" 2>/dev/null)
|
|
|
|
if [ -e ${current_version} ]; then
|
|
|
|
current_version=$(lastversion format "${prog_out} | grep -o "version=[0-9.]\+")")
|
|
|
|
fi
|
2024-02-22 18:37:43 +01:00
|
|
|
|
2024-06-19 18:26:45 +02:00
|
|
|
# Highlight program's version
|
|
|
|
echo ${prog_out} | grep --colour=always -F "${current_version}"
|
|
|
|
\ls -lh =${program}
|
2024-02-22 18:37:43 +01:00
|
|
|
fi
|
|
|
|
|
2024-06-19 18:26:45 +02:00
|
|
|
# Repository
|
|
|
|
#
|
|
|
|
echo "\n${bg[cyan]} ${repository} ${reset_color}"
|
|
|
|
|
|
|
|
# Retrieve latest repository version
|
|
|
|
repo_version=$(lastversion ${repository} --newer-than ${current_version})
|
|
|
|
|
|
|
|
# Check last result code
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "${fg[red]}${repo_version}${fg[cyan]} > ${current_version}${reset_color}\n"
|
|
|
|
|
2024-06-20 13:00:06 +02:00
|
|
|
echo "${fg[cyan]}${repository}/releases/latest${reset_color}"
|
|
|
|
lastversion ${repository} --assets --filter="." \
|
|
|
|
| rg --color=always --passthru --regexp="${filter}"
|
2024-06-19 18:26:45 +02:00
|
|
|
|
|
|
|
else
|
|
|
|
echo "${fg[green]}${repo_version}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo ${reset_color}
|
2024-02-22 18:37:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
###
|
|
|
|
|
2024-06-20 13:00:06 +02:00
|
|
|
filter='([^/]+amd64\.deb|\w+\.txt)$'
|
2024-06-19 18:26:45 +02:00
|
|
|
|
2024-06-20 13:00:06 +02:00
|
|
|
debian bat 'https://github.com/sharkdp/bat'
|
|
|
|
debian delta 'https://github.com/dandavison/delta' git-delta
|
|
|
|
debian lsd 'https://github.com/lsd-rs/lsd'
|
2024-06-19 18:26:45 +02:00
|
|
|
|
2024-06-20 13:00:06 +02:00
|
|
|
filter='(Linux_x86_64|\w*\.appimage$|\w+\.appimage\.\w+sum$|\w+\.txt$)'
|
2024-06-19 18:26:45 +02:00
|
|
|
|
|
|
|
archive lazygit https://github.com/jesseduffield/lazygit
|
|
|
|
archive nvim https://github.com/neovim/neovim
|
2024-06-19 19:06:32 +02:00
|
|
|
|
2024-06-19 19:16:15 +02:00
|
|
|
print_age nnn
|
|
|
|
|
2024-06-19 19:06:32 +02:00
|
|
|
# Fonts
|
|
|
|
setopt nullglob
|
|
|
|
fonts=( $(echo /opt/fonts/**/*NerdFont* $HOME/.fonts/**/*NerdFont*) )
|
|
|
|
if (( ${#fonts} )); then
|
2024-06-20 13:00:06 +02:00
|
|
|
font_version=$(lastversion format "$(strings ${fonts[1]} | grep -o 'Nerd Fonts [0-9.]\+')")
|
2024-06-19 19:06:32 +02:00
|
|
|
fi
|
|
|
|
|
2024-06-20 13:00:06 +02:00
|
|
|
filter='((JetBrainsMono|NerdFontsSymbolsOnly)\.tar\.xz|\w+\.txt)$'
|
2024-06-19 19:06:32 +02:00
|
|
|
archive "Nerd Fonts" https://github.com/ryanoasis/nerd-fonts "${font_version}"
|