🍻 Fix everything that was broken

Note to self - maybe consider testing things as you write them instead
of just making one thousand edits and then moving on.
This commit is contained in:
Marley Rae 2024-01-29 19:54:57 -08:00
parent 017efbb202
commit 52a8da2336
12 changed files with 209 additions and 217 deletions

70
.tmux.conf Normal file
View file

@ -0,0 +1,70 @@
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'catppuccin/tmux'
set -g @plugin 'Morantron/tmux-fingers'
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# catppuccin
set -g @catppuccin_flavour 'mocha'
set -g @catppuccin_window_left_separator " "
set -g @catppuccin_window_right_separator ""
set -g @catppuccin_window_middle_separator "█ "
set -g @catppuccin_window_number_position "left"
set -g @catppuccin_window_default_fill "number"
set -g @catppuccin_window_default_text "#W"
set -g @catppuccin_window_current_fill "number"
set -g @catppuccin_window_current_text "#W"
set -g @catppuccin_status_modules_left "directory"
set -g @catppuccin_status_modules_right "user host session date_time"
set -g @catppuccin_status_left_separator " "
set -g @catppuccin_status_right_separator ""
set -g @catppuccin_status_right_separator_inverse "no"
set -g @catppuccin_status_fill "icon"
set -g @catppuccin_status_connect_separator "no"
set -g @catppuccin_directory_text "#{pane_current_path}"
set -g @catppuccin_date_time_text "%b %d • %I:%M %p"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Remap prefix.
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# Vi copy mode.
set-window-option -g mode-keys vi
bind-key -T copy-mode-vi 'v' send -X begin-selection
bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel
# Better split commands.
bind | split-window -h -c "#{pane_current_path}" # cmd-| in iTerm2
bind - split-window -v -c "#{pane_current_path}" # cmd-- in iTerm2
unbind '"'
unbind %
# Vi-like resizing.
bind-key j resize-pane -D # cmd-j in iTerm2
bind-key k resize-pane -U # cmd-k in iTerm2
bind-key h resize-pane -L # cmd-h in iTerm2
bind-key l resize-pane -R # cmd-l in iTerm2
# Easy reload config.
bind r source-file ~/.tmux.conf
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Install tpm if not already installed.
if "test ! -d ~/.tmux/plugins/tpm" \
"run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && ~/.tmux/plugins/tpm/bin/install_plugins'"
# Init tmux plugin manager.
# Must be very last line!!
run '~/.tmux/plugins/tpm/tpm'

View file

@ -0,0 +1,5 @@
#!/usr/bin/env fish
function dscleanup -d "Recursively delete '.DS_Store' files"
find . -type f -name '*.DS_Store' -ls -delete
end

View file

@ -0,0 +1,22 @@
#!/usr/bin/env fish
source "$DOT/script/utils.fish"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function up -d "Update all software across all package managers"
set -f cmd "brew update && brew upgrade && brew cleanup"
set -a cmd "npm install npm -g && npm update -g"
if cmd_exists 'gem'
set -a cmd "sudo gem update --system && sudo gem update && sudo gem cleanup"
end
if [ "$(uname)" = "Darwin" ]
set -p cmd "sudo softwareupdate --install --all"
else if [ "$(uname)" = "Linux" ]
set -p cmd "sudo apt update && sudo apt upgrade"
end
echo (string join '; ' $cmd)
end

47
fish/aliases.config.fish Normal file
View file

@ -0,0 +1,47 @@
#!/usr/bin/env fish
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Shell aliases.
abbr -a rl --position command "source ~/.config/fish/config.fish"
abbr -a c --position command "clear"
abbr -a e --position command "$EDITOR"
abbr -a v --position command "$EDITOR"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Location aliases.
abbr -a hack --position command "cd ~/hackin"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Default command options.
abbr -a cp --position command "cp -iv"
# │└─ list copied files
# └─ prompt before overwriting an existing file
abbr -a mkdir --position command "mkdir -pv"
# │└─ list created directories
# └─ create intermediate directories
abbr -a mv --position command "mv -iv"
# │└─ list moved files
# └─ prompt before overwriting an existing file
abbr -a rm --position command "rm -rf"
# │└─ do not ask for confirmation
# └─ recursively remove directories and files
# Colored grep output.
abbr -a grep --position command "grep --color=auto"
abbr -a fgrep --position command "fgrep --color=auto"
abbr -a egrep --position command "egrep --color=auto"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if [ "$(uname)" = "Darwin" ]
abbr -a o --position command "open"
else if [ "$(uname)" = "Linux" ]
abbr -a o --position command "xdg-open"
end

View file

@ -217,7 +217,7 @@ abbr -a glap --position command "git log --pretty=lf --graph --all --cc --patch"
# Shortcuts to Feel Smart #
################################################################################
function gprevision -a $N $path
function gprevision -a N path
git checkout \
(git log --online $path | awk -v commit="$N" "FNR == -commit+1 {print $N}") \
$path

0
git/install.fish Normal file → Executable file
View file

View file

@ -1,6 +1,6 @@
#!/user/bin/env fish
source "$DOT/script/utils"
source "$DOT/script/utils.fish"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -16,7 +16,7 @@ function brew_prefix
end
end
function brew_tap -a $tap
function brew_tap -a tap
brew tap "$tap" &>/dev/null
end
@ -30,14 +30,14 @@ end
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function brew_install -a $formula_readable_name $formula $arguments $tap_value
function brew_install -a formula_readable_name formula arguments tap_value
# Check that Homebrew is installed
if ! cmd_exists "brew"
print_error "$formula_readable_name ('Homebrew' is not installed)"
end
# If 'brew tap' needs to be executed, check if it executed correctly.
if [ -n "$tap_value"]
if [ -n "$tap_value" ]
if ! brew_tap "$tap_value"
print_error "$formula_readable_name ('brew tap $tap_value' failed)"
return 1

View file

@ -4,7 +4,7 @@ source "$DOT/script/utils.fish"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function npm_install -a $msg $pkg
function npm_install -a msg pkg
execute \
"source $DOT/node/path.config.fish && npm install --global --silent $pkg" \
"$msg"

View file

@ -12,20 +12,27 @@ source "$DOT/script/utils.fish"
function set_os_prefs
print_title "OS Preferences"
set os $(uname | string lower)
set -f os $(uname | string lower)
set -f file "{$DOT}/os/{$os}.fish"
"$DOT/os/$os.fish"
if [ -e "$file" -a -x "$file" ]
"$file"
end
end
################################################################################
# Symlink Dotfiles #
################################################################################
function link_file -a $src $dst
function link_file -a src dst
set -f action
if [ -f "$dst" ] || [ -d "$dst" ] || [ -L "$dst" ]
set -f overwrite ""
set -f backup ""
set -f skip ""
if [ -f "$dst" -o -d "$dst" -o -L "$dst" ]
if ! $overwrite_all && ! $backup_all && ! $skip_all
set -f current_src (readlink "$dst")
@ -38,24 +45,32 @@ function link_file -a $src $dst
switch $action
case o
set -f overwrite true
set overwrite true
case O
set -f overwrite_all true
set overwrite_all true
case b
set -f backup true
set backup true
case B
set -f backup_all true
set backup_all true
case s
set -f skip true
set skip true
case S
set -f skip_all true
set skip_all true
end
end
end
set -q overwrite || set overwrite $overwrite_all
set -q backup || set backup $backup_all
set -q skip || set skip $skip_all
if [ -z "$overwrite" ]
set overwrite $overwrite_all
end
if [ -z "$backup" ]
set backup $backup_all
end
if [ -z $skip ]
set skip $skip_all
end
if $overwrite
rm -rf "$dst"
@ -72,7 +87,7 @@ function link_file -a $src $dst
end
end
if ! $skip
if [ -z $skip ] || ! $skip
# See of any directories need to be created.
if echo "$dst" | grep -q '/' 2> /dev/null
mkdir -p (string replace -r '\/[^\/]+$' '' "$dst")
@ -88,14 +103,6 @@ function link_file -a $src $dst
end
end
function make_dst -a $src
set -l path (string replace -a '/' '\/' "$DOT")
set -l regex (string join '' '^' "$path" '\/[a-zA-Z]+\/(.+)\.symlink$')
set -l dst (string replace -r $regex '$1' "$src")
printf '%s' "$HOME/$dst"
end
function install_dotfiles
print_title "Installing Dotfiles"
@ -103,8 +110,11 @@ function install_dotfiles
set -g backup_all false
set -g skip_all false
for src in (find -H "$DOT" -name "*.symlink" -not -path ".git")
link_file $src (make_dst $src)
set -l path (string replace -a '/' '\/' "$DOT")
set -l regex (string join '' '^' "$path" '\/[a-zA-Z]+\/(.+)\.(sym|hard)link$')
for src in (find -H "$DOT" -name "*.symlink" -or -name "*.hardlink" -not -path ".git")
link_file $src "$(string replace -r $regex '$1' "$src")"
end
end

View file

@ -2,50 +2,50 @@
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function print_in_color -a $color $text
function print_in_color -a text color
printf '%b' \
"$(tput setaf $color 2> /dev/null)" \
$text \
"$(tput sgr0 2> /dev/null)"
end
function print_in_red -a $text
function print_in_red -a text
print_in_color $text 1
end
function print_in_yellow -a $text
function print_in_yellow -a text
print_in_color $text 3
end
function print_in_green -a $text
function print_in_green -a text
print_in_color $text 2
end
function print_in_purple -a $text
function print_in_purple -a text
print_in_color $text 5
end
function print_title -a $text
function print_title -a text
print_in_purple "\n • $text\n\n"
end
function print_success -a $text
function print_success -a text
print_in_green " [✔] $text\n"
end
function print_warning -a $text
function print_warning -a text
print_in_yellow " [!] $text\n"
end
function print_error -a $text $text2
function print_error -a text text2
print_in_red " [✖] $text $text2\n"
end
function print_question -a $text
function print_question -a text
print_in_yellow " [?] $text\n"
end
function print_result -a $exit_code $text
function print_result -a exit_code text
if [ "$exit_code" -eq 0 ]
print_success $text
else
@ -63,7 +63,7 @@ end
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function show_spinner -a $pid $cmds $msg
function show_spinner -a pid cmds msg
set -l frames '/-\|'
set -l number_of_frames (string length $FRAMES)
@ -91,7 +91,7 @@ end
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function set_trap -a $sig $func
function set_trap -a sig func
trap -p "$sig" | grep "$func" &> /dev/null \
|| trap "$func" "$sig"
end
@ -107,10 +107,12 @@ end
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function execute -a $cmds
set -q $argv[2] and set -l msg $argv[2] or set -l msg "$cmds"
function execute -a cmds msg
if ! set -q msg
set -f msg "$cmds"
end
set -l tmp_file "$(mktmp /tmp/XXXXX)"
set -l tmp_file "$(mktemp /tmp/XXXXX)"
set -l exit_code 0
@ -134,3 +136,9 @@ function execute -a $cmds
return $exit_code
end
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function cmd_exists -a cmd
command -v "$cmd" &>/dev/null
end

View file

@ -1,97 +0,0 @@
#!/usr/bin/env zsh
# Base path.
export PATH="$HOME/bin:/usr/local/bin:$PATH"
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# Dotfiles root dir.
export DOT="$HOME/dotfiles"
# Projects dir.
export HACK="$HOME/hackin"
# Theme.
ZSH_THEME=""
# Use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
HYPHEN_INSENSITIVE="true"
# Auto-update behavior.
# zstyle ':omz:update' mode disabled # disable automatic updates
# zstyle ':omz:update' mode auto # update automatically without asking
zstyle ':omz:update' mode reminder # just remind me to update when it's time
# Display red dots whilst waiting for completion.
# You can also set it to another string to have that shown instead of the
# default red dots.
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
COMPLETION_WAITING_DOTS="true"
# Plugins to load.
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
plugins=(git zsh-syntax-highlighting zsh-autosuggestions colored-man-pages gh gulp iterm2 laravel macos npm nvm sudo thefuck)
# iTerm2 Shell Integration
if [[ "$(uname)" == "Darwin" ]] && [[ $(mdfind "iTerm.app") ]]; then
zstyle ':omz:plugins:iterm2' shell-integration yes
fi
# the fuck
eval $(thefuck --alias)
# zsh completions
fpath+=${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions/src
source $ZSH/oh-my-zsh.sh
# Local environment variables.
if [[ -e $HOME/.local.env ]]; then
source ~/.local.env
fi
# All zsh dotfiles.
typeset -U config_files
config_files=($DOT/**/*.zsh)
# Load path files first.
for file in ${(M)config_files:#*/path.zsh}; do
source $file
done
# Load everything else, except completion.
for file in ${${config_files:#*/path.zsh}:#*/completion.zsh}; do
source $file
done
# Initialize autocomplete.
autoload -U compinit
compinit
# Load autocompletions.
for file in ${(M)config_files:#*/completion.zsh}; do
source $file
done
unset config_files
# Starship
eval "$(starship init zsh)"
# Herd injected PHP binary.
export PATH="/Users/marley/Library/Application Support/Herd/bin/":$PATH
# Herd injected PHP 8.2 configuration.
export HERD_PHP_82_INI_SCAN_DIR="/Users/marley/Library/Application Support/Herd/config/php/82/"
# Herd injected PHP 8.3 configuration.
export HERD_PHP_83_INI_SCAN_DIR="/Users/marley/Library/Application Support/Herd/config/php/83/"
# Herd injected PHP 8.1 configuration.
export HERD_PHP_81_INI_SCAN_DIR="/Users/marley/Library/Application Support/Herd/config/php/81/"

View file

@ -1,73 +0,0 @@
#!/usr/bin/env zsh
# Remove that annoying 'last logged in' message.
# Tested this method vs in iTerm settings - latter is less portable and slower.
printf '\33c\e[3J'
# Base path.
export PATH="$HOME/bin:/usr/local/bin:$HOME/dotfiles/bin:$PATH"
# Dotfiles root dir.
export DOT="$HOME/dotfiles"
# Projects dir.
export HACK="$HOME/hackin"
# Local environment variables.
if [[ -e $HOME/.local.env ]]; then
source ~/.local.env
fi
# All zsh dotfiles.
typeset -U config_files
config_files=($DOT/**/*.zsh)
# Load path files first.
for file in ${(M)config_files:#*/path.zsh}; do
source $file
done
#
# Initialize autocomplete.
autoload -U compinit
compinit
# Load everything else, except completion.
for file in ${${config_files:#*/path.zsh}:#*/completion.zsh}; do
source $file
done
# Load autocompletions.
for file in ${(M)config_files:#*/completion.zsh}; do
source $file
done
unset config_files
# Starship
export STARSHIP_CONFIG=$DOT/zsh/starship.toml
eval "$(starship init zsh)"
# Zsh Autosuggestions
source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh
# The Fuck
eval "$(thefuck --alias)"
# Zsh Syntax Highlighting
# Must go last!!!
source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# Herd injected PHP binary.
export PATH="/Users/marley/Library/Application Support/Herd/bin/":$PATH
# Herd injected PHP 8.2 configuration.
export HERD_PHP_82_INI_SCAN_DIR="/Users/marley/Library/Application Support/Herd/config/php/82/"
# Herd injected PHP 8.3 configuration.
export HERD_PHP_83_INI_SCAN_DIR="/Users/marley/Library/Application Support/Herd/config/php/83/"
# Herd injected PHP 8.1 configuration.
export HERD_PHP_81_INI_SCAN_DIR="/Users/marley/Library/Application Support/Herd/config/php/81/"