Skip to content

Instantly share code, notes, and snippets.

@pedro-mass
Last active February 1, 2024 17:02
Show Gist options
  • Save pedro-mass/276b655ed2d60b2e11db0367d35c4930 to your computer and use it in GitHub Desktop.
Save pedro-mass/276b655ed2d60b2e11db0367d35c4930 to your computer and use it in GitHub Desktop.
dev profile file
echo "loading profile..."
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
# set PATH so it includes homebrew if it exists
if [ -d "/home/linuxbrew/.linuxbrew/bin" ] ; then
PATH="/home/linuxbrew/.linuxbrew/bin:$PATH"
fi
# set PATH so it includes volta
export VOLTA_HOME=$HOME/.volta
if [ -d "$VOLTA_HOME/bin" ] ; then
PATH="$VOLTA_HOME/bin:$PATH"
fi
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
# wsl tweaks
export BROWSER=wslview
# -------
# pedro utils
# -------
alias shell-reset="source ~/.zshrc"
alias profile-edit="code ~/.profile"
# brewfile
export PEDRO_FILES=~/.pedro
brew-view() {
code $PEDRO_FILES/Brewfile
}
brew-backup() {
rm -f Brewfile
brew bundle dump
mv -f Brewfile $PEDRO_FILES
}
brew-restore() {
cp -f $PEDRO_FILES/Brewfile Brewfile
brew bundle
rm Brewfile
}
# -----
# dev
# -----
# git
alias git-cheatsheet="cat ~/.oh-my-zsh/plugins/git/git.plugin.zsh"
alias gu="git pull --rebase --prune"
alias gtl="git tag -l"
alias gta="gtl"
alias gbdf="git branch -D"
alias git-undo="git reset HEAD~1 --mixed"
is_in_git_repo() {
git rev-parse HEAD > /dev/null 2>&1
}
gcoo() {
is_in_git_repo || return
git branch -a --color=always | grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn} -v '/HEAD\s' | sort | fzf --ansi --multi --tac --preview-window right:70% --preview 'git log --oneline --graph --date=short --color=always --pretty="format:%C(auto)%cd %h%d %s" $(sed s/^..// <<< {} | cut -d" " -f1) | head -'$LINES | sed 's/^..//' | cut -d' ' -f1 | sed 's#^remotes/origin/##' | xargs git checkout
}
alias gpr="git pull-request"
alias git-branch-clear="git branch | grep -v -E '(\\*|master|main|dev|test|develop)' | xargs -n1 git branch -D"
alias gbc="git-branch-clear"
alias git-cleanup="git branch --merged | egrep -v '(^\\*|master|main|dev)' | xargs git branch -d"
# alias git-delete-branches="git branch | grep -v "^*" | xargs git branch -D"
alias git-merge-develop="git merge origin/develop"
alias gmd="git-merge-develop"
fix-upstream() {
# get current branch
local branch=$(git rev-parse --abbrev-ref HEAD)
# set git upstream
git branch --set-upstream-to=origin/$branch $branch
}
###########
# node
node-modules-delete() {
echo "deleting ./node_modules ..."
rm -rf ./node_modules
echo "✅ deleted ./node_modules"
}
# @antfu/ni - https://github.com/antfu/ni
ni-cheat() {
echo "https://github.com/antfu/ni#readme"
echo "ni - install"
echo "nr - run"
echo "nlx - download & execute"
echo "nu - upgrade"
echo "nun - uninstall"
echo "na - agent alias"
echo "na - agent alias"
}
ni-reset() {
node-modules-delete
ni
echo "✅ Installed deps"
}
# alias n="npm run"
# alias ni="npm install"
# alias nt="npm run test"
# npm-reset() {
# node-modules-delete
# npm install
# echo "✅ Installed deps"
# # echo "resetting jest cache"
# # n test --clearCache
# }
# alias nr="npm-reset"
# pnpm
# alias p="pnpm run"
# alias pi="pnpm install"
# alias px="pnpm exec"
# pnpm-reset() {
# node-modules-delete
# pnpm install
# echo "✅ Installed deps"
# # echo "resetting jest cache"
# # n test --clearCache
# }
# alias pr="pnpm-reset"
# vs code
alias cr="code . -r"
alias ca="code . -a"
alias c="code"
port-lookup() {
PORT=$1
shift 1
lsof -i:$PORT $@
}
port-kill() {
PORT="${1:-5000}"
port-lookup $PORT
PID=$(port-lookup $PORT -t)
if [ -z "$PID" ]
then
echo "Nothing running on port $PORT"
else
kill $PID
echo Killed process on port $PORT
fi
}
alias code-client="code ~/dev/work/client-rater.code-workspace"
alias cr-client="code-client -r"
alias code-agent="code ~/dev/work/agent-rater.code-workspace"
alias cr-agent="code-agent -r"
alias code-apps="code ~/dev/work/goosehead-apps"
alias cr-apps="code-apps -r"
alias git-reset-develop="gco develop && git reset --hard origin/develop && gu"
alias grd="git-reset-develop"
alias git-refresh-main="gco main && git reset --hard origin/main && gu"
alias grm="git-refresh-main"
source ~/.profile-improvements
echo "loaded profile."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment