Skip to content

Commit 1c5692c

Browse files
committed
update
1 parent 6fa2971 commit 1c5692c

33 files changed

Lines changed: 531 additions & 310 deletions

.bash_profile

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
#!/bin/bash
22

3-
# -------------- History Configuration --------------
4-
export HISTCONTROL=erasedups
5-
export HISTSIZE=10000
6-
export HISTFILESIZE=20000
7-
export HISTIGNORE="ls:ll:cd:pwd:exit:clear:history"
8-
93
# -------------- Path Configuration --------------
104
# Function to add directory to PATH if it exists
115
pathadd() {
@@ -25,25 +19,19 @@ pathadd "/opt/homebrew/opt/llvm/bin"
2519
pathadd "/usr/local/sbin"
2620
pathadd "$HOME/Library/Python/3.9/bin"
2721
pathadd "/usr/textbin"
28-
pathadd "/opt/homebrew/opt/llvm@16/bin"
2922
pathadd "$HOME/.elan/bin"
3023

3124
# -------------- Development Tool Configuration --------------
3225
# Cargo configuration
3326
export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
3427

35-
# Docker for M1 configuration
36-
export DOCKER_BUILDKIT=0
37-
export COMPOSE_DOCKER_CLI_BUILD=0
38-
export DOCKER_DEFAULT_PLATFORM=linux/amd64
39-
4028
# GHCI configuration
4129
export ghci="TERM=dumb ghci"
4230

4331
# Java configuration
44-
if [ -f /usr/libexec/java_home ]; then
45-
JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"
46-
export JAVA_HOME
32+
if [ -x /usr/libexec/java_home ]; then
33+
_jh=$(/usr/libexec/java_home -v 1.8 2>/dev/null) && export JAVA_HOME="$_jh"
34+
unset _jh
4735
fi
4836

4937
# Homebrew configuration
@@ -59,27 +47,31 @@ if [ "$(uname)" == "Darwin" ]; then
5947
fi
6048

6149
# -------------- External Tool Initialization --------------
62-
# Source bashrc if it exists
63-
if [ -f "$HOME/.bashrc" ]; then
64-
# shellcheck source=./.bashrc
65-
source "$HOME/.bashrc"
50+
# Run env/PATH setup BEFORE sourcing .bashrc so that per-shell tool inits
51+
# in .bashrc (starship, atuin) can find their binaries on PATH.
52+
if [ -x /opt/homebrew/bin/brew ]; then
53+
eval "$(/opt/homebrew/bin/brew shellenv)"
54+
elif [ -x /home/linuxbrew/.linuxbrew/bin/brew ]; then
55+
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
56+
elif [ -x "$HOME/.linuxbrew/bin/brew" ]; then
57+
eval "$("$HOME/.linuxbrew/bin/brew" shellenv)"
6658
fi
6759

6860
if [ -r "$HOME/.opam/opam-init/init.sh" ]; then
6961
. "$HOME/.opam/opam-init/init.sh" >/dev/null 2>/dev/null
7062
fi
7163

72-
# Initialize shell enhancements
73-
[ -x /opt/homebrew/bin/brew ] && eval "$(/opt/homebrew/bin/brew shellenv)"
74-
[ -x "$(command -v starship)" ] && eval "$(starship init bash)"
75-
[ -x "$(command -v atuin)" ] && eval "$(atuin init bash)"
76-
77-
# Source cargo environment if it exists
7864
if [ -f "$HOME/.cargo/env" ]; then
7965
. "$HOME/.cargo/env"
8066
fi
8167

82-
# List directory contents when opening a new terminal (personal preference)
83-
ls -l
68+
# Source bashrc — covers interactive-shell setup (history, aliases, functions,
69+
# starship/atuin) for login shells too.
70+
if [ -f "$HOME/.bashrc" ]; then
71+
# shellcheck source=./.bashrc
72+
source "$HOME/.bashrc"
73+
fi
8474

85-
complete -C /opt/homebrew/bin/terraform terraform
75+
# List directory contents when opening a new terminal (login shells only).
76+
# Guarded so sourcing this from a non-interactive context doesn't emit stray output.
77+
[[ $- == *i* ]] && ls -l

.bashrc

Lines changed: 50 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
#!/bin/bash
22

3-
alias python='python3'
4-
alias pip='pip3'
3+
# Only apply for interactive shells. Aliases, functions, prompt hooks, and
4+
# atuin/starship don't make sense in non-interactive bash.
5+
[[ $- == *i* ]] || return
56

6-
#if [ "$(uname)" == "Darwin" ]; then
7-
#alias gcc='gcc-7'
8-
#alias cc='gcc-7'
9-
#alias g++='g++-7'
10-
#alias c++='g++-7'
11-
#fi
7+
# -------------- History Configuration --------------
8+
export HISTCONTROL=erasedups
9+
export HISTSIZE=10000
10+
export HISTFILESIZE=20000
11+
export HISTIGNORE="ls:ll:cd:pwd:exit:clear:history"
1212

13-
if [[ -d ~/.linuxbrew ]]; then
14-
eval "$(/home/pwl45/.linuxbrew/bin/brew shellenv)"
15-
fi
13+
alias python='python3'
14+
alias pip='pip3'
1615

1716
alias duck='{ du -ha | sort -rh | head -20;} 2> /dev/null'
1817

@@ -28,10 +27,11 @@ function brew() {
2827

2928
# Only check deps if we actually removed something successfully
3029
if [[ $? -eq 0 && -n "$pkg" ]]; then
31-
local deps=$(join <(brew leaves) <(brew deps "$pkg") 2>/dev/null)
32-
if [[ -n "$deps" ]]; then
33-
echo "Removing unused dependencies: $deps"
34-
command brew rm $deps
30+
local -a deps
31+
mapfile -t deps < <(join <(brew leaves) <(brew deps "$pkg") 2>/dev/null)
32+
if (( ${#deps[@]} > 0 )); then
33+
echo "Removing unused dependencies: ${deps[*]}"
34+
command brew rm "${deps[@]}"
3535
fi
3636
fi
3737
else
@@ -51,7 +51,14 @@ function git() {
5151
}
5252

5353
function ls() {
54-
if [[ $* == *l* ]]; then
54+
local arg long=0
55+
for arg in "$@"; do
56+
if [[ $arg == -[!-]*l* ]]; then
57+
long=1
58+
break
59+
fi
60+
done
61+
if (( long )); then
5562
if [[ "$(uname)" == "Darwin" ]]; then
5663
command ls -GhLa "$@"
5764
else
@@ -62,21 +69,15 @@ function ls() {
6269
fi
6370
}
6471

65-
function cd() {
66-
command cd -P "$@" || return
67-
68-
# Auto-activate venv if present
69-
if [[ -d venv ]]; then
70-
source venv/bin/activate
71-
fi
72-
73-
# Always ls after successful cd (the $? check is redundant here)
74-
ls -l
75-
}
76-
7772
function rm() {
78-
if [[ $* == *r* ]]
79-
then
73+
local arg recursive=0
74+
for arg in "$@"; do
75+
if [[ $arg == -[!-]*r* || $arg == -[!-]*R* || $arg == --recursive ]]; then
76+
recursive=1
77+
break
78+
fi
79+
done
80+
if (( recursive )); then
8081
command rm -f "$@"
8182
else
8283
command rm "$@"
@@ -91,11 +92,7 @@ function rm() {
9192
}
9293

9394
function cat() {
94-
if [[ $* == *.md* ]]; then
95-
command mdcat "$@" 2>/dev/null || command cat "$@"
96-
else
97-
command ccat "$@" 2>/dev/null || command cat "$@"
98-
fi
95+
command bat --style=plain --paging=never "$@" 2>/dev/null || command cat "$@"
9996
}
10097

10198
function extract() {
@@ -125,54 +122,7 @@ function gh() {
125122
local exit_code=$?
126123

127124
if [[ $exit_code -eq 0 ]]; then
128-
# Find the repo argument (first non-flag, non-subcommand arg)
129-
local repo_arg=""
130-
for arg in "${@:3}"; do
131-
if [[ "$arg" != -* ]]; then
132-
repo_arg="$arg"
133-
break
134-
fi
135-
done
136-
137-
if [[ -n "$repo_arg" ]]; then
138-
local repo_name=$(basename "$repo_arg" .git)
139-
if [[ -d "$repo_name" ]]; then
140-
(
141-
cd "$repo_name" || exit 1
142-
# Get the repository from the origin remote and set it explicitly
143-
local origin_url=$(git remote get-url origin 2>/dev/null)
144-
if [[ -n "$origin_url" ]]; then
145-
# Extract owner/repo from the URL
146-
local repo_path=""
147-
case "$origin_url" in
148-
*github.com*)
149-
repo_path=$(echo "$origin_url" | sed -E 's|.*github\.com[:/]([^/]+/[^/]+)(\.git)?.*|\1|')
150-
;;
151-
esac
152-
153-
if [[ -n "$repo_path" ]]; then
154-
command gh repo set-default "$repo_path" 2>/dev/null || true
155-
else
156-
command gh repo set-default 2>/dev/null || true
157-
fi
158-
fi
159-
)
160-
fi
161-
fi
162-
fi
163-
164-
return $exit_code
165-
else
166-
command gh "$@"
167-
fi
168-
}
169-
170-
function gh() {
171-
if [[ "$1" == "repo" && "$2" == "clone" ]]; then
172-
command gh "$@"
173-
local exit_code=$?
174-
175-
if [[ $exit_code -eq 0 ]]; then
125+
# First non-flag arg after "clone" is the repo identifier
176126
local repo_arg=""
177127
for arg in "${@:3}"; do
178128
if [[ "$arg" != -* ]]; then
@@ -182,10 +132,18 @@ function gh() {
182132
done
183133

184134
if [[ -n "$repo_arg" ]]; then
185-
local repo_name=$(basename "$repo_arg" .git)
186-
if [[ -d "$repo_name" ]]; then
187-
cd "$repo_name" || return 1
188-
command gh repo set-default "$repo_arg" 2>/dev/null || true
135+
local repo_name
136+
repo_name=$(basename "$repo_arg" .git)
137+
if [[ -d "$repo_name" ]] && cd "$repo_name"; then
138+
# Derive owner/repo from origin so set-default works regardless
139+
# of which form the user passed to clone (owner/repo, https://, git@…)
140+
local origin_url
141+
origin_url=$(git remote get-url origin 2>/dev/null)
142+
if [[ "$origin_url" == *github.com* ]]; then
143+
local repo_path
144+
repo_path=$(echo "$origin_url" | sed -E 's|.*github\.com[:/]([^/]+/[^/]+)(\.git)?.*|\1|')
145+
[[ -n "$repo_path" ]] && command gh repo set-default "$repo_path" 2>/dev/null || true
146+
fi
189147
fi
190148
fi
191149
fi
@@ -196,6 +154,8 @@ function gh() {
196154
fi
197155
}
198156

199-
## Need something like this for atuin
200-
source ~/.bash-preexec.sh
201-
eval "$(atuin init bash)"
157+
# -------------- Per-shell tool initialization --------------
158+
# These hook into PROMPT_COMMAND / keybindings / PS1, which are shell-local —
159+
# they must run in every interactive shell, not just login shells. Hence .bashrc.
160+
[ -x "$(command -v starship)" ] && eval "$(starship init bash)"
161+
[ -x "$(command -v atuin)" ] && eval "$(atuin init bash)"

.config/.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ gh/hosts.yml
22
gspread/service_account.json
33
grammarly-languageserver
44
raycast/extensions
5-
StardewValley
5+
StardewValley
6+
configstore
7+
rust-analyzer
8+
htop/htoprc_old

.config/configstore/update-notifier-npm.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

.config/git/ignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/.claude/settings.local.json

.config/htop/htoprc_old

Lines changed: 0 additions & 26 deletions
This file was deleted.

.config/rust-analyzer/metadata.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

.emacs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
;; Make sure emacs knows the background is black
1313
(add-to-list 'default-frame-alist '(background-color . "black"))
1414
;; ## added by OPAM user-setup for emacs / base ## 56ab50dc8996d2bb95e7856a6eddb17b ## you can edit, but keep this line
15-
(require 'opam-user-setup "~/.emacs.d/opam-user-setup.el")
15+
(when (file-exists-p "~/.emacs.d/opam-user-setup.el")
16+
(require 'opam-user-setup "~/.emacs.d/opam-user-setup.el"))
1617
;; ## end of OPAM user-setup addition for emacs / base ## keep this line

.gitconfig

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
user = Pat-Lafon
77

88
[core]
9-
editor = emacs
9+
editor = emacs -nw
1010

1111
[alias]
12-
cleanup = !sh ~/UsefulScripts/git_aliases/cleanup.sh
13-
up = !sh ~/UsefulScripts/git_aliases/up.sh
12+
cleanup = !sh "$(dirname "$(readlink ~/.gitconfig)")/git_aliases/cleanup.sh"
13+
up = !sh "$(dirname "$(readlink ~/.gitconfig)")/git_aliases/up.sh"
1414

1515
[color]
1616
ui = true
@@ -31,6 +31,12 @@
3131
changed = green
3232
untracked = red
3333

34+
[merge]
35+
conflictStyle = zdiff3
36+
[rerere]
37+
enabled = true
38+
[diff]
39+
algorithm = histogram
3440
[rebase]
3541
autostash = true
3642
[init]

.github/dependabot.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: weekly
7+
groups:
8+
actions:
9+
patterns: ["*"]

0 commit comments

Comments
 (0)