Skip to content

Instantly share code, notes, and snippets.

@seperman
Last active April 21, 2017 06:45
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 seperman/9746307 to your computer and use it in GitHub Desktop.
Save seperman/9746307 to your computer and use it in GitHub Desktop.
mac bash profile
alias ll="ls -lah";
alias chrome="open /Applications/Google\ Chrome.app";
alias firefox="open -a Firefox.app";
alias ssh_box="source ~/useful_shell_scripts/ssh_box.sh"
alias kcachegrind="open /Applications/qcachegrind.app";
alias fix_office_borders="~/useful_shell_scripts/fix_office_borders.py";
alias tree="find . -not -name '*.pyc' -not -name '*.pyo' -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'";
alias dsize="du -ch -d 1 2>/dev/null";
alias dsize2="du -ch | tail -n 10";
export CLICOLOR=1;
export LSCOLORS=exfxcxdxbxegedabagacad;
export PATH=/usr/local/share/python:$PATH
source ~/useful_shell_scripts/copyx.sh
#Git branch in prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
current_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
export PS1="\[\033[01;36m\]\u\[\033[01;31m\]@\[\033[01;36m\]\h\[\033[01;33m\]:\[\033[01;31m\]\w\[\033[01;33m\]\[\033[32m\]\$(parse_git_branch)\[\033[00m\]\$ "
if test -f "/usr/local/bin/virtualenvwrapper.sh"; then source "/usr/local/bin/virtualenvwrapper.sh";fi
function list_links () {
for thing in `find . -type l 2>/dev/null`; do
echo $thing "-->" `readlink $thing`
done
}
function findit () {
find . -iname "*$1*" 2>/dev/null
}
function mark2htm () {
fullpath="$1"
filename=$(basename "$1")
extension="${filename##*.}"
filename="${filename%.*}"
output="${fullpath%.*}"
pandoc "$fullpath" -o "$output".html --standalone -c ../markdown/GitHub2.css --toc --variable=pagetitle:"$filename" -t html5
}
function gitreset () {
git fetch origin
git reset --hard origin/$(parse_git_branch)
}
function gitfile(){
git log --follow -p -- "$1"
}
function gitpull () {
git pull origin $(parse_git_branch)
}
function gitpush () {
git push origin $(parse_git_branch) --recurse-submodules=check
}
function gits(){
git status
}
function gitc(){
git commit -av
}
function gita(){
git add -A
}
function ports(){
cat << EOF
-------- lsof --------
- All connections
lsof -i
- All tcp connections
lsof -iTCP
- All processes listening to ports on TCP (+port number):
lsof -iTCP -sTCP:LISTEN -P
- All processes listening to ports on TCP (+process name):
lsof -iTCP -sTCP:LISTEN -n
- All connections to a specific host
lsof -i@172.16.12.5
lsof -i@172.16.12.5:22
- All established connections
lsof -i -sTCP:ESTABLISHED
- process that listens to specific port
lsof -i:8000
- what a given process ID has open
lsof -p [pid]
-------- Netcat --------
Linux: netcat, Mac: nc
- Make a server listening to port
netcat -l 0.0.0.0 8089
netcat -l localhost 8089
- Connect to a port
netcat 0.0.0.0 8089
EOF
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment