From 3150e5d1bb77899d4b71338619b89b2201dc9fca Mon Sep 17 00:00:00 2001 From: Jedrzej Orbik Date: Wed, 25 Sep 2024 18:01:58 +0200 Subject: [PATCH] WIP --- README.md | 20 +++++- common/.config/nvim/lazy-lock.json | 14 ++--- debian/.config/clangd | 1 + debian/clangd | 1 - dotfiles_private | 2 +- scripts/debian/install.sh | 5 +- scripts/debian/install_min.sh | 97 +++++++++++++----------------- scripts/install.sh | 73 ++++++++++++++++------ scripts/macos/install.sh | 1 - scripts/set_up_common.sh | 17 ++++-- scripts/uninstall.sh | 32 ++++++---- 11 files changed, 158 insertions(+), 105 deletions(-) create mode 120000 debian/.config/clangd delete mode 120000 debian/clangd diff --git a/README.md b/README.md index 6fb3ac8..eba8514 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,19 @@ # dotfiles -### TODO: -- at some point: - - use better option for installing dotfiles, like stow or [chezmoi](https://www.chezmoi.io) +To install: + +Clone: +``` +git clone https://github.com/Jendker/dotfiles.git ~/.dotfiles +# to clone with the private dotfiles +git clone --recurse-submodules https://github.com/Jendker/dotfiles.git ~/.dotfiles +``` + +Install: +``` +# Minimal debian or macos +~/.dotfiles/scripts/install.sh + +# Full debian install for development machine +~/.dotfiles/scripts/install.sh --dev +``` diff --git a/common/.config/nvim/lazy-lock.json b/common/.config/nvim/lazy-lock.json index 013d5a1..537cbe6 100644 --- a/common/.config/nvim/lazy-lock.json +++ b/common/.config/nvim/lazy-lock.json @@ -1,5 +1,5 @@ { - "CopilotChat.nvim": { "branch": "canary", "commit": "2352cd3e7e980cd73594be05f96b2dc4c0dd4a74" }, + "CopilotChat.nvim": { "branch": "canary", "commit": "9333944fde3c65868818e245c73aa29eef826e9b" }, "LuaSnip": { "branch": "master", "commit": "e808bee352d1a6fcf902ca1a71cee76e60e24071" }, "Navigator.nvim": { "branch": "master", "commit": "91d86506ac2a039504d5205d32a1d4bc7aa57072" }, "aerial.nvim": { "branch": "master", "commit": "140f48fb068d21c02e753c63f7443649e55576f0" }, @@ -16,7 +16,7 @@ "copilot.lua": { "branch": "master", "commit": "1a237cf50372830a61d92b0adf00d3b23882e0e1" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, "dressing.nvim": { "branch": "master", "commit": "1b7921eecc65af1baf8ac1dc06f0794934cbcfb2" }, - "dropbar.nvim": { "branch": "master", "commit": "b7b0cd2670cfab298afc955f2531206218736766" }, + "dropbar.nvim": { "branch": "master", "commit": "a12869f34f8cd236dc708fb2815ccf1663000bf4" }, "flash.nvim": { "branch": "main", "commit": "34c7be146a91fec3555c33fe89c7d643f6ef5cf1" }, "friendly-snippets": { "branch": "main", "commit": "00ba9dd3df89509f95437b8d595553707c46d5ea" }, "fugitive-gitlab.vim": { "branch": "master", "commit": "838d3a110836f511be099002ce1a71493c042615" }, @@ -30,7 +30,7 @@ "indent-blankline.nvim": { "branch": "master", "commit": "18603eb949eba08300799f64027af11ef922283f" }, "kanagawa.nvim": { "branch": "master", "commit": "f491b0fe68fffbece7030181073dfe51f45cda81" }, "last-color.nvim": { "branch": "main", "commit": "4086c5810bbe35b4184502f190e8d1ba910180cd" }, - "lazy.nvim": { "branch": "main", "commit": "460e1cd8f24e364d54543a4b0e83f6f4ec1f65fb" }, + "lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" }, "lsp-zero.nvim": { "branch": "v4.x", "commit": "b8411704591ae8e1501f1b9b31c801c09927baac" }, "lsp_signature.nvim": { "branch": "master", "commit": "fc38521ea4d9ec8dbd4c2819ba8126cea743943b" }, "lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" }, @@ -39,7 +39,7 @@ "mason-null-ls.nvim": { "branch": "main", "commit": "de19726de7260c68d94691afb057fa73d3cc53e7" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "8b9363d83b5d779813cdd2819b8308651cec2a09" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, - "neoconf.nvim": { "branch": "main", "commit": "c5516054f2342e6fe4d3befd56249d02d5eeb380" }, + "neoconf.nvim": { "branch": "main", "commit": "4bba87a057867004e70596dafe7262bbaac38810" }, "neoscroll.nvim": { "branch": "master", "commit": "4e0428a41c6ec191df543fc95349f6e1c598e53f" }, "nvim-autopairs": { "branch": "master", "commit": "f158dcb865c36f72c92358f87787dab2c272eaf3" }, "nvim-bqf": { "branch": "main", "commit": "1b24dc6050c34e8cd377b6b4cd6abe40509e0187" }, @@ -53,12 +53,12 @@ "nvim-early-retirement": { "branch": "main", "commit": "2c36a5671b9d8f0d9e11b77c5a55de802bc45e34" }, "nvim-fundo": { "branch": "main", "commit": "ac9c9372c4bf677721e24f144ef29d3a05c2b589" }, "nvim-lint": { "branch": "master", "commit": "968a35d54b3a4c1ce66609cf80b14d4ae44fe77f" }, - "nvim-lspconfig": { "branch": "master", "commit": "dd329912c8d446240584a2dbcd3802af3a19105a" }, + "nvim-lspconfig": { "branch": "master", "commit": "a9bc587e9ae0cbcb3e90a2e9342f86b3b78c4408" }, "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, "nvim-scrollview": { "branch": "main", "commit": "401c0498689dcaa54b2e7483d823e33cdc051e72" }, "nvim-spectre": { "branch": "master", "commit": "ba7fb777edff6c1fbbeffd343e113af64c04e90a" }, "nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" }, - "nvim-treesitter": { "branch": "master", "commit": "6511cd984ab4b21e28f83af488f38dc89c3b0586" }, + "nvim-treesitter": { "branch": "master", "commit": "0c8a582e474e248f2a4406188e0c653f92a064cf" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "bf8d2ad35d1d1a687eae6c065c3d524f7ab61b23" }, "nvim-web-devicons": { "branch": "master", "commit": "26220156aafb198b2de6a4cf80c1b120a3768da0" }, "oil.nvim": { "branch": "master", "commit": "1360be5fda9c67338331abfcd80de2afbb395bcd" }, @@ -70,7 +70,7 @@ "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, "promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" }, "quicker.nvim": { "branch": "master", "commit": "183041a46d6c908eefb1c23ea02cce9c8f41256e" }, - "render-markdown.nvim": { "branch": "main", "commit": "67288febca78b7aac8fae9543ef8980237e27d2a" }, + "render-markdown.nvim": { "branch": "main", "commit": "aad1a1220dc9da5757e3af3befbc7fc3869dd334" }, "spaceless.nvim": { "branch": "main", "commit": "8d46bc098dba18d4e19bce89bf19aab5007ef767" }, "stickybuf.nvim": { "branch": "master", "commit": "183b9569bef78f44b17c078214f7d731f19cbefe" }, "substitute.nvim": { "branch": "main", "commit": "17ffaeb5a1dc2dbef39cf0865d8a4b6000836714" }, diff --git a/debian/.config/clangd b/debian/.config/clangd new file mode 120000 index 0000000..8d4b595 --- /dev/null +++ b/debian/.config/clangd @@ -0,0 +1 @@ +../../redundant/clangd \ No newline at end of file diff --git a/debian/clangd b/debian/clangd deleted file mode 120000 index 8462b08..0000000 --- a/debian/clangd +++ /dev/null @@ -1 +0,0 @@ -../redundant/clangd \ No newline at end of file diff --git a/dotfiles_private b/dotfiles_private index e94ab1a..341c9a7 160000 --- a/dotfiles_private +++ b/dotfiles_private @@ -1 +1 @@ -Subproject commit e94ab1ab350fa00f5b5e1b561655d0b0a12ffb73 +Subproject commit 341c9a771d46bedcacffa541a289bbc45b8133d0 diff --git a/scripts/debian/install.sh b/scripts/debian/install.sh index 34e95f9..8472399 100755 --- a/scripts/debian/install.sh +++ b/scripts/debian/install.sh @@ -1,5 +1,6 @@ #!/bin/bash set -e +set -x SCRIPT_DIR=$(dirname "$0") ROOT_DIR=$(realpath "${SCRIPT_DIR}/../..") @@ -20,8 +21,6 @@ function setup_nerdfont() { git clone https://github.com/epk/SF-Mono-Nerd-Font.git /tmp/SF-Mono-Nerd-Font cp /tmp/SF-Mono-Nerd-Font/*.otf ~/.local/share/fonts/ rm -rf /tmp/SF-Mono-Nerd-Font - cp "$ROOT_DIR"/dotfiles_private/fonts/* ~/.local/share/fonts/ - rm ~/.local/share/fonts/MonacoNerdFont-Regular.ttf fc-cache -f } @@ -43,7 +42,7 @@ function setup_spotify() { if ! [ -x "$(command -v spotify)" ]; then curl -sS https://download.spotify.com/debian/pubkey_6224F9941A8AA6D1.gpg | sudo gpg --dearmor --yes -o /etc/apt/trusted.gpg.d/spotify.gpg echo "deb http://repository.spotify.com stable non-free" | sudo tee /etc/apt/sources.list.d/spotify.list - sudo apt-get update && sudo apt-get install spotify-client + sudo apt-get update && sudo apt-get install spotify-client -y fi } diff --git a/scripts/debian/install_min.sh b/scripts/debian/install_min.sh index 61a6869..342ac14 100755 --- a/scripts/debian/install_min.sh +++ b/scripts/debian/install_min.sh @@ -1,5 +1,6 @@ #!/bin/bash set -e +set -x SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) @@ -28,8 +29,6 @@ function install_nvim_source() { branch_str="--branch $1" fi sudo apt-get install ninja-build gettext cmake unzip curl -y - sudo apt install libreadline-dev -y # for hererocks - sudo apt install libmagickwand-dev -y # for image.nvim cd /tmp && rm -rf neovim && git clone https://github.com/neovim/neovim.git $branch_str --single-branch cd neovim if [ "$1" == "master" ]; then @@ -58,17 +57,6 @@ function install_nvim_tarball() { export PATH="$PATH:/opt/nvim-linux64/bin" } -function update_dotfiles() { - cd /tmp/ && rm -rf dotfiles && git clone https://github.com/Jendker/dotfiles.git - mkdir -p $HOME/.config - bash dotfiles/install.sh --copy - run_times=1 - nvim --headless "+Lazy! install" +qa - # repeat again until successful - while [ $? -ne 0 ]; do !!; done - rm -rf dotfiles -} - function install_node() { installed=false if ! [ -x "$(command -v nvm)" ]; then @@ -160,6 +148,8 @@ function install_nvim_binary() { fi install_node update_git + sudo apt install libreadline-dev -y # for hererocks + sudo apt install libmagickwand-dev -y # for image.nvim } function install_zoxide() { @@ -218,16 +208,12 @@ function install_direnv() { } if [[ ! $# -eq 0 ]]; then - if [[ $1 == "--update" ]]; then - echo "Updating dotfiles..." - update_dotfiles - exit 0 - elif [[ $1 == "--update-nvim" ]]; then - echo "Updating nvim binary..." + if [[ $1 == "--install-nvim" ]]; then + echo "Installing nvim binary..." install_nvim_binary stable exit 0 - elif [[ $1 == "--update-nvim-dev" ]]; then - echo "Updating nvim binary from git dev branch..." + elif [[ $1 == "--install-nvim-dev" ]]; then + echo "Installing nvim binary from git dev branch..." install_nvim_binary master exit 0 elif [[ $1 == "--install-node" ]]; then @@ -256,8 +242,9 @@ if [[ ! $# -eq 0 ]]; then fi fi +# --- MAIN --- sudo apt update -sudo apt install tmux curl wget locales lsb-release zsh xclip unzip python3-venv fd-find ccache git imagemagick pipx -y +sudo apt install tmux curl wget locales lsb-release zsh xclip unzip python3-venv fd-find ccache git imagemagick pipx libglib2.0-bin vim zsh -y # for thefuck sudo apt install python3-dev python3-pip python3-setuptools -y # symlink fdfind as fd @@ -266,12 +253,38 @@ ln -s $(which fdfind) $HOME/.local/bin/fd || true sudo apt install ripgrep -y || true +# set up nvim +if ! [ -x "$(command -v nvim)" ]; then + echo 'nvim is not installed. installing' + install_nvim_binary stable + # install plugins + nvim --headless "+Lazy! install" +qa + # repeat again until successful + while [ $? -ne 0 ]; do !!; done +fi + +# set up fzf for zsh +if [ ! -d "$HOME/.fzf" ]; then + git clone --depth 1 https://github.com/junegunn/fzf.git $HOME/.fzf + $HOME/.fzf/install --key-bindings --completion --update-rc --no-bash +fi + +# install git lfs +if ! command_exists git-lfs; then + curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash && sudo apt-get install git-lfs && git lfs install +fi + +install_zoxide + +install_direnv + +install_delta + +install_gh + # run set_up_common.sh "$SCRIPT_DIR/../set_up_common.sh" -if command -v doit &>/dev/null; then - pipx install thefuck -fi if ! grep -q "unsetopt BEEP" $HOME/.zshrc; then sudo tee -a $HOME/.zshrc >/dev/null <<'EOT' if command -v nvim &> /dev/null; then @@ -286,10 +299,12 @@ export LC_ALL=en_US.UTF-8 export PATH=$PATH:$HOME/.local/bin export PATH="/usr/lib/ccache:$PATH" eval $(thefuck --alias doit) - -# don't show the warning which happens if direnv loads the .envrc file -typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet EOT + +if command -v thefuck &>/dev/null; then + pipx install thefuck +fi + # set plugin variables before sourcing oh-my-zsh ex -s $HOME/.zshrc <<\IN /source \$ZSH\/oh-my-zsh.sh/i @@ -314,29 +329,3 @@ sudo locale-gen en_US.UTF-8 # .tmux.conf grep -qxF 'set-option -g default-shell /bin/zsh' $HOME/.tmux.conf || echo "set-option -g history-limit 125000\nset-option -g default-shell /bin/zsh" >>$HOME/.tmux.conf - -# set up nvim -if ! [ -x "$(command -v nvim)" ]; then - echo 'nvim is not installed. installing' - install_nvim_binary stable - update_dotfiles -fi - -# set up fzf for zsh -if [ ! -d "$HOME/.fzf" ]; then - git clone --depth 1 https://github.com/junegunn/fzf.git $HOME/.fzf - $HOME/.fzf/install --key-bindings --completion --update-rc --no-bash -fi - -# install git lfs -if ! command_exists git-lfs; then - curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash && sudo apt-get install git-lfs && git lfs install -fi - -install_zoxide - -install_direnv - -install_delta - -install_gh diff --git a/scripts/install.sh b/scripts/install.sh index b8a5a2e..f4671fe 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -6,6 +6,22 @@ set -e SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) ROOT_DIR=$(dirname "$SCRIPT_DIR") +# Initialize flags +dev=false +copy=false +install_only=false + +# Loop through the arguments +for arg in "$@"; do + if [ "$arg" == "--copy" ]; then + copy=true + elif [ "$arg" == "--optional" ]; then + dev=true + elif [ "$arg" == "--install-only" ]; then + install_only=true + fi +done + copy=false if [[ $1 == "--copy" ]]; then copy=true @@ -43,30 +59,49 @@ if ! [ -x "$(command -v stow)" ]; then fi brew install stow else - echo "Unsupported OS" + echo "Unsupported OS" fi fi -# Stow common config -stow -t ~ common -cd dotfiles_private/stow -stow -t ~ common_private -cd ../.. - # Stow platform-specific config if [[ "$OSTYPE" == "linux-gnu"* ]]; then - stow -t ~ debian - cd dotfiles_private/stow - stow -t ~ debian_private - cd ../.. - scripts/debian/install_min.sh - scripts/debian/install.sh --optional + prefix="debian" elif [[ "$OSTYPE" == "darwin"* ]]; then - stow -t ~ macos - cd dotfiles_private/stow - stow -t ~ macos_private - cd ../.. - scripts/macos/install.sh + prefix="macos" else - echo "Unsupported OS" + echo "Unsupported OS" +fi + +if [[ $install_only != true ]]; then + # Stow common config + stow -t ~ common + stow -t ~ "${prefix}" +fi + +# Platform-specific config install +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + "${SCRIPT_DIR}/debian/install_min.sh" + if [[ $dev == true ]]; then + "${SCRIPT_DIR}/debian/install.sh" --optional + fi +elif [[ "$OSTYPE" == "darwin"* ]]; then + "${SCRIPT_DIR}/macos/install.sh" +else + echo "Unsupported OS" +fi + +echo "Current directory: $(pwd)" + +# Private submodule install +SUBMODULE_PATH="dotfiles_private" +# Check if the submodule is not empty +if [[ ! -z "$(ls -A ${SUBMODULE_PATH})" ]]; then + echo "Private submodule is available. Installing..." + install_only_arg="" + if [[ $install_only == true ]]; then + install_only_arg="--install-only" + fi + "${SUBMODULE_PATH}/scripts/install.sh" $install_only_arg +else + echo "Private submodule is not cloned. Skipping installation." fi diff --git a/scripts/macos/install.sh b/scripts/macos/install.sh index 130af54..d60185c 100755 --- a/scripts/macos/install.sh +++ b/scripts/macos/install.sh @@ -12,7 +12,6 @@ if [ -e "$KEYBOARD_SOURCE_PATH" ] && [ ! -e $KEYBOARD_TARGET_PATH ]; then cp "$KEYBOARD_SOURCE_PATH" "$KEYBOARD_TARGET_PATH" echo "Reboot and add the Polish-German keyboard layout from Polish keyboards" fi -cp $ROOT_DIR/dotfiles_private/fonts/* ~/Library/Fonts/ SSH_CONFIG_PATH=/etc/ssh/sshd_config.d/100-macos.conf if ! grep -Fxq "PasswordAuthentication no" "$SSH_CONFIG_PATH"; then diff --git a/scripts/set_up_common.sh b/scripts/set_up_common.sh index 42b1ae9..8c9c3c8 100755 --- a/scripts/set_up_common.sh +++ b/scripts/set_up_common.sh @@ -1,5 +1,6 @@ #!/bin/bash set -e +set -x if [ -d ~/.oh-my-zsh ]; then echo "oh-my-zsh is installed" @@ -8,8 +9,8 @@ else sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended echo "Changing default shell, password required" sudo chsh -s "$(which zsh)" "$(whoami)" || true - git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "${ZSH_CUSTOM:-~/.oh-my-zsh/custom}"/plugins/zsh-syntax-highlighting - git clone https://github.com/MenkeTechnologies/zsh-expand.git "${ZSH_CUSTOM:-~/.oh-my-zsh/custom}"/plugins/zsh-expand + git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}"/plugins/zsh-syntax-highlighting + git clone https://github.com/MenkeTechnologies/zsh-expand.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}"/plugins/zsh-expand fi # auto setup remote for new branches @@ -21,8 +22,16 @@ git config --global user.name "Jedrzej Orbik" git config --global user.email Jendker@users.noreply.github.com grep -qF 'source ~/.aliases' "$HOME/.zshrc" || echo '[ -e ~/.aliases ] && source ~/.aliases' >>"$HOME/.zshrc" -grep -qxF 'eval "$(direnv hook zsh)"' "$HOME"/.zshrc || echo 'eval "$(direnv hook zsh)"' >>"$HOME/.zshrc" +if ! grep -qxF 'eval "$(direnv hook zsh)"' "$HOME"/.zshrc; then + tee -a "$HOME"/.zshrc >/dev/null <<'EOT' +eval "$(direnv hook zsh)" +# don't show the warning which happens if direnv loads the .envrc file +typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet +# show the node version only if it's set as a project version +typeset -g POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY=true +EOT +fi mkdir -p ~/.config/direnv echo '[global] load_dotenv = true -strict_env = true' >~/.config/direnv/direnv.toml +strict_env = true' >"$HOME"/.config/direnv/direnv.toml diff --git a/scripts/uninstall.sh b/scripts/uninstall.sh index 67e2023..2c30977 100755 --- a/scripts/uninstall.sh +++ b/scripts/uninstall.sh @@ -1,23 +1,31 @@ #!/usr/bin/env bash set -e +SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) +ROOT_DIR=$(dirname "$SCRIPT_DIR") + +cd "$ROOT_DIR" + +# Private submodule uninstall +SUBMODULE_PATH="dotfiles_private" +SUBMODULE_STATUS=$(git submodule status $SUBMODULE_PATH) || (git config --add safe.directory "${ROOT_DIR}" && SUBMODULE_STATUS=$(git submodule status $SUBMODULE_PATH)) + +# Check if the submodule is not empty +if [[ ! -z "$(ls -A ${SUBMODULE_PATH})" ]]; then + echo "Private submodule is available. Uninstalling..." + "${SUBMODULE_PATH}/scripts/uninstall.sh" +else + echo "Private submodule is not cloned. Skipping uninstallation." +fi + # Unstow platform-specific config if [[ "$OSTYPE" == "linux-gnu"* ]]; then - cd dotfiles_private/stow - stow -D -t ~ debian_private - cd ../.. - stow -D -t ~ debian + stow -D -t ~ debian elif [[ "$OSTYPE" == "darwin"* ]]; then - cd dotfiles_private/stow - stow -D -t ~ macos_private - cd ../.. - stow -D -t ~ macos + stow -D -t ~ macos else - echo "Unsupported OS" + echo "Unsupported OS" fi # Unstow common -cd dotfiles_private/stow -stow -D -t ~ common_private -cd ../.. stow -D -t ~ common