diff --git a/distribution/ubuntu/install.sh b/distribution/ubuntu/install.sh index 1dccbbc..ab45241 100644 --- a/distribution/ubuntu/install.sh +++ b/distribution/ubuntu/install.sh @@ -99,7 +99,7 @@ install_docker() { } install_kubectl() { - curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.33/deb/Release.key | gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg + curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.33/deb/Release.key | gpg --batch --yes --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg chmod 644 /etc/apt/keyrings/kubernetes-apt-keyring.gpg echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.33/deb/ /' | tee /etc/apt/sources.list.d/kubernetes.list chmod 644 /etc/apt/sources.list.d/kubernetes.list @@ -110,34 +110,51 @@ install_kubectl() { export EXTRA_INSTALL_MESSAGE="Installing snap packages" extra_init() { # Install ghostty + echo -ne "ghostty" + # TODO: use a ppa / something updatable /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/mkasberg/ghostty-ubuntu/HEAD/install.sh)" >/dev/null 2>&1 if [ $? -ne 0 ]; then echo -e "${BRed}Could not install ghostty. Skipping.${NC}" fi + erase_text "ghostty" + + + # Install VSCode + # NOTE: would be better to install code-oss, and features+marketplace + echo -ne "code" + sudo snap install code --classic >/dev/null 2>&1 + erase_text "code" - # TODO: Install code-oss, and features+marketplace # TODO: Install jellyfin-media-player # Install android-studio - sudo snap install android-studio --classic >/dev/null 2>&1 - + echo -ne "android-studio" + snap install android-studio --classic >/dev/null 2>&1 + erase_text "android-studio" + # TODO: Install zen browser + echo -ne "github-cli" install_github_cli >/dev/null 2>&1 if [ $? -ne 0 ]; then echo -e "${BRed}Could not install github-cli. Skipping.${NC}" fi + erase_text "github-cli" # Docker, Kubectl + echo -ne "docker" install_docker >/dev/null 2>&1 if [ $? -ne 0 ]; then echo -e "${BRed}Could not install docker. Skipping.${NC}" fi + erase_text "docker" + echo -ne "kubectl" install_kubectl >/dev/null 2>&1 if [ $? -ne 0 ]; then echo -e "${BRed}Could not install kubectl. Skipping.${NC}" fi + erase_text "kubectl" } extra_finish() { diff --git a/dotfiles.sh b/dotfiles.sh new file mode 100644 index 0000000..2ffa746 --- /dev/null +++ b/dotfiles.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +install_dotfile_ifnot() { + mkdir -p $(dirname -- /home/${USERNAME}/${1}) + cp --update=none ${script_dir}/dotfiles/${1} /home/${USERNAME}/${1} +} + +echo "Installing dotfiles..." +# cp -r --update=none ${script_dir}/dotfiles/. /home/${USERNAME}/ +cat ${script_dir}/dotfiles/.config/git/config | envsubst '$GIT_USER $EMAIL' >/home/${USERNAME}/.config/git/config + +# Install bashrc if not mymachine-installed +if ! [[ "$(head -n 1 /home/${USERNAME}/.bashrc)" = "# mymachine" ]]; then + cp "${script_dir}/dotfiles/.bashrc" "/home/${USERNAME}/.bashrc" +fi + +# Install code settings depending on which code is installed +CODE_NAME="Code - OSS" +if [ "${ID}" = "ubuntu" ]; then + # On Ubuntu, we install official code snap + CODE_NAME="Code" +fi +mkdir -p /home/${USERNAME}/.config/${CODE_NAME}/User +cp "${script_dir}/dotfiles/.config/Code - OSS/User/settings.json" "/home/${USERNAME}/.config/${CODE_NAME}/User/settings.json" + +# Install ghostty, git, gh settings if not present +install_dotfile_ifnot .config/ghostty/config +install_dotfile_ifnot .config/git/config +install_dotfile_ifnot .config/gh/config.yml diff --git a/dotfiles/.bashrc b/dotfiles/.bashrc index 4784881..8ad9d9d 100644 --- a/dotfiles/.bashrc +++ b/dotfiles/.bashrc @@ -1,10 +1,13 @@ -# +# mymachine # ~/.bashrc # # If not running interactively, don't do anything [[ $- != *i* ]] && return +# OS-specific information +source /etc/os-release + # History file settings # No duplicate lines / lines starting with space in history HISTCONTROL=ignoreboth @@ -34,7 +37,12 @@ fi source /home/${USER}/.config/prompt.sh # Bitwarden SSH agent -export SSH_AUTH_SOCK=/home/${USER}/.bitwarden-ssh-agent.sock +if [ "${ID}" = "ubuntu" ]; then + # On Ubuntu, Bitwarden snap is used, which changes the sock path + export SSH_AUTH_SOCK=/home/${USER}/snap/bitwarden/current/.bitwarden-ssh-agent.sock +else + export SSH_AUTH_SOCK=/home/${USER}/.bitwarden-ssh-agent.sock +fi # PATH modifications # Local binaries @@ -48,3 +56,5 @@ alias e=${EDITOR} alias l="ls -lla" alias c="clear" alias k="kubectl" + +### End of default bashrc, append anything here diff --git a/dotfiles/.config/Code - OSS/User/settings.json b/dotfiles/.config/Code - OSS/User/settings.json index 4a6ea39..68ebd89 100644 --- a/dotfiles/.config/Code - OSS/User/settings.json +++ b/dotfiles/.config/Code - OSS/User/settings.json @@ -26,5 +26,9 @@ "workbench.preferredDarkColorTheme": "Adwaita Dark", "workbench.preferredLightColorTheme": "Adwaita Light", "editor.renderLineHighlight": "none", - "workbench.tree.indent": 12 + "workbench.tree.indent": 12, + "redhat.telemetry.enabled": false, + "telemetry.feedback.enabled": false, + "telemetry.telemetryLevel": "off", + "docker.lsp.telemetry": "off", } diff --git a/dotfiles/.config/prompt.sh b/dotfiles/.config/prompt.sh index 9f33607..1019cec 100644 --- a/dotfiles/.config/prompt.sh +++ b/dotfiles/.config/prompt.sh @@ -1,7 +1,5 @@ #!/usr/bin/env bash -source /etc/os-release - parse_git_branch() { branch=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ <\1>/') diff --git a/mymachine.sh b/mymachine.sh index 028d0b9..5762ebb 100755 --- a/mymachine.sh +++ b/mymachine.sh @@ -106,6 +106,13 @@ fi # Install packages source ${script_dir}/distribution/${ID}/install.sh +erase_text() { + # Remove text from terminal + count=$(echo "${1}" | wc -m) + for ((i=1; i<$count; i++)); do echo -ne '\b'; done + for ((i=1; i<$count; i++)); do echo -ne ' '; done + for ((i=1; i<$count; i++)); do echo -ne '\b'; done +} install_package() { package="${1}" command="${2}" @@ -118,11 +125,7 @@ install_package() { echo -e "\n${BRed}Failed to install package '${package}'. Skipping." fi - # Remove current package name from terminal - count=$(echo "${package}" | wc -m) - for ((i=1; i<$count; i++)); do echo -ne '\b'; done - for ((i=1; i<$count; i++)); do echo -ne ' '; done - for ((i=1; i<$count; i++)); do echo -ne '\b'; done + erase_text "${package}" } refresh_package_db @@ -138,8 +141,9 @@ done echo "" # Install distribution-specific extra packages -echo -e "Initializing extra package installation..." +echo -ne "Initializing extra package installation... " extra_init +echo "" echo -ne "${EXTRA_INSTALL_MESSAGE}... " for package in "${EXTRA_PACKAGES[@]}"; do install_package "${package}" install_extra_command @@ -165,6 +169,12 @@ fi export VSCODE_EXTENSIONS="${script_dir}/vscode-extensions.txt" echo -ne "Installing VSCode extensions... " i=0 total=$(wc -l < ${VSCODE_EXTENSIONS}); while read ext; do + # Ignore commented extensions + if [[ "${ext}" == \#* ]]; then + i=$((i + 1)) + continue + fi + # TODO: Here we assume extensions are at most a 2-digit number ; change that :) istr=$(printf "%02d" $i) echo -ne "\b\b\b\b\b${istr}/${total}" @@ -181,9 +191,7 @@ if [[ $i = $total ]]; then fi # Install dotfiles, without overwriting -echo "Installing dotfiles..." -cp -r --update=none ${script_dir}/dotfiles/. /home/${USERNAME}/ -cat ${script_dir}/dotfiles/.config/git/config | envsubst '$GIT_USER $EMAIL' >/home/${USERNAME}/.config/git/config +source "${script_dir}/dotfiles.sh" # Setup GRUB theme echo "Setting up GRUB theme..." @@ -223,4 +231,4 @@ if [ "$MICROCODE_INSTALLED" == "false" ]; then fi echo "To use WireGuard, don't forget to add this client on VPN server (your private key is under ~/.wireguard/privatekey)" echo "To use GitHub, you need to use 'gh auth login' to connect to GitHub" -echo -e "${BNC}Goodbye ! Make sure to ${BGreen}reboot${BNC} to apply all changes !${NC}" +echo -e "${BNC}Goodbye ! Make sure to ${BGreen}reboot${NC}${BNC} to apply all changes !${NC}" diff --git a/vscode-extensions.txt b/vscode-extensions.txt index 9b0e325..ba294bf 100644 --- a/vscode-extensions.txt +++ b/vscode-extensions.txt @@ -33,7 +33,7 @@ ms-vscode.hexeditor ms-vscode.makefile-tools ms-vscode.remote-explorer ms-vscode.vscode-serial-monitor -nvarner.typst-lsp +# nvarner.typst-lsp piousdeer.adwaita-theme pkief.material-icon-theme pkief.material-product-icons