diff --git a/Brewfile b/Brewfile index 845223b..cf6f726 100644 --- a/Brewfile +++ b/Brewfile @@ -41,6 +41,7 @@ brew 'cmake' brew 'colordiff' brew 'coreutils' brew 'cppcheck' +brew 'diff-so-fancy' brew 'gmp' brew 'mpfr' brew 'gawk' diff --git a/aptgets b/aptgets index 442dfdb..d6f1d0f 100644 --- a/aptgets +++ b/aptgets @@ -1,12 +1,17 @@ apt-listdifferences autoconf +bash-completion bat +btm ccache curl +fzf git-delta keychain +luarocks neovim nodejs +openocd python-optcomplete python3-pip python3-venv @@ -21,7 +26,7 @@ stow tig ubuntu-restricted-extras universal-ctags -universal-ctags vim +wl-clipboard xclip xsel diff --git a/bash/.bashrc b/bash/.bashrc index 3bca68f..e568fbe 100644 --- a/bash/.bashrc +++ b/bash/.bashrc @@ -1,9 +1,26 @@ #!/usr/bin/env bash + # Simple function to check if a command exists command_exists() { type "$1" &> /dev/null ; } +# Simple function to check if a .local/env exists +# and if it does parse it for all the values you want +# to add to the shell session. +function export_env() +{ + if [ ! -f $HOME/.local/env ]; then + return + fi + + pushd $HOME/.local > /dev/null + unamestr=$(uname) + if [ "$unamestr" = 'Linux' ]; then + export $(grep -v '^#' env | xargs -d '\n') + fi + popd > /dev/null +} # # Append to history file, don't over write it # And limit the size it can grow to @@ -96,8 +113,8 @@ if command_exists rg ; then fi if command_exists batcat ; then - alias bat="batcat --color-always --style=numbers" - alias fzf="fzf --preview 'batcat --color-always --style=numbers --line-range=:500 {}'" + alias bat="batcat --color always --style=numbers" + alias fzf="fzf --preview 'batcat --color always --style=numbers --line-range=:500 {}'" fi # Thanks to jvillalovos for this @@ -144,10 +161,12 @@ fi source_additions=( "${HOME}/.dan_profile" "${HOME}/.bashrc-private" - "${HOME}/.fzf.bash" "${HOME}/.git-completion.bash" "${HOME}/.stgit-completion.bash" "${HOME}/.delta-completion.bash" + "/usr/share/bash-completion/completions/git" + "/usr/share/doc/fzf/examples/key-bindings.bash" + "/usr/share/doc/fzf/examples/completion.bash" "/usr/share/virtualenvwrapper/virtualenvwrapper.sh" ) @@ -211,3 +230,7 @@ fi if command_exists ag ; then alias ag="ag --ignore '*tags'" fi + +# if the custom bash function export_env exists, then run it and load the +# custom environment variables needed. +[[ $(type -t export_env) == function ]] && export_env diff --git a/bootstrap.sh b/bootstrap.sh index 9b34d73..01acba6 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -18,7 +18,11 @@ if [[ -n "${DEBUG_SCRIPT:-}" ]]; then fi DOTFILES_DIR="$( cd "$(dirname "$0")" ; pwd -P )" -PLATFORM="$(uname)" + +readonly PLATFORM_LINUX="Linux" +readonly PLATFORM_DARWIN="Darwin" +readonly PLATFORM_MICROSOFT="MSYS" + DEBUG_PRINTS=0 # Font colors @@ -55,6 +59,31 @@ debug() { fi } +_configure_platform() { + # + # Why add a function that basically mimics uname? + # Have run into cases where the uname value is different + # for some distros. This just gives a chance to ensure + # there is a consistent naming going forward. + # + local uname="$(uname)" + + # by default assume Linux right now + if [ "${uname}" == "Darwin" ]; then + echo "${PLATFORM_DARWIN}" + return + fi + + if [[ "${uname}" == *"MSYS"* ]]; then + echo "${PLATFORM_MICROSOFT}" + return + fi + + echo "${PLATFORM_LINUX}" +} + +PLATFORM="$(_configure_platform)" + doStow() { if hash stow 2>/dev/null; then @@ -127,7 +156,7 @@ doSync() { doBrew() { - if [ "${PLATFORM}" != "Darwin" ]; then + if [ "${PLATFORM}" != "${PLATFORM_DARWIN}" ]; then return fi @@ -163,12 +192,16 @@ doInstall() { doFonts() { info "Installing Fonts" + # + # Assuming Linux is the default here + # + fonts_dir="${HOME}/.local/share/fonts" # Grab the latest Microsoft Cascadia Code font - curl --output cascadia.zip -O https://github.com/microsoft/cascadia-code/releases/download/v2404.23/CascadiaCode-2404.23.zip + curl --output cascadia.zip -O https://github.com/microsoft/cascadia-code/releases/download/v2407.24/CascadiaCode-2407.24.zip unzip cascadia.zip - if [ "${PLATFORM}" == "MSYS" ]; then + if [ "${PLATFORM}" == "${PLATFORM_MICROSOFT}" ]; then info "You will need to manually install the fonts by clicking on them." info "I have not setup the PowerShell script to do so yet." info "This might help: https://medium.com/@slmeng/how-to-install-powerline-fonts-in-windows-b2eedecace58" @@ -177,10 +210,8 @@ doFonts() { fi - if [ "${PLATFORM}" == "Darwin" ]; then + if [ "${PLATFORM}" == "${PLATFORM_DARWIN}" ]; then fonts_dir="${HOME}/Library/Fonts" - elif [ "${PLATFORM}" == "Linux" ]; then - fonts_dir="${HOME}/.local/share/fonts" fi mkdir -p "${fonts_dir}" @@ -215,13 +246,13 @@ doPython() { } doWindowsConfig() { - if [ "${PLATFORM}" != "MSYS" ]; then + if [ "${PLATFORM}" != "${PLATFORM_MICROSOFT}" ]; then return fi } doMacOSConfig() { - if [ "${PLATFORM}" != "Darwin" ]; then + if [ "${PLATFORM}" != "${PLATFORM_DARWIN}" ]; then return fi @@ -336,10 +367,11 @@ doMacOSConfig() { # [ "${xcode_status:=2}" -ne 2 ] && doBrew fi + } doLinuxConfig() { - if [ "${PLATFORM}" != "Linux" ]; then + if [ "${PLATFORM}" != "${PLATFORM_LINUX}" ]; then return fi @@ -360,6 +392,9 @@ doLinuxConfig() { if [ "${distro}" == "Ubuntu" ]; then + info "Installing snaps" + sudo snap install diff-so-fancy + info "Installing from aptgets" if ((EUID != 0)); then if [[ -t 1 ]]; then @@ -418,14 +453,20 @@ doConfig() { doLinuxConfig doWindowsConfig - if [ ! -d "${HOME}/.fzf" ]; then + if hash fzf 2>/dev/null; then + info "FZF already installed at $(which fzf)" + else + #if [ ! -d "${HOME}/.fzf" ]; then info "Installing fzf" git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf "${HOME}"/.fzf/install --bin --no-update-rc --completion --key-bindings fi if [[ ${update} == true ]]; then - if [ -d "${HOME}/.fzf" ]; then + if [[ "$(which fzf)" != "/usr/bin/fzf" ]] && [[ -d "${HOME}/.fzf" ]]; then + # this is not a system installed FZF and likely a personally installed + # meaning we can update it + info "Updating fzf" pushd "${HOME}"/.fzf > /dev/null git pull --prune && ./install popd > /dev/null @@ -440,7 +481,6 @@ doConfig() { [ -f "${HOME}/.git-completion.bash" ] && rm "${HOME}/.git-completion.bash" [ -f "${HOME}/.tigrc.vim" ] && rm "${HOME}/.tigrc.vim" [ -f "${HOME}/bin/git-quick-stats" ] && rm "${HOME}/bin/git-quick-stats" - [ -f "${HOME}/bin/diff-so-fancy" ] && rm "${HOME}/bin/diff-so-fancy" [ -d "${HOME}/.yarn" ] && rm -Rf "${HOME}/.yarn" fi @@ -471,12 +511,6 @@ doConfig() { rm -Rf "${HOME}/git-quick-stats" fi - info "Installing diff-so-fancy" - if [ ! -f "${HOME}/bin/diff-so-fancy" ]; then - curl -L https://raw.githubusercontent.com/so-fancy/diff-so-fancy/master/third_party/build_fatpack/diff-so-fancy -o "${HOME}/bin/diff-so-fancy" - chmod +x "${HOME}/bin/diff-so-fancy" - fi - if ! command -v yarn > /dev/null; then curl --compressed -o- -L https://yarnpkg.com/install.sh | bash fi diff --git a/config/.config/ghostty/config b/config/.config/ghostty/config index 6e96ecf..13b537f 100644 --- a/config/.config/ghostty/config +++ b/config/.config/ghostty/config @@ -1,6 +1,6 @@ font-family = "Cascadia Code NF" -font-size = 16 -theme = "Argonaut" +font-size = 12 +theme = "TokyoNight Night" shell-integration = "bash" shell-integration-features = no-cursor,sudo,no-title adjust-cell-height = 25% @@ -12,5 +12,7 @@ mouse-scroll-multiplier = 2 window-save-state = always +clipboard-read = allow +clipboard-write = allow copy-on-select = clipboard diff --git a/config/.config/nvim/init.lua b/config/.config/nvim/init.lua index 01dfc4e..424e48d 100644 --- a/config/.config/nvim/init.lua +++ b/config/.config/nvim/init.lua @@ -1,24 +1,27 @@ -require "user.launch" -require "user.options" -require "user.keymaps" -spec "user.colorscheme" -spec "user.devicons" -spec "user.gitsigns" -spec "user.guard" --- schemastore and mason need to be before lspconfig so we can get the right schemea -spec "user.schemastore" -spec "user.treesitter" -spec "user.mason" ---spec "user.osc52" -spec "user.lspconfig" --- cmp must come after lspconfig it seems -spec "user.cmp" -spec "user.lualine" -spec "user.neoclip" -spec "user.neogit" -spec "user.telescope" -spec "user.trouble" -spec "user.undotree" -spec "user.whichkey" --- spec "user.gutentags" -require "user.lazy" +-- This file simply bootstraps the installation of Lazy.nvim and then calls other files for execution +-- This file doesn't necessarily need to be touched, BE CAUTIOUS editing this file and proceed at your own risk. +local lazypath = vim.env.LAZY or vim.fn.stdpath "data" .. "/lazy/lazy.nvim" + +if not (vim.env.LAZY or (vim.uv or vim.loop).fs_stat(lazypath)) then + -- stylua: ignore + local result = vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath }) + if vim.v.shell_error ~= 0 then + -- stylua: ignore + vim.api.nvim_echo({ { ("Error cloning lazy.nvim:\n%s\n"):format(result), "ErrorMsg" }, { "Press any key to exit...", "MoreMsg" } }, true, {}) + vim.fn.getchar() + vim.cmd.quit() + end +end + +vim.opt.rtp:prepend(lazypath) + +-- validate that lazy is available +if not pcall(require, "lazy") then + -- stylua: ignore + vim.api.nvim_echo({ { ("Unable to load lazy from: %s\n"):format(lazypath), "ErrorMsg" }, { "Press any key to exit...", "MoreMsg" } }, true, {}) + vim.fn.getchar() + vim.cmd.quit() +end + +require "lazy_setup" +require "polish" diff --git a/config/.config/nvim/lua/community.lua b/config/.config/nvim/lua/community.lua new file mode 100644 index 0000000..52380dd --- /dev/null +++ b/config/.config/nvim/lua/community.lua @@ -0,0 +1,13 @@ +-- AstroCommunity: import any community modules here +-- We import this file in `lazy_setup.lua` before the `plugins/` folder. +-- This guarantees that the specs are processed before any user plugins. + +---@type LazySpec +return { + "AstroNvim/astrocommunity", + { import = "astrocommunity.pack.lua" }, + -- import/override with your plugins folder + { import = "astrocommunity.colorscheme.tokyonight-nvim" }, + { import = "astrocommunity.fuzzy-finder.fzf-lua" }, + { import = "astrocommunity.git.neogit" }, +} diff --git a/config/.config/nvim/lua/lazy_setup.lua b/config/.config/nvim/lua/lazy_setup.lua new file mode 100644 index 0000000..8e1abfb --- /dev/null +++ b/config/.config/nvim/lua/lazy_setup.lua @@ -0,0 +1,32 @@ +require("lazy").setup({ + { + "AstroNvim/AstroNvim", + version = "^6", -- Remove version tracking to elect for nightly AstroNvim + import = "astronvim.plugins", + opts = { -- AstroNvim options must be set here with the `import` key + mapleader = " ", -- This ensures the leader key must be configured before Lazy is set up + maplocalleader = ",", -- This ensures the localleader key must be configured before Lazy is set up + icons_enabled = true, -- Set to false to disable icons (if no Nerd Font is available) + pin_plugins = nil, -- Default will pin plugins when tracking `version` of AstroNvim, set to true/false to override + update_notifications = true, -- Enable/disable notification about running `:Lazy update` twice to update pinned plugins + }, + }, + { import = "community" }, + { import = "plugins" }, +} --[[@as LazySpec]], { + -- Configure any other `lazy.nvim` configuration options here + install = { colorscheme = { "astrotheme", "habamax" } }, + ui = { backdrop = 100 }, + performance = { + rtp = { + -- disable some rtp plugins, add more to your liking + disabled_plugins = { + "gzip", + "netrwPlugin", + "tarPlugin", + "tohtml", + "zipPlugin", + }, + }, + }, +} --[[@as LazyConfig]]) diff --git a/config/.config/nvim/lua/polish.lua b/config/.config/nvim/lua/polish.lua new file mode 100644 index 0000000..642719f --- /dev/null +++ b/config/.config/nvim/lua/polish.lua @@ -0,0 +1,5 @@ +if true then return end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE + +-- This will run last in the setup process. +-- This is just pure lua so anything that doesn't +-- fit in the normal config locations above can go here diff --git a/git/.gitconfig b/git/.gitconfig index 6bca6f3..86a72d4 100644 --- a/git/.gitconfig +++ b/git/.gitconfig @@ -34,6 +34,8 @@ # show the current list of files to be assumed unchanged hidden = !git ls-files -v | grep \"^[[:lower:]]\" ignored = !git status -s --ignored | grep \"^!!\" + # check the velocity of the project over time by commits + velocity = "!git log --format='%ad' --date=format:'%Y-%m' | sort | uniq -c" # get the current number of commits ahead of source branch count = "!f() { git rev-list --count HEAD ^$(git rev-parse --abbrev-ref --symbolic-full-name @{u}); }; f" # On an interactive add, work around the githooks adding back in the whole file at commit @@ -63,6 +65,8 @@ frbi = "!f() { git rebase -i $(git log --pretty=oneline --color=always | fzf --ansi | cut -d ' ' -f1)^ ; }; f" rmfind = "!git log --all -p --reverse --source -S" branch-compare = "!f() {git log --left-right --graph --chery-mark --oneline $1...$2}" + # check which files are the most hot, these are usually problem files + most-changed = "!git log --format=format: --name-only --since=\"1 year ago\" | sort | uniq -c | sort -nr | head -20" [diff] tool = delta #tool = kitty @@ -157,3 +161,11 @@ default = matching [grep] lineNumber = true +[init] + defaultBranch = main +[credential "https://github.com"] + helper = + helper = !/usr/bin/gh auth git-credential +[credential "https://gist.github.com"] + helper = + helper = !/usr/bin/gh auth git-credential