151 lines
3.4 KiB
Bash
Executable File
151 lines
3.4 KiB
Bash
Executable File
#!/bin/zsh
|
|
#
|
|
|
|
# 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
|
|
|
|
# asdf, direnv, python & lastversion
|
|
#
|
|
# - https://github.com/dvershinin/lastversion
|
|
#
|
|
cd $(dirname $0)
|
|
eval $(asdf exec direnv export zsh)
|
|
|
|
# Debian Package
|
|
#
|
|
function debian
|
|
{
|
|
program=$1
|
|
repository=$2
|
|
apt_name=${3:-$1}
|
|
current_version="0.0.0"
|
|
|
|
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}")
|
|
|
|
# Highlight program's version
|
|
echo ${prog_out} | grep --colour=always -F "${current_version}"
|
|
\ls -lh =${program}
|
|
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"
|
|
|
|
echo -n ${repository}/releases
|
|
echo "${fg[cyan]}"
|
|
lastversion ${repository} --filter="${filter}" --assets
|
|
|
|
else
|
|
echo "${fg[green]}${repo_version}"
|
|
fi
|
|
echo -n ${reset_color}
|
|
|
|
|
|
# Debian Package
|
|
apt_list=$(apt list ${apt_name} 2>/dev/null)
|
|
deb_version=$(lastversion format "${apt_list}" 2>/dev/null)
|
|
|
|
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"
|
|
else
|
|
echo "${fg[green]}${deb_version}"
|
|
fi
|
|
echo -n ${reset_color}
|
|
fi
|
|
|
|
echo
|
|
}
|
|
|
|
# Archive
|
|
#
|
|
function archive
|
|
{
|
|
program=$1
|
|
repository=$2
|
|
current_version="0.0.0"
|
|
|
|
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
|
|
|
|
# Highlight program's version
|
|
echo ${prog_out} | grep --colour=always -F "${current_version}"
|
|
\ls -lh =${program}
|
|
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"
|
|
|
|
echo -n ${repository}/releases
|
|
echo "${fg[cyan]}"
|
|
lastversion ${repository} --filter="${filter}" --assets
|
|
|
|
else
|
|
echo "${fg[green]}${repo_version}"
|
|
fi
|
|
|
|
echo ${reset_color}
|
|
}
|
|
|
|
###
|
|
|
|
filter=amd64\\.deb
|
|
|
|
debian bat "https://github.com/sharkdp/bat"
|
|
debian delta "https://github.com/dandavison/delta" git-delta
|
|
debian lsd "https://github.com/lsd-rs/lsd"
|
|
|
|
filter=Linux_x86_64
|
|
|
|
archive lazygit https://github.com/jesseduffield/lazygit
|
|
archive nvim https://github.com/neovim/neovim
|