Skip to content

Instantly share code, notes, and snippets.

@rayantony
Last active September 2, 2016 08:54
Show Gist options
  • Select an option

  • Save rayantony/80e320452b60d8f6a32450e85bb97473 to your computer and use it in GitHub Desktop.

Select an option

Save rayantony/80e320452b60d8f6a32450e85bb97473 to your computer and use it in GitHub Desktop.
My Shell Gits Extensions Aliases and Functions
#Standard Aliases from cloudyvbx
alias cls='clear'
alias lsh='ls -lashR --color=auto'
alias lsa='ls -lashF --color=auto '
alias shutdown='sudo shutdown -PH -v 0'
alias mem='echo -e "Memory Info:\n";free -m;df --total -h;echo -e "\n"'
alias os='echo -e "OS Info:\n";grep . /etc/os-release;grep . /etc/lsb-release;echo -e "\n"'
alias cpu='echo -e "CPU Info:\n";grep . /proc/cpuinfo;echo -e "\n"'
alias kernel='echo -e "\n";grep . /proc/cmdline;echo -e "\n";dmesg | grep -i "command line";echo -e "\n";uname -a'
alias history='cat ~/.bash_history | uniq -u | grep -i .'
alias psa='ps -eHf'
alias treecmd='tree --charset utf-8 -A -C -x -u --dirsfirst --filelimit 1024'
alias free='free -glt'
alias treeall='tree -ashA'
alias whoauth='sudo cat /var/log/auth*log /var/log/fail2*log /var/log/ufw*log |grep -i "auth"'
alias breakins='sudo cat /var/log/auth*log|grep -i "break"'
alias mydiff='colordiff -siyaW 100'
#apt
alias aptfind='apt-cache search $@ '
alias aptshow='apt-cache show $@ '
alias aptshowpkg='apt-cache showpkg $@ '
#Server specific
alias badips='cd /home/admin/badips;bash badips.sh|grep -ic .;echo -e "added to list and dedupped update firewall yourself please\n";cd $OLDPWD'
alias loggedin='cls;echo -e "Successful Logins:\n===============";cat /var/log/auth.log | grep -i -n "accept"'
alias fwall='sudo ufw status verbose'
alias breakins='cat /var/log/auth.log | grep -i "break"'
alias restartweb='sudo /etc/apache2/init.d/apache restart'
#git
alias gittree='tree -A -H . > ./gittree.html'
alias gitwhonow='git config --global user.name && git config --global user.email'
alias whogitnow='gitwhonow'
#tests
alias bigwho='cls;sudo ls /home;who;w;ps -eHf;net sessions;ip addr;read;sudo trafshow;read;sudo whowatch'
alias mytree='tree -u -p -a -c -D -h -L 5'
alias processcheck='cls;printf "\nBEGIN NETSTAT CONNECTION LISTING\n";netstat -lp;printf "\n NETSTAT END \n BEGIN PROCESS CHECK...\nany key continues...\n";read proceedyesno;ps -ax;printf "\n END PROCESS CHECK \n";'
alias breakins='sudo cat /var/log/auth*|grep -i ccept;cat /var/log/auth*|grep -i break'
# newer
alias branchsizefull='sudo du -chx --summarize'
#bashrc functions cloudyvbx
#ray functions
#git
function getparserepos() { printf "\nType User or Org Repo name get back clean list of repos\n";read srch;curl --silent "https://api.github.com/users/$srch/repos?per_page=100&page=1" -q|grep clone_url | sort | awk -F'"' '{print $4}'; }
function getparserepos2() { printf "\nType User or Org Repo name get back clean list of repos\n";read srch;curl --silent "https://api.github.com/users/$srch/repos?per_page=100&page=2" -q|grep clone_url | sort | awk -F'"' '{print $4}'; }
function getparserepos3() { printf "\nType User or Org Repo name get back clean list of repos\n";read srch;curl --silent "https://api.github.com/users/$srch/repos?per_page=100&page=3" -q|grep clone_url | sort | awk -F'"' '{print $4}'; }
# lightweight minimal clone of a single branch. diff for yourself, this is lean like a mofo
function gitclonelight () {
printf "\n Enter username/repo combination \n"
read repocombo
branch=""
printf "which branch? default is master \n"
read branch
if [ "$branch" == "" ]; then
branch="master"
fi
git clone --depth 1 --single-branch --branch $branch http://github.com/$repocombo; }
alias gitclonelite='gitclonelight'
alias clonelight='gitclonelight'
#update from changes at server
#gitupdates [path to org/user git root]
function gitupdates() { for i in [ /opt/gits/$@/* ] ; do cd $i; git pull ; cd $PWD ; done ; }
function shownewips () { cat /var/log/auth.log | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}'; }
function shownewbadips () { cat /var/log/auth.log | grep -i 'break' | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}'; }
alias mydiff='colordiff -aIql -W 120 --suppress-common-lines -y'

=== The only thing bigger than my bash files is the number of versions I have across users, across servers(x)instances. An exponential headache made for git. For reasons of identity separation there is little upside to private gits so its just secondary storage to be able to have those here but I can focus on some public ones that are less a big deal.

These would normally be strewn across .bashrc and .bash_aliases but I'll no doubt include some that I would have in a separate script in an attempt to organize this stuff before bash goes out of style or https5000 makes my keyboard illegal or some nonsense. Anyway help yourself these are real handy!

For now I'm placing all in gits.sh for the sake of this repo. You can grab them to "livecurl" in with this raw link

Copy this line into your console and hit enter to load in your current session:

curl -qL --silent --url https://gist.githubusercontent.com/rayantony/80e320452b60d8f6a32450e85bb97473/raw/647e255cf0e42a376a19162953b654168c679713/gits.sh|bash -

by @rayantony under @rayrc

#!/bin/bash
alias gitwhonow='git config -l && git config --global user.name && git config --global user.email'
alias whogitnow='gitwhonow'
function gitupdates() { for i in [ /opt/gits/$@/* ] ; do cd $i; git pull ; cd $PWD ; done ; }
function whogit(){ printf "\n Enter an Organization or user \n";read GITUSER;for i in $(echo $GITUSER);do curl https://api.github.com/users/$i;done; }
function listgits() { curl --silent "https://api.github.com/users/${@}/repos?per_page=100&page=1" -q|sort|grep "clone_url"|awk -F'"' '{print $4}'; }
function listgists(){ curl --silent "https://api.github.com/users/$@/gists?per_page=100&page=1" -qjk|grep '"url":'|awk -F'"' '{print $4}'; }
function getparserepos() { printf "\n Type User or Org Repo name get back clean list of repos \n";read srch;curl --silent "https://api.github.com/users/$srch/repos?per_page=100&page=1" -q|grep html_url|awk -F'"' '{print $4}'; }
# lightweight minimal clone of a single branch. diff for yourself, this is lean like a mofo
function gitclonelight () {
printf "\n Enter username/repo combination \n"
read repocombo
branch=""
printf "which branch? default is master \n"
read branch
if [ "$branch" == "" ]; then
branch="master"
fi
git clone --depth 1 --single-branch --branch $branch http://github.com/$repocombo; }
alias gitclonelite='gitclonelight'
alias clonelight='gitclonelight'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment