Last active
December 12, 2023 22:56
-
-
Save albannurkollari/7ba1c0cea0aa3ee35dffe949880be252 to your computer and use it in GitHub Desktop.
My go to .bashrc
This file contains hidden or 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
env=~/.ssh/agent.env | |
bind 'set enable-bracketed-paste off' | |
agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; } | |
agent_start () { | |
(umask 077; ssh-agent >| "$env") | |
. "$env" >| /dev/null ; | |
} | |
agent_load_env | |
# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running | |
agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?) | |
if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then | |
agent_start | |
ssh-add | |
elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then | |
ssh-add | |
fi | |
unset env | |
GIT_COMMITTER_NAME="Alban Nurkollari" | |
GIT_COMMITTER_EMAIL_DEF="[email protected]" | |
GIT_COMMITTER_EMAIL="" | |
alias cbranch="git branch --show-current | clip" | |
alias getJira="git log -n 1 | grep JIRA | sed -e 's/^[ \t]*//' | clip" | |
alias cleannode="rm -rf node_modules/ && npm cache clean" | |
alias npxcu="npx npm-check-updates -u" | |
alias projects="cd '/e/Documents/My Programming/Web/Projects'" | |
alias getGPGKey="gpg --list-secret-keys --keyid-format LONG" | |
alias genGPGKey="gpg --full-generate-key" | |
addGitUserWithGPGKey() { | |
email="${[email protected]}" | |
name="${2-Alban Nurkollari}" | |
signingkey="${3-AB3AC4A1CB5D45CD}" | |
git config user.email $email && \ | |
git config user.name $name && \ | |
git config user.signingkey $signingkey && \ | |
git config commit.gpgsign true | |
} | |
gitRewrite() { | |
CORRECT_NAME="$1" | |
CORRECT_EMAIL="$2" | |
FROM_SHA_OR_BRANCH="${3:-main}" | |
TO_SHA_OR_BRANCH="${4:-HEAD}" | |
REF="$FROM_SHA_OR_BRANCH..$TO_SHA_OR_BRANCH" | |
WRONG_EMAIL=$GIT_COMMITTER_EMAIL | |
echo $FROM_SHA_OR_BRANCH | |
echo $TO_SHA_OR_BRANCH | |
echo $CORRECT_NAME | |
echo $CORRECT_EMAIL | |
echo $GIT_COMMITTER_NAME | |
echo $WRONG_EMAIL | |
FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch --env-filter ' | |
if [ "$GIT_COMMITTER_EMAIL" = "$WRONG_EMAIL" ] | |
then | |
export GIT_COMMITTER_NAME="$CORRECT_NAME" | |
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL" | |
fi | |
if [ "$GIT_AUTHOR_EMAIL" = "$WRONG_EMAIL" ] | |
then | |
export GIT_AUTHOR_NAME="$CORRECT_NAME" | |
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL" | |
fi | |
' -f | |
} | |
generateNewSSH () { | |
EMAIL=$1; | |
FILE=$2 | |
TYPE="${3:-rsa}" | |
BYTES="${4:-4096}" | |
ssh-keygen -t $TYPE -b $BYTES -C $EMAIL -f $4 | |
} | |
cpPath() { | |
echo $1 | clip | |
} | |
exportAndCopyGPGKey() { | |
gpg --armor --export $1 | clip | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment