Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions ansible/tasks/link_files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
- { src: "fish/fish_plugins", dest: ".config/fish/fish_plugins" }
- {
src: "fish/completions/fish_gh_completion.fish",
dest: ".config/fish/fish_gh_completion",
dest: ".config/fish/completions/fish_gh_completion.fish",
}
- { src: "atuin/config.toml", dest: ".config/atuin/config.toml" }
- { src: "lazygit/config.yml", dest: ".config/lazygit/config.yml" }
Expand All @@ -28,7 +28,6 @@
# Scripts for working with data
- { src: "parquet/csv_to_parquet.py", dest: ".bin/csv_to_parquet" }
- { src: "parquet/parquet_to_csv.py", dest: ".bin/parquet_to_csv" }
- { src: "yml/format_yml.py", dest: ".bin/format_yml" }

# Misc. scripts and config
- { src: "zettel/today.sh", dest: ".bin/today" }
Expand Down
1 change: 0 additions & 1 deletion ansible/tasks/neovim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
- pynvim
- pyright
- ruff
- ruff-lsp
- yamllint

- name: Remove existing ftplugin directory if it exists (to allow symlinking)
Expand Down
85 changes: 43 additions & 42 deletions bash/bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -88,50 +88,52 @@ export GIT_COMMITTER_EMAIL=$EMAIL
export PAGER='less'
export LESS='-R -M --shift 5'

export JAVA_HOME=$(/usr/libexec/java_home -v 18)
# Java home (only set if java_home exists and returns a valid path)
if [ -x /usr/libexec/java_home ]; then
_java_home=$(/usr/libexec/java_home 2>/dev/null)
if [ -n "$_java_home" ]; then
export JAVA_HOME="$_java_home"
fi
unset _java_home
fi

# language
export LC_ALL='en_GB.UTF-8'
export LANG='en_GB.UTF-8'
export LC_CTYPE=C
export DISPLAY=:0

###################################################################
#
# Shell history improvements
# Bash-specific settings (skipped when sourced from zsh)
#
###################################################################

export HISTSIZE=50000
export HISTFILESIZE=100000
export HISTCONTROL=ignoredups:erasedups
export HISTTIMEFORMAT="[%F %T] "
shopt -s histappend # Append to history, don't overwrite

###################################################################
#
# Modern shell tool initialization
#
###################################################################

# Initialize starship prompt
if command -v starship &>/dev/null; then
eval "$(starship init bash)"
fi

# Initialize zoxide for smart directory navigation
if command -v zoxide &>/dev/null; then
eval "$(zoxide init bash)"
fi

# Initialize atuin for enhanced shell history
if command -v atuin &>/dev/null; then
eval "$(atuin init bash)"
fi

# Initialize mise for runtime version management
if command -v mise &>/dev/null; then
eval "$(mise activate bash)"
if [ -n "$BASH_VERSION" ]; then
# Shell history improvements
export HISTSIZE=50000
export HISTFILESIZE=100000
export HISTCONTROL=ignoredups:erasedups
export HISTTIMEFORMAT="[%F %T] "
shopt -s histappend # Append to history, don't overwrite

# Initialize starship prompt
if command -v starship &>/dev/null; then
eval "$(starship init bash)"
fi

# Initialize zoxide for smart directory navigation
if command -v zoxide &>/dev/null; then
eval "$(zoxide init bash)"
fi

# Initialize atuin for enhanced shell history
if command -v atuin &>/dev/null; then
eval "$(atuin init bash)"
fi

# Initialize mise for runtime version management
if command -v mise &>/dev/null; then
eval "$(mise activate bash)"
fi
fi


Expand All @@ -145,27 +147,26 @@ fi
# For full GNU environment, add to PATH instead:
# export PATH="$(brew --prefix)/opt/coreutils/libexec/gnubin:$PATH"

if command -v brew >/dev/null 2>&1; then
brew_prefix=$(brew --prefix)

# Check for coreutils by looking for a binary instead of running brew --prefix
if [ -x /opt/homebrew/bin/gcat ]; then
brew_prefix=/opt/homebrew

# Core file operations
alias cp="$brew_prefix/bin/gcp"
alias mv="$brew_prefix/bin/gmv"
alias rm="$brew_prefix/bin/grm"

# Text processing
alias sed="$brew_prefix/bin/gsed"
alias awk="$brew_prefix/bin/gawk"
alias grep="$brew_prefix/bin/ggrep"

# Date/time
alias date="$brew_prefix/bin/gdate"

# System info
alias stat="$brew_prefix/bin/gstat"
alias readlink="$brew_prefix/bin/greadlink"

# Note: ls/cat/find are overridden with modern alternatives (eza/bat/fd) in aliases section above
fi

