Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #Set Nano as default editor
- export EDITOR=nano
- #Force Python3
- alias python="python3"
- alias pip='pip3'
- #Sylization Aliases
- #########################################
- ## Colorize the ls output ##
- alias ls='ls --color=auto'
- ## Show hidden files ##
- alias l.='ls -d .* --color=auto'
- ## Colorize the grep command output for ease of use (good for log files)##
- alias grep='grep --color=auto'
- alias egrep='egrep --color=auto'
- alias fgrep='fgrep --color=auto'
- ##install colordiff package :) ##
- alias diff='colordiff'
- ##Prety Print mount output ##
- alias mount='mount |column -t'
- #Misstype Correctors
- #########################################
- ## get rid of command not found ##
- alias cd..='cd ..'
- alias sl='ls'
- alias pdw="pwd"
- #Easy Directory Traversal ++
- ##########################################
- ## a quick way to get out of current directory ##
- alias ..='cd ..'
- alias ...='cd ../../../'
- alias ....='cd ../../../../'
- alias .....='cd ../../../../'
- alias ......='cd ../../../../'
- alias .......='cd ../../../../..'
- ## Use a long listing format ##
- alias ll='ls -la'
- #Ease of use Aliases
- ##############################################
- ##Create parent directories on demand##
- alias mkdir='mkdir -pv'
- ## tAdds continue flag to continue downloads in case of network interuptions. ##
- alias wget='wget -c'
- ## set some other defaults ##
- alias df='df -H'
- alias du='du -ch'
- # share history between terminal sessions
- alias he="history -a" # export history
- alias hi="history -n" # import history
- # pipe ps aux to grep. Use: psg java
- #alias psg="ps aux | grep -v grep | grep -i -e VSZ -e"
- #paste thing to termbin.com (use: echo test | tb)
- alias tb="nc termbin.com 9999"
- #System Information Aliases
- #############################################
- ## pass options to free ##
- alias meminfo='free -m -l -t'
- ## get top process eating memory
- alias psmem='ps auxf | sort -nr -k 4'
- alias psmem10='ps auxf | sort -nr -k 4 | head -10'
- ## get top process eating cpu ##
- alias pscpu='ps auxf | sort -nr -k 3'
- alias pscpu10='ps auxf | sort -nr -k 3 | head -10'
- ## Get server cpu info ##
- alias cpuinfo='lscpu'
- ## older system use /proc/cpuinfo ##
- alias cpuinfo='less /proc/cpuinfo'
- ## get GPU ram on desktop / laptop##
- alias gpumeminfo='grep -i --color memory /var/log/Xorg.0.log'
- #Extra Commands and Command Shortcuts
- #############################################
- # handy short cuts #
- alias h='history'
- alias j='jobs -l'
- alias path='echo -e ${PATH//:/\\n}'
- alias now='date +"%T"'
- alias nowtime='now'
- alias nowdate='date +"%d-%m-%Y"'
- #copy output of last command to clipboard
- alias cl="fc -e -|pbcopy"
- # copy the working directory path
- alias cpwd='pwd|tr -d "\n"|pbcopy'
- # Frees up the cached memory
- alias freemem='sync && echo 3 | sudo tee /proc/sys/vm/drop_caches'
- #Networking Controls
- #################################################
- # Get your current public IP
- alias ip="curl icanhazip.com"
- # Stop after sending count ECHO_REQUEST packets #
- alias ping='ping -c 5'
- # Do not wait interval 1 second, go fast #
- alias fastping='ping -c 100 -s.2'
- ##Show Open Ports##
- alias ports='netstat -tulanp'
- ## shortcut for iptables and pass it via sudo#
- alias ipt='sudo /sbin/iptables'
- ## display all rules ##
- alias iptlist='sudo /sbin/iptables -L -n -v --line-numbers'
- alias iptlistin='sudo /sbin/iptables -L INPUT -n -v --line-numbers'
- alias iptlistout='sudo /sbin/iptables -L OUTPUT -n -v --line-numbers'
- alias iptlistfw='sudo /sbin/iptables -L FORWARD -n -v --line-numbers'
- alias firewall='iptlist'
- ## All of our servers eth1 is connected to the Internets via vlan / router etc ##
- alias dnstop='dnstop -l 5 eth1'
- alias vnstat='vnstat -i eth1'
- alias iftop='iftop -i eth1'
- alias tcpdump='tcpdump -i eth1'
- alias ethtool='ethtool eth1'
- # work on wlan0 by default # Only useful for laptop as all servers are without wireless interface
- alias iwconfig='iwconfig wlan0'
- #Safety Nets (Dont Break Your Machine!)
- #################################################
- # do not delete / or prompt if deleting more than 3 files at a time #
- alias rm='rm -I --preserve-root'
- # confirmation #
- alias mv='mv -i'
- alias cp='cp -i'
- alias ln='ln -i'
- # Parenting changing perms on / #
- alias chown='chown --preserve-root'
- alias chmod='chmod --preserve-root'
- alias chgrp='chgrp --preserve-root'
- #File Manipulation Aliases
- #########################################
- # trim newlines
- alias tn='tr -d "\n"'
- ##optimize images for web using imagemacick to reduce the mo 690px
- #(apt-get install imagemagick) if this fails.
- alias webify="mogrify -resize 690\> *.png"
- #Functions
- ########################################
- ### Get os name via uname ###
- _myos="$(uname)"
- ### add alias as per os using $_myos ###
- case $_myos in
- Linux) alias foo='/path/to/linux/bin/foo';;
- FreeBSD|OpenBSD) alias foo='/path/to/bsd/bin/foo' ;;
- SunOS) alias foo='/path/to/sunos/bin/foo' ;;
- *) ;; esac
- function extract {
- if [ -z "$1" ]; then
- # display usage if no parameters given
- echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
- else
- if [ -f "$1" ] ; then
- # NAME=${1%.*} mkdir $NAME && cd $NAME
- case $1 in
- *.tar.bz2) tar xvjf ../"$1" ;;
- *.tar.gz) tar xvzf ../"$1" ;;
- *.tar.xz) tar xvJf ../"$1" ;;
- *.lzma) unlzma ../"$1" ;;
- *.bz2) bunzip2 ../"$1" ;;
- *.rar) unrar x -ad ../"$1" ;;
- *.gz) gunzip ../"$1" ;;
- *.tar) tar xvf ../"$1" ;;
- *.tbz2) tar xvjf ../"$1" ;;
- *.tgz) tar xvzf ../"$1" ;;
- *.zip) unzip ../"$1" ;;
- *.Z) uncompress ../"$1" ;;
- *.7z) 7z x ../"$1" ;;
- *.xz) unxz ../"$1" ;;
- *.exe) cabextract ../"$1" ;;
- *) echo "extract: '$1' - unknown archive method" ;;
- esac
- else
- echo "$1 - file does not exist"
- fi fi
- }
- function top10 {
- history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10
- }
- ####### Begin Uploadfiles.io api aliases #######
- ufiles() {
- source ~/ufiles.conf
- if [ "$1" != "" ]; then
- if [ "$1" == "put" ]; then
- if [ "$KEY" != "" ]; then
- if [ "$USER" != "" ]; then
- if [ "$2" != "" ]; then
- curl -X POST -F "file=@$2" -F "user_id=$USER" -F "auth_key=$KEY" https://up.uploadfiles.io/upload
- else
- echo "No Files was specified for upload"
- echo "please retry as follows:"
- echo "ufile put <file to upload>"
- fi
- else
- echo "No User was Specified in ~/ufiles.conf"
- echo "Please Check your configuration and try again."
- fi
- else
- echo "No KEY was Specified in ~/ufiles.conf"
- echo "Please Check your configuration and try again."
- fi
- elif [ "$1" == "get" ]; then
- if [ "$KEY" != "" ]; then
- if [ "$USER" != "" ]; then
- if [ "$2" != "" ]; then
- if [ "$3" != "" ]; then
- curl -u $USER:$KEY -o $2 https://down.uploadfiles.io/get/$1
- else
- curl -u $USER:$KEY -o $1 https://down.uploadfiles.io/get/$1
- fi
- else
- echo "No save path was specified."
- echo "please retry as follows:"
- echo "ufile get SLUG OPTIONAL SAVE PATH"
- fi
- else
- echo "No User was Specified in ~/ufiles.conf"
- echo "Please Check your configuration and try again."
- fi
- else
- echo "No KEY was Specified in ~/ufiles.conf"
- echo "Please Check your configuration and try again."
- fi
- elif [ "$1" == "auth" ]; then
- if [ "$2" != "" ]; then
- if [ "$3" != "" ]; then
- cat <<EOT > ~/ufiles.conf #!/bin/bash
- ##This config file store user credentials for using the ufiles-tools bash aliase.
- USER=$2
- KEY=$3
- EOT
- else
- echo "Positional arguemnt USER is empty"
- echo "Please re-try as follows:"
- echo "ufile auth USER_ID AUTH_KEY"
- fi
- else
- echo "Positional argument KEY is empty"
- echo "Please re-try as follows:"
- echo "ufile auth USER_ID AUTH_KEY"
- fi
- elif [ "$1" == "--help" ]; then
- echo "Usage: ufile [OPTIONS] COMMAND [ARGS]..."
- echo ""
- echo "This is a command line utility to aid in handling file transfers to and"
- echo "from Uploadfiles.io. Additional information is avilable at"
- echo "https://github.com/osteth/ufile-tools/"
- echo ""
- echo "Options:"
- echo "--help Show this message and exit."
- echo ""
- echo "Commands:"
- echo "put Upload a file to Uploadfiles.io"
- echo "get Download a file from Uploadfiles.io"
- echo "auth Change your user credentials."
- fi
- else
- echo "fail"
- fi
- }
- ####### End Uploadfiles.io api aliases #######
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement