Last active
September 21, 2020 16:55
-
-
Save Waltibaba/973c4c303054f54ce8b4bfc78d738ece to your computer and use it in GitHub Desktop.
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
| export PS1='\[\033[0;35m\]\h\[\033[0;33m\] \w\[\033[00m\]: ' | |
| export PROMPT_DIRTRIM=2 | |
| alias l='ls -lhA --color=auto' | |
| alias d='dirs -v' | |
| function psauxgrep(){ | |
| ps aux | grep $@ | grep -v grep | |
| } | |
| alias p=psauxgrep | |
| alias jobs='jobs -l' | |
| #git functions | |
| function lazygit { | |
| git add . | |
| git commit -a -m "$1" | |
| git push | |
| } | |
| function yolo { | |
| lazygit "`wget -qO- http://whatthecommit.com/index.txt`" | |
| } | |
| #general system utilities | |
| function n { | |
| if [ -w "$1" ]; then | |
| nano -t "$1" | |
| else | |
| echo "$1 isn't writable" | |
| fi | |
| } | |
| function reload { | |
| . ~/.bashrc | |
| } | |
| function installed_packages { | |
| bash -c "pacman -Qe && echo '####DEPENDENCIES####' && pacman -Qd " | sed -e 's|\([a-zA-Z0-9\-\_]\+\) .*|\1|g' | |
| } | |
| function cpx { | |
| rsync --info=progress2 $@ | |
| } | |
| function mountit { | |
| sudo mount -o gid=users,fmask=113,dmask=002 $@ | |
| } | |
| max_threads=8 | |
| function parallel { | |
| local time1=$(date +"%H:%M:%S") | |
| local time2="" | |
| # for the sake of the example, I'm using $2 as a description, you may be interested in other description | |
| echo "starting $2 ($time1)..." | |
| "$@" && time2=$(date +"%H:%M:%S") && echo "finishing $2 ($time1 -- $time2)..." & | |
| local my_pid=$$ | |
| local children=$(ps -eo ppid | grep -w $my_pid | wc -w) | |
| children=$((children-1)) | |
| if [[ $children -ge $max_threads ]]; then | |
| wait -n | |
| fi | |
| } | |
| #docker functions | |
| alias dockerkillall='docker kill $(docker ps -q)' | |
| # Delete all stopped/dangling containers/images/volumes | |
| alias dockercleanc='printf "\n>>> Deleting stopped containers\n\n" && docker ps -a --format \"{{.ID}}\t{{.Status}}\" | grep -v Up | cut -f 1 | xargs docker rm' | |
| alias dockercleani='printf "\n>>> Deleting untagged images\n\n" && docker images --format \"{{.ID}}\t{{.Tag}}\" | grep "<none>" | cut -f 1 | xargs docker rmi' | |
| alias dockercleanv='docker volume ls -qf dangling=true | xargs -r docker volume rm' | |
| # Delete all unused | |
| alias dockerclean='dockercleanc || true && dockercleanv || true && dockercleani' | |
| export EDITOR=nano | |
| export MAKEFLAGS="-j14" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment