Last active
November 10, 2023 17:20
-
-
Save sko00o/2458ea1f84e766ee093775f38a4e5d23 to your computer and use it in GitHub Desktop.
Make Mac Terminal Better
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# Reference: https://www.youtube.com/watch?v=CF1tMjvHDRA | |
install_brew() { | |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
} | |
setup_brew() { | |
(echo; echo 'eval "$(/usr/local/bin/brew shellenv)"') >> /Users/shank/.zprofile | |
eval "$(/usr/local/bin/brew shellenv)" | |
} | |
install_iterm2() { | |
brew install --cask iterm2 | |
} | |
download_iterm2_color() { | |
curl https://raw.githubusercontent.com/josean-dev/dev-environment-files/main/coolnight.itermcolors --output ~/Downloads/coolnight.itermcolors | |
} | |
download_helper_shell() { | |
curl https://raw.githubusercontent.com/mbadolato/iTerm2-Color-Schemes/master/tools/import-scheme.sh --output ~/Downloads/import-scheme.sh | |
} | |
import_iterm2_color() { | |
bash ~/Downloads/import-scheme.sh ~/Downloads/coolnight.itermcolors | |
} | |
install_oh-my-zsh() { | |
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" | |
} | |
zsh_plugin_zsh-autosuggestions() { | |
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions | |
} | |
zsh_plugin_zsh-syntax-highlighting() { | |
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting | |
} | |
zsh_setup_plugin() { | |
plugin_name="$1" | |
# Check if the plugin is already present in the .zshrc file | |
if grep -q "$plugin_name" ~/.zshrc; then | |
echo "Plugin $plugin_name is already present in .zshrc" | |
else | |
# Add the plugin to the plugin array in .zshrc | |
sed -i '' 's/^plugins=(/plugins=('"$plugin_name"' /' ~/.zshrc | |
echo "Plugin $plugin_name added to .zshrc" | |
fi | |
source ~/.zshrc | |
} | |
install_p10k() { | |
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k | |
} | |
setup_p10k() { | |
# Why using `sed -i '' on macOS`: | |
# https://stackoverflow.com/questions/25124969/sed-replacement-command-not-working-on-mac/72473197#72473197 | |
sed -i '' 's/^ZSH_THEME=.*/ZSH_THEME="powerlevel10k\/powerlevel10k"/g' ~/.zshrc | |
grep -e '^ZSH_THEME=' ~/.zshrc | |
source ~/.zshrc | |
} | |
setup_iterm2_font() { | |
# font size to 20 | |
/usr/libexec/PlistBuddy -c "SET ':New Bookmarks:0:Normal Font' 'MesloLGS-NF-Regular 20'" ~/Library/Preferences/com.googlecode.iterm2.plist | |
} | |
setup_iterm2_color() { | |
# TODO | |
} | |
main() { | |
install_brew | |
setup_brew | |
install_iterm2 | |
install_oh-my-zsh | |
zsh_plugin_zsh-autosuggestions | |
zsh_setup_plugin zsh-autosuggestions | |
zsh_plugin_zsh-syntax-highlighting | |
zsh_setup_plugin zsh-syntax-highlighting | |
zsh_setup_plugin web-search | |
download_iterm2_color | |
download_helper_shell | |
import_iterm2_color | |
install_p10k | |
setup_p10k | |
setup_iterm2_font | |
setup_iterm2_color | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment