diff --git a/.commonrc b/.commonrc index c390719..b29c28e 100644 --- a/.commonrc +++ b/.commonrc @@ -8,6 +8,10 @@ export XDG_CONFIG_HOME="$HOME/.config" export XDG_DATA_HOME="$XDG_CONFIG_HOME/local/share" export XDG_CACHE_HOME="$XDG_CONFIG_HOME/cache" export XDG_STATE_HOME="$HOME/.local/state" +# BUG: fix for https://github.com/ibhagwan/fzf-lua/issues/1243 +export XDG_RUNTIME_DIR="$XDG_CONFIG_HOME/local/runtime-dir" +[ -d "$XDG_RUNTIME_DIR" ] || mkdir -p "$XDG_RUNTIME_DIR" +[ "$(stat -c "%a" "$XDG_RUNTIME_DIR")" = "700" ] || chmod 700 "$XDG_RUNTIME_DIR" # Set system locale export LANG=C.UTF-8 diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 372ad43..81244f3 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -8,29 +8,29 @@ "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp-vsnip": { "branch": "main", "commit": "989a8a73c44e926199bfd05fa7a516d51f2d2752" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "conform.nvim": { "branch": "master", "commit": "2122fe2ff01e9a542fc358ee9398ce2cbddf345d" }, + "conform.nvim": { "branch": "master", "commit": "667102f26106709cddd2dff1f699610df5b94d7f" }, "fidget.nvim": { "branch": "main", "commit": "d855eed8a06531a7e8fd0684889b2943f373c469" }, "flash.nvim": { "branch": "main", "commit": "34c7be146a91fec3555c33fe89c7d643f6ef5cf1" }, - "fzf-lua": { "branch": "main", "commit": "2c4f76ac810de3b1ef91f06371ebc3cff55b1b3c" }, + "fzf-lua": { "branch": "main", "commit": "64a305a2490e48c44be9f5a489e01b995dd58c92" }, "gitsigns.nvim": { "branch": "main", "commit": "562dc47189ad3c8696dbf460d38603a74d544849" }, "harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" }, "incline.nvim": { "branch": "main", "commit": "16fc9c073e3ea4175b66ad94375df6d73fc114c0" }, - "indent-blankline.nvim": { "branch": "master", "commit": "3fe94b8034dd5241cb882bb73847303b58857ecf" }, + "indent-blankline.nvim": { "branch": "master", "commit": "dddb5d21811c319eb6e51a993d8fb44b193aae3f" }, "lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" }, - "lazygit.nvim": { "branch": "main", "commit": "dc56df433bfbf107fee0139e187eb9750878fa84" }, + "lazygit.nvim": { "branch": "main", "commit": "2432b447483f42ff2e18b2d392cb2bb27e495c08" }, "lualine.nvim": { "branch": "master", "commit": "544dd1583f9bb27b393f598475c89809c4d5e86b" }, "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "62360f061d45177dda8afc1b0fd1327328540301" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, - "mini.nvim": { "branch": "main", "commit": "d8faae693d266ee4f3a2bf1fb7ca4bc81314c3e9" }, + "mini.nvim": { "branch": "main", "commit": "608e15779f3d672d30c8ee01ad8ff9cac9f7d723" }, "neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" }, "noice.nvim": { "branch": "main", "commit": "d9328ef903168b6f52385a751eb384ae7e906c6f" }, "nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" }, "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, - "nvim-lspconfig": { "branch": "master", "commit": "652386deae739e38fa1bcf2f06e3e7de9b3436ba" }, - "nvim-tree.lua": { "branch": "master", "commit": "f9ff00bc06d7cb70548a3847d7a2a05e928bc988" }, - "nvim-treesitter": { "branch": "master", "commit": "3e0feeb062b29bb7d6d6df1e32ba28111c2bb734" }, + "nvim-lspconfig": { "branch": "master", "commit": "ff97d376b1d22b2eaf9274605531babf0cd0cf21" }, + "nvim-tree.lua": { "branch": "master", "commit": "ad0b95dee55955817af635fa121f6e2486b10583" }, + "nvim-treesitter": { "branch": "master", "commit": "8a966f32c973511f9697264b3533e9846d29fd09" }, "nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" }, "oil.nvim": { "branch": "master", "commit": "fcca212c2e966fc3dec1d4baf888e670631d25d1" }, "onedark.nvim": { "branch": "master", "commit": "fae34f7c635797f4bf62fb00e7d0516efa8abe37" }, diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua index 65aed2e..a673394 100644 --- a/.config/nvim/lua/plugins/lsp.lua +++ b/.config/nvim/lua/plugins/lsp.lua @@ -186,6 +186,11 @@ return { -- LSP Configuration & Plugins -- for you, so that they are available from within Neovim. local ensure_installed = vim.tbl_keys(servers or {}) vim.list_extend(ensure_installed, { + -- you can turn off/on auto_update per tool + { 'bash-language-server', auto_update = true }, + 'shfmt', + 'shellcheck', + 'lua-language-server', 'stylua', -- Used to format lua code }) require('mason-tool-installer').setup({ ensure_installed = ensure_installed }) diff --git a/.github/workflows/wsl-distro-custom.yml b/.github/workflows/wsl-distro-custom.yml index 8821c58..797450d 100644 --- a/.github/workflows/wsl-distro-custom.yml +++ b/.github/workflows/wsl-distro-custom.yml @@ -13,10 +13,11 @@ jobs: timeout-minutes: 15 strategy: matrix: - BASE_IMAGE: [ ubuntu, alpine ] + BASE_IMAGE: [ alpine, ubuntu ] + INSTALL_TYPE: [ mini, full ] runs-on: ubuntu-latest env: - IMAGE_NAME: ${{ matrix.BASE_IMAGE }}-custom + IMAGE_NAME: ${{ matrix.BASE_IMAGE }}.${{ matrix.INSTALL_TYPE }}-custom steps: - name: Checkout uses: actions/checkout@v4 @@ -36,6 +37,8 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max file: Dockerfile.${{ matrix.BASE_IMAGE }} + build-args: | + INSTALL_TYPE=${{ matrix.INSTALL_TYPE }} - name: Upload docker image to registry run: docker image push ${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest - name: Export docker container to a tar.gz file using gzip @@ -50,4 +53,4 @@ jobs: name: wsl-${{ env.IMAGE_NAME }} path: | /tmp/${{ env.IMAGE_NAME }}.tar.gz - /tmp/install.cmd \ No newline at end of file + /tmp/install.cmd diff --git a/.profile b/.profile index 2ac712f..6ab0f0e 100644 --- a/.profile +++ b/.profile @@ -2,4 +2,6 @@ # This file is not read by bash(1), if $HOME/.bash_profile or $HOME/.bash_login exists. # If running bash, include .bashrc if it exists -[ -n "$BASH_VERSION" ] && [ -f "$HOME/.bashrc" ] && source "$HOME/.bashrc" \ No newline at end of file +[ -n "$BASH_VERSION" ] && [ -f "$HOME/.bashrc" ] && source "$HOME/.bashrc" +export NVM_DIR="$HOME/.config/nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm diff --git a/.stow-local-ignore b/.stow-local-ignore index 991adbf..9d5717f 100644 --- a/.stow-local-ignore +++ b/.stow-local-ignore @@ -30,4 +30,5 @@ src tests bin ^/Dockerfile.* +install.sh .*.md diff --git a/Dockerfile.alpine b/Dockerfile.alpine index fe5f7cc..042a68e 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -9,65 +9,10 @@ ARG USERNAME=maurice ARG USER_UID=1000 ARG USER_GID=$USER_UID ARG HOME=/home/$USERNAME +ARG INSTALL_TYPE=mini -# Alpine uses MUSL binaries # Install required packages -RUN apk -q --no-progress --no-cache add \ - # coreutils is for dircolors, procps is for vim-tmux-navigator - # build-base installs a C compiler for nvim-treesitter - sudo zsh coreutils tar bzip2 rlwrap curl git vim stow openssh tmux procps build-base xclip \ - # Busybox binaries (default) doesn't support all features. E.g. `grep -P` - grep \ - # util-linux-misc is for script - neovim bash util-linux-misc nodejs npm \ - # Entry in man - mandoc man-pages less \ - # Install the documentation companion package - docs && \ - # Manual install of man pages for release binaries - mkdir -p /usr/local/share/man/man1 && \ - # Install MUSL ripgrep from source - RIPGREP_VERSION=$(curl -sL "https://api.github.com/repos/BurntSushi/ripgrep/releases/latest" | grep tag_name | cut -d '"' -f4) && \ - curl -sL https://github.com/BurntSushi/ripgrep/releases/download/${RIPGREP_VERSION}/ripgrep-${RIPGREP_VERSION}-x86_64-unknown-linux-musl.tar.gz \ - | tar xz ripgrep-${RIPGREP_VERSION}-x86_64-unknown-linux-musl/rg ripgrep-${RIPGREP_VERSION}-x86_64-unknown-linux-musl/doc/rg.1 --strip-components=1 && \ - install rg /usr/local/bin && mv doc/rg.1 /usr/local/share/man/man1 && rm -r rg doc && \ - # Install MUSL fd from source - FD_VERSION=$(curl -sL "https://api.github.com/repos/sharkdp/fd/releases/latest" | grep -Po '"tag_name": "v\K[^"]*') && \ - curl -sL https://github.com/sharkdp/fd/releases/download/v${FD_VERSION}/fd-v${FD_VERSION}-x86_64-unknown-linux-musl.tar.gz \ - | tar xz fd-v${FD_VERSION}-x86_64-unknown-linux-musl/fd fd-v${FD_VERSION}-x86_64-unknown-linux-musl/fd.1 --strip-components=1 && \ - install fd /usr/local/bin && mv fd.1 /usr/local/share/man/man1 && rm fd && \ - # Install MUSL bat from source - BAT_VERSION=$(curl -sL "https://api.github.com/repos/sharkdp/bat/releases/latest" | grep -Po '"tag_name": "v\K[^"]*') && \ - curl -sL https://github.com/sharkdp/bat/releases/download/v${BAT_VERSION}/bat-v${BAT_VERSION}-x86_64-unknown-linux-musl.tar.gz \ - | tar xz bat-v${BAT_VERSION}-x86_64-unknown-linux-musl/bat bat-v${BAT_VERSION}-x86_64-unknown-linux-musl/bat.1 --strip-components=1 && \ - install bat /usr/local/bin && mv bat.1 /usr/local/share/man/man1 && rm bat && \ - # Install MUSL eza from source - EZA_VERSION=$(curl -sL "https://api.github.com/repos/eza-community/eza/releases/latest" | grep -Po '"tag_name": "v\K[^"]*') && \ - curl -sL https://github.com/eza-community/eza/releases/latest/download/eza_x86_64-unknown-linux-musl.tar.gz | tar xz && \ - curl -sL https://github.com/eza-community/eza/releases/latest/download/man-${EZA_VERSION}.tar.gz | tar xz ./target/man-${EZA_VERSION}/eza.1 --strip-components=3 && \ - install eza /usr/local/bin && mv eza.1 /usr/local/share/man/man1 && rm eza && \ - # Install MUSL delta from source - DELTA_VERSION=$(curl -sL "https://api.github.com/repos/dandavison/delta/releases/latest" | grep tag_name | cut -d '"' -f4) && \ - curl -sL https://github.com/dandavison/delta/releases/latest/download/delta-${DELTA_VERSION}-x86_64-unknown-linux-musl.tar.gz \ - | tar xz delta-${DELTA_VERSION}-x86_64-unknown-linux-musl/delta --strip-components=1 && \ - install delta /usr/local/bin && rm delta && \ - # Install MUSL yazi from source - YAZI_VERSION=$(curl -sL "https://api.github.com/repos/sxyazi/yazi/releases/latest" | grep tag_name | cut -d '"' -f4) && \ - curl -sLo yazi.zip https://github.com/sxyazi/yazi/releases/download/${YAZI_VERSION}/yazi-x86_64-unknown-linux-musl.zip && \ - unzip -qj yazi.zip yazi-x86_64-unknown-linux-musl/yazi && \ - install yazi /usr/local/bin && rm yazi yazi.zip && \ - # Install LINUX lazygit from source - LAZYGIT_VERSION=$(curl -sL "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": "v\K[^"]*') && \ - curl -sL https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz \ - | tar xz lazygit && \ - install lazygit /usr/local/bin && rm lazygit && \ - # Install LINUX jq - JQ_VERSION=$(curl -sL "https://api.github.com/repos/jqlang/jq/releases/latest" | grep tag_name | cut -d '"' -f4) && \ - curl -sLo jq https://github.com/jqlang/jq/releases/latest/download/jq-linux-amd64 && \ - curl -sL https://github.com/jqlang/jq/releases/latest/download/${JQ_VERSION}.tar.gz | tar xz ${JQ_VERSION}/jq.1 --strip-components=1 && \ - install jq /usr/local/bin && mv jq.1 /usr/local/share/man/man1 && rm jq && \ - # Install zoxide - curl -sLS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash -s -- --bin-dir /usr/local/bin --man-dir /usr/local/share/man && \ +RUN apk -q --no-progress --no-cache add sudo bash && \ # Create user addgroup --gid $USER_GID $USERNAME && \ # Set Zsh as the default shell @@ -83,64 +28,12 @@ RUN apk -q --no-progress --no-cache add \ # Set default user USER $USERNAME WORKDIR $HOME -# Setup dotfiles +COPY --chown=$USERNAME:$USERNAME install.sh $HOME/install.sh COPY --chown=$USERNAME:$USERNAME tests /tmp/tests -SHELL ["/bin/bash", "-c"] - # Bootstrap -RUN \ - # Create the top level directories before stowing so that stow does not symlink from the top level - mkdir -p $HOME/.config/{nvim,tmux,yazi,zsh} $HOME/.vim && \ - # Stow the dotfiles - git clone -q --depth=1 https://github.com/mau-mauricelim/dotfiles.git $HOME/dotfiles && \ - cd $HOME/dotfiles && git remote set-url origin git@github.com:mau-mauricelim/dotfiles.git && \ - stow . && git restore . && cd $HOME && \ - # Install local binaries - sudo install $HOME/dotfiles/bin/* /usr/local/bin && \ - # Create a symlink for zshenv to HOME - ln -s $HOME/.config/zsh/.zshenv $HOME/.zshenv && \ - # Source the latest zshenv - source $HOME/.zshenv && \ - # Create ZDOTDIR and XDG_DATA_HOME directories - mkdir -p $ZDOTDIR $XDG_DATA_HOME/{nvim,vim}/{undo,swap,backup} && \ - # Zsh Theme - Powerlevel10k (Requires manual font installation) - git clone -q --depth=1 https://github.com/romkatv/powerlevel10k.git $ZDOTDIR/powerlevel10k && \ - # Zsh Auto Suggestions - git clone -q --depth=1 https://github.com/zsh-users/zsh-autosuggestions $ZDOTDIR/zsh-autosuggestions && \ - # Zsh Syntax Highlighting - git clone -q --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting.git $ZDOTDIR/zsh-syntax-highlighting && \ - # fzf - git clone -q --depth 1 https://github.com/junegunn/fzf.git $ZDOTDIR/fzf && \ - $ZDOTDIR/fzf/install --xdg --no-update-rc --completion --key-bindings >/dev/null 2>&1 && \ - # Vim syntax and indent - mkdir -p $HOME/.vim/{indent,syntax} && \ - git clone -q --depth=1 https://github.com/katusk/vim-qkdb-syntax.git $HOME/.vim/vim-qkdb-syntax && \ - ln -s $HOME/.vim/vim-qkdb-syntax/indent/{k,q}.vim $HOME/.vim/indent && \ - ln -s $HOME/.vim/vim-qkdb-syntax/syntax/k.vim $HOME/.vim/syntax && \ - git clone -q --depth=1 https://github.com/jshinonome/vim-q-syntax.git $HOME/.vim/vim-q-syntax && \ - ln -s $HOME/.vim/vim-q-syntax/syntax/q.vim $HOME/.vim/syntax && \ - # Symlink Vim syntax and indent files to Neovim - ln -s $HOME/.vim/indent $XDG_CONFIG_HOME/nvim && \ - ln -s $HOME/.vim/syntax $XDG_CONFIG_HOME/nvim && \ - # bash and zsh key bindings for Git objects, powered by fzf. - curl -sLo $XDG_CONFIG_HOME/fzf/fzf-git.sh https://raw.githubusercontent.com/junegunn/fzf-git.sh/main/fzf-git.sh && \ - # TPM installation - # git clone -q --depth=1 https://github.com/tmux-plugins/tpm $XDG_CONFIG_HOME/tmux/plugins/tpm && $XDG_CONFIG_HOME/tmux/plugins/tpm/bin/install_plugins && \ - # Install q language server for neovim - sudo npm --global i @jo.shinonome/qls && \ - # Install yazi themes - git clone -q --depth=1 https://github.com/yazi-rs/flavors.git flavors && \ - mkdir -p $XDG_CONFIG_HOME/yazi/flavors && \ - mv flavors/*.yazi $XDG_CONFIG_HOME/yazi/flavors && rm -rf flavors && \ - # Run Lazy install, clean and update non-interactively from command line - # nvim --headless '+Lazy! sync' +qa && \ +RUN bash install.sh $INSTALL_TYPE && rm install.sh && \ # Run tests - source $HOME/.bashrc && \ - echo -e "\n#########\n# TESTS #\n#########\n" && \ + echo -e "\n#########\n# TESTS #\n#########\n" && \ for test in /tmp/tests/*.sh; do bash "$test"; done && \ - rm -rf /tmp/tests && \ - # Start zsh and exit (It'll allow powerlevel10k to do everything it needs to do on first run.) - echo exit | script -qec zsh /dev/null >/dev/null && \ - # Clean up - sudo apk del util-linux-misc + rm -rf /tmp/tests diff --git a/Dockerfile.ubuntu b/Dockerfile.ubuntu index f2b78c6..15c9578 100644 --- a/Dockerfile.ubuntu +++ b/Dockerfile.ubuntu @@ -9,73 +9,16 @@ ARG USERNAME=maurice ARG USER_UID=1001 ARG USER_GID=$USER_UID ARG HOME=/home/$USERNAME +ARG INSTALL_TYPE=mini SHELL ["/bin/bash", "-c"] -# Bootstrap -RUN \ - # Install man pages in Ubuntu docker image - sed -i 's:^path-exclude=/usr/share/man:#path-exclude=/usr/share/man:' /etc/dpkg/dpkg.cfg.d/excludes && \ +# Install man pages in Ubuntu docker image +RUN sed -i 's:^path-exclude=/usr/share/man:#path-exclude=/usr/share/man:' /etc/dpkg/dpkg.cfg.d/excludes && \ # Install required packages apt-get -qq update >/dev/null 2>&1 && \ apt-get -qq install -y --no-install-recommends \ - # ca-certificates is required for build success, file is required for yazi - # build-essential installs a C compiler for nvim-treesitter - sudo zsh tar bzip2 unzip rlwrap curl ca-certificates git vim man less stow openssh-server tmux file build-essential xclip && \ - # Manual install of man pages for release binaries - mkdir -p /usr/local/share/man/man1 && \ - # Install MUSL ripgrep from source - RIPGREP_VERSION=$(curl -sL "https://api.github.com/repos/BurntSushi/ripgrep/releases/latest" | grep tag_name | cut -d '"' -f4) && \ - curl -sL https://github.com/BurntSushi/ripgrep/releases/download/${RIPGREP_VERSION}/ripgrep-${RIPGREP_VERSION}-x86_64-unknown-linux-musl.tar.gz \ - | tar xz ripgrep-${RIPGREP_VERSION}-x86_64-unknown-linux-musl/{rg,doc/rg.1} --strip-components=1 && \ - install rg /usr/local/bin && mv doc/rg.1 /usr/local/share/man/man1 && rm -r rg doc && \ - # Install GNU fd from source - FD_VERSION=$(curl -sL "https://api.github.com/repos/sharkdp/fd/releases/latest" | grep -Po '"tag_name": "v\K[^"]*') && \ - curl -sL https://github.com/sharkdp/fd/releases/download/v${FD_VERSION}/fd-v${FD_VERSION}-x86_64-unknown-linux-gnu.tar.gz \ - | tar xz fd-v${FD_VERSION}-x86_64-unknown-linux-gnu/{fd,fd.1} --strip-components=1 && \ - install fd /usr/local/bin && mv fd.1 /usr/local/share/man/man1 && rm fd && \ - # Install GNU bat from source - BAT_VERSION=$(curl -sL "https://api.github.com/repos/sharkdp/bat/releases/latest" | grep -Po '"tag_name": "v\K[^"]*') && \ - curl -sL https://github.com/sharkdp/bat/releases/download/v${BAT_VERSION}/bat-v${BAT_VERSION}-x86_64-unknown-linux-gnu.tar.gz \ - | tar xz bat-v${BAT_VERSION}-x86_64-unknown-linux-gnu/{bat,bat.1} --strip-components=1 && \ - install bat /usr/local/bin && mv bat.1 /usr/local/share/man/man1 && rm bat && \ - # Install GNU eza from source - EZA_VERSION=$(curl -sL "https://api.github.com/repos/eza-community/eza/releases/latest" | grep -Po '"tag_name": "v\K[^"]*') && \ - curl -sL https://github.com/eza-community/eza/releases/latest/download/eza_x86_64-unknown-linux-gnu.tar.gz | tar xz && \ - curl -sL https://github.com/eza-community/eza/releases/latest/download/man-${EZA_VERSION}.tar.gz | tar xz ./target/man-${EZA_VERSION}/eza.1 --strip-components=3 && \ - install eza /usr/local/bin && mv eza.1 /usr/local/share/man/man1 && rm eza && \ - # Install GNU delta from source - DELTA_VERSION=$(curl -sL "https://api.github.com/repos/dandavison/delta/releases/latest" | grep tag_name | cut -d '"' -f4) && \ - curl -sL https://github.com/dandavison/delta/releases/latest/download/delta-${DELTA_VERSION}-x86_64-unknown-linux-gnu.tar.gz \ - | tar xz delta-${DELTA_VERSION}-x86_64-unknown-linux-gnu/delta --strip-components=1 && \ - install delta /usr/local/bin && rm delta && \ - # Install GNU yazi from source - YAZI_VERSION=$(curl -sL "https://api.github.com/repos/sxyazi/yazi/releases/latest" | grep tag_name | cut -d '"' -f4) && \ - curl -sLo yazi.zip https://github.com/sxyazi/yazi/releases/download/${YAZI_VERSION}/yazi-x86_64-unknown-linux-gnu.zip && \ - unzip -qj yazi.zip yazi-x86_64-unknown-linux-gnu/yazi && \ - install yazi /usr/local/bin && rm yazi yazi.zip && \ - # Install GNU Neovim from source - curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz && \ - rm -rf /opt/nvim && \ - tar -C /opt -xzf nvim-linux64.tar.gz && rm nvim-linux64.tar.gz && \ - # Install LINUX lazygit from source - LAZYGIT_VERSION=$(curl -sL "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": "v\K[^"]*') && \ - curl -sL https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz \ - | tar xz lazygit && \ - install lazygit /usr/local/bin && rm lazygit && \ - # Install LINUX jq - JQ_VERSION=$(curl -sL "https://api.github.com/repos/jqlang/jq/releases/latest" | grep tag_name | cut -d '"' -f4) && \ - curl -sLo jq https://github.com/jqlang/jq/releases/latest/download/jq-linux-amd64 && \ - curl -sL https://github.com/jqlang/jq/releases/latest/download/${JQ_VERSION}.tar.gz | tar xz ${JQ_VERSION}/jq.1 --strip-components=1 && \ - install jq /usr/local/bin && mv jq.1 /usr/local/share/man/man1 && rm jq && \ - # Install zoxide - curl -sLS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash -s -- --bin-dir /usr/local/bin --man-dir /usr/local/share/man && \ - # Clean up - apt-get -qq remove ca-certificates && \ - apt-get -qq autoclean -y && \ - apt-get -qq clean -y && \ - apt-get -qq autoremove -y && \ - rm -rf /var/cache/apt/archives /var/lib/apt/lists && \ + sudo && \ # Create user groupadd --gid $USER_GID $USERNAME && \ # Set Zsh as the default shell @@ -92,63 +35,12 @@ RUN \ # Set default user USER $USERNAME WORKDIR $HOME -# Setup dotfiles +COPY --chown=$USERNAME:$USERNAME install.sh $HOME/install.sh COPY --chown=$USERNAME:$USERNAME tests /tmp/tests # Bootstrap -# Create the top level directories before stowing so that stow does not symlink from the top level -RUN mkdir -p $HOME/.config/{nvim,tmux,yazi,zsh} $HOME/.vim && \ - # Stow the dotfiles - git clone -q --depth=1 https://github.com/mau-mauricelim/dotfiles.git $HOME/dotfiles && \ - cd $HOME/dotfiles && git remote set-url origin git@github.com:mau-mauricelim/dotfiles.git && \ - stow . && git restore . && cd $HOME && \ - # Install local binaries - sudo install $HOME/dotfiles/bin/* /usr/local/bin && \ - # Create a symlink for zshenv to HOME - ln -s $HOME/.config/zsh/.zshenv $HOME/.zshenv && \ - # Source the latest zshenv - source $HOME/.zshenv && \ - # Create ZDOTDIR, XDG_DATA_HOME - mkdir -p $ZDOTDIR $XDG_DATA_HOME/{nvim,vim}/{undo,swap,backup} && \ - # Zsh Theme - Powerlevel10k (Requires manual font installation) - git clone -q --depth=1 https://github.com/romkatv/powerlevel10k.git $ZDOTDIR/powerlevel10k && \ - # Zsh Auto Suggestions - git clone -q --depth=1 https://github.com/zsh-users/zsh-autosuggestions $ZDOTDIR/zsh-autosuggestions && \ - # Zsh Syntax Highlighting - git clone -q --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting.git $ZDOTDIR/zsh-syntax-highlighting && \ - # fzf - git clone -q --depth 1 https://github.com/junegunn/fzf.git $ZDOTDIR/fzf && \ - $ZDOTDIR/fzf/install --xdg --no-update-rc --completion --key-bindings >/dev/null 2>&1 && \ - # Vim syntax and indent - mkdir -p $HOME/.vim/{indent,syntax} && \ - git clone -q --depth=1 https://github.com/katusk/vim-qkdb-syntax.git $HOME/.vim/vim-qkdb-syntax && \ - ln -s $HOME/.vim/vim-qkdb-syntax/indent/{k,q}.vim $HOME/.vim/indent && \ - ln -s $HOME/.vim/vim-qkdb-syntax/syntax/k.vim $HOME/.vim/syntax && \ - git clone -q --depth=1 https://github.com/jshinonome/vim-q-syntax.git $HOME/.vim/vim-q-syntax && \ - ln -s $HOME/.vim/vim-q-syntax/syntax/q.vim $HOME/.vim/syntax && \ - # Symlink Vim syntax and indent files to Neovim - ln -s $HOME/.vim/indent $XDG_CONFIG_HOME/nvim && \ - ln -s $HOME/.vim/syntax $XDG_CONFIG_HOME/nvim && \ - # bash and zsh key bindings for Git objects, powered by fzf. - curl -sLo $XDG_CONFIG_HOME/fzf/fzf-git.sh https://raw.githubusercontent.com/junegunn/fzf-git.sh/main/fzf-git.sh && \ - # TPM installation - # git clone -q --depth=1 https://github.com/tmux-plugins/tpm $XDG_CONFIG_HOME/tmux/plugins/tpm && $XDG_CONFIG_HOME/tmux/plugins/tpm/bin/install_plugins && \ - # Install nvm, node.js, and npm - PROFILE=/dev/null bash -c 'curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash' && \ - export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"; \ - [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \ - nvm install node && \ - # Install q language server for neovim - npm --global i @jo.shinonome/qls && \ - # Install yazi themes - git clone -q --depth=1 https://github.com/yazi-rs/flavors.git flavors && \ - mkdir -p $XDG_CONFIG_HOME/yazi/flavors && \ - mv flavors/*.yazi $XDG_CONFIG_HOME/yazi/flavors && rm -rf flavors && \ - # Run Lazy install, clean and update non-interactively from command line - # nvim --headless '+Lazy! sync' +qa && \ +RUN bash install.sh $INSTALL_TYPE && rm install.sh && \ # Run tests echo -e "\n#########\n# TESTS #\n#########\n" && \ for test in /tmp/tests/*.sh; do bash "$test"; done && \ - rm -rf /tmp/tests && \ - # Start zsh and exit (It'll allow powerlevel10k to do everything it needs to do on first run.) - echo exit | script -qec zsh /dev/null >/dev/null + rm -rf /tmp/tests diff --git a/README.md b/README.md index 33d75e5..f0fd5be 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,13 @@ # ✨ dotfiles -## [Install custom Distribution to use with 🐧 WSL](docs%2Fwsl.md) +## Installation +Install via the install script: +- Only supported on Alpine and Ubuntu +```sh +curl -sSfL https://raw.githubusercontent.com/mau-mauricelim/dotfiles/main/install.sh | bash +``` + +### [Install custom Distribution to use with 🐧 WSL](docs%2Fwsl.md) ## Manage dotfiles with GNU Stow ```bash diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..9e847eb --- /dev/null +++ b/install.sh @@ -0,0 +1,220 @@ +#!/usr/bin/env bash +INSTALL_TYPE="${1:-min}" # Defaults to minimal install +INSTALL_TYPE="${INSTALL_TYPE,,}" # Lowercase + +main() { + source /etc/os-release + case $ID in + alpine|ubuntu) + run_install $ID + ;; + *) + echo "$ID is not supported" + ;; + esac +} + +run_install() { echo "Running $1 installer"; cd "$HOME" || exit 1; "${1}_install"; } + +set_url_and_version() { + repo_name=$(echo "$1" | cut -d"/" -f2) + repo_name=${repo_name^^} # Uppercase + # Sets release url e.g. RIPGREP_URL=https://github.com/BurntSushi/ripgrep/releases/latest/download + eval "${repo_name}_URL"="https://github.com/$1/releases/latest/download" + latest_tag=$(curl -sL "https://api.github.com/repos/$1/releases/latest" | grep tag_name | cut -d '"' -f4) + # Strip v (first charcter) from tag + if [ "$2" = "true" ]; then latest_tag="${latest_tag:1}"; fi + # Sets release version e.g. RIPGREP_VERSION=14.1.0 + eval "${repo_name}_VERSION"="$latest_tag" +} + +set_all_url_and_version() { + set_url_and_version "jqlang/jq" + set_url_and_version "sxyazi/yazi" + set_url_and_version "neovim/neovim" + set_url_and_version "dandavison/delta" + set_url_and_version "BurntSushi/ripgrep" + set_url_and_version "sharkdp/fd" true + set_url_and_version "sharkdp/bat" true + set_url_and_version "eza-community/eza" true + set_url_and_version "jesseduffield/lazygit" true +} + +common_root_install() { + # Manual install of man pages for release binaries + sudo mkdir -p /usr/local/share/man/man1 + # Set release url and version + set_all_url_and_version + # Install MUSL ripgrep from source + [ -n "$RIPGREP_VERSION" ] && \ + curl -sL "$RIPGREP_URL/ripgrep-$RIPGREP_VERSION-x86_64-unknown-linux-musl.tar.gz" \ + | tar xz "ripgrep-${RIPGREP_VERSION}-x86_64-unknown-linux-musl/rg" "ripgrep-$RIPGREP_VERSION-x86_64-unknown-linux-musl/doc/rg.1" --strip-components=1 && \ + sudo install rg /usr/local/bin && sudo mv doc/rg.1 /usr/local/share/man/man1 && rm -r rg doc + # Install LINUX lazygit from source + [ -n "$LAZYGIT_VERSION" ] && \ + curl -sL "$LAZYGIT_URL/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz" | tar xz lazygit && \ + sudo install lazygit /usr/local/bin && rm lazygit + # Install LINUX jq + [ -n "$JQ_VERSION" ] && \ + curl -sLo jq "$JQ_URL/jq-linux-amd64" && \ + curl -sL "$JQ_URL/$JQ_VERSION.tar.gz" | tar xz "$JQ_VERSION/jq.1" --strip-components=1 && \ + sudo install jq /usr/local/bin && sudo mv jq.1 /usr/local/share/man/man1 && rm jq + # Install zoxide + curl -sLS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh |\ + bash -s -- --bin-dir /usr/local/bin --man-dir /usr/local/share/man >/dev/null +} + +common_user_install() { + # Create the top level directories before stowing so that stow does not symlink from the top level + mkdir -p "$HOME/.config/"{nvim,tmux,yazi,zsh} "$HOME/.vim" + # Clone the dotfiles + [ -d "$HOME/dotfiles" ] || git clone --depth=1 https://github.com/mau-mauricelim/dotfiles.git "$HOME/dotfiles" >/dev/null + # Stow the dotfiles + cd "$HOME/dotfiles" && git pull https://github.com/mau-mauricelim/dotfiles.git HEAD && \ + git remote set-url origin git@github.com:mau-mauricelim/dotfiles.git && \ + stow . && git restore . && cd "$HOME" || exit 1 + # Install local binaries + sudo install "$HOME/dotfiles/bin/"* /usr/local/bin + # Create a symlink for zshenv to HOME + ln -sf "$HOME/.config/zsh/.zshenv" "$HOME/.zshenv" + # Source the latest zshenv + source "$HOME/.zshenv" + # Create ZDOTDIR and XDG_DATA_HOME directories + mkdir -p "$ZDOTDIR" "$XDG_DATA_HOME/"{nvim,vim}/{undo,swap,backup} + # Zsh Theme - Powerlevel10k (Requires manual font installation) + [ -d "$ZDOTDIR/powerlevel10k" ] || git clone -q --depth=1 https://github.com/romkatv/powerlevel10k.git "$ZDOTDIR/powerlevel10k" + # Zsh Auto Suggestions + [ -d "$ZDOTDIR/zsh-autosuggestions" ] || git clone -q --depth=1 https://github.com/zsh-users/zsh-autosuggestions "$ZDOTDIR/zsh-autosuggestions" + # Zsh Syntax Highlighting + [ -d "$ZDOTDIR/zsh-syntax-highlighting" ] || git clone -q --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting.git "$ZDOTDIR/zsh-syntax-highlighting" + # fzf + [ -d "$ZDOTDIR/fzf" ] || git clone -q --depth 1 https://github.com/junegunn/fzf.git "$ZDOTDIR/fzf" + command -v fzf >/dev/null || "$ZDOTDIR/fzf/install" --xdg --no-update-rc --completion --key-bindings >/dev/null 2>&1 + # Vim syntax and indent + mkdir -p "$HOME/.vim/"{indent,syntax} + [ -d "$HOME/.vim/vim-qkdb-syntax" ] || git clone -q --depth=1 https://github.com/katusk/vim-qkdb-syntax.git "$HOME/.vim/vim-qkdb-syntax" + ln -sf "$HOME/.vim/vim-qkdb-syntax/indent/"{k,q}.vim "$HOME/.vim/indent" + ln -sf "$HOME/.vim/vim-qkdb-syntax/syntax/k.vim" "$HOME/.vim/syntax" + [ -d "$HOME/.vim/vim-q-syntax" ] || git clone -q --depth=1 https://github.com/jshinonome/vim-q-syntax.git "$HOME/.vim/vim-q-syntax" + ln -sf "$HOME/.vim/vim-q-syntax/syntax/q.vim" "$HOME/.vim/syntax" + # Symlink Vim syntax and indent files to Neovim + ln -sf "$HOME/.vim/indent" "$XDG_CONFIG_HOME/nvim" && \ + ln -sf "$HOME/.vim/syntax" "$XDG_CONFIG_HOME/nvim" + # bash and zsh key bindings for Git objects, powered by fzf. + [ -f "$XDG_CONFIG_HOME/fzf/fzf-git.sh" ] || curl -sLo "$XDG_CONFIG_HOME/fzf/fzf-git.sh" https://raw.githubusercontent.com/junegunn/fzf-git.sh/main/fzf-git.sh + # TPM installation + [ "$INSTALL_TYPE" = "full" ] && \ + git clone -q --depth=1 https://github.com/tmux-plugins/tpm "$XDG_CONFIG_HOME/tmux/plugins/tpm" && "$XDG_CONFIG_HOME/tmux/plugins/tpm/bin/install_plugins" + # Install nvm, node.js, and npm + if ! command -v npm >/dev/null; then + PROFILE=/dev/null bash -c 'curl -so- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash >/dev/null' && \ + export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "$HOME/.nvm" || printf %s "$XDG_CONFIG_HOME/nvm")"; \ + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" && \ + nvm install node >/dev/null + fi + # Install q language server for neovim + sudo npm --global i @jo.shinonome/qls || npm --global i @jo.shinonome/qls + # Install yazi themes + git clone -q --depth=1 https://github.com/yazi-rs/flavors.git flavors && \ + mkdir -p "$XDG_CONFIG_HOME/yazi/flavors" && \ + cp -r flavors/*.yazi "$XDG_CONFIG_HOME/yazi/flavors" && rm -rf flavors + # Run Lazy install, clean and update non-interactively from command line + [ "$INSTALL_TYPE" = "full" ] && nvim --headless '+Lazy! sync' +qa + # Start zsh and exit (It'll allow powerlevel10k to do everything it needs to do on first run.) + echo exit | script -qec zsh /dev/null >/dev/null + # Set Zsh as the default shell + sudo chsh -s "$(which zsh)" + # Clear the npm cache + [ -d "$HOME/.npm" ] && rm -rf "$HOME/.npm" + # Clean up tmp directories + rm -rf /tmp/tmp.* +} + +install_fd() { + [ -n "$FD_VERSION" ] && \ + curl -sL "$FD_URL/fd-v$FD_VERSION-x86_64-unknown-linux-$1.tar.gz" \ + | tar xz "fd-v$FD_VERSION-x86_64-unknown-linux-$1/fd" "fd-v$FD_VERSION-x86_64-unknown-linux-$1/fd.1" --strip-components=1 && \ + sudo install fd /usr/local/bin && sudo mv fd.1 /usr/local/share/man/man1 && rm fd +} + +install_bat() { + [ -n "$BAT_VERSION" ] && \ + curl -sL "$BAT_URL/bat-v$BAT_VERSION-x86_64-unknown-linux-$1.tar.gz" \ + | tar xz "bat-v$BAT_VERSION-x86_64-unknown-linux-$1/bat" "bat-v$BAT_VERSION-x86_64-unknown-linux-$1/bat.1" --strip-components=1 && \ + sudo install bat /usr/local/bin && sudo mv bat.1 /usr/local/share/man/man1 && rm bat +} + +install_eza() { + [ -n "$EZA_VERSION" ] && \ + curl -sL "$EZA_URL/eza_x86_64-unknown-linux-$1.tar.gz" | tar xz && \ + curl -sL "$EZA_URL/man-$EZA_VERSION.tar.gz" | tar xz "./target/man-$EZA_VERSION/eza.1" --strip-components=3 && \ + sudo install eza /usr/local/bin && sudo mv eza.1 /usr/local/share/man/man1 && rm eza +} + +install_delta() { + [ -n "$DELTA_VERSION" ] && \ + curl -sL "$DELTA_URL/delta-$DELTA_VERSION-x86_64-unknown-linux-$1.tar.gz" \ + | tar xz "delta-$DELTA_VERSION-x86_64-unknown-linux-$1/delta" --strip-components=1 && \ + sudo install delta /usr/local/bin && rm delta +} + +install_yazi() { + [ -n "$YAZI_VERSION" ] && \ + curl -sLo yazi.zip "$YAZI_URL/yazi-x86_64-unknown-linux-$1.zip" && \ + unzip -qj yazi.zip "yazi-x86_64-unknown-linux-$1/yazi" && \ + sudo install yazi /usr/local/bin && rm yazi yazi.zip +} + +# Alpine uses MUSL binaries +alpine_install() { + # Install required packages + # coreutils is for dircolors + # procps is for vim-tmux-navigator + # build-base installs a C compiler for nvim-treesitter + # Busybox binaries (default) doesn't support all features. E.g. `grep -P` + # util-linux-misc is for script + # docs installs the documentation companion package + # shadow is for chsh + # ncurses installs tput for fzf-git (fzf-tmux) + sudo apk -q --no-progress --no-cache add \ + tar bzip2 rlwrap curl git vim stow openssh tmux grep neovim \ + mandoc man-pages less docs \ + zsh coreutils procps build-base xclip util-linux-misc nodejs npm shadow ncurses + # Common root installs + common_root_install + # Install MUSL binaries from source + for bin in fd bat eza delta yazi; do "install_$bin" musl; done + # Common user installs + common_user_install + # Clean up + sudo apk -q --no-progress --no-cache del util-linux-misc shadow +} + +ubuntu_install() { + # Install required packages + # ca-certificates is required for build success + # file is required for yazi + # build-essential installs a C compiler for nvim-treesitter + sudo apt-get -qq update >/dev/null 2>&1 && \ + sudo apt-get -qq install -y --no-install-recommends \ + zsh tar bzip2 unzip rlwrap curl ca-certificates git vim man less stow openssh-server tmux file build-essential xclip >/dev/null + # Common root installs + common_root_install + # Install GNU binaries from source + for bin in fd bat eza delta yazi; do "install_$bin" gnu; done + # Install GNU Neovim from source + curl -LO "$NEOVIM_URL/nvim-linux64.tar.gz" && \ + sudo rm -rf /opt/nvim && \ + sudo tar -C /opt -xzf nvim-linux64.tar.gz && rm nvim-linux64.tar.gz + # Common user installs + common_user_install + # Clean up + sudo apt-get -qq remove ca-certificates >/dev/null && \ + sudo apt-get -qq autoclean -y && \ + sudo apt-get -qq clean -y && \ + sudo apt-get -qq autoremove -y >/dev/null && \ + sudo rm -rf /var/cache/apt/archives /var/lib/apt/lists +} + +# This is put in braces to ensure that the script does not run until it is downloaded completely +{ main "$@" || exit 1; } diff --git a/tests/version.sh b/tests/version.sh index 5dc541c..0f1cbe7 100755 --- a/tests/version.sh +++ b/tests/version.sh @@ -60,10 +60,6 @@ latestAndInstalledVersion fzf \ "$(curl -sL https://github.com/junegunn/fzf/releases/latest|grep 'breadcrumb-item-selected'|rev|cut -d'>' -f1|rev|xargs)" \ "$(fzf --version)" -latestAndInstalledVersion nvm \ - "$(curl -sL https://github.com/nvm-sh/nvm/releases/latest|grep 'breadcrumb-item-selected'|rev|cut -d'>' -f1|rev|xargs)" \ - "$(nvm --version)" - latestAndInstalledVersion npm \ "$(curl -sL https://github.com/npm/cli/releases/latest|grep 'breadcrumb-item-selected'|rev|cut -d'>' -f1|rev|xargs)" \ "$(npm --version)"