Skip to content

Commit b817b82

Browse files
fix: update deprecated tools and improve shell script robustness
- Replace youtube-dl with yt-dlp (actively maintained fork) - Replace python with ipconfig for localip alias (Python 2 removed from macOS) - Rename 'now' export to 'kforce' to avoid shadowing date alias - Remove deprecated PIP_DOWNLOAD_CACHE from .exports - Replace systemsetup with pmset in osx_defaults.sh (deprecated in Monterey+) - Replace launchctl unload with bootout syntax - Comment out deprecated tmutil disablelocal commands - Replace hub with gh (official GitHub CLI) - Remove unmaintained legit package - Update setup_fedora.sh: oh-my-zsh URL, powerlevel9k to powerlevel10k - Add idempotent checks for git clone operations - Fix $(whoami) in vscode settings.json (shell vars don't work in JSON) - Quote variables in bootstrap.sh to handle paths with spaces - Quote command substitution in .zshrc pack completion - Use chmod +x instead of +rwx for binaries
1 parent 227a3ec commit b817b82

File tree

8 files changed

+56
-44
lines changed

8 files changed

+56
-44
lines changed

.aliases

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Youtube downloader
2-
alias youtube-mp3='youtube-dl -x --audio-format mp3 --audio-quality 0'
1+
# Youtube downloader (yt-dlp is the maintained fork of youtube-dl)
2+
alias youtube-mp3='yt-dlp -x --audio-format mp3 --audio-quality 0'
33

44
# eve - export vscode extensions
55
alias eve="code --list-extensions |
@@ -53,7 +53,7 @@ alias whois="whois -h whois-servers.net"
5353

5454
# IP addresses
5555
alias ip="curl ipinfo.io/ip"
56-
alias localip='python -c "import socket; print(socket.gethostbyname(socket.gethostname()));"'
56+
alias localip='ipconfig getifaddr en0 2>/dev/null || ipconfig getifaddr en1'
5757

5858
# Copy my public key to my clipboard
5959
alias pubkey="more ~/.ssh/id_rsa.pub | pbcopy | echo '=> Public key copied to pasteboard.'"
@@ -134,7 +134,7 @@ alias kgpw='kubectl get pods -w'
134134
# CRITICAL: Export variables for exam speed
135135
# Usage: k run nginx --image=nginx $do > pod.yaml
136136
export do='--dry-run=client -o yaml'
137-
export now='--force --grace-period=0'
137+
export kforce='--force --grace-period=0'
138138

139139

140140
# ------------------------------------------------------------------------------

.exports

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ export LC_TIME="en_US.UTF-8"
3838
export LC_ALL=
3939

4040

41-
# Let pip install the dependencies from local cache
42-
export PIP_DOWNLOAD_CACHE=$HOME/Library/Caches/pip-downloads
4341
export PYTHONHASHSEED=random
4442

4543
export PATH=~/bin:~/dotfiles/bin:$PATH

.zshrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export PATH="/usr/local/opt/gettext/bin:$PATH"
3737
export PATH="$PATH:$HOME/.rvm/bin"
3838

3939
# Enable buildpack `packs` completion for docker
40-
command -v pack >/dev/null && . $(pack completion --shell zsh)
40+
command -v pack >/dev/null && . "$(pack completion --shell zsh)"
4141
source ~/powerlevel10k/powerlevel10k.zsh-theme
4242

4343
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.

bootstrap.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ function createSymlinks() {
4444
# shellcheck disable=SC2068
4545
for F in ${FILES[@]}; do
4646
# Delete files if --force was used
47-
if [ $FORCE == true ]; then
47+
if [ "$FORCE" == true ]; then
4848
TIME=$(date +%s)
4949
echoR "--> [BACKUP]: $HOME/${F}"
50-
mv $HOME/$F $HOME/$F.$TIME.bak
50+
mv "$HOME/$F" "$HOME/$F.$TIME.bak"
5151
fi
5252

5353
# Make symlink
5454
echoY "--> [LINK]: ${HOME}/${F} -> ${CURRENTPATH}/${F}"
55-
ln -s $CURRENTPATH/$F $HOME/$F
55+
ln -s "$CURRENTPATH/$F" "$HOME/$F"
5656

5757
if [ $? -eq 1 ]; then
5858
echo
@@ -72,11 +72,11 @@ createSymlinks
7272
## Install custom binary utilities
7373

7474
if [ ! -d "$HOME/.bin" ]; then
75-
mkdir $HOME/.bin
75+
mkdir "$HOME/.bin"
7676
fi
7777

7878
# Symlink binaries
79-
ln -sf $PWD/bin/* $HOME/.bin/
79+
ln -sf "$PWD/bin/"* "$HOME/.bin/"
8080

8181
declare -a BINARIES=(
8282
'batcharge.py'
@@ -99,7 +99,7 @@ declare -a BINARIES=(
9999

100100
for i in "${BINARIES[@]}"; do
101101
echo "Changing access permissions for binary script :: ${i##*/}"
102-
chmod +rwx $HOME/.bin/${i##*/}
102+
chmod +x "$HOME/.bin/${i##*/}"
103103
done
104104

105105
echo "Binaries installed"

setup/osx_defaults.sh

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,18 @@ defaults write com.apple.helpviewer DevMode -bool true
103103
sudo defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo HostName
104104

105105
# Restart automatically if the computer freezes
106-
sudo systemsetup -setrestartfreeze on
106+
# Note: systemsetup is deprecated in macOS Monterey+, using pmset instead
107+
sudo pmset -a autorestart 1
107108

108109
# Never go into computer sleep mode
109-
sudo systemsetup -setcomputersleep Off > /dev/null
110+
sudo pmset -a sleep 0
110111

111112
# Check for software updates daily, not just once per week
112113
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
113114

114115
# Disable Notification Center and remove the menu bar icon
115-
launchctl unload -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist 2> /dev/null
116+
# Note: launchctl unload is deprecated, using bootout instead (may require SIP disabled)
117+
launchctl bootout gui/$(id -u) /System/Library/LaunchAgents/com.apple.notificationcenterui.plist 2> /dev/null || true
116118

117119
# Disable smart quotes as they’re annoying when typing code
118120
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
@@ -130,8 +132,8 @@ defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false
130132
# SSD-specific tweaks #
131133
###############################################################################
132134

133-
# Disable local Time Machine snapshots
134-
sudo tmutil disablelocal
135+
# Disable local Time Machine snapshots (removed in macOS High Sierra+)
136+
# sudo tmutil disablelocal # deprecated - local snapshots managed automatically now
135137

136138
# Disable hibernation (speeds up entering sleep mode)
137139
sudo pmset -a hibernatemode 0
@@ -593,8 +595,8 @@ defaults write com.googlecode.iterm2 PromptOnQuit -bool false
593595
# Prevent Time Machine from prompting to use new hard drives as backup volume
594596
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
595597

596-
# Disable local Time Machine backups
597-
hash tmutil &> /dev/null && sudo tmutil disablelocal
598+
# Disable local Time Machine backups (deprecated in High Sierra+)
599+
# hash tmutil &> /dev/null && sudo tmutil disablelocal
598600

599601
###############################################################################
600602
# Activity Monitor #
@@ -750,8 +752,8 @@ defaults write com.twitter.twitter-mac ShowFullNames -bool true
750752
# Hide the app in the background if it’s not the front-most window
751753
defaults write com.twitter.twitter-mac HideInBackground -bool true
752754

753-
# disable local time machine backups http://classicyuppie.com/what-crap-is-this-os-xs-mobilebackups/
754-
tmutil disablelocal
755+
# disable local time machine backups (deprecated in High Sierra+)
756+
# tmutil disablelocal
755757

756758
###############################################################################
757759
# Kill affected applications #

setup/setup_fedora.sh

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ sudo dnf -y install zsh
1010

1111
# Install everything else
1212
sudo dnf -y install ack
13-
sudo dnf -y install git git-extras hub
13+
sudo dnf -y install git git-extras gh
1414
sudo dnf -y install htop ngrep nmap
1515
sudo dnf -y install autojump # A smart command to change directory (https://github.com/wting/autojump)
16-
pip install legit # http://www.git-legit.org/
17-
legit install # Enables the extra git commands
1816
sudo dnf -y install zopfli # Data compression software (https://github.com/google/zopfli)
1917
sudo dnf -y install cowsay
2018
# pup not available for Linux (Fedora)
@@ -142,30 +140,29 @@ install_oh_my_zsh () {
142140
# Test to see if zshell is installed. If it is:
143141
if [ -f /bin/zsh ] || [ -f /usr/bin/zsh ]; then
144142
# Install Oh My Zsh if it isn't already present
145-
if [[ ! -d "$HOME/oh-my-zsh/" ]]; then
146-
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
147-
fi
148-
# Set the default shell to zsh if it isn't currently set to zsh
149-
if [[ ! $SHELL == $(command -v zsh) ]]; then
150-
chsh -s "$(command -v zsh)"
143+
if [[ ! -d "$HOME/.oh-my-zsh/" ]]; then
144+
# Use RUNZSH=no to prevent oh-my-zsh from launching a new shell
145+
# Use CHSH=no to skip changing shell (we'll do it at the end)
146+
RUNZSH=no CHSH=no sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
151147
fi
152148
else
153149
# If zsh isn't installed, get the platform of the current machine
154150
platform=$(uname);
155151
# If the platform is Linux, try an apt-get to install zsh and then recurse
156152
if [[ $platform == 'Linux' ]]; then
157153
if [[ -f /etc/redhat-release ]]; then
158-
sudo yum install zsh
154+
sudo yum install -y zsh
159155
fi
160156
if [[ -f /etc/debian_version ]]; then
161-
sudo apt-get install zsh
157+
sudo apt-get install -y zsh
162158
fi
163-
# If the platform is OS X, tell the user to install zsh :)
159+
# If the platform is OS X, install zsh via brew and continue
164160
elif [[ $platform == 'Darwin' ]]; then
165-
echo "We'll install zsh, then re-run this script!"
161+
echo "Installing zsh via Homebrew..."
166162
brew install zsh
167-
exit
168163
fi
164+
# Recurse to install oh-my-zsh now that zsh is installed
165+
install_oh_my_zsh
169166
fi
170167
}
171168

@@ -175,13 +172,28 @@ install_oh_my_zsh
175172
# Zsh #
176173
###############################################################################
177174

178-
set -P
179175
# Install Zsh settings
180176
ln -sf "$PWD/zsh/themes/curiouslearner.zsh-theme" "$HOME/.oh-my-zsh/themes"
181-
# Zsh Syntax highlighting
182-
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting"
183177

184-
# Install Powerlevel9k theme
185-
git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
178+
# Zsh Syntax highlighting
179+
ZSH_CUSTOM="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}"
180+
if [[ ! -d "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting" ]]; then
181+
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting"
182+
fi
183+
184+
# Install PowerLevel10k theme (powerlevel9k is unmaintained)
185+
if [[ ! -d "$HOME/powerlevel10k" ]]; then
186+
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "$HOME/powerlevel10k"
187+
fi
188+
189+
# Change default shell to zsh at the very end
190+
if [[ ! "$SHELL" == $(command -v zsh) ]]; then
191+
echo "Changing default shell to zsh..."
192+
chsh -s "$(command -v zsh)"
193+
fi
194+
195+
echo ""
196+
echo "Setup complete! Restart your terminal to use zsh."
197+
echo ""
186198

187199
exit 0

setup/setup_mac.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,9 @@ installcask sublime-text
6161
installcask visual-studio-code
6262
brew install openssl
6363
brew install ack
64-
brew install git git-extras hub git-ftp git-crypt
64+
brew install git git-extras gh git-ftp git-crypt
6565
brew install rename htop tree ngrep mtr nmap
6666
brew install autojump
67-
brew install legit # http://www.git-legit.org/
6867
# brew install Zopfli # https://code.google.com/p/zopfli/
6968
brew install fortune cowsay
7069
brew tap heroku/brew && brew install heroku

setup/vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@
9090
"notebook.includeCellOutputs": true,
9191
"continue.enableTabAutocomplete": true,
9292
"continue.telemetryEnabled": false,
93-
"dart.flutterSdkPath": "/Users/$(whoami)/Downloads/flutter",
93+
// Note: Update this path to your actual flutter SDK location
94+
"dart.flutterSdkPath": "~/Downloads/flutter",
9495
"workbench.sideBar.location": "right",
9596
"[json]": {
9697
"editor.defaultFormatter": "vscode.json-language-features"

0 commit comments

Comments
 (0)