From 5ee12eaf1d9e5666c0b9ea9d170da23241857491 Mon Sep 17 00:00:00 2001 From: "Castillo, Andres Eduardo" Date: Wed, 15 Mar 2023 10:30:16 -0400 Subject: [PATCH] adding zsh support --- dotfiles_zsh/.aliases | 50 ++++++++++++++++ dotfiles_zsh/.zprofile | 13 ++++ dotfiles_zsh/.zsh_prompt | 125 +++++++++++++++++++++++++++++++++++++++ dotfiles_zsh/.zshrc | 5 ++ dotfiles_zsh/brew.sh | 14 +++++ dotfiles_zsh/install.sh | 38 ++++++++++++ 6 files changed, 245 insertions(+) create mode 100755 dotfiles_zsh/.aliases create mode 100644 dotfiles_zsh/.zprofile create mode 100755 dotfiles_zsh/.zsh_prompt create mode 100755 dotfiles_zsh/.zshrc create mode 100755 dotfiles_zsh/brew.sh create mode 100755 dotfiles_zsh/install.sh diff --git a/dotfiles_zsh/.aliases b/dotfiles_zsh/.aliases new file mode 100755 index 00000000..7645cb7c --- /dev/null +++ b/dotfiles_zsh/.aliases @@ -0,0 +1,50 @@ +# Shortcuts +alias ch='history | grep "git commit"' +alias hg='history | grep' + +# 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}" +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:' + +export LSCOLORS='Gxfxcxdxbxegedabagacad' + + +# 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' + +# Enable aliases to be sudo’ed +alias sudo='sudo ' + +# Get OS X Software Updates, and update installed Ruby gems, Homebrew, npm, and their installed packages +alias update_system='sudo softwareupdate -i -a' + +# Show/hide hidden files in Finder +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;' + +alias clean='rm -rf ~/.Trash/*; rm -rf ~/Downloads/*' +alias wipe_env='rm -rf ~/tutorial_env; python3 -m venv ~/tutorial_env' +alias tut_env='source ~/tutorial_env/bin/activate' diff --git a/dotfiles_zsh/.zprofile b/dotfiles_zsh/.zprofile new file mode 100644 index 00000000..ec3aa038 --- /dev/null +++ b/dotfiles_zsh/.zprofile @@ -0,0 +1,13 @@ +eval "$(/usr/local/bin/brew shellenv)" + + +# Load dotfiles: +for file in ~/.{zsh_prompt,aliases,private}; do + [ -r "$file" ] && [ -f "$file" ] && source "$file"; +done; +unset file; + + +# Setting PATH for Python 3.7 +# PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}" +# export PATH diff --git a/dotfiles_zsh/.zsh_prompt b/dotfiles_zsh/.zsh_prompt new file mode 100755 index 00000000..750fbb54 --- /dev/null +++ b/dotfiles_zsh/.zsh_prompt @@ -0,0 +1,125 @@ +# https://dev.to/cassidoo/customizing-my-zsh-prompt-3417 +autoload -Uz vcs_info +precmd() { vcs_info } + +zstyle ':vcs_info:git:*' formats '%b ' + +setopt PROMPT_SUBST +PROMPT='%F{green}%*%f %F{blue}%C%f %F{red}${vcs_info_msg_0_}%f$ ' + + + +# # Shell prompt based on the Solarized Dark theme. +# # Screenshot: http://i.imgur.com/EkEtphC.png +# # Heavily inspired by @necolas’s prompt: https://github.com/necolas/dotfiles +# # iTerm → Profiles → Text → use 13pt Monaco with 1.1 vertical spacing. + +# if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then +# export TERM='gnome-256color'; +# elif infocmp xterm-256color >/dev/null 2>&1; then +# export TERM='xterm-256color'; +# fi; + +# prompt_git() { +# local s=''; +# local branchName=''; + +# # Check if the current directory is in a Git repository. +# if [ $(git rev-parse --is-inside-work-tree &>/dev/null; echo "${?}") == '0' ]; then + +# # check if the current directory is in .git before running git checks +# if [ "$(git rev-parse --is-inside-git-dir 2> /dev/null)" == 'false' ]; then + +# # Ensure the index is up to date. +# git update-index --really-refresh -q &>/dev/null; + +# # Check for uncommitted changes in the index. +# if ! $(git diff --quiet --ignore-submodules --cached); then +# s+='+'; +# fi; + +# # Check for unstaged changes. +# if ! $(git diff-files --quiet --ignore-submodules --); then +# s+='!'; +# fi; + +# # Check for untracked files. +# if [ -n "$(git ls-files --others --exclude-standard)" ]; then +# s+='?'; +# fi; + +# # Check for stashed files. +# if $(git rev-parse --verify refs/stash &>/dev/null); then +# s+='$'; +# fi; + +# fi; + +# # Get the short symbolic ref. +# # If HEAD isn’t a symbolic ref, get the short SHA for the latest commit +# # Otherwise, just give up. +# branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || \ +# git rev-parse --short HEAD 2> /dev/null || \ +# echo '(unknown)')"; + +# [ -n "${s}" ] && s=" [${s}]"; + +# echo -e "${1}${branchName}${2}${s}"; +# else +# return; +# fi; +# } + +# if tput setaf 1 &> /dev/null; then +# tput sgr0; # reset colors +# bold=$(tput bold); +# reset=$(tput sgr0); +# # Solarized colors, taken from http://git.io/solarized-colors. +# black=$(tput setaf 0); +# blue=$(tput setaf 153); +# green=$(tput setaf 71); +# orange=$(tput setaf 166); +# red=$(tput setaf 167); +# white=$(tput setaf 15); +# yellow=$(tput setaf 228); +# else +# bold=''; +# reset="\e[0m"; +# black="\e[1;30m"; +# blue="\e[1;34m"; +# green="\e[1;32m"; +# orange="\e[1;33m"; +# red="\e[1;31m"; +# white="\e[1;37m"; +# yellow="\e[1;33m"; +# fi; + +# # Highlight the user name when logged in as root. +# if [[ "${USER}" == "root" ]]; then +# userStyle="${red}"; +# else +# userStyle="${orange}"; +# fi; + +# # Highlight the hostname when connected via SSH. +# if [[ "${SSH_TTY}" ]]; then +# hostStyle="${bold}${red}"; +# else +# hostStyle="${yellow}"; +# fi; + +# # Set the terminal title to the current working directory. +# PS1="\[\033]0;\w\007\]"; +# PS1+="\[${bold}\]\n"; # newline +# PS1+="\[${userStyle}\]\u"; # username +# PS1+="\[${white}\] at "; +# PS1+="\[${hostStyle}\]\h"; # host +# PS1+="\[${white}\] in "; +# PS1+="\[${green}\]\W"; # working directory +# PS1+="\$(prompt_git \"\[${white}\] on \[${blue}\]\" \"\[${blue}\]\")"; # Git repository details +# PS1+="\n"; +# PS1+="\[${white}\]\$ \[${reset}\]"; # `$` (and reset color) +# export PS1; + +# PS2="\[${yellow}\]→ \[${reset}\]"; +# export PS2; diff --git a/dotfiles_zsh/.zshrc b/dotfiles_zsh/.zshrc new file mode 100755 index 00000000..d77e2fb2 --- /dev/null +++ b/dotfiles_zsh/.zshrc @@ -0,0 +1,5 @@ +# If not running interactively, don't do anything +[[ $- == *i* ]] || return + +# -n Checks if the length of a string is nonzero. +[ -n "$PS1" ] && source ~/.zprofile; diff --git a/dotfiles_zsh/brew.sh b/dotfiles_zsh/brew.sh new file mode 100755 index 00000000..fa3ea838 --- /dev/null +++ b/dotfiles_zsh/brew.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env zsh + +# Install Brew Packages +brew install python@3.11 +brew install tree + +# Install MacOS Applications +brew install --cask virtualbox +brew install --cask visual-studio-code + +# Install Source Code Pro Font +brew tap homebrew/cask-fonts +brew install --cask font-source-code-pro + diff --git a/dotfiles_zsh/install.sh b/dotfiles_zsh/install.sh new file mode 100755 index 00000000..d9886246 --- /dev/null +++ b/dotfiles_zsh/install.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env zsh +############################ +# This script creates symlinks from the home directory to any desired dotfiles in ${homedir}/dotfiles +# And also installs Homebrew Packages +# And sets Sublime preferences +############################ + +if [ "$#" -ne 1 ]; then + echo "Usage: install.sh " + exit 1 +fi + +homedir=$1 + +# dotfiles directory +dotfiledir=${homedir}/dotfiles_zsh + +# list of files/folders to symlink in ${homedir} +files="zprofile zshrc zsh_prompt aliases private" + +# change to the dotfiles directory +echo "Changing to the ${dotfiledir} directory" +cd ${dotfiledir} +echo "...done" + +# create symlinks (will overwrite old dotfiles) +for file in ${=~files}; do + echo "Creating symlink to $file in home directory." + ln -sf ${dotfiledir}/.${file} ${homedir}/.${file} + echo "created the .${file} symlink" +done + +# Download Git Auto-Completion +# curl "https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash" > ${homedir}/.git-completion.bash + +# Run the Homebrew Script +./brew.sh +