# Source local overrides if they exist
Expand Down
44 changes: 21 additions & 23 deletions fish/config.fish
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/local/bin/fish

# --- XDG Base Directory Specification ---
set -x XDG_CONFIG_HOME $HOME/.config
set -x XDG_DATA_HOME $HOME/.local/share
Expand Down Expand Up @@ -88,6 +86,7 @@ fish_add_path $HOMEBREW_BIN
fish_add_path $DOTFILES_BIN
fish_add_path $USER_BIN
fish_add_path $LOCAL_BIN
fish_add_path $PYTHON_BIN

# FZF configuration with better preview
set -x FZF_DEFAULT_COMMAND 'fd --type f --hidden --follow --exclude .git'
Expand All @@ -110,16 +109,17 @@ set -x GIT_COMMITTER_EMAIL $EMAIL
set -x PAGER less
set -x LESS '-R -M --shift 5'

# Java home - commented out as it adds startup delay
# if test -x /usr/libexec/java_home
# set -x JAVA_HOME (/usr/libexec/java_home -v 18 2>/dev/null)
# end
# Java home (only set if java_home exists and returns a valid path)
if test -x /usr/libexec/java_home
set -l java_home (/usr/libexec/java_home 2>/dev/null)
if test -n "$java_home"
set -gx JAVA_HOME $java_home
end
end

# Language settings
set -x LC_ALL 'en_GB.UTF-8'
set -x LANG 'en_GB.UTF-8'
set -x LC_CTYPE C
set -x DISPLAY :0

###################################################################
#
Expand Down Expand Up @@ -151,9 +151,9 @@ end
#
###################################################################

# Improve the ssh function to use mosh only when appropriate
# Use mosh when connecting to a simple hostname with no extra arguments
function ssh
if test (count $argv) -gt 0; and string match -qr '^[a-zA-Z0-9._-]+$' -- $argv[1]
if test (count $argv) -eq 1; and string match -qr '^[a-zA-Z0-9._-]+$' -- $argv[1]
mosh $argv
else
command ssh $argv
Expand All @@ -166,7 +166,7 @@ end

# Cat the contents of a file into the clipboard
function pbcat
cat $argv[1] | pbcopy
command cat $argv[1] | pbcopy
end

# Use ctrl+s to fzf search the current directory
Expand All @@ -182,21 +182,19 @@ bind \cg wiki_file

# Search for all files *containing* text
function wt
set dir (pwd)
cd ~/Dropbox/wiki/zettel/; and rg $argv[1] --files-with-matches \
| fzf --preview 'bat --style=numbers --color=always {}' --preview-window="right:65%" --height="70%" \
| xargs -I {} -o nvim ~/Dropbox/wiki/zettel/{}
cd $dir
rg $argv[1] --files-with-matches ~/Dropbox/wiki/zettel/ \
| fzf --preview "bat --style=numbers --color=always {}" --preview-window="right:65%" --height="70%" \
| xargs -I {} -o nvim {}
end

