diff --git a/reference/bash_profile.md b/reference/bash_profile.md index 60008e3..9a99f12 100644 --- a/reference/bash_profile.md +++ b/reference/bash_profile.md @@ -8,17 +8,32 @@ Useful aliases and alike from my `.zshrc` ``` export EDITOR="nano" - export HISTSIZE=1000000 export HISTFILESIZE=1000000 -## Git +# PATH -alias master='git checkout master' +# Homebrew +export PATH=/opt/homebrew/bin:$PATH +# npm global packages +export PATH="$HOME/.npm-global/bin:$PATH" +# Signing scripts +export PATH="~/src/bin/sign:$PATH" + + +# Git +alias giti='code .git/info/exclude' +alias gitig='code ~/.gitignore' + +autoload -Uz compinit && compinit + +alias main='git checkout main || git checkout master' +alias master='main' alias pull='git pull' alias push='git push origin HEAD' -alias gitclean='git branch | grep -v "^*"" | xargs git branch -d' +alias fush='git push origin HEAD -f' +alias amend='git commit --amend --no-edit' parse_git_branch() { git_status="$(git status 2> /dev/null)" @@ -28,7 +43,7 @@ parse_git_branch() { fi if [[ ${git_status} =~ ${pattern} ]]; then branch=${match[1]} - branch_cut=${branch:0:35} + branch_cut=${branch:0:60} if (( ${#branch} > ${#branch_cut} )); then echo "(${branch_cut}…${state})" else @@ -37,8 +52,23 @@ parse_git_branch() { fi } -# Ruby +setopt PROMPT_SUBST +PROMPT='%{%F{blue}%}%9c%{%F{none}%}$(parse_git_branch)$ ' +RPROMPT='%*' + + +## Mac shortcuts +alias zshrc='code --new-window --add ~/common.code-workspace ~/.zshrc' +alias profile='code --new-window --add ~/common.code-workspace ~/.zshrc' +alias sp='source ~/.zshrc' +alias hist='code --new-window --add ~/common.code-workspace ~/.zsh_history' + +## App shortcuts +alias vlc='/Applications/VLC.app/Contents/MacOS/VLC' + + +# Ruby alias brake='bundle exec rake' alias brails='bundle exec rails' @@ -46,8 +76,36 @@ export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)" -# signing scripts -export PATH="$HOME/bin:$PATH" +# Python +eval "$(pyenv init --path)" +export PATH="/opt/homebrew/opt/libpq/bin:$PATH" + + +# Functions + +stopwatch() { + start_time=$(date +%s) + "$@" + end_time=$(date +%s) + execution_time=$((end_time-start_time)) + echo "Execution time: $execution_time seconds" +} + +generate_alias() { + cd_alias_name="cd${1}" + code_alias_name="co${1}" + pull_alias_name="p${1}" + dir_path="$2" + + alias "$cd_alias_name"="cd $dir_path" + alias "$code_alias_name"="code $dir_path" + alias "$pull_alias_name"="(cd $dir_path && git pull)" +} + +# Example usage: +generate_alias g ~/src/gregology.github.io +generate_alias e ~/src/esphome + ``` My old `.bash_profile` from before MacOS moved from bash to zsh by default.