Skip to content

Instantly share code, notes, and snippets.

@sajmoni
Last active April 23, 2019 07:50
Show Gist options
  • Select an option

  • Save sajmoni/ed283fd0348cacb9ff5bceccd28bf2fb to your computer and use it in GitHub Desktop.

Select an option

Save sajmoni/ed283fd0348cacb9ff5bceccd28bf2fb to your computer and use it in GitHub Desktop.
alias ll='ls -laG'
alias gst="git status"
alias gp="git push"
alias gpr="git pull --rebase"
alias gsh="git stash"
alias gshp="git stash pop"
alias gco="git checkout"
alias gsync="gsh && gpr && gshp"
qwe-checkout() {
MAIN_BRANCH=`git remote show origin | grep "HEAD branch" | sed 's/.*: //'`
read -p "Enter branch name: " name
git fetch && git rebase "origin/$MAIN_BRANCH" "$MAIN_BRANCH"
git checkout -b "$name" "$MAIN_BRANCH"
}
qwe-pullmain() {
CURRENT_BRANCH=`git branch | grep \* | cut -d ' ' -f2`
MAIN_BRANCH=`git remote show origin | grep "HEAD branch" | sed 's/.*: //'`
git fetch && git rebase "origin/$MAIN_BRANCH" "$MAIN_BRANCH"
git checkout "$CURRENT_BRANCH"
}
alias gra="git commit --amend --reset-author"
alias grc="git rebase --continue"
alias gri="git rebase -i"
alias gpf="git push --force-with-lease"
alias unstage="git reset HEAD"
alias undo-commit="git reset --soft HEAD^"
alias branch-update="git fetch && git rebase origin/master"
# Prune and remove all local branches that have been removed on the remote
alias qwe-prune="git fetch && git remote update origin --prune && git branch -vv | grep ': gone]' | cut -f 3 -d ' ' | xargs git branch -D"
#TODO: Add as a post merge hook
# If package.json changed, run yarn install
# git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD | grep yarn.lock && yarn install
alias yui="yarn upgrade-interactive --latest"
# yarn and npm script suggestions
alias yar=yarn-run
alias npr=npm-run
export GOPATH=$HOME/code/go
export PATH="$(yarn global bin):$PATH"
export PATH=/usr/lib/node_modules:$PATH
# Add devtools to PATH
export PATH=$PATH:~/code/devtools/script
# Set the title of each tab in iterm to the current folder name
export PROMPT_COMMAND='echo -ne "\033]0;${PWD##*/}\007"'
export AWS_DEFAULT_PROFILE=profile
# Change "theFuck"s "fuck" command to "magic"
eval $(thefuck --alias)
alias magic="fuck"
# Log the internal IP
function ip {
IP="$(ifconfig | grep broadcast | sed -E "s/inet (([0-9]{1,3}\.){3}[0-9]{1,3}).*/\1/")"
echo $IP
}
# Switch AWS profile
function awsp {
prev=$AWS_PROFILE
profiles=($(sed -n 's:.*profile\s*\(.*\)]:\1:p' ~/.aws/config))
echo "Select Profile:"
select opt in "${profiles[@]}"
do
export AWS_PROFILE=${profiles[$REPLY]}
echo "Switched AWS_PROFILE from '$prev' to '${profiles[$REPLY]}'"
break
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment