Skip to content

Instantly share code, notes, and snippets.

@azam
Last active January 5, 2017 03:12
Show Gist options
  • Select an option

  • Save azam/5898a0ae791e3686dbab3da4d35e59b9 to your computer and use it in GitHub Desktop.

Select an option

Save azam/5898a0ae791e3686dbab3da4d35e59b9 to your computer and use it in GitHub Desktop.

Revisions

  1. azam revised this gist Jan 5, 2017. 1 changed file with 76 additions and 0 deletions.
    76 changes: 76 additions & 0 deletions .profile
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,79 @@
    ### prep a dir for git with github sane defaults
    ### usage: gitprep ulidj azam/ulidj
    gitprep() {
    if [ -z "$2" ]
    then
    echo "gitprep: illegal arguments"
    echo "usage: gitprep [dirname] [reponame]"
    return -1
    else
    mkdir $1
    cd $1
    git init
    git config user.name "azam"
    git config user.email "[email protected]"
    git config push.default simple
    git config core.precomposeunicode true
    git remote add origin [email protected]:$2
    git remote update
    return 0
    fi
    }

    ### Generate 16 random alphanumeric chars
    ### Usage: randpass
    randpass() {
    cat /dev/urandom | env LC_CTYPE=C tr -dc "a-zA-Z0-9" | head -c 16
    echo
    return 0
    }

    ### Runs command for n times asynchronously
    ### Usage: runasync N my command here
    runasync() {
    local n=$1
    shift
    for i in `seq $n`; do
    nohup $@ &> nohup.out.$i &
    done
    }

    ### Runs command for n times synchronously
    ### Usage: run N my command here
    run() {
    local n=$1
    shift
    for i in `seq $n`; do
    $@
    done
    }

    ### Zip all files and directories in current directory in separate zip files
    ### Usage: zipall
    zipall() {
    for i in */; do zip -r "${i%/}.zip" "$i"; done
    }

    ### Zip all files and directories in current directory in one file
    ### Usage: zd .
    zd() {
    zip -r "$1.zip" "$1"
    }

    ### Watch a directory for changes and echo the changed file
    ### Usage: watch . 3
    watch() {
    local interval=$2
    while [[ true ]]
    do
    local files=`find $1 -type f -mtime -${interval}s`
    if [$files != ""] ; then
    echo $files
    fi
    sleep $interval
    done
    }

    ### Useful settings
    export PS1="\D{%T} \W$ "
    alias ll="ls -alG"
  2. azam created this gist Jan 5, 2017.
    30 changes: 30 additions & 0 deletions .profile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    ### Useful settings
    export PS1="\D{%T} \W$ "
    alias ll="ls -alG"
    alias mroe=more
    alias flushdns="sudo killall -HUP mDNSResponder"
    alias servehere="python -c 'import BaseHTTPServer as bhs, SimpleHTTPServer as shs; bhs.HTTPServer((\"0.0.0.0\", 8888), shs.SimpleHTTPRequestHandler).serve_forever()'"
    alias genkey="ssh-keygen -t rsa -N '' -f"
    alias lslisten="lsof -P -iTCP -sTCP:LISTEN"
    alias lsports="sudo lsof -iTCP -sTCP:LISTEN -n -P"
    alias grepjava="grep -R --include=*.java"
    alias grepjs="grep -R --include=*.js"
    alias grepxml="grep -R --include=*.xml"

    ### Java
    export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)

    ### NPM
    export PATH=$PATH:./node_modules/.bin

    ### Rust
    export PATH="$HOME/.cargo/bin:$PATH"
    export RUST_SRC_PATH="$HOME/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/src"

    ### Helper for macOS apps
    __APPPATHS=("ce:CotEditor" "st:Sublime\ Text" "vsc:Visual\ Studio\ Code")
    for __apppath in "${__APPPATHS[@]}" ; do
    __alias=${__apppath%%:*}
    __path=${__apppath#*:}
    alias $__alias="open -a /Applications/$__path.app"
    done