Skip to content

Instantly share code, notes, and snippets.

@JacobCallahan
Last active January 29, 2024 15:21
Show Gist options
  • Save JacobCallahan/fbb7e43595c75b8f34ea3e0eae2791a0 to your computer and use it in GitHub Desktop.
Save JacobCallahan/fbb7e43595c75b8f34ea3e0eae2791a0 to your computer and use it in GitHub Desktop.
public
# .bashrc
# If the shell is not running interactively, immediately return. This ensures
# that programs like scp are given a pristine environment.
[[ $- != *i* ]] && return
export TERM=gnome-256color
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
if [ -f `which powerline-daemon` ]; then
powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
. /usr/share/powerline/bash/powerline.sh
fi
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# Envar modifications
export EDITOR=vim
export PATH="$PATH:$GOPATH/bin"
# export JIRA_API_TOKEN=<token>
export JIRA_AUTH_TYPE=bearer
export GOPATH=$HOME/go
export GLOBIGNORE=__pycache__
# tomasr/molokai
export FZF_DEFAULT_OPTS="--color=bg+:#293739,bg:#1B1D1E,border:#808080,spinner:#E6DB74,hl:#7E8E91,fg:#F8F8F2,header:#7E8E91,info:#A6E22E,pointer:#A6E22E,marker:#F92672,fg+:#F8F8F2,prompt:#F92672,hl+:#F92672"
alias refresh='source ~/.bashrc'
alias venv='python -m venv'
alias diff='colordiff'
alias vi='vim'
alias ls='ls -h --color=auto'
alias l.='ls -d .* --color=auto'
alias genid="python -c 'import uuid; print(uuid.uuid4())'"
alias vimlog='git log | vim -R -'
alias prettygit="git log --graph --abbrev-commit --no-notes --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all"
alias flushmem='sync; echo 3 > /proc/sys/vm/drop_caches'
alias config="git --git-dir ~/dotfiles --work-tree $HOME"
alias grep='grep --color=auto'
alias cgrep='grep --color=auto -inrC 3'
alias ping='ping -c 5'
alias fping='ping -c 1 -s 1'
alias ports='netstat -tulanp'
alias meminfo='free -m -l -t -h'
alias top10='ps auxf | sort -nr -k 3 | head -10'
alias wget='wget -c'
alias space='du -hd 1'
alias podkill='podman kill $(podman ps -q)'
alias podrm='podman rm -v $(podman ps -aq)'
alias podrmi='podman rmi $(podman images -f "dangling=true" -q)'
alias podrmv='podman volume rm $(podman volume ls -f dangling=true -q)'
alias podclean='podrm; podrmv; podrmi'
alias podtail='podman logs -f $(podman ps -lq)'
alias dockerrm='docker rm -v $(docker ps -aq)'
alias dockerrmi='docker rmi $(docker images -f "dangling=true" -q)'
alias dockerrmv='docker volume rm $(docker volume ls -f dangling=true -q)'
alias dockerclean='dockerrm; dockerrmv; dockerrmi'
alias dockertail='docker logs -f $(docker ps -lq)'
alias flatclean='flatpak uninstall --unused'
alias dlflac='youtube-dl --extract-audio --audio-format flac --output "%(title)s.%(ext)s" '
alias dlsong='youtube-dl --extract-audio --audio-format mp3 --output "%(title)s.%(ext)s" '
alias dlvid='youtube-dl -f 18 --output "%(title)s.%(ext)s" '
alias serveme='podman run -d -p 1337:80 -v $(pwd):/usr/local/apache2/htdocs/ httpd'
alias tempuser='sudo useradd -m -e "$(date -d "+1 day")" tempguest -p letmein'
alias delipyhistory='rm /home/jake/.ipython/profile_default/history.sqlite'
alias ycl='yum clean all && yum repolist enabled'
alias tailem='tail -f /var/log/messages -f /var/log/foreman/production.log -f /var/log/rhsm/rhsm.log'
alias pulpwd='grep default_password /etc/pulp/server.conf'
alias dpycache='rm -rf $(find . -name __pycache__); rm -f $(find . -name *.pyc)'
alias hotfiles='git log --pretty=format: --name-only | sort | uniq -c | sort -rg | head -25'
alias dirtyclone='env GIT_SSL_NO_VERIFY=true git clone'
alias wgetdir='wget -r -np -nH --cut-dirs=100'
alias jirafiled='jira issue list -r$(jira me) --order-by updated'
alias jirassigned='jira issue list -a$(jira me) -s~Closed --order-by updated --columns TYPE,KEY,SUMMARY,STATUS,ASSIGNEE,REPORTER,PRIORITY,CREATED,UPDATED'
alias jirawatch='jira issue list -w --updated -1d --order-by updated --columns TYPE,KEY,SUMMARY,STATUS,ASSIGNEE,REPORTER,PRIORITY,CREATED,UPDATED'
alias jirawatch5d='jira issue list -w --updated -5d --order-by updated --columns TYPE,KEY,SUMMARY,STATUS,ASSIGNEE,REPORTER,PRIORITY,CREATED,UPDATED'
alias ffc='cargo fix --allow-dirty && cargo fmt && cargo check'
alias fopen="fzf --preview 'cat {}' --bind 'enter:become(vim {})'"
alias flatrun="flatpak list --columns application | fzf --bind 'enter:become(flatpak run {})'"
alias fps='ps aux | fzf'
alias frpm='rpm -qa | fzf'
alias irust='evcxr'
alias wx="curl http://wttr.in/"
# Some miscellaneous functions
cpbash () {
sed -n '/# User/,$p' ~/.bashrc > tmpbash
scp tmpbash root@$1:/root/.bashrc
rm tmpbash
scp ~/.toprc root@$1:/root/.toprc
}
mrfreeze() {
python -m venv tempvenv
source tempvenv/bin/activate
for repo in "$@"
do
git clone $repo
reponame=$(echo "$repo" | awk -F/ '{ print $NF }' | awk -F. '{ print $1 }')
echo "moving into $reponame"
cd $reponame
if [ -f setup.py ]; then
pip install .
fi
if [ -f requirements.txt ]; then
pip install -r requirements.txt
fi
if [ -f requirements-optional.txt ]; then
pip install -r requirements-optional.txt
fi
cd ..
rm -rf $reponame
done
pip freeze | grep -v "@" | awk -F= '{ print $1 }' > fullreqs.txt
deactivate
rm -rf tempvenv
}
mcd () {
mkdir -p $1
cd $1
}
backup () {
if [ -z "$1" ]; then
echo "Usage: backup <file to backup>"
else
cp $1 $1.bak
fi
}
restore () {
if [ -z "$1" ]; then
echo "Usage: restore <file to restore>"
else
cp $1.bak $1
fi
}
del () {
if [ -z "$1" ]; then
echo "Usage: del <line number to remove from ~/.ssh/known_hosts>"
else
sed -i "$1d" ~/.ssh/known_hosts
fi
}
log() {
if [ ! -f ~/personal.log ]; then
touch ~/personal.log
fi
if [ -n "$1" ]; then
echo "$(date +'%a %d-%b-%y, %T') - $@" >> ~/personal.log
else
tail -10 ~/personal.log
fi
}
switch() {
# Usage: switch <name> or switch
if [ -n "$1" ]; then
if [ "$1" = "." ]; then
VENV="$(pwd)/venv$(pwd | tr '/' ' ' | awk '{print $NF}')"
else
VENV=~/Programming/venv$1
fi
if [ -d $VENV ]; then
if hash deactivate 2>/dev/null; then
deactivate
fi
source $VENV/bin/activate
else
echo "Creating venv at $VENV"
python3 -m venv $VENV
source $VENV/bin/activate
echo "Installing IPython"
pip install -U pip ipython
fi
else
if hash deactivate 2>/dev/null; then
deactivate
fi
fi
}
todo() {
if [ ! -f ~/todo.log ]; then
touch ~/todo.log
touch ~/done.log
fi
if [ -n "$1" ]; then
L=${2:-1}
case "$1" in
'push')
if [ "$L" == $(cat ~/todo.log | wc -l) ]; then
echo "Can't push it any lower!"
else
sed -i -n "$L{h;n;G};p" ~/todo.log
fi
;;
'bump')
if [ "$L" == 1 ]; then
echo "Can't bump it any higher!"
else
sed -i -n "$((L-1)){h;n;G};p" ~/todo.log
fi
;;
'done')
echo "$(date +'%a %d-%b-%y, %T') - $(sed -n ${L}p ~/todo.log)" >> ~/done.log
sed -i "${L}d" ~/todo.log
;;
'--help')
echo "Create and manage a personal todo log. Saved at ~/todo.log"
echo "todo <whatever you need to do> -- Saves that text to your todo log"
echo "todo -- Will print out your current todo list"
echo "todo push <line number> -- Pushes down the line by 1 position"
echo "todo bump <line number> -- Bumps up the line by 1 position"
echo "todo done <line number> -- Removes the line from your todo list"
;;
*)
echo "$@" >> ~/todo.log
;;
esac
else
cat -n ~/todo.log
fi
}
compress () {
if [ -z "$1" ]; then
echo "Usage: compress <new file name> <folder to compress>"
else
if [ -z "$2" ]; then
tar -cvzf compressed.tar.gz $1
else
tar -cvzf $1 $2
fi
fi
}
catline () {
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: catline <line number> <filename>"
else
sed -n $1p $2
fi
}
# Jira functions
workon () {
# Get a Jira issue ID and store it in ~/.active
if [ -z "$1" ]; then
issue=$(jirassigned | fzf | awk '{print $2}')
workon "$issue"
else
echo "$1" > ~/.active
fi
}
comment () {
# add a comment to the currently active Jira issue
if [ -f ~/.active ]; then
jira issue comment add $(cat ~/.active)
else
echo "No active issue."
fi
}
move () {
# move the currently active Jira issue to a new status
if [ -f ~/.active ]; then
jira issue move $(cat ~/.active)
else
echo "No active issue."
fi
}
view () {
# view the currently active Jira issue
if [ -f ~/.active ]; then
jira issue view $(cat ~/.active)
else
echo "No active issue."
fi
}
finish () {
# finish the currently active Jira issue
if [ -f ~/.active ]; then
move
rm ~/.active
else
echo "No active issue."
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment