Created
June 13, 2023 03:48
-
-
Save connoro7/d958e7b9f266c411c9d89523b23648de to your computer and use it in GitHub Desktop.
aliases
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
## | |
## export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$\C " | |
## export CLICOLOR=1 | |
## export LSCOLORS=ExFxBxDxCxegedabagacad | |
## source-all: recursively source all files in a path (or the path itself if applicable) | |
shopt -s nullglob | |
shopt -s dotglob | |
source-all () { | |
# if its a folder source all files in it | |
if [ -d "$1" ] ; then | |
for filename in "$1"/* ; do | |
source-all "$filename" | |
done | |
# if its a file, source it | |
elif [ -f "$1" ] ; then | |
if [ "$VERBOSE_REPROFILE" = true ] ; then | |
echo "sourcing $1" | |
fi | |
source "$1" | |
fi | |
} | |
# Uncomment to enable login shell debugging session | |
# set -x | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
#~~ Bash Dotfile Load Order ~~~ | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# source ~/.bashrc && echo -e "sourcing $HOME/.bashrc" ; | |
# source ~/.bash_ps1 && echo -e "sourcing $HOME/.bash_ps1" ; | |
source-all ~/.bashrc | |
source-all ~/.bash_ps1 | |
source-all ~/.bash_env | |
source-all ~/.bash_aliases | |
source-all ~/.bash_private # must load before shell_scripts | |
source-all ~/.secrets # must load before shell_scripts | |
# source-all ~/.inputrc | |
source-all ~/.dotfiles | |
# source-all ~/.config/fish | |
## Rust | |
source-all ~/.cargo/env | |
# . "$HOME/.cargo/env" |
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
# Customize BASH PS1 prompt to show current GIT repository and branch. | |
# by Mike Stewart - http://MediaDoneRight.com | |
# SETUP CONSTANTS | |
# Bunch-o-predefined colors. Makes reading code easier than escape sequences. | |
# I don't remember where I found this. o_O | |
# Reset | |
Color_Off=$'\033[0m' # Text Reset | |
# Regular Colors | |
export Black=$'\033[0;30m' # Black | |
export Red=$'\033[0;31m' # Red | |
export Green=$'\033[0;32m' # Green | |
export Yellow=$'\033[0;33m' # Yellow | |
export Blue=$'\033[0;34m' # Blue | |
export Purple=$'\033[0;35m' # Purple | |
export Cyan=$'\033[0;36m' # Cyan | |
export White=$'\033[0;37m' # White | |
# Bold | |
export BBlack=$'\033[1;30m' # Black | |
export BRed=$'\033[1;31m' # Red | |
export BGreen=$'\033[1;32m' # Green | |
export BYellow=$'\033[1;33m' # Yellow | |
export BBlue=$'\033[1;34m' # Blue | |
export BPurple=$'\033[1;35m' # Purple | |
export BCyan=$'\033[1;36m' # Cyan | |
export BWhite=$'\033[1;37m' # White | |
# Underline | |
export UBlack=$'\033[4;30m' # Black | |
export URed=$'\033[4;31m' # Red | |
export UGreen=$'\033[4;32m' # Green | |
export UYellow=$'\033[4;33m' # Yellow | |
export UBlue=$'\033[4;34m' # Blue | |
export UPurple=$'\033[4;35m' # Purple | |
export UCyan=$'\033[4;36m' # Cyan | |
export UWhite=$'\033[4;37m' # White | |
# Background | |
export On_Black=$'\033[0;37;40m' # Black | |
export On_Red=$'\033[41m' # Red | |
export On_Green=$'\033[42m' # Green | |
export On_Yellow=$'\033[43m' # Yellow | |
export On_Blue=$'\033[44m' # Blue | |
export On_Purple=$'\033[45m' # Purple | |
export On_Cyan=$'\033[46m' # Cyan | |
export On_White=$'\033[0;30;47m' # White | |
# High Intensty | |
export IBlack=$'\033[0;90m' # Black | |
export IRed=$'\033[0;91m' # Red | |
export IGreen=$'\033[0;92m' # Green | |
export IYellow=$'\033[0;93m' # Yellow | |
export IBlue=$'\033[0;94m' # Blue | |
export IPurple=$'\033[0;95m' # Purple | |
export ICyan=$'\033[0;96m' # Cyan | |
export IWhite=$'\033[0;97m' # White | |
# Bold High Intensty | |
export BIBlack=$'\033[1;90m' # Black | |
export BIRed=$'\033[1;91m' # Red | |
export BIGreen=$'\033[1;92m' # Green | |
export BIYellow=$'\033[1;93m' # Yellow | |
export BIBlue=$'\033[1;94m' # Blue | |
export BIPurple=$'\033[1;95m' # Purple | |
export BICyan=$'\033[1;96m' # Cyan | |
export BIWhite=$'\033[1;97m' # White | |
# High Intensty backgrounds | |
export On_IBlack=$'\033[0;37;100m' # Black | |
export On_IRed=$'\033[0;101m' # Red | |
export On_IGreen=$'\033[0;102m' # Green | |
export On_IYellow=$'\033[0;103m' # Yellow | |
export On_IBlue=$'\033[0;104m' # Blue | |
export On_IPurple=$'\033[10;95m' # Purple | |
export On_ICyan=$'\033[0;106m' # Cyan | |
export On_IWhite=$'\033[0;30;107m' # White | |
# Blink | |
export Blink=$'\033[5m' # Blinking text | |
export ResetBlink=$'\033[25m' # Removes blinking text | |
# Statuses | |
export Info=$'\033[0;44;97m' # Blue background | |
export Warning=$'\033[0;101;97m' # Red background | |
export Success=$'\033[0;102;30m' # Green background | |
export Highlight=$'\033[0;43;30m' # Yellow background | |
# Various variables you might want for your PS1 prompt instead | |
Time12h="\T" | |
Time12a="\@" | |
PathShort="\w" | |
PathFull="\W" | |
NewLine="\n" | |
Jobs="\j" | |
Prompt="λ" # $ λ Σ Ξ Π ⛬ ☭ ⛧ ⛏ | |
# Locale, `locale -a` to list available locales | |
# Make sure `locale` v | |
export LC_ALL="en_US.UTF-8" | |
command_exists () { | |
type "$1" > /dev/null 2>&1 ; | |
} | |
if command_exists scutil ; then | |
# OS X | |
COMPUTER_NAME="$(scutil --get ComputerName)" | |
else | |
# Standard | |
COMPUTER_NAME="\h" | |
fi | |
source ~/.git-completion.bash | |
source ~/.git-prompt.sh | |
# This PS1 snippet was adopted from code for MAC/BSD from: http://allancraig.net/index.php?option=com_content&view=article&id=108:ps1-export-command-for-git&catid=45:general&Itemid=96 | |
# It was tweaked to work on UBUNTU 11.04 & 11.10 and be mo' better | |
#export PS1='\n'$Cyan$COMPUTER_NAME$IBlack'\n'$Time12h$Color_Off'$(git branch &>/dev/null;\ | |
export PS1='\n'$IBlack$Time12h' '$Cyan$COMPUTER_NAME$Color_Off'$(git branch &>/dev/null;\ | |
if [ $? -eq 0 ]; then \ | |
echo "$(echo `git status` | grep "nothing to commit" > /dev/null 2>&1; \ | |
if [ "$?" -eq "0" ]; then \ | |
# @4 - Clean repository - nothing to commit | |
echo "'$Green'"$(__git_ps1 " (%s)"); \ | |
else \ | |
# @5 - Changes to working tree | |
echo "'$IRed'"$(__git_ps1 " {%s}"); \ | |
fi) '$Blue$PathFull$Color_Off'\n$Prompt "; \ | |
else \ | |
# @2 - Prompt when not in GIT repo | |
echo " '$Yellow$PathShort$Color_Off'\n$Prompt "; \ | |
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
## Git | |
## Functions | |
## Oh Shit, Git!?! | |
## Pulled from https://ohshitgit.com/ | |
gitTimeMachine(){ | |
echo -e "${Yellow}\t $ git reflog${Color_Off}" | |
echo "# you will see a list of every thing you've done in git, across all branches! each one has an index \`HEAD@{INDEX}\` find the one before you broke everything" | |
echo -e "${Yellow}\t $ git reset HEAD@{INDEX}${Color_Off}" | |
echo "# magic time machine - You can use this to get back stuff you accidentally deleted, or just to remove some stuff you tried that broke the repo, or to recover after a bad merge, or just to go back to a time when things actually worked." | |
} | |
gitAmmendCommit(){ | |
echo "# make your changes, then:" | |
echo -e "${Yellow}\t $ git add . # or add individual files${Color_Off}" | |
echo -e "${Yellow}\t $ git commit --amend --no-edit${Color_Off}" | |
echo "# now your last commit contains that change!" | |
echo "# WARNING: never amend public commits" | |
echo "# This usually happens to me if I commit, then run tests/linters... and FML, I didn't put a space after an equals sign." | |
echo "# You could also make the change as a new commit and then do \`rebase -i\` in order to squash them both together, but this is about a million times faster." | |
} | |
gitFixCommitMessage(){ | |
echo -e "${Yellow}\t $ git commit --amend${Color_Off}" | |
echo "# follow prompts to change the commit message" | |
} | |
gitFixMainCommit(){ | |
echo "# create a new branch from the current state of main" | |
echo -e "${Yellow}\t $ git branch some-new-branch-name${Color_Off}" | |
echo "# remove the last commit from the main branch" | |
echo -e "${Yellow}\t $ git reset HEAD~ --hard${Color_Off}" | |
echo -e "${Yellow}\t $ git checkout some-new-branch-name${Color_Off}" | |
echo "# your commit lives in this branch now :)" | |
echo "# This doesn't work if you've already pushed the commit to a public/shared branch, and if you tried other things first, you might need to git reset HEAD@{number-of-commits-back} instead of HEAD~. Infinite sadness" | |
} | |
gitFixCommitToWrongBranch(){ | |
echo "# undo the last commit, but leave the changes available" | |
echo -e "${Yellow}\t $ git reset HEAD~ --soft${Color_Off}" | |
echo -e "${Yellow}\t $ git stash${Color_Off}" | |
echo "" | |
echo "# move to the correct branch" | |
echo -e "${Yellow}\t $ git checkout name-of-the-correct-branch${Color_Off}" | |
echo -e "${Yellow}\t $ git stash pop${Color_Off}" | |
echo -e "${Yellow}\t $ git add . # or add individual files${Color_Off}" | |
echo -e "${Yellow}\t $ git commit -m \"your message here\";${Color_Off}" | |
echo "# now your changes are on the correct branch" | |
echo "" | |
echo "# OR, USING CHERRY-PICK:" | |
echo -e "${Yellow}\t $ git checkout name-of-the-correct-branch${Color_Off}" | |
echo "# grab the last commit to main" | |
echo -e "${Yellow}\t $ git cherry-pick main${Color_Off}" | |
echo "# delete it from main" | |
echo -e "${Yellow}\t $ git checkout main${Color_Off}" | |
echo -e "${Yellow}\t $ git reset HEAD~ --hard${Color_Off}" | |
} | |
gitUndoOldCommit(){ | |
echo "# find the commit you need to undo" | |
echo -e "${Yellow}\t $ git log${Color_Off}" | |
echo "# use the arrow keys to scroll up and down in history" | |
echo "" | |
echo "# once you've found your commit, save the hash" | |
echo -e "${Yellow}\t $ git revert [saved hash]${Color_Off}" | |
echo "# git will create a new commit that undoes that commit" | |
echo "# follow prompts to edit the commit message, or just save and commit" | |
} | |
gitUndoFileChanges(){ | |
echo "# find a hash for a commit before the file was changed" | |
echo -e "${Yellow}\t $ git log${Color_Off}" | |
echo "# use the arrow keys to scroll up and down in history" | |
echo "# once you've found your commit, save the hash" | |
echo "" | |
echo -e "${Yellow}\t $ git checkout [saved hash] -- path/to/file${Color_Off}" | |
echo "# the old version of the file will be in your index" | |
echo "" | |
echo -e "${Yellow}\t $ git commit -m \"Wow, you don't have to copy-paste to undo\"${Color_Off}" | |
} | |
gitNuke(){ | |
read -p "Enter the remote name ${Yellow}[origin]${Color_Off}: " REMOTE | |
REMOTE=${REMOTE:-origin} | |
echo "# get the lastest state of $REMOTE" | |
echo -e "${Yellow}\t $ git fetch $REMOTE${Color_Off}" | |
echo -e "${Yellow}\t $ git checkout main${Color_Off}" | |
echo "" | |
echo "# delete untracked files and directories" | |
echo -e "${Yellow}\t $ git reset --hard $REMOTE/main${Color_Off}" | |
echo "" | |
echo "# repeat checkout/reset/clean for each borked branch" | |
echo -e "${Yellow}\t $ git clean -d --force${Color_Off}" | |
} | |
ohshitgit(){ | |
echo -e " | |
${Yellow}gitTimeMachine${Color_Off} - Go back in time! Undo anything! | |
${Yellow}gitAmmendCommit${Color_Off} - Ammend new changes to the most recent commit | |
${Yellow}gitFixCommitMessage${Color_Off} - Ammend a commit message | |
${Yellow}gitFixMainCommit${Color_Off} - Undo a commit to Main | |
${Yellow}gitFixCommitToWrongBranch${Color_Off} - Undo commit and move changes to new branch | |
${Yellow}gitUndoOldCommit${Color_Off} - Find an old commit and revert changes made by that commit | |
${Yellow}gitUndoFileChanges${Color_Off} - Pull an older version of a file into index and commit that to HEAD | |
${Yellow}gitNuke${Color_Off} - Full reset from remote" | |
} | |
gcht() { | |
# Fetches the branch at remote, then checks it out and sets it as the upstream branch. | |
REMOTE="$1" ; BRANCH="$2" ; git fetch $REMOTE $BRANCH && git checkout -t "$REMOTE/$BRANCH"; } | |
gitredate() { | |
local HELP=' | |
\tAmends date of most recent commit, using format:\n | |
\tSat May 19 01:01:01 2019 -0700\n | |
\t-0800 for PST, -0700 for PDT\n | |
\tPDT observed 2nd Sunday in March thru 1st Sunday in November\n' | |
case "$1" in | |
-h) echo -e $HELP;; | |
-r) GIT_COMMITTER_DATE="$2" git commit --amend --date="$2" --no-edit ;; | |
*) echo -e "Please provide an action flag" | |
esac | |
} | |
git-view-changes() { FROM="$1" ; TO="$2" ; git checkout $TO && git reset $FROM --soft ; } | |
code-review() { | |
BRANCH="$1" ; | |
git fetch origin main && git checkout code-review && git reset $BRANCH --hard && git reset origin/main --soft ; } | |
ginit() { | |
# Initializes a new git repo at the current working directory | |
echo -e "${IGreen}Initializing git repository...$Color_Off" | |
read -p "Please enter remote URL: " REPO | |
read -p "Enter the remote name ${Yellow}[origin]${Color_Off}: " REMOTE | |
REMOTE=${REMOTE:-origin} | |
git init -b main && git remote add $REMOTE $REPO && git remote --v && git fetch --all --prune -v && git pull $REMOTE main ; } | |
open-repo() { | |
# For HTTPS connectiosn to remote | |
# open $(git config remote.origin.url) | |
# git remote -v | awk '/origin.*push/ {print$2}' | xargs open | |
# For SSH connections to remote | |
remote=$(git remote -v | awk '/origin.*push/ {print$2}' | awk -F "[:]" '/connoro7/ {print$2}' | awk -F "[.]" '/connoro7/ {print$1}') | |
printf "\nClick to open: https://github.com/${remote}\n" | |
# open "https://github.com/${remote}" | |
} | |
## branch management | |
gbmake() { NEW_BRANCH="$1" ; git branch $NEW_BRANCH && git checkout $NEW_BRANCH ; } | |
gbmakenext() { | |
OLD_BRANCH=`git rev-parse --abbrev-ref HEAD` | |
NEW_BRANCH="$1" ; | |
git branch $NEW_BRANCH && git checkout $NEW_BRANCH && git merge $OLD_BRANCH && echo -e "${Green}Merged $OLD_BRANCH into $NEW_BRANCH${Color_Off}" ; gbmerged ; } | |
gbrename() { | |
read -p 'Rename which branch? [this branch]: ' OLD_NAME ; | |
OLD_NAME=${OLD_NAME:-`git rev-parse --abbrev-ref HEAD`} | |
read -p 'Enter new branch name: ' NEW_NAME && | |
git branch --move $OLD_NAME $NEW_NAME && | |
read -p "Enter the remote name ${Yellow}[origin]${Color_Off}: " REMOTE | |
REMOTE=${REMOTE:-origin} | |
git push --set-upstream $REMOTE $NEW_NAME ; | |
git branch -a ; | |
echo -e "${BYellow}Please remove the old branch on remote${Color_Off}" ; | |
echo -e "git push $REMOTE --delete $OLD_NAME" ; | |
} | |
gbmerged() { | |
echo "" | |
echo -e "${BICyan}--Merged branches--${Color_Off}" | |
git branch --merged | |
echo "" | |
echo -e "${BRed}--Unmerged branches--${Color_Off}" | |
git branch --no-merged | |
} | |
## branch cleanup | |
alias gbdl='echo -e "$Red>About to delete a local branch...$Color_Off" && confirm && git branch -d $1' | |
alias gbdlF='echo -e "$Red>About to $Warning FORCE $Red delete a local branch...$Color_Off" && confirm && git branch -D $1' | |
alias gbdr='echo -e "$Red>About to delete remote branch...$Color_Off" && confirm && git push $1 --delete $2' | |
## add | |
alias ga='git add' | |
alias gaa='git add -A && git status && emoji?' | |
alias gap='echo -e "Begin partial git commit prompt?" && confirm && git add -p' | |
## branch | |
alias gb='git branch' | |
alias gba="git branch -a" | |
alias gbuoh='git branch -u origin/$(grph)' | |
alias gbpp='git log -r --oneline --no-merges --simplify-by-decoration --pretty=format:"%n %Cred CommitID %Creset: %h %n %Cred Remote Branch %Creset :%d %n %Cred Commit Message %Creset: %s %n"' | |
## commit | |
alias gc='git commit' | |
alias gca='git commit --amend' # see gitFixCommitMessage() | |
alias gcane='git commit --amend --no-edit' # see gitAmmendCommit() | |
alias gcanenv='gcane --no-verify' | |
alias gcm='git commit -m' | |
alias gcms='git commit -S -m' | |
alias gcmwip='git add -A && git commit -m ":construction: WIP" --no-verify' | |
## diff | |
alias gd='git diff' | |
alias gds='git diff --staged' | |
alias gdi='git diff --ignore-space-at-eol' | |
alias gdhns='git diff HEAD~ HEAD --name-status' | |
## fetch | |
alias gf='git fetch --all --prune -v' | |
alias gft='git fetch --all --prune --tags -v' | |
alias gfom='git fetch origin main:main -v' | |
alias gfox='git fetch origin $1:$1 -v' | |
## merge | |
alias gm="git merge" | |
alias gmnf="git merge --no-ff" | |
alias gma="git merge --abort" | |
alias gmc="git merge --continue" | |
## rebase | |
alias grb="git rebase" | |
## pull | |
alias gpull="git pull" | |
alias gpullr="git pull --rebase" | |
alias gpullom='git pull origin main' | |
alias gpullo\+\+='git pull origin $(grph)' | |
alias gpullomd='gch HEAD --detach && git fetch origin main:main && gch main' | |
alias gpullohr='glp -5 && git pull origin $(grph) --rebase' | |
alias gfpullom="gf && gch main && gpullom" | |
fix-failed-ff-abort() { | |
# Workaround solution for instances where a `git pull` aborts due to failed fast-forwarding | |
read -p "Enter the remote name ${Yellow}[origin]${Color_Off}: " REMOTE | |
REMOTE=${REMOTE:-origin} | |
read -p "Enter branch name ${Yellow}[main]${Color_Off}: " BRANCH | |
BRANCH=${BRANCH:-main} | |
git pull $REMOTE $BRANCH --rebase ; } | |
## push | |
alias gp="git push" | |
alias gpo='git push origin' | |
alias gpo\+\+='git push origin $(grph)' | |
alias gpx\+\+='git push $1 $(grph)' | |
## stash | |
alias gst='git stash' | |
alias gsl='git stash list' | |
alias gsp='git stash push' # 'git stash save' is deprecated | |
alias gsa='git stash apply' | |
alias gsd='git stash drop' | |
alias gsc="confirm 'Confirm stash clear?' && git stash clear" | |
## log | |
alias gl='git log --decorate --abbrev-commit' | |
alias glg='git log --decorate --abbrev-commit --graph' | |
alias glgp='git log --decorate --abbrev-commit --graph --pretty=oneline' | |
alias glp='git log --decorate --abbrev-commit --pretty=oneline -10' | |
alias glp\*='git log --decorate --abbrev-commit --pretty=oneline' | |
alias gld='git log --pretty=format:"%h %ad %s" --date=short --all' | |
# Git log find by commit message | |
function glf() { git log --all --grep="$1" -i; } | |
## rev-parse | |
alias grph='git rev-parse --abbrev-ref HEAD' | |
alias grphc='echo $(git rev-parse --abbrev-ref HEAD) | pbcopy' | |
## misc. | |
alias gch='git checkout' | |
alias gtl='git tag --list' | |
alias gitmoji='gec' | |
alias gs='git status -s -b' | |
alias gs\+='git status' | |
alias grv='git remote -v' | |
alias groot='cd $(git rev-parse --show-toplevel)' | |
## undo | |
alias undo-commit="confirm 'Undo most recent commit?' && git reset --soft HEAD~1 " | |
alias undo-changes="confirm 'Discard changes since last commit?' && git reset --hard HEAD~1" | |
## reset, revert, restore | |
alias greset='git reset' | |
alias gresetH='git reset HEAD' | |
alias grevert='git revert' # see gitUndoOldCommit() | |
alias grestore='git restore' | |
alias gunstage='git restore --staged' | |
## merge via command line | |
# Step 1: From your project repository, bring in the changes and test | |
gbmakemerge() { | |
echo -e "${BIYellow}${Color_Off}" | |
read -p "Enter new branch name: " BRANCH | |
read -p "Enter the remote name ${Yellow}[origin]${Color_Off}: " REMOTE | |
REMOTE=${REMOTE:-origin} | |
git fetch $REMOTE | |
git checkout -b $BRANCH $REMOTE/$BRANCH | |
git merge main ; | |
} | |
# Step 2: Merge the changes and update on GitHub. | |
#` alias gmergemain="git checkout main && git merge --no-ff $(grph) && git push origin main" | |
# Step 3: Branch cleanup and pulling updates from main after a PR merge | |
alias gnext='grphc && gch main && gf && echo "" && echo "Pulling from main" && gpullom && gbmerged && echo "" && echo -e "Deleting branch: ${Highlight} `pbpaste` ${Color_Off}" && gbdl `pbpaste`' | |
gitfailedgpgfix () { | |
# If gpg is updated (by brew), location of gpg/gpg1/gpg2 may have changed: git config --global gpg.program gpg1 | |
brew upgrade gnupg && | |
brew link --overwrite gnupg && | |
brew install pinentry-mac && | |
echo "pinentry-program /usr/local/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf && | |
killall gpg-agent && | |
echo "test" | gpg --clearsign && # on linux it's gpg2 but brew stays as gpg | |
echo "" | |
} | |
alias gitignore='cat ~/.help_docs/gitignoreTemplate.txt >> .gitignore' | |
alias readme='cat ~/.help_docs/READMETemplate.txt >> README.md' | |
alias fixNpmPackage='open /usr/local/lib/node_modules' |
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
function note () { | |
NOTE_HELP=' | |
\n\t-p\t\tPrint note\n | |
\t-r\t\tRead note, alias of -p\n | |
\t-e\t\tEdit note | |
\t-g\t\tGrep mode\n | |
\t-G\t\tLoud grep mode\n | |
\t-d\t\tSoft delete note\n | |
\t-D\t\tHard delete note\n | |
\t-h, --help\tPrint this again\n' | |
case "$1" in | |
# soft delete note | |
-d) echo "" > note.md;; | |
# hard delete note | |
-D) rm note.md;; | |
# print note | |
-p) xcat note.md;; | |
# read note, alias of -p | |
-r) xcat note.md;; | |
# edit note | |
-e) nvim note.md;; | |
# grep mode | |
-g) grep $2 note.md -iE --color=always;; | |
# loud grep mode | |
-G) xcat note.md | perl -pe "s/$2/\e[1;31;43m$&\e[0m/g";; | |
# help | |
-h | --help) echo -e $NOTE_HELP;; | |
# If no flag, append $1 to note | |
*) echo "$1" >> note.md | |
esac | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment