-
-
Notifications
You must be signed in to change notification settings - Fork 644
Expand file tree
/
Copy path.aliases
More file actions
202 lines (170 loc) · 8.65 KB
/
.aliases
File metadata and controls
202 lines (170 loc) · 8.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# Shortcuts
alias ch='history 0 | grep "git commit"'
alias hg='history 0 | grep'
alias yt="code $HOME/My_Drive/YouTube/Scripts/"
alias cyt="cd $HOME/My_Drive/YouTube/Scripts/"
alias oyt="open $HOME/My_Drive/YouTube/Scripts/"
# Detect which `ls` flavor is in use
if ls --color >/dev/null 2>&1; then # GNU `ls`
colorflag="--color"
else # OS X `ls`
colorflag="-G"
fi
# List all files colorized in long format, including dot files
alias la="ls -lahF ${colorflag}"
# Always use color output for `ls`
alias ls="command ls ${colorflag}"
# For detailed colors on Mac, run 'man ls' and see the LSCOLORS section
export LSCOLORS='Dxexcxdxcxegedabagacad'
export LS_COLORS='no=00:fi=00:di=04;35:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:'
# Always enable colored `grep` output
# Note: `GREP_OPTIONS="--color=auto"` is deprecated, hence the alias usage.
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
# Update/upgrade Homebrew and their installed packages
alias update_brew='brew update; brew upgrade; brew upgrade --cask; brew link --overwrite node; brew cleanup; $(brew --prefix)/bin/npm update --global; $(brew --prefix)/bin/pipx upgrade-all; $(brew --prefix)/bin/uv tool upgrade --all'
# Show/hide hidden files in Finder
# As of macOS Sierra (10.12) and later, you can simply press Cmd + Shift + . (period) while in Finder to toggle the visibility of hidden files.
alias show="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
alias hide="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
# To prep before screencasts
alias tut_mode='defaults write com.apple.dock autohide -bool true && killall Dock;
defaults write com.apple.finder CreateDesktop -bool false && killall Finder;
defaults write com.apple.menuextra.clock IsAnalog -bool true && killall SystemUIServer;
rm -rf ~/.Trash/*;
rm -rf ~/Downloads/*'
alias reg_mode='defaults write com.apple.dock autohide -bool false && killall Dock;
defaults write com.apple.finder CreateDesktop -bool true && killall Finder;
defaults write com.apple.menuextra.clock IsAnalog -bool false && killall SystemUIServer;'
clean() {
osascript -e 'tell application "Finder" to empty the trash' 2>/dev/null
rm -rf ~/Downloads/*
# Clean junk files from YouTube Scripts directory
local scripts="$HOME/My_Drive/YouTube/Scripts"
fd -t d --hidden --no-ignore '__pycache__' -0 --search-path "$scripts" | xargs -0 rm -rf
fd -t d --hidden --no-ignore '\.mypy_cache' -0 --search-path "$scripts" | xargs -0 rm -rf
fd -t d --hidden --no-ignore '\.ruff_cache' -0 --search-path "$scripts" | xargs -0 rm -rf
fd -t d --hidden --no-ignore '\.ipynb_checkpoints' -0 --search-path "$scripts" | xargs -0 rm -rf
fd -t d --hidden --no-ignore '\.pytest_cache' -0 --search-path "$scripts" | xargs -0 rm -rf
fd -t f --hidden --no-ignore '\.DS_Store' -0 --search-path "$scripts" | xargs -0 rm -f
}
# Virtual Environments
alias wipe_env='rm -rf ~/venvs/tutorial; python3 -m venv ~/venvs/tutorial'
alias tut_env='source ~/venvs/tutorial/bin/activate'
# Find Files and Directories
# COMMENTING THESE WHILE I EVALUATE fd (https://github.com/sharkdp/fd)
# alias fd='find . -type d -iname'
# alias ff='find . -type f -iname'
# CLI - AI FULL AUTO
alias claude-auto='claude --dangerously-skip-permissions --disallowedTools "Bash(rm *)"'
alias codex-auto='codex --full-auto'
alias copilot-auto='copilot --allow-all-tools --deny-tool "shell(rm)"'
# Local launchd services (auto-start at login, auto-restart on crash).
# Service definitions live in ~/Library/LaunchAgents/ — edit the plists there to change config.
# Personal YouTube Script Organizer App — http://scripts.localhost:9111
alias scripts_start='launchctl bootstrap "gui/$(id -u)" "$HOME/Library/LaunchAgents/com.coreyschafer.scripts.plist"'
alias scripts_stop='launchctl bootout "gui/$(id -u)/com.coreyschafer.scripts"'
alias scripts_restart='launchctl kickstart -k "gui/$(id -u)/com.coreyschafer.scripts"'
# Personal TODO App — http://todos.localhost:6969
alias todos_start='launchctl bootstrap "gui/$(id -u)" "$HOME/Library/LaunchAgents/com.coreyschafer.todos.plist"'
alias todos_stop='launchctl bootout "gui/$(id -u)/com.coreyschafer.todos"'
alias todos_restart='launchctl kickstart -k "gui/$(id -u)/com.coreyschafer.todos"'
# YouTube script initialization
# Usage:
# yt_init # init current dir
# yt_init project_name # create ./project_name, set it up, but stay where you are
yt_init() {
local template="$HOME/dotfiles/prompts/AGENTS.md"
local template_dir="$HOME/My_Drive/YouTube/Youtube-Tutorial-Template"
local gitignore_stack="${GITIGNORE_STACK:-python,macos,visualstudiocode,dotenv}"
local gitignore_url="https://www.toptal.com/developers/gitignore/api/${gitignore_stack}"
local orig="$PWD"
local target="."
local dir
local prompt_file
local copied_prompts=0
# minimal sanity: require template file so we don't error later
[[ -f "$template" ]] || { echo "Template not found: $template"; return 1; }
if [[ $# -eq 1 ]]; then
target="$1"
# Check if target directory exists and is not empty
if [[ -d "$target" ]] && [[ -n "$(ls -A "$target" 2>/dev/null)" ]]; then
echo "❌ Error: Directory '$target' already exists and is not empty."
echo " Please use an empty directory or remove existing contents."
return 1
fi
uv init "$target" || return # keep uv's error behavior
elif [[ $# -eq 0 ]]; then
# Check if current directory is not empty
if [[ -n "$(ls -A . 2>/dev/null)" ]]; then
echo "❌ Error: Current directory is not empty."
echo " Please run yt_init from an empty directory or specify a new directory name."
return 1
fi
uv init || return
else
echo "Usage: yt_init [project_name]"
return 1
fi
dir="$orig"; [[ "$target" == "." ]] || dir="$orig/$target"
# .gitignore (overwrite with your preferred stack)
if command -v curl >/dev/null; then
curl -fsSL "$gitignore_url" -o "$dir/.gitignore" \
|| echo "⚠️ Could not fetch .gitignore; keeping uv's default."
else
echo "⚠️ curl not found; keeping uv's default .gitignore."
fi
# Append YT Script Organizer marker file to .gitignore
printf '\n# YT Script Organizer\n.tutorial.json\n' >> "$dir/.gitignore"
# AGENTS.md + empty sandbox files
cp -f "$template" "$dir/AGENTS.md"
: > "$dir/s.txt"
: > "$dir/sandbox.txt"
: > "$dir/sandbox.py"
: > "$dir/snippets.txt"
python3 -c "import uuid, json; print(json.dumps({'id': uuid.uuid4().hex, 'type': 'video'}, indent=2))" > "$dir/.tutorial.json"
# Copy tutorial prompt files from template to project root
for prompt_file in 1_bullets.md 2_structure.md 3_code_examples.md 4_script.md; do
if [[ -f "$template_dir/$prompt_file" ]]; then
cp -f "$template_dir/$prompt_file" "$dir/$prompt_file" && copied_prompts=$((copied_prompts + 1))
fi
done
if [[ $copied_prompts -gt 0 ]]; then
echo "✅ Copied $copied_prompts tutorial prompt file(s) from template."
else
echo "⚠️ Could not copy tutorial prompt files from template."
fi
# Copy CLAUDE.md from template
if [[ -f "$template_dir/CLAUDE.md" ]]; then
cp -f "$template_dir/CLAUDE.md" "$dir/CLAUDE.md" \
&& echo "✅ Copied CLAUDE.md from template." \
|| echo "⚠️ Could not copy CLAUDE.md."
else
echo "⚠️ Template CLAUDE.md not found."
fi
# Create virtual environment (run from project root)
( cd "$dir" && uv venv ) || return
# Initial commit (assumes brand-new repo with no commits)
if command -v git >/dev/null; then
git -C "$dir" add -A
if git -C "$dir" commit -m "Initial Commit"; then
echo "✅ Created initial Git commit."
else
echo "ℹ️ Git commit skipped/failed (possibly re-ran yt_init or git not configured)."
fi
else
echo "⚠️ git not found; skipping initial commit."
fi
echo "✅ Project ready at $dir"
}
# Copy to clipboard without newlines. Can be piped to or run as a command.
c() {
if [[ $# -eq 0 ]]; then
# No arguments, read from stdin (piped input)
tr -d '\n' | pbcopy
else
# Arguments provided, run as command
"$@" | tr -d '\n' | pbcopy
fi
}