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.
Major 2024 Update. Switching to zsh and VS Code. Added a lot of error…
… checks and took out a lot of hard-coded references so that these are more portable.
- Loading branch information
1 parent
f7a1634
commit 46a469e
Showing
26 changed files
with
864 additions
and
364 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,16 +1,8 @@ | ||
# Simplified dotfile for video recordings | ||
|
||
# Load dotfiles: | ||
for file in ~/.{bash_prompt,aliases,private}; do | ||
[ -r "$file" ] && [ -f "$file" ] && source "$file"; | ||
done; | ||
unset file; | ||
|
||
#Git auto-complete | ||
if [ -f ~/.git-completion.bash ]; then | ||
source ~/.git-completion.bash | ||
# Load .bashrc if available | ||
if [ -f ~/.bashrc ]; then | ||
source ~/.bashrc | ||
fi | ||
|
||
# Setting PATH for Python 3.7 | ||
# PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}" | ||
# export PATH | ||
# export PATH |
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,4 +1,8 @@ | ||
# If not running interactively, don't do anything | ||
[[ $- == *i* ]] || return | ||
# If not running interactively, exit script | ||
[[ $- != *i* ]] && return | ||
|
||
[ -n "$PS1" ] && source ~/.bash_profile; | ||
# Load dotfiles: | ||
for file in ~/.{bash_prompt,aliases,private}; do | ||
[ -r "$file" ] && [ -f "$file" ] && source "$file"; | ||
done; | ||
unset 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,64 @@ | ||
# 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 | ||
} | ||
|
||
export VIRTUAL_ENV_DISABLE_PROMPT=1 | ||
prompt_venv() { | ||
if [[ -n "$VIRTUAL_ENV" ]]; then | ||
# Extract the last directory name in the $VIRTUAL_ENV path | ||
venv_name=$(basename "$VIRTUAL_ENV") | ||
printf "\n%b(%s)\n" "${steel_blue}" "${venv_name}" | ||
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}" | ||
else | ||
userStyle="${orange}" | ||
fi | ||
|
||
# Highlight the hostname when connected via SSH. | ||
if [[ "${SSH_TTY}" ]]; then | ||
hostStyle="${bold}${red}" | ||
else | ||
hostStyle="${yellow}" | ||
fi |
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,17 @@ | ||
|
||
source "${HOME}/dotfiles/.shared_prompt" | ||
|
||
PS1="\$(prompt_venv)" # virtual environment | ||
PS1+="%{${bold}%}"$'\n' # newline | ||
PS1+="%{${userStyle}%}%n" # username | ||
PS1+="%{${white}%} at " | ||
PS1+="%{${hostStyle}%}%m" # host | ||
PS1+="%{${white}%} in " | ||
PS1+="%{${green}%}%c" # working directory | ||
PS1+="\$(prompt_git)" # Git repository details | ||
PS1+=$'\n' | ||
PS1+="%{${white}%}\$ %{${reset}%}" # `$` (and reset color) | ||
export PS1 | ||
|
||
PS2="%{${yellow}%}→ %{${reset}%}" | ||
export PS2 |
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,82 +1,9 @@ | ||
# 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 | ||
# Load dotfiles: | ||
for file in ~/.{zprompt,aliases,private}; do | ||
[ -r "$file" ] && [ -f "$file" ] && source "$file"; | ||
done; | ||
unset file; |
Oops, something went wrong.