Skip to content

Instantly share code, notes, and snippets.

@penguinpowernz
Last active February 28, 2022 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save penguinpowernz/228abec1753ad08c1c2172f1c8f75ff3 to your computer and use it in GitHub Desktop.
Save penguinpowernz/228abec1753ad08c1c2172f1c8f75ff3 to your computer and use it in GitHub Desktop.
Quickly installable useful utils

Quickly installable aliases and functions

curl -H 'Cache-Control: no-cache' -fsSL https://gist.githubusercontent.com/penguinpowernz/228abec1753ad08c1c2172f1c8f75ff3/raw/install.sh | bash
alias dco='docker-compose'
alias dcb='docker-compose build'
alias dce='docker-compose exec'
alias dcps='docker-compose ps'
alias dcrestart='docker-compose restart'
alias dcrm='docker-compose rm'
alias dcr='docker-compose run'
alias dcstop='docker-compose stop'
alias dcup='docker-compose up'
alias dcdn='docker-compose down'
alias dcl='docker-compose logs'
alias dclf='docker-compose logs --tail=50 -f'
alias scs="sudo systemctl start"
alias scr="sudo systemctl restart"
alias scrr="sudo systemctl reload"
alias sct="sudo systemctl status"
alias scx="sudo systemctl stop"
alias sce="sudo systemctl enable"
alias scd="sudo systemctl disable"
alias sdr="sudo systemctl daemon-reload"
alias follow="sudo journalctl -fu"
alias drrm="docker run -it --rm "
alias drm="docker rm "
alias db="docker build"
alias drmi="docker rmi "
alias dls="docker images"
alias dlsc="docker ps"
alias gst="git status|head -1 && git status -s"
alias glg='git log --pretty=format:"%h : %ar : %s"'
alias glv="git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --decorate"
alias gfo="git fetch origin"
alias gmn="git merge --no-ff"
alias gt="git tag"
alias gfa="git fetch --all"
alias gpt="git push --tags"
alias gpa="git push --all"
alias piu="netstat -tulpna | grep "
alias sanscom="grep -Pv '^#'"
alias treesize="du -h --max-depth=1"
alias l="ls -lh"
alias la="ls -lah"
alias ll="ls -lh"
alias s="sudo"
alias myip="curl icanhazip.com"
alias acp="apt-cache policy"
alias agi="apt-get install"
alias agu="apt-get update; apt-file update"
alias agp="apt-file search"
alias ags="apt-cache search"
alias fd=fdfind
# unix epoch handling
epoch() {
[[ -z "$1" ]] && date +%s && return 0;
if [[ "$1" =~ '^[0-9]+$' ]]; then
echo "$1" | ruby -pne '$_ = Time.at($_.to_i)'
echo ""
else
echo $1 | ruby -rtime -pne '$_ = Time.parse($_).to_i'
echo ""
fi
}
jcat() {
cat $1 | json_pp
}
jless() {
cat $1 | json_pp | less
}
zless() {
zcat $1 | less
}
zgrep() {
zcat $1 | grep "$@"
}
# shorthand clone
gclo() {
git clone $*;
}
# GIT PULL CURRENT BRANCH
glb() {
CB=`git branch |grep "\*" |tr -d '* '`;
git pull origin $CB;
}
# GIT PUSH CURRENT BRANCH
gpb() {
CB=`git branch |grep "\*" |tr -d '* '`;
git push origin $CB;
}
# list all IPs on the network
function lsnet {
fping -ag $1 2>/dev/null
}
# put the makefile in a menu
function mk {
[[ -f "Makefile" ]] || return 1;
t=`cat Makefile|grep -P "^\w+\:"|fzf|cut -d':' -f1`
make $t
}
#!/bin/bash
curl https://gist.githubusercontent.com/penguinpowernz/228abec1753ad08c1c2172f1c8f75ff3/raw/functions -o ~/.functions
curl https://gist.githubusercontent.com/penguinpowernz/228abec1753ad08c1c2172f1c8f75ff3/raw/aliases -o ~/.aliases
[[ -f "$HOME/.bashrc" ]] && {
grep -q "\.aliases" ~/.bashrc || echo -e "\nsource ~/.aliases" >> ~/.bashrc;
grep -q "\.functions" ~/.bashrc || echo -e "\nsource ~/.functions" >> ~/.bashrc;
}
[[ -f "$HOME/.zshrc" ]] && {
grep -q "\.aliases" ~/.zshrc || echo -e "\nsource ~/.aliases" >> ~/.zshrc;
grep -q "\.functions" ~/.zshrc || echo -e "\nsource ~/.functions" >> ~/.zshrc;
}
source ~/.aliases;
source ~/.functions;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment