Last active
September 27, 2023 17:29
-
-
Save FelisDiligens/d5fcd98ccc99013c085b27857a822fb5 to your computer and use it in GitHub Desktop.
Setup Ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PACKAGE_LIST=( | |
# Essentials | |
ca-certificates | |
gnupg | |
apt-transport-https | |
vim | |
wget | |
curl | |
git | |
tar | |
unzip | |
p7zip | |
# Shell | |
fish | |
zoxide | |
bat | |
exa # eza | |
fzf | |
# Command line tools | |
shellcheck | |
imagemagick | |
# Build tools | |
build-essential | |
make | |
cmake | |
gcc | |
g++ | |
# Python | |
python3 | |
python-is-python3 | |
python3-pip | |
pipx | |
# Node.js | |
nodejs | |
npm | |
# Java | |
openjdk-19-jdk | |
#openjdk-20-jdk | |
# Docker | |
#docker.io | |
#docker-compose | |
) | |
GUI_PACKAGE_LIST=( | |
# Flatpak, and FUSE for AppImage | |
flatpak | |
libfuse2 | |
# Fonts | |
fonts-firacode | |
fonts-hack | |
fonts-liberation | |
) | |
function has_sudo_permission () { | |
# sudo -l -U $USER | |
if groups | grep -iq "wheel" || \ | |
groups | grep -iq "admin" || \ | |
groups | grep -iq "sudoers" || \ | |
groups | grep -iq "sudo"; then | |
return 0 | |
else | |
return 1 | |
fi | |
} | |
function install_software () { | |
# Update and install software | |
sudo apt update -y | |
# sudo apt install vim fish zoxide exa bat fzf wget curl git unzip shellcheck -y | |
sudo apt install "${PACKAGE_LIST[@]}" -y | |
if [[ "$XDG_CURRENT_DESKTOP" == "ubuntu:GNOME" ]]; then | |
sudo apt install "${GUI_PACKAGE_LIST[@]}" -y | |
fi | |
snap refresh | |
snap install clipboard # by bachatero | |
curl -sS https://starship.rs/install.sh | sh | |
} | |
function install_software_nonroot () { | |
bin_directory="$HOME/.local/bin" | |
mkdir -p "$bin_directory" | |
curl -sS https://starship.rs/install.sh | sh -s -- --bin-dir "$bin_directory" # Starship | |
curl -sS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash # Zoxide | |
# Exa | |
wget "https://github.com/ogham/exa/releases/download/v0.10.1/exa-linux-x86_64-musl-v0.10.1.zip" -O "$HOME/Downloads/exa.zip" | |
unzip "$HOME/Downloads/exa.zip" -d "$HOME/Downloads/exa" | |
cp "$HOME/Downloads/exa/bin/exa" "$bin_directory" | |
rm -v "$HOME/Downloads/exa.zip" | |
rm -rv "$HOME/Downloads/exa" | |
# fzf | |
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf | |
~/.fzf/install | |
# shellcheck | |
wget "https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz" -O "$HOME/Downloads/shellcheck.tar.xz" | |
mkdir -p "$HOME/Downloads/shellcheck" | |
tar -xJvf "$HOME/Downloads/shellcheck.tar.xz" -C "$HOME/Downloads/shellcheck" | |
cp "$HOME/Downloads/shellcheck/shellcheck-stable/shellcheck" "$bin_directory" | |
rm -v "$HOME/Downloads/shellcheck.tar.xz" | |
rm -rv "$HOME/Downloads/shellcheck" | |
# bat | |
wget "https://github.com/sharkdp/bat/releases/download/v0.23.0/bat-v0.23.0-x86_64-unknown-linux-musl.tar.gz" -O "$HOME/Downloads/bat.tar.gz" | |
mkdir -p "$HOME/Downloads/bat" | |
tar -xzvf "$HOME/Downloads/bat.tar.gz" -C "$HOME/Downloads/bat" | |
cp "$HOME/Downloads/bat/bat-v0.23.0-x86_64-unknown-linux-musl/bat" "$bin_directory" | |
rm -v "$HOME/Downloads/bat.tar.gz" | |
rm -rv "$HOME/Downloads/bat" | |
} | |
function copy_dotfiles () { | |
# Clone and copy dotfiles | |
mkdir -p "$HOME/Workspace" | |
pushd "$HOME/Workspace" || exit 1 | |
git clone --depth 1 "https://github.com/FelisDiligens/dotfiles.git" | |
popd || exit 1 | |
pushd "$HOME/Workspace/dotfiles" || exit 1 | |
< .bashrc tail -n +2 | tee -a "$HOME/.bashrc" | |
mkdir -p "$HOME/.bash" | |
mkdir -p "$HOME/.config" | |
cp "./.bash/aliases.sh" "$HOME/.bash/" | |
cp "./.bash/functions.sh" "$HOME/.bash/" | |
cp "./.bash/imagemagick-helpers.sh" "$HOME/.bash/" | |
cp "./.bash/options.sh" "$HOME/.bash/" | |
cp "./.bash/pipx.sh" "$HOME/.bash/" | |
cp "./.bash/prompt.sh" "$HOME/.bash/" | |
cp "./.bash/starship.sh" "$HOME/.bash/" | |
cp "./.bash/variables.sh" "$HOME/.bash/" | |
cp "./.bash/zoxide.sh" "$HOME/.bash/" | |
# cat <<EOF | tee "$HOME/.bash/variables.sh" | |
# #!/bin/bash | |
# export EDITOR="vim" | |
# export VISUAL="vim" | |
# export PATH=\$PATH:\$HOME/bin:\$HOME/.local/bin | |
# EOF | |
cp "./.gitconfig" "$HOME/" | |
cp "./.vimrc" "$HOME/" | |
cp "./.config/starship.toml" "$HOME/.config/" | |
cp -R "./.config/fish" "$HOME/.config/" | |
cp -R "./.config/fontconfig" "$HOME/.config/" | |
cp -R "./.config/gtk-3.0" "$HOME/.config/" | |
cat <<EOF | tee "$HOME/.hidden" | |
bin | |
go | |
snap | |
certs | |
EOF | |
popd || exit 1 | |
} | |
function download_nerdfonts () { | |
# Download Nerd fonts | |
wget "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.0.2/FiraCode.zip" -O "$HOME/Downloads/FiraCode.zip" | |
mkdir -p "$HOME/.fonts/FiraCode" | |
unzip "$HOME/Downloads/FiraCode.zip" -d "$HOME/.fonts/FiraCode" | |
rm -v "$HOME/Downloads/FiraCode.zip" | |
wget "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.0.2/Hack.zip" -O "$HOME/Downloads/Hack.zip" | |
mkdir -p "$HOME/.fonts/Hack" | |
unzip "$HOME/Downloads/Hack.zip" -d "$HOME/.fonts/Hack" | |
rm -v "$HOME/Downloads/Hack.zip" | |
fc-cache | |
} | |
function main () { | |
if has_sudo_permission; then | |
echo "Installing software globally." | |
install_software | |
else | |
echo "Installing software for user only." | |
install_software_nonroot | |
fi | |
copy_dotfiles | |
download_nerdfonts | |
} | |
if [ $UID == 0 ]; then | |
echo "Don't run as root!" | |
exit 1 | |
fi | |
main |
Author
FelisDiligens
commented
Sep 3, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment