Skip to content

Instantly share code, notes, and snippets.

@lundeen-bryan
Last active September 15, 2023 13:24
Show Gist options
  • Save lundeen-bryan/5cc025b8b1c1cdcd804088c221561697 to your computer and use it in GitHub Desktop.
Save lundeen-bryan/5cc025b8b1c1cdcd804088c221561697 to your computer and use it in GitHub Desktop.
bash_backups
# list files per line
alias lf="ls -1ASk"
# quit bash like in vim
alias :q="exit"
# clear the screen
alias clr="clear"
# run ipython with vi
alias ipy="ipython --TerminalInteractiveShell.editing_mode='vi'"
# show grep history
alias gh="history|grep"
# show enter history
alias hist='history'
# list files by size
alias listsize="ls --human-readable --size -1 -S --classify"
# list files by mod date
alias listmod="ls -t -1"
# show file count
alias filecount="find . -type f | wc -l"
# create python virtual environment
alias ve="python3 -m venv .venv"
alias va="source ./venv/Scripts/activate"
# Navigate up one level
alias ..='cd ..'
# Show Git status
alias gs='git status'
# Navigate to the downloads folder
alias dl='cd ~/Downloads'
# Show this alias file in bash
alias myal='cat ~/.bashbackup/.bash_aliases'
gitfiles2clip() {
git status --porcelain | awk '{print $2}' | tr '\n' ' ' | clip
echo "Files modified in git have been copied to the clipboard."
}
alias :e="explorer"
echo "~/.bashbackup/.bash_profile is loaded."
# generated by Git for Windows
#test -f ~/.profile && . ~/.profile
# test to see if the bashrc exists
#test -f ~/.bashbackup/.bashrc && . ~/.bashbackup/.bashrc
# code below does the same as test above
if
[ -f ~/.bashbackup/.bashrc ];
then
source ~/.bashbackup/.bashrc
else
source ~/.bashrc
fi
echo "~/.bashbackup/.bashrc is loaded"
# use vim keybindings in bash
set -o vi
# use jk to go to normal mode
bind '"jk":"\e"'
# Alias definitions.
# Put all aliases into a separate file
if [ -f ~/.bashbackup/.bash_aliases ]; then
. ~/.bashbackup/.bash_aliases
fi
# don't put duplicate lines or lines starting with space in the history.
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
#set history size
HISTSIZE=1000
HISTFILESIZE=2000
if [ "$TERM" = "linux" ]; then
echo -en "\e]P0232323" #black
echo -en "\e]P82B2B2B" #darkgrey
echo -en "\e]P1D75F5F" #darkred
echo -en "\e]P9E33636" #red
echo -en "\e]P287AF5F" #darkgreen
echo -en "\e]PA98E34D" #green
echo -en "\e]P3D7AF87" #brown
echo -en "\e]PBFFD75F" #yellow
echo -en "\e]P48787AF" #darkblue
echo -en "\e]PC7373C9" #blue
echo -en "\e]P5BD53A5" #darkmagenta
echo -en "\e]PDD633B2" #magenta
echo -en "\e]P65FAFAF" #darkcyan
echo -en "\e]PE44C9C9" #cyan
echo -en "\e]P7E5E5E5" #lightgrey
echo -en "\e]PFFFFFFF" #white
clear #for background artifacting
fi
# Add vscode to the bash path so that I can type "code ." in a directory
# and it will open that directory in vscode
export PATH=$PATH:C:\Users\admin\AppData\Local\Programs\Microsoft VS Code\bin
## Colours have names too. Stolen from Arch wiki
#txtblk='\[\e[0;30m\]' # Black - Regular
#txtred='\[\e[0;31m\]' # Red
#txtgrn='\[\e[0;32m\]' # Green
#txtylw='\[\e[0;33m\]' # Yellow
#txtblu='\[\e[0;34m\]' # Blue
#txtpur='\[\e[0;35m\]' # Purple
#txtcyn='\[\e[0;36m\]' # Cyan
#txtwht='\[\e[0;37m\]' # White
#bldblk='\[\e[1;30m\]' # Black - Bold
#bldred='\[\e[1;31m\]' # Red
#bldgrn='\[\e[1;32m\]' # Green
#bldylw='\[\e[1;33m\]' # Yellow
#bldblu='\[\e[1;34m\]' # Blue
#bldpur='\[\e[1;35m\]' # Purple
#bldcyn='\[\e[1;36m\]' # Cyan
#bldwht='\[\e[1;37m\]' # White
#unkblk='\[\e[4;30m\]' # Black - Underline
#undred='\[\e[4;31m\]' # Red
#undgrn='\[\e[4;32m\]' # Green
#undylw='\[\e[4;33m\]' # Yellow
#undblu='\[\e[4;34m\]' # Blue
#undpur='\[\e[4;35m\]' # Purple
#undcyn='\[\e[4;36m\]' # Cyan
#undwht='\[\e[4;37m\]' # White
#bakblk='\[\e[40m\]' # Black - Background
#bakred='\[\e[41m\]' # Red
#badgrn='\[\e[42m\]' # Green
#bakylw='\[\e[43m\]' # Yellow
#bakblu='\[\e[44m\]' # Blue
#bakpur='\[\e[45m\]' # Purple
#bakcyn='\[\e[46m\]' # Cyan
#bakwht='\[\e[47m\]' # White
#txtrst='\[\e[0m\]' # Text Reset
#
## Prompt colours
#atC="${txtpur}"
#nameC="${txtpur}"
#hostC="${txtpur}"
#pathC="${txtgrn}"
#gitC="${txtpur}"
#pointerC="${txtgrn}"
#normalC="${txtwht}"
#
## Red name for root
#if [ "${UID}" -eq "0" ]; then
# nameC="${txtred}"
#fi
#

BashBackup


Description

This is a setup for backing up my bashrc and bash_profile files


How To Use

Installation

In your home folder create a folder called .bashbackup. In that folder put your .bashrc and .bash_profile files. In your home folder put a .bashrc file that says:

    source ~/.bashbackup/.bashrc

Then in your home folder put a .bash_profile file that says:

    source ~/.bashbackup/.bash_profile

Back To The Top


Contributions

I am currently not accepting contributions to this project, however feel free to leave comments on the issues tab of this project for consideration.


License

Copyright © [2020] [Bryan Lundeen]

MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Back To The Top


Author Info

Back To The Top

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment