Skip to content

Instantly share code, notes, and snippets.

@DavidDobr
Created January 8, 2017 10:55
Show Gist options
  • Save DavidDobr/32cd8a4c787dd6bf9250202b948f45bd to your computer and use it in GitHub Desktop.
Save DavidDobr/32cd8a4c787dd6bf9250202b948f45bd to your computer and use it in GitHub Desktop.
##### USER GENERATED ALIASES
PATH=$PATH:$HOME/anaconda3/bin:$HOME/
alias howdoi='howdoi -c -n 5'
alias la='ls -a1'
alias brc="vi ~/.bashrc"
alias sbrc="source ~/.bashrc"
EDITOR=vim
alias vi=vim
alias rvim='sudo -E vim' # open file as root vim but with CURRENT configuration
alias rvi='sudo -E vim' # open file as root vim but with CURRENT configuration
# GIT Aliases
alias gitrm='git ls-files --deleted -z | xargs -0 git rm'
gitp () {
# Stage all changes, commit and push in succession
# If comments are typed after the command, add them as commit message
echo "##############################################################"
echo "# There are $# positional arguements"
# '$#' calculates the number of positional arguements;
# if $# is greater than zero, then we have a commit message to use;
# if $# is zero, then we have no commit message - git will
# open an editor;
if [ $# -gt 0 ]; then
comments="$*" # concatenate all positional arguements into a string
echo "##############################################################"
echo "# Pushing with comment: \"$comments\" "
echo "##############################################################"
git add . ; git add ".*" ; git commit -m "$comments"; git push
else
echo "##############################################################"
echo "# No comment; Opening standard text editor for commit message"
echo "##############################################################"
git add . ; git add ".*" ; git commit ; git push
fi
}
# Complicated user aliases
rmd () {
# preview a MarkDown document in the terminal
# @param: the MD file to preview
# renders an HTML in pandoc and pipes it to lynx
pandoc $1 | lynx -stdin
}
rmd_loop () {
# preview a MarkDown document in the terminal
# @param: the MD file to preview
# renders an HTML in pandoc and pipes it to lynx
# after closing the preview, re-renders it in a second
# good for editing and viewing MD side-by-side in terminals
while true
do
echo 'Hit CTRL+C to stop'
sleep 0.5
pandoc $1 | lynx -stdin
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment