diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-05-04 08:44:50 +0200 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-05-06 16:43:16 +0200 |
| commit | 0bc002288b984d8ec8123c135456570c78a22da3 (patch) | |
| tree | 020ed3f6a7f28a081687a3e46ea190e3aa724f7c /.local/bin | |
| download | dotfiles-0bc002288b984d8ec8123c135456570c78a22da3.tar.gz dotfiles-0bc002288b984d8ec8123c135456570c78a22da3.zip | |
feat: initial setup
- `dotfiles` (this project's CLI)
- foot configuration
- tmux configuration
- bash configuration
- nvim (as a git submodule) + configuration
- ranger configuration
- fzf configuration
- KDE global shortcuts
- Other miscellaneous dependencies
Diffstat (limited to '.local/bin')
| -rwxr-xr-x | .local/bin/dotfiles | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/.local/bin/dotfiles b/.local/bin/dotfiles new file mode 100755 index 0000000..faf2c1f --- /dev/null +++ b/.local/bin/dotfiles @@ -0,0 +1,104 @@ +#!/usr/bin/bash +set -euo pipefail + +prompt_for_install() { + local label=${1:?label argument missing} + echo "$label" + read -rn 1 -p "Install? (y/n)" input + echo + if [[ $input == y ]]; then return 0; else return 1; fi +} + +clipboard_hint() { + local cmd=${1:?cmd argument missing} + wl-copy "$cmd" + echo -e "Copied to clipboard:\n\n$cmd\n" +} + +sync_deps() { + local missing_deps=() + for dep; do + if ! pacman --query "$dep" >/dev/null 2>&1; then missing_deps+=("$dep"); fi + done + if [[ ${#missing_deps[@]} -eq 0 ]]; then return; fi + if prompt_for_install "Missing dependencies: ${missing_deps[*]}"; then + sudo pacman --sync "${missing_deps[@]}" + fi +} + +sync_mdformat() { + local pipx_json + pipx_json="$(pipx list --json)" + if ! jq --exit-status '.venvs | has("mdformat")' <<<"$pipx_json" >/dev/null 2>&1; then + if prompt_for_install "Missing mdformat"; then pipx install mdformat; else return; fi + fi + local missing_injected_packages=() + for pack in mdformat-gfm mdformat-frontmatter; do + if ! jq --exit-status ".venvs.mdformat.metadata.injected_packages | has(\"$pack\")" <<<"$pipx_json" >/dev/null 2>&1; then + missing_injected_packages+=("$pack") + fi + done + if [[ ${#missing_injected_packages[@]} -eq 0 ]]; then return; fi + if prompt_for_install "Missing mdformat extensions: ${missing_injected_packages[*]}"; then + pipx inject mdformat "${missing_injected_packages[@]}" + fi +} + +build_and_install_nvim() { + local src_dir="$HOME/.local/share/dotfiles/deps/neovim" + local build_dir="$HOME/.local/share/nvim" + rm -rf "$build_dir/build/" + make \ + --directory="$src_dir" \ + CMAKE_BUILD_TYPE=RelWithDebInfo \ + CMAKE_INSTALL_PREFIX="$build_dir" + make --directory="$src_dir" install + ln --symbolic --force "$build_dir/bin/nvim" "$HOME/.local/bin/nvim" +} + +sync_nvim() { + local nvim_dir="$HOME/.local/share/dotfiles/deps/neovim" + local git_args=(--git-dir "$nvim_dir/.git" --work-tree "$nvim_dir") + git "${git_args[@]}" fetch --tags --force >/dev/null + local current_version latest_version + if ! command -v nvim >/dev/null; then + if prompt_for_install "Missing nvim"; then build_and_install_nvim; fi + return + fi + current_version="$(command nvim --version | head -1 | grep -E --only-matching "v[0-9]+\.[0-9]+\.[0-9]+")" + latest_version="$(git "${git_args[@]}" tag --list "v*" --sort=-version:refname | head -1)" + if [[ $current_version == "$latest_version" ]]; then return; fi + if prompt_for_install "New nvim version $current_version → $latest_version"; then + git "${git_args[@]}" checkout "$latest_version" + build_and_install_nvim + fi +} + +case ${1:-} in +sync) + declare deps=( + foot # terminal emulator + tmux # terminal multiplexer + bash # shell + bash-completion # collection of bash completions + fzf # fuzzy finder + ranger # file explorer + bat # syntax highlighter + python-pipx # Python apps environment + wl-clipboard # Wayland clipboard + jq # JSON processor + shfmt # shell program formatter + stylua # Lua formatter + base-devel cmake ninja git # nvim build dependencies + ) + sync_deps "${deps[@]}" + sync_nvim + sync_mdformat + ;; +on) clipboard_hint "source $HOME/.local/share/dotfiles/dotfiles_on.env" ;; +off) clipboard_hint "source $HOME/.local/share/dotfiles/dotfiles_off.env" ;; +*) + echo "What?" + exit 1 + ;; +esac |
