标题很糟糕,不知道解释它的好方法是什么。
这可能都是一个坏主意,但我试图为Linux / Ubuntu做一种无限的事情。我希望在您检查要安装的内容的列表中显示正确样式的名称,而安装时需要包名称。我试图实现这一点,但没有太多运气。
菜单/互动位取自本网站。我只添加了数组作为选项,还有一些其他修改。我对此非常陌生,它主要是一个学习项目。
#!/bin/bash
# customize with your own.
#Packages
filezilla=("FileZilla" "filezilla" "ftp")
nmap=("Nmap" "nmap" "network_tools")
linssider=("LinSSIDer" "linssider" "network_tools")
wireshark=("Wireshark" "wireshark" "network_tools")
atom=("Atom" "atom" "editor")
vim=("Vim" "vim" "editor")
steam=("Steam" "steam" "chat")
streamlink=("Streamlink GUI" "streamlink" "media")
whois=("Whois" "whois" "network_tools")
htop=("Htop" "htop" "monitoring")
traceroute=("Traceroute" "traceroute" "network_tools")
options=(
"${filezilla[0]}"
#echo Network Tools
"${nmap[0]}"
"${linssider[0]}"
"${wireshark[0]}"
"${whois[0]}"
"${htop[0]}"
"${traceroute[0]}"
#echo "Text Editor"
"${atom[0]}"
"${vim[0]}"
#echo "Chat"
"${steam[0]}"
#echo "Media"
"${streamlink[0]}"
#select all in category x
#select all in cat y
)
#render list
clear
menu() {
echo ""
echo "What do you want to install:"
for i in ${!options[@]}; do
printf "%3d%s) %s\n" $((i+1)) "${choices[i]:- }" "${options[i]}"
done
[[ "$msg" ]] && echo "$msg"; :
}
#selecting
prompt="Check an option (again to uncheck, ENTER when done): "
while menu && read -rp "$prompt" num && [[ "$num" ]]; do
clear
[[ "$num" != *[![:digit:]]* ]] &&
(( num > 0 && num <= ${#options[@]} )) ||
{ msg="Invalid option: $num"; continue; }
((num--)); msg="${options[num]} was ${choices[num]:+un}checked"
[[ "${choices[num]}" ]] && choices[num]="" || choices[num]="+"
done
#what was selected
printf "You selected"; msg=" nothing"
for i in ${!options[@]}; do
[[ "${choices[i]}" ]] && { printf " \n%s" "${options[i]}"; msg=""; }
echo ${choices[1]}
done
echo "$msg"
#install selected
#sudo apt install -y update ${choices[1]}