Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Filesystem
- alias noproxy="http_proxy= HTTP_PROXY= https_proxy= HTTPS_PROXY= ftp_proxy= FTP_PROXY="
- alias rs="nice rsync --archive --no-owner --sparse --hard-links --partial --progress"
- alias rsz="rs --compress-level=9 --skip-compress=gz/zip/z/rpm/deb/iso/bz2/t[gb]z/7z/mp[34]/mov/avi/ogg/jpg/jpeg/rar/gif/png/dat"
- alias port="sudo nice port"
- alias mvn="nice mvn"
- alias cp="nice cp -v"
- alias mv="nice mv -v"
- alias tree="tree -F --dirsfirst"
- if ls --color >/dev/null 2>/dev/null; then
- alias ls="ls -bFk --color=auto"
- else
- alias ls="ls -bFkG"
- fi
- alias ll="ls -lh"
- alias l=" ll -a"
- alias df="nice df -h"
- # Aliases
- alias cal="cal -m -3"
- alias git="nice git"
- alias gsh="git stash"
- alias gst="git status --short --branch"
- alias gsu="git submodule update --recursive --merge"
- alias gdf="git diff"
- alias gdt="git difftool"
- alias glo="git log"
- alias gps="git push"
- alias gpl="git pull"
- alias gco="git checkout"
- alias gci="git commit"
- alias gad="git add"
- alias grm="git rm"
- alias gmv="git mv"
- alias gtg="git tag"
- alias gbr="git branch"
- alias gs="git svn"
- alias n="netstat -np tcp"
- alias mtr="mtr -t"
- alias nmap="nmap -v -v -T5"
- alias nmapp="nmap -P0 -A --osscan_limit"
- alias pktstat="sudo pktstat -tBFT"
- # Shell History
- shopt -s histappend
- HISTCONTROL=ignoreboth
- HISTSIZE=
- HISTFILE=~/.bash.log
- HISTFILESIZE=
- HISTTIMEFORMAT='%F %T%t'
- # Prompt
- PS1='\h\[$blue\] $(git-repo-status)\W \[$red\]${?/#0/\[$green\]}\$\[$reset\] '
- if (( EUID )); then
- PS1='\[$reset$bold$green\]\u@'$PS1
- else
- PS1='\[$reset$bold$red\]'$PS1
- fi
- forcePS1ToFront() {
- origExitCode=$?
- read r c < <(cloc)
- (( c > 1 )) && printf '\n' >&2
- return $origExitCode
- }
- #PS1='$(forcePS1ToFront)'$PS1 # Put the prompt on a new line if the cursor isn't in the beginning of the line.
- #PS1='\[$reset$bold$green\]\u@\h\[$blue\] \W \[$green\]$(: "${?#0}"; printf "\[%s\]" "${_:+$save$red\r$_ $load}")\$\[$reset\] '
- # Colors
- if [[ -f /etc/DIR_COLORS.env ]]
- then source "/etc/DIR_COLORS.env"
- elif [[ -f /etc/DIR_COLORS ]] && exists dircolors
- then eval "$(dircolors -b "/etc/DIR_COLORS")"
- fi
- if [[ -f ~/.dir_colors.env ]]
- then source ~/.dir_colors.env
- elif [[ -f ~/.dir_colors ]] && exists dircolors
- then eval "$(dircolors -b ~/.dir_colors)"
- fi
- # functions
- i() {
- bash --rcfile <(printf '%s\n' "$(<~/.bashrc)" "HISTFILE='$HISTFILE.i'" "PS1='\[$yellow\]~\[$reset\]$PS1'" "cd; clear"); clear
- }
- d() {
- if exists colordiff; then
- colordiff -ur "$@"
- elif exists diff; then
- diff -ur "$@"
- elif exists comm; then
- # functions - filesystem
- comm -3 "$1" "$2"
- fi | less
- }
- # f pattern [find-args]
- f() {
- local root pattern=$1; shift
- find "${@:-.}" -iname "*$pattern*"
- }
- rerun() {
- local h history histories dialogMenu=() startIndex
- # Load in history entries (ignoring the last)
- IFS=$'\n' read -r -d '' -a histories < <(history | tail -n "${1:-10}")
- unset histories[${#histories[@]}-1]
- # Build a dialog(1) menu and show it to ask for the starting index.
- for h in "${!histories[@]}"; do dialogMenu+=( "$h" "${histories[h]}" ); done
- startIndex=$(dialog --stdout --menu "Bash History" 0 0 0 "${dialogMenu[@]}")
- # Run all history commands starting from the starting index.
- for history in "${histories[@]:startIndex}"; do
- eval "${history#*$'\t'}" || break
- done
- }
- sw() {
- local bak="$1~"
- while [[ -e $bak ]]
- do bak+='~'; done
- mv -v "$1" "$bak"
- mv -v "$2" "$1"
- mv -v "$bak" "$2"
- }
- ppg() {
- pat=$1; shift
- p | grep -i "$@" "$pat"
- }
- cwatch() {
- while sleep .5; do
- o="$("$@")"
- clear && echo "$o"
- done
- }
- mvns() {
- export PATH=/usr/local/share/soylatte16-amd64-1.0.3/bin:${PATH}
- export JAVA_HOME=/usr/local/share/soylatte16-amd64-1.0.3
- mvn "$@"
- }
- mvnroot() {
- local p=$PWD c=${1:-1}
- until p=${p%/*}; [[ -e "$p/pom.xml" ]] && (( --c <= 0 )); do :; done
- echo "${p}${red}${PWD#$p}${reset}"
- cd "$p"
- }
- gf() {
- git-forest -a --sha "${@:---all}" | less
- }
- gd() {
- git describe --always --dirty
- }
- gdm() {
- emit "GIT Daemon starting with base path: $(shorten "$PWD")"
- git daemon --base-path=. "$@" &
- }
- git-redo-move() {
- (( $# == 2 )) || { emit -r "Expected two parameters; [source] [destination]."; return; }
- [[ -e $2 ]] || { emit -r "$2 doesn't exist, can't redo move."; return; }
- [[ ! -e $1 ]] || { emit -r "$1 exists, don't want to overwrite, aborting redo move."; return; }
- mkdir -p "${1%/*}" && \mv "$2" "$1" && git mv "$1" "$2" && rmdir -p "${1%/*}"
- }
- git-repo-status() {
- local exit=$? cwd=$PWD repo= tag
- while [[ $cwd ]]; do
- [[ -d $cwd/.git ]] && { repo=git; break; }
- cwd=${cwd%/*}
- done
- case $repo in
- git)
- if ! tag=$(git describe --tags --exact-match 2>&-); then
- tag=$(git describe --tags 2>&-)
- tag=${tag%-*} # Chop off hash.
- fi
- printf '[%s%s%s] \n' "${cwd##*/}" "${tag:+:}" "$tag"
- ;;
- esac
- return $exit
- }
- portget() {
- (( $# )) || { emit -r "$0 [revision] [category/portname]"; return; }
- [[ -e "${2#*/}" ]] && { ask -Ny! 'Target exists, delete?' && rm -rf "${2#*/}" || return; }
- svn co -r "$1" http://svn.macports.org/repository/macports/trunk/dports/"$2"
- cd "${2#*/}"
- }
- # Fink environment
- test -r /sw/bin/init.sh && . /sw/bin/init.sh
Advertisement
Add Comment
Please, Sign In to add comment