# LESS colors for man pages
set -Ux LESS_TERMCAP_us \e\[1\;32m
set -Ux LESS_TERMCAP_md \e\[1\;31m
set -Ux LESS_TERMCAP_mb \e\[01\;31m
set -Ux LESS_TERMCAP_me \e\[0m
set -Ux LESS_TERMCAP_se \e\[0m
set -Ux LESS_TERMCAP_so \e\[01\;44\;33m
set -Ux LESS_TERMCAP_ue \e\[0m
set -gx LESS_TERMCAP_us \e\[1\;32m
set -gx LESS_TERMCAP_md \e\[1\;31m
set -gx LESS_TERMCAP_mb \e\[01\;31m
set -gx LESS_TERMCAP_me \e\[0m
set -gx LESS_TERMCAP_se \e\[0m
set -gx LESS_TERMCAP_so \e\[01\;44\;33m
set -gx LESS_TERMCAP_ue \e\[0m

# Source local environment variables if they exist
if test -f ~/.local/environment.fish
Expand Down
56 changes: 28 additions & 28 deletions git/clean_branches.sh
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
#!/bin/bash
#
# Remove any local branches that don't exist on the origin
# Remove local branches that have been merged and no longer exist on the remote.
# Protects main, master, and the currently checked-out branch.
#
# Usage: clean_branches.sh [-f]
# -f Force delete unmerged branches that no longer exist on remote

set -o errexit
set -o nounset

#!/bin/bash

# Check if Git is installed
if ! git --version >/dev/null 2>&1; then
echo "Error: Git is not installed. Please install Git and try again."
exit 1
fi

# Check if the current directory is a Git repository
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "Error: The current directory is not a Git repository. Please navigate to a Git repository and try again."
echo "Error: not inside a git repository."
exit 1
fi

# Check for the -f flag
force_delete=false
if [[ "$1" == "-f" ]]; then
if [[ "${1:-}" == "-f" ]]; then
force_delete=true
fi

# Fetch the latest changes from the remote repository and prune deleted branches
# Fetch and prune remote tracking branches
git fetch --prune

# Get a list of merged branches and filter out the branches that no longer exist on the origin
merged_branches=$(git branch --merged | grep -v "\*" | grep -v "^\s*master" | grep -v "^\s*main" | xargs -n 1 git branch -r --contains | sed 's/origin\///' | uniq)
current_branch=$(git symbolic-ref --short HEAD)

# Iterate through each local branch and check if it exists in the list of merged branches
for branch in $(git for-each-ref --format='%(refname:short)' refs/heads); do
if ! echo "$merged_branches" | grep -q "^$branch$"; then
if [ "$force_delete" = true ]; then
echo "Force deleting branch '$branch' as it either doesn't exist on the origin or isn't merged."
git branch -D "$branch" 2>/dev/null || echo "Error: Could not delete branch '$branch'."
else
echo "Skipping branch '$branch' as it either doesn't exist on the origin or isn't merged."
fi
else
echo "Deleting branch '$branch' as it is merged and doesn't exist on the origin."
git branch -d "$branch" 2>/dev/null || echo "Error: Could not delete branch '$branch'."
# Delete local branches that have been merged into the current branch
git branch --merged | while read -r branch; do
branch=$(echo "$branch" | tr -d '* ')
# Skip protected branches
if [[ "$branch" == "main" || "$branch" == "master" || "$branch" == "$current_branch" ]]; then
continue
fi
echo "Deleting merged branch '$branch'"
git branch -d "$branch" 2>/dev/null || echo " Could not delete '$branch'"
done

# Optionally force-delete branches whose remote tracking branch is gone
if [ "$force_delete" = true ]; then
git branch -vv | grep ': gone]' | while read -r line; do
branch=$(echo "$line" | awk '{print $1}')
if [[ "$branch" == "main" || "$branch" == "master" || "$branch" == "$current_branch" ]]; then
continue
fi
echo "Force deleting gone branch '$branch'"
git branch -D "$branch" 2>/dev/null || echo " Could not delete '$branch'"
done
fi
12 changes: 4 additions & 8 deletions git/gitconfig
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
lst = diff HEAD^..HEAD # Show changes in the last commit

# Branch operations
sw = checkout # Switch branches
swb = checkout -b # Create and switch to a branch
pd = checkout - # Jump to previous branch
sw = switch # Switch branches
swb = switch -c # Create and switch to a branch
pd = switch - # Jump to previous branch
b = branch # List branches
bd = branch -d # Delete branch

Expand Down Expand Up @@ -90,6 +90,7 @@
excludesfile = ~/.gitignore
autocrlf = input
whitespace = trailing-space,space-before-tab
pager = delta
[branch]
autosetupmerge = true
sort = -committerdate
Expand Down Expand Up @@ -122,11 +123,6 @@
[push]
default = current
autoSetupRemote = true
[ghi]
token = !security find-internet-password -a michaelbarton -s github.com -l 'ghi token' -w

[core]
pager = delta

[interactive]
diffFilter = delta --color-only
Expand Down
2 changes: 0 additions & 2 deletions gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ htmlcov/

# Rust
target/
Cargo.lock

# Go
*.test
Expand All @@ -103,7 +102,6 @@ Cargo.lock
node_modules/
.npm/
.yarn/
package-lock.json # Optional: remove if you want to track this

# Python
.venv/
Expand Down
15 changes: 0 additions & 15 deletions lein/profiles.clj

This file was deleted.

2 changes: 1 addition & 1 deletion markdown/md2docx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ IN_FILE=$1
FILENAME=$(basename -- "$IN_FILE")
FILENAME_NOEXT="${FILENAME%.*}"

pandoc -o ${FILENAME_NOEXT}.docx -f markdown -t docx $IN_FILE
pandoc -o "${FILENAME_NOEXT}.docx" -f markdown -t docx "$IN_FILE"
2 changes: 1 addition & 1 deletion markdown/md2pdf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ IN_FILE=$1
FILENAME=$(basename -- "$IN_FILE")
FILENAME_NOEXT="${FILENAME%.*}"

pandoc -o ${FILENAME_NOEXT}.pdf -f markdown -t pdf $IN_FILE
pandoc -o "${FILENAME_NOEXT}.pdf" -f markdown -t pdf "$IN_FILE"
Loading
Loading