mirror of
https://gitlab.com/dabruh/dotfiles.git
synced 2025-04-12 18:58:10 +02:00
Compare commits
23 commits
422d513037
...
ecf99fd136
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ecf99fd136 | ||
![]() |
569d807040 | ||
![]() |
4cbbf46270 | ||
![]() |
5690e8d1ce | ||
![]() |
4db75aa36c | ||
![]() |
e829294c1f | ||
![]() |
b8e2e5568e | ||
![]() |
9d4bd9c858 | ||
![]() |
1a1571a5d2 | ||
![]() |
5f82d19662 | ||
![]() |
48f7e427ac | ||
![]() |
b588774f7e | ||
![]() |
0adf10cfe9 | ||
![]() |
5754a02099 | ||
![]() |
c96e785676 | ||
![]() |
f8aad57c4b | ||
![]() |
fe6feee615 | ||
![]() |
29a6b36cd0 | ||
![]() |
f429afc5ee | ||
![]() |
efb6243145 | ||
![]() |
a5db9cdc9a | ||
![]() |
d1c9475692 | ||
![]() |
81b4be6471 |
7 changed files with 123 additions and 92 deletions
|
@ -1,2 +1 @@
|
|||
config.post-main-90-gaps
|
||||
config.post-main-90-laptop
|
||||
|
|
|
@ -15,7 +15,7 @@ alias \
|
|||
|
||||
# Kubernetes things
|
||||
alias \
|
||||
cx="kubectl ctx" \
|
||||
cx="kubectl-ctx" \
|
||||
f='flux' \
|
||||
h='helm' \
|
||||
k='kubectl' \
|
||||
|
|
|
@ -128,13 +128,13 @@ git_prompt_string() {
|
|||
|
||||
## Plugins section: Enable fish style features
|
||||
# Use syntax highlighting
|
||||
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||
source $HOME/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||
|
||||
# Use history substring search
|
||||
source /usr/share/zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh
|
||||
source $HOME/homebrew/share/zsh-history-substring-search/zsh-history-substring-search.zsh
|
||||
|
||||
# Use autosuggestion
|
||||
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
|
||||
source $HOME/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh
|
||||
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20
|
||||
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8'
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#!/usr/bin/zsh
|
||||
|
||||
# Auto-complete section
|
||||
autoload bashcompinit && bashcompinit
|
||||
command -v kubectl >/dev/null && . <(kubectl completion zsh) && complete -F __start_kubectl k
|
||||
command -v velero >/dev/null && . <(velero completion zsh) && complete -F __start_velero v
|
||||
command -v helm >/dev/null && . <(helm completion zsh) && complete -F _helm h
|
||||
command -v flux >/dev/null && . <(flux completion zsh) && complete -F _flux f
|
||||
command -v kubectl-ctx >/dev/null && complete -W "$(kubectl-ctx)" kubectl-ctx
|
||||
|
|
|
@ -1,19 +1,24 @@
|
|||
pacman-any:i3-gaps,feh,i3status,network-manager-applet,pasystray,xautolock,inotify-tools,xss-lock,noto-fonts-emoji
|
||||
pacman-any:gst-libav,phonon-qt5-gstreamer,gst-plugins-good,qt5-quickcontrols,qt5-graphicaleffects,qt5-multimedia
|
||||
pacman-any:code,vim,ufw,scrot,dunst
|
||||
pacman-laptop:brightnessctl
|
||||
aur-any:picom-git,sddm-theme-aerial-git
|
||||
pacman-base:acpi wget curl # Required for setup_system.sh
|
||||
pacman-any:i3-gaps feh i3status network-manager-applet pasystray xautolock inotify-tools xss-lock noto-fonts-emoji
|
||||
pacman-any:zsh tmux code vim ufw scrot dunst arandr ranger thunar flameshot
|
||||
pacman-any:gst-libav phonon-qt5-gstreamer gst-plugins-good qt5-quickcontrols qt5-graphicaleffects qt5-multimedia
|
||||
pacman-type-hasbattery:brightnessctl
|
||||
aur-any:picom-git sddm-theme-aerial-git
|
||||
|
||||
apt-any:i3-gaps,feh,i3status,nm-tray,pasystray,xautolock,inotify-tools,xss-lock,fonts-noto-color-emoji,xclip
|
||||
apt-any:libxext-dev,libxcb1-dev,libxcb-damage0-dev,libxcb-xfixes0-dev,libxcb-shape0-dev,libxcb-render-util0-dev,libxcb-render0-dev,libxcb-randr0-dev,libxcb-composite0-dev,libxcb-image0-dev,libxcb-present-dev,libxcb-xinerama0-dev,libxcb-glx0-dev,libpixman-1-dev,libdbus-1-dev,libconfig-dev,libgl1-mesa-dev,libpcre2-dev,libpcre3-dev,libevdev-dev,uthash-dev,libev-dev,libx11-xcb-dev,meson
|
||||
apt-any:python3,python3-pip
|
||||
apt-any:sddm,gstreamer1.0-libav qml-module-qtmultimedia libqt5multimedia5-plugins
|
||||
apt-any:codium,vim,ufw,scrot
|
||||
apt-laptop:brightnessctl
|
||||
|
||||
apt-any:libxcb-render0-dev,libffi-dev,python3-dev,python3-cffi
|
||||
apt-base:acpi wget curl # Required for setup_system.sh
|
||||
apt-any:i3 feh i3status nm-tray pasystray xautolock inotify-tools xss-lock fonts-noto-color-emoji fonts-hack-ttf xclip
|
||||
apt-any:chromium-browser zsh tmux codium vim ufw scrot dunst arandr ranger thunar flameshot
|
||||
apt-any:libxext-dev libxcb1-dev libxcb-damage0-dev libxcb-xfixes0-dev libxcb-shape0-dev libxcb-render-util0-dev libxcb-render0-dev libxcb-randr0-dev libxcb-composite0-dev libxcb-image0-dev libxcb-present-dev libxcb-xinerama0-dev libxcb-glx0-dev libpixman-1-dev libdbus-1-dev libconfig-dev libgl1-mesa-dev libpcre2-dev libpcre3-dev libevdev-dev uthash-dev libev-dev libx11-xcb-dev meson
|
||||
apt-any:python3 python3-pip
|
||||
apt-any:sddm gstreamer1.0-libav phonon4qt5-backend-gstreamer gstreamer1.0-plugins-good qml-module-qtquick-controls qml-module-qtgraphicaleffects qml-module-qtmultimedia
|
||||
apt-any:cargo cmake pkg-config libfreetype6-dev libfontconfig1-dev libxcb-xfixes0-dev libxkbcommon-dev python3
|
||||
apt-any:libxcb-render0-dev libffi-dev python3-dev python3-cffi
|
||||
apt-any:libpam-u2f # For YubiKey
|
||||
apt-type-hasbattery:brightnessctl
|
||||
pip-any:flashfocus
|
||||
|
||||
brew-formulas-any:helm,shellcheck,velero,azure/kubelogin/kubelogin,derailed/k9s/k9s,fluxcd/tap/flux,weaveworks/tap/gitops
|
||||
brew-host-5cg9521pyj:azure-cli
|
||||
brew-any:kubectl helm shellcheck velero azure/kubelogin/kubelogin derailed/k9s/k9s fluxcd/tap/flux weaveworks/tap/gitops # Kubernetes related
|
||||
brew-any:zsh-autosuggestions zsh-history-substring-search zsh-syntax-highlighting # ZSH related
|
||||
|
||||
krew-any:ctx,krew,ns,slice,stern,tree
|
||||
krew-any:ctx krew ns slice stern tree
|
||||
|
|
|
@ -89,5 +89,6 @@ function override_bg() {
|
|||
|
||||
install
|
||||
override_bg
|
||||
"$SCRIPT_DIR/.local/bin/i3-config-builder"
|
||||
i3-config-builder
|
||||
echo "Done! 👌"
|
||||
|
|
168
setup_system.sh
168
setup_system.sh
|
@ -4,9 +4,8 @@
|
|||
# Default variables
|
||||
#
|
||||
|
||||
UPGRADE_PACKAGES=false
|
||||
SCRIPT_NAME="$(basename -- "$0")"
|
||||
SCRIPT_DIR="$(
|
||||
upgrade_packages=false
|
||||
script_dir="$(
|
||||
cd -- "$(dirname "$0")" >/dev/null 2>&1 || exit 1
|
||||
pwd -P
|
||||
)"
|
||||
|
@ -16,7 +15,7 @@ SCRIPT_DIR="$(
|
|||
#
|
||||
|
||||
function usage() {
|
||||
echo "Usage: $SCRIPT_NAME [OPTIONS]"
|
||||
echo "Usage: $(basename -- "$0") [OPTIONS]"
|
||||
echo
|
||||
echo "Options:"
|
||||
echo " -h Display help."
|
||||
|
@ -27,7 +26,7 @@ function usage() {
|
|||
while getopts ":uh" arg; do
|
||||
case $arg in
|
||||
h) usage ;;
|
||||
u) UPGRADE_PACKAGES=true ;;
|
||||
u) upgrade_packages=true ;;
|
||||
:)
|
||||
echo "$0: Must supply an argument to -$OPTARG." >&2
|
||||
exit 1
|
||||
|
@ -49,24 +48,39 @@ function _acpib() {
|
|||
acpi -b | grep -Fv ' 0%'
|
||||
}
|
||||
|
||||
function is_laptop() {
|
||||
function has_battery() {
|
||||
[[ $(_acpib | wc -l) -gt 0 ]] && return 0 || return 1
|
||||
}
|
||||
|
||||
# Returns a comma-separated list of packages for one or more targets.
|
||||
# Returns a list of packages for one or more targets.
|
||||
# The packages file may contain multiple rows with the same target name.
|
||||
function get_packages() {
|
||||
local packages pkg_file="$SCRIPT_DIR/.installer/packages"
|
||||
local pkg_file="$script_dir/.installer/packages"
|
||||
|
||||
for target in "$@"; do
|
||||
while read -r row; do
|
||||
for package in ${row//,/ }; do
|
||||
for package in $row; do
|
||||
echo "$package"
|
||||
done
|
||||
done <<<"$(grep "^${target:?}:" "$pkg_file" | cut -d':' -f2)"
|
||||
done <<<"$(grep "^${target:?}:" "$pkg_file" | cut -d: -f2 | cut -d# -f1)"
|
||||
done
|
||||
}
|
||||
|
||||
# Return a list of targets for a given package manager
|
||||
function construct_target_list() {
|
||||
local package_manager=${1:?package_manager not set} targets=()
|
||||
|
||||
targets+=("$package_manager-any")
|
||||
targets+=("$package_manager-host-$(hostname | cut -d. -f1)")
|
||||
has_battery && targets+=("$package_manager-type-hasbattery")
|
||||
echo "${targets[@],,}" # Return lowercase
|
||||
}
|
||||
|
||||
function setup_pip_packages() {
|
||||
# shellcheck disable=SC2046
|
||||
sudo pip3 install $(get_packages $(construct_target_list pip)) --no-input || return 1
|
||||
}
|
||||
|
||||
function install_sddm_aerial_theme() {
|
||||
local theme_dir="/usr/share/sddm/themes/aerial"
|
||||
|
||||
|
@ -103,6 +117,7 @@ function configure_sddm() {
|
|||
|
||||
echo "Setting up '$theme_dir'."
|
||||
[ -f "$theme_user_config" ] && sudo mv "$theme_user_config" "$theme_user_config.disabled"
|
||||
return 0
|
||||
}
|
||||
|
||||
function configure_ufw() {
|
||||
|
@ -148,13 +163,12 @@ function setup_homebrew() {
|
|||
}
|
||||
|
||||
function setup_brew_formulas() {
|
||||
local targets=("brew-formulas-any") packages
|
||||
|
||||
brew update || return 1
|
||||
|
||||
for package in $(get_packages "${targets[@]}"); do
|
||||
# shellcheck disable=SC2046
|
||||
for package in $(get_packages $(construct_target_list brew)); do
|
||||
if brew list --full-name | grep -Eq "(^| )$package($| )" >/dev/null; then
|
||||
if $UPGRADE_PACKAGES; then
|
||||
if $upgrade_packages; then
|
||||
echo "Package '$package' will be upgraded."
|
||||
brew upgrade "$package" || return 2
|
||||
else
|
||||
|
@ -168,17 +182,29 @@ function setup_brew_formulas() {
|
|||
done
|
||||
}
|
||||
|
||||
function setup_krew() {
|
||||
cd "$(mktemp -d)" &&
|
||||
OS="$(uname | tr '[:upper:]' '[:lower:]')" &&
|
||||
ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" &&
|
||||
KREW="krew-${OS}_${ARCH}" &&
|
||||
curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" &&
|
||||
tar zxvf "${KREW}.tar.gz" &&
|
||||
./"${KREW}" install krew
|
||||
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
|
||||
}
|
||||
|
||||
function setup_krew_plugins() {
|
||||
local targets=("krew-any") packages
|
||||
local targets=("krew-any")
|
||||
|
||||
if ! command -v kubectl-krew >/dev/null; then
|
||||
echo "WARN: Krew not installed: kubectl-krew"
|
||||
return 1
|
||||
fi
|
||||
|
||||
for package in $(get_packages "${targets[@]}"); do
|
||||
# shellcheck disable=SC2046
|
||||
for package in $(get_packages $(construct_target_list krew)); do
|
||||
if kubectl-krew list | grep -q "^$package$" >/dev/null; then
|
||||
if $UPGRADE_PACKAGES; then
|
||||
if $upgrade_packages; then
|
||||
echo "Package '$package' will be upgraded."
|
||||
else
|
||||
echo "Package '$package' already exists."
|
||||
|
@ -192,6 +218,23 @@ function setup_krew_plugins() {
|
|||
done
|
||||
}
|
||||
|
||||
function build_alacritty() {
|
||||
local tmp_dir="/tmp/alacritty"
|
||||
|
||||
echo "Installing Alacritty."
|
||||
git clone https://github.com/alacritty/alacritty.git $tmp_dir
|
||||
sudo cargo build --release --manifest-path=$tmp_dir/Cargo.toml
|
||||
sudo cp $tmp_dir/target/release/alacritty /usr/local/bin
|
||||
sudo cp $tmp_dir/extra/logo/alacritty-term.svg /usr/share/pixmaps/Alacritty.svg
|
||||
sudo desktop-file-install $tmp_dir/extra/linux/Alacritty.desktop
|
||||
sudo update-desktop-database
|
||||
sudo rm -Rf /tmp/alacritty
|
||||
}
|
||||
|
||||
function change_shell() {
|
||||
sudo chsh -s "$(which zsh)" "$USER"
|
||||
}
|
||||
|
||||
#
|
||||
# Setup for Arch-like systems
|
||||
#
|
||||
|
@ -202,21 +245,15 @@ function prepare_arch() {
|
|||
}
|
||||
|
||||
function setup_arch_with_pamac() {
|
||||
local targets=("pacman-any") packages
|
||||
is_laptop && targets+=("pacman-laptop")
|
||||
|
||||
packages="$(get_packages "${targets[@]}")"
|
||||
# shellcheck disable=SC2086
|
||||
sudo pamac install $packages --no-confirm || return 1
|
||||
# shellcheck disable=SC2046
|
||||
sudo pamac install $(get_packages $(construct_target_list pacman)) --no-confirm || return 1
|
||||
}
|
||||
|
||||
function setup_arch_with_yay() {
|
||||
local targets=("aur-any") packages
|
||||
is_laptop && targets+=("aur-laptop")
|
||||
|
||||
for package in $(get_packages "${targets[@]}"); do
|
||||
# shellcheck disable=SC2046
|
||||
for package in $(get_packages $(construct_target_list aur)); do
|
||||
if pacman -Qs "^$package$" >/dev/null; then
|
||||
if $UPGRADE_PACKAGES; then
|
||||
if $upgrade_packages; then
|
||||
echo "Package '$package' will be upgraded."
|
||||
else
|
||||
echo "Package '$package' already exists."
|
||||
|
@ -230,35 +267,24 @@ function setup_arch_with_yay() {
|
|||
done
|
||||
}
|
||||
|
||||
function setup_arch_with_pip(){
|
||||
local targets=("pip-any") packages
|
||||
|
||||
packages="$(get_packages "${targets[@]}")"
|
||||
# shellcheck disable=SC2086
|
||||
sudo pip3 install $packages --no-input || return 1
|
||||
}
|
||||
|
||||
function setup_arch() {
|
||||
prepare_arch || return 1
|
||||
setup_arch_with_pamac || return 2
|
||||
setup_arch_with_yay || return 3
|
||||
setup_arch_with_pip || return 4
|
||||
setup_pip_packages || return 4
|
||||
configure_sddm || return 5
|
||||
configure_ufw || return 6
|
||||
setup_homebrew || return 7
|
||||
setup_brew_formulas || return 8
|
||||
setup_krew_plugins || return 9
|
||||
setup_krew || return 9
|
||||
setup_krew_plugins || return 10
|
||||
change_shell || return 11
|
||||
}
|
||||
|
||||
#
|
||||
# Setup for Debian-like systems
|
||||
#
|
||||
|
||||
function setup_debian_repo_i3gaps() {
|
||||
echo "Setting up repository for i3-gaps."
|
||||
sudo add-apt-repository -y ppa:regolith-linux/release
|
||||
}
|
||||
|
||||
function setup_debian_repo_vscodium() {
|
||||
echo "Setting up repository for VSCodium."
|
||||
wget -qO - https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/master/pub.gpg |
|
||||
|
@ -268,57 +294,55 @@ function setup_debian_repo_vscodium() {
|
|||
sudo tee /etc/apt/sources.list.d/vscodium.list
|
||||
}
|
||||
|
||||
function prepare_debian() {
|
||||
setup_debian_repo_i3gaps || return 1
|
||||
setup_debian_repo_vscodium || return 2
|
||||
function setup_debian_base_with_apt() {
|
||||
sudo apt-get update
|
||||
# shellcheck disable=SC2046
|
||||
sudo apt-get install $(get_packages apt-base) -y || return 1
|
||||
}
|
||||
|
||||
function setup_debian_with_apt() {
|
||||
local targets=("apt-any") packages
|
||||
is_laptop && targets+=("apt-laptop")
|
||||
|
||||
packages="$(get_packages "${targets[@]}")"
|
||||
sudo apt-get update
|
||||
# shellcheck disable=SC2086
|
||||
sudo apt-get install $packages -y || return 1
|
||||
}
|
||||
|
||||
function setup_debian_with_pip(){
|
||||
local targets=("pip-any") packages
|
||||
|
||||
packages="$(get_packages "${targets[@]}")"
|
||||
# shellcheck disable=SC2086
|
||||
sudo pip3 install $packages --no-input || return 1
|
||||
# shellcheck disable=SC2046
|
||||
sudo apt-get install $(get_packages $(construct_target_list apt)) -y || return 2
|
||||
}
|
||||
|
||||
function setup_debian_with_git() {
|
||||
install_picom || return 1
|
||||
install_sddm_aerial_theme || return 2
|
||||
build_alacritty || return 3
|
||||
}
|
||||
|
||||
function setup_debian() {
|
||||
prepare_debian || return 1
|
||||
setup_debian_with_apt || return 2
|
||||
setup_debian_with_pip || return 3
|
||||
setup_debian_with_git || return 4
|
||||
configure_sddm || return 5
|
||||
configure_ufw || return 6
|
||||
setup_homebrew || return 7
|
||||
setup_brew_formulas || return 8
|
||||
setup_krew_plugins || return 9
|
||||
setup_debian_base_with_apt || return 1
|
||||
setup_debian_repo_vscodium || return 2
|
||||
setup_debian_with_apt || return 3
|
||||
setup_pip_packages || return 4
|
||||
setup_debian_with_git || return 5
|
||||
configure_sddm || return 6
|
||||
configure_ufw || return 7
|
||||
setup_homebrew || return 8
|
||||
setup_brew_formulas || return 9
|
||||
setup_krew || return 10
|
||||
setup_krew_plugins || return 11
|
||||
change_shell || return 12
|
||||
}
|
||||
|
||||
if [ "$EUID" -eq 0 ]; then
|
||||
echo "Don't run this script as root." 1>&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
ID_LIKE="$(grep ID_LIKE= </etc/os-release | cut -d= -f2)"
|
||||
|
||||
echo "Setting up ${ID_LIKE^:?}-like OS."
|
||||
|
||||
if [[ "$ID_LIKE" == "arch" ]]; then
|
||||
setup_arch
|
||||
setup_arch || echo "Setup failed: $?"
|
||||
elif [[ "$ID_LIKE" == "debian" ]]; then
|
||||
setup_debian
|
||||
setup_debian || echo "Setup failed: $?"
|
||||
else
|
||||
echo "ERROR: Unsupported system: ID_LIKE=$ID_LIKE"
|
||||
exit 2
|
||||
exit 3
|
||||
fi
|
||||
|
||||
echo "Setup finished."
|
||||
|
|
Loading…
Reference in a new issue