forked from CoreyMSchafer/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e421764
commit f7a1634
Showing
12 changed files
with
188 additions
and
129 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,114 +1,77 @@ | ||
# 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; | ||
|
||
# Define the prompt_git function for git repository status | ||
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; | ||
local git_status='' | ||
local branchName='' | ||
|
||
# Check for unstaged changes. | ||
if ! $(git diff-files --quiet --ignore-submodules --); then | ||
s+='!'; | ||
fi; | ||
# Check if the current directory is in a Git repository. | ||
if git rev-parse --is-inside-work-tree &>/dev/null; then | ||
# Get the status summary. | ||
local gitSummary=$(git status --porcelain) | ||
|
||
# Check for untracked files. | ||
if [ -n "$(git ls-files --others --exclude-standard)" ]; then | ||
s+='?'; | ||
fi; | ||
# Check for uncommitted changes in the index, unstaged changes, untracked files, and stashed files. | ||
[[ -n $(echo "$gitSummary" | grep '^M') ]] && git_status+='+' | ||
[[ -n $(echo "$gitSummary" | grep '^ M') ]] && git_status+='!' | ||
[[ -n $(echo "$gitSummary" | grep '^\?\?') ]] && git_status+='?' | ||
[[ $(git rev-parse --verify refs/stash &>/dev/null; echo "${?}") == '0' ]] && git_status+='$' | ||
|
||
# Check for stashed files. | ||
if $(git rev-parse --verify refs/stash &>/dev/null); then | ||
s+='$'; | ||
fi; | ||
# Get the short symbolic ref or the short SHA for the latest commit. | ||
branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || git rev-parse --short HEAD 2> /dev/null || echo '(unknown)')" | ||
|
||
fi; | ||
[ -n "${git_status}" ] && git_status=" [${git_status}]" | ||
|
||
# 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}]"; | ||
printf "%b on %b%s%s" "${white}" "${blue}" "${branchName}" "${git_status}" | ||
else | ||
return | ||
fi | ||
} | ||
|
||
echo -e "${1}${branchName}${2}${s}"; | ||
prompt_pyenv() { | ||
if [ -n "${VIRTUAL_ENV_PROMPT:-}" ] && [ -n "${_OLD_VIRTUAL_PS1:-}" ]; then | ||
PS1="${_OLD_VIRTUAL_PS1:-}" | ||
export PS1 | ||
printf "\n%bVENV: %s\n" "${steel_blue}" "${VIRTUAL_ENV_PROMPT}" | ||
else | ||
return; | ||
fi; | ||
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; | ||
# Using tput for colors and formatting. | ||
tput sgr0 # reset colors | ||
bold=$(tput bold) | ||
reset=$(tput sgr0) | ||
blue=$(tput setaf 153) | ||
steel_blue=$(tput setaf 67) | ||
green=$(tput setaf 71) | ||
orange=$(tput setaf 166) | ||
red=$(tput setaf 167) | ||
white=$(tput setaf 15) | ||
yellow=$(tput setaf 228) | ||
|
||
# Highlight the user name when logged in as root. | ||
if [[ "${USER}" == "root" ]]; then | ||
userStyle="${red}"; | ||
userStyle="${red}" | ||
else | ||
userStyle="${orange}"; | ||
fi; | ||
userStyle="${orange}" | ||
fi | ||
|
||
# Highlight the hostname when connected via SSH. | ||
if [[ "${SSH_TTY}" ]]; then | ||
hostStyle="${bold}${red}"; | ||
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; | ||
hostStyle="${yellow}" | ||
fi | ||
|
||
PS1="\$(prompt_pyenv)" # virtual environment | ||
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)" # Git repository details | ||
PS1+="\n" | ||
PS1+="\[${white}\]\$ \[${reset}\]" # `$` (and reset color) | ||
export PS1 | ||
|
||
PS2="\[${yellow}\]→ \[${reset}\]" | ||
export PS2 |
Empty file.
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Define the prompt_git function for git repository status | ||
prompt_git() { | ||
local git_status='' | ||
local branchName='' | ||
|
||
# Check if the current directory is in a Git repository. | ||
if git rev-parse --is-inside-work-tree &>/dev/null; then | ||
# Get the status summary. | ||
local gitSummary=$(git status --porcelain) | ||
|
||
# Check for uncommitted changes in the index, unstaged changes, untracked files, and stashed files. | ||
[[ -n $(echo "$gitSummary" | grep '^M') ]] && git_status+='+' | ||
[[ -n $(echo "$gitSummary" | grep '^ M') ]] && git_status+='!' | ||
[[ -n $(echo "$gitSummary" | grep '^\?\?') ]] && git_status+='?' | ||
[[ $(git rev-parse --verify refs/stash &>/dev/null; echo "${?}") == '0' ]] && git_status+='$' | ||
|
||
# Get the short symbolic ref or the short SHA for the latest commit. | ||
branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || git rev-parse --short HEAD 2> /dev/null || echo '(unknown)')" | ||
|
||
[ -n "${git_status}" ] && git_status=" [${git_status}]" | ||
|
||
printf "%b on %b%s%s" "${white}" "${blue}" "${branchName}" "${git_status}" | ||
|
||
else | ||
return | ||
fi | ||
} | ||
|
||
prompt_pyenv() { | ||
if [ -n "${VIRTUAL_ENV_PROMPT:-}" ] && [ -n "${_OLD_VIRTUAL_PS1:-}" ]; then | ||
PS1="${_OLD_VIRTUAL_PS1:-}" | ||
export PS1 | ||
printf "\n%bVENV: %s\n" "${steel_blue}" "${VIRTUAL_ENV_PROMPT}" | ||
else | ||
return | ||
fi | ||
} | ||
|
||
# Initialize color variables using tput. This should work similarly in Zsh. | ||
autoload -Uz colors && colors | ||
tput sgr0; # reset colors | ||
bold=$(tput bold) | ||
reset=$(tput sgr0) | ||
blue=$(tput setaf 153) | ||
steel_blue=$(tput setaf 67) | ||
green=$(tput setaf 71) | ||
orange=$(tput setaf 166) | ||
red=$(tput setaf 167) | ||
white=$(tput setaf 15) | ||
yellow=$(tput setaf 228) | ||
|
||
# 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 | ||
|
||
setopt PROMPT_SUBST | ||
|
||
# Properly using variables and command substitution in Zsh PROMPT | ||
PS1="\$(prompt_pyenv)" | ||
PS1+="%{${bold}%}"$'\n' | ||
PS1+="%{${userStyle}%}%n" | ||
PS1+="%{${white}%} at " | ||
PS1+="%{${hostStyle}%}%m" | ||
PS1+="%{${white}%} in " | ||
PS1+="%{${green}%}%c" | ||
PS1+="\$(prompt_git)" | ||
PS1+=$'\n' | ||
PS1+="%{${white}%}\$ %{${reset}%}" | ||
export PS1 | ||
|
||
PS2="%{${yellow}%}→ %{${reset}%}" | ||
export PS2 |
Empty file.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
#!/bin/zsh | ||
#!/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 [ "$#" -eq 0 ]; then | ||
homedir=$HOME | ||
homedir=$HOME | ||
else | ||
homedir=$1 | ||
homedir=$1 | ||
fi | ||
|
||
# dotfiles directory | ||
dotfiledir=${homedir}/dotfiles | ||
dotfiledir="${homedir}/dotfiles" | ||
|
||
# list of files/folders to symlink in ${homedir} | ||
files="bash_profile bashrc bash_prompt aliases private zshrc zprofile zprompt" | ||
files=(bash_profile bashrc bash_prompt aliases private zshrc zprofile zprompt) | ||
|
||
# change to the dotfiles directory | ||
echo "Changing to the ${dotfiledir} directory" | ||
cd ${dotfiledir} | ||
cd "${dotfiledir}" || exit | ||
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} | ||
for file in "${files[@]}"; do | ||
echo "Creating symlink to $file in home directory." | ||
ln -sf "${dotfiledir}/.${file}" "${homedir}/.${file}" | ||
done | ||
|
||
# Download Git Auto-Completion | ||
curl "https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash" > ${homedir}/.git-completion.bash | ||
curl "https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash" > "${homedir}/.git-completion.bash" | ||
|
||
# Run the Homebrew Script | ||
./brew.sh | ||
# ./brew.sh | ||
|
||
# Run the Sublime Script | ||
./sublime.sh | ||
# ./sublime.sh |
This file contains 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