diff --git a/bash_profile b/bash_profile index f8785e4..9be1e90 100644 --- a/bash_profile +++ b/bash_profile @@ -33,49 +33,9 @@ shopt -s cmdhist export HISTCONTROL=ignoredups export HISTIGNORE="&:ls:[bf]g:exit" -function local_pi() { -LOCAL_PI_IP=$(en4ip) -ssh -b $LOCAL_PI_IP pi@169.254.100.100 -} - -#################### Project Initialization Tools ################### -function download_bootstrap() { - mkdir -p static - mkdir -p static/css - mkdir -p static/js - - cd static/css - wget "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" - cd ../ - cd js - wget "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" - cd ../.. -} - -function init_flask() { - mkdir -p templates - touch templates/index.html - curl "https://raw.githubusercontent.com/lewagon/bootstrap-boilerplate/gh-pages/index.html" > templates/index.html - FLASK_TEMPLATE="from flask import Flask, render_template, request - -app = Flask(__name__) - -@app.route('/') -def index(): - return render_template('index.html') - -if __name__ == '__main__': - app.debug = True - app.run() -" - echo "$FLASK_TEMPLATE" > app.py -} - -function weather() { - LOCATION=milwaukee - - curl wttr.in/$LOCATION -} +if [ -f ~/.common_shell_functions ]; then + . ~/.common_shell_functions +fi #Enable ~/.ssh/config host tab completion _complete_ssh_hosts () diff --git a/common_shell_functions b/common_shell_functions new file mode 100644 index 0000000..2b3e1e5 --- /dev/null +++ b/common_shell_functions @@ -0,0 +1,72 @@ +################################################################### +# This file is for shell functions common between shells: zsh, bash +################################################################### + +function local_pi() { +LOCAL_PI_IP=$(en4ip) +ssh -b $LOCAL_PI_IP pi@169.254.100.100 +} + +function pubkey() { + if [ -f ~/.ssh/id_rsa.pub ]; then + if which pbcopy &> /dev/null; then + cat ~/.ssh/id_rsa.pub | pbcopy + echo "Copied public key using pbcopy" + else + echo "pbcopy not available - printing public key" + echo + cat ~/.ssh/id_rsa.pub + fi + fi +} + +function pwgen() { + if [ -f ~/.dotfile_util/pwgen.py ]; then + if which python &> /dev/null; then + ~/.dotfile_util/pwgen.py 4 + else + echo "Need python for pwgen" + fi + else + echo "Could not find ~/.dotfile_util/pwgen.py" + fi +} + +#################### Project Initialization Tools ################### +function download_bootstrap() { + mkdir -p static + mkdir -p static/css + mkdir -p static/js + + cd static/css + wget "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" + cd ../ + cd js + wget "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" + cd ../.. +} + +function init_flask() { + mkdir -p templates + touch templates/index.html + curl "https://raw.githubusercontent.com/lewagon/bootstrap-boilerplate/gh-pages/index.html" > templates/index.html + FLASK_TEMPLATE="from flask import Flask, render_template, request + +app = Flask(__name__) + +@app.route('/') +def index(): + return render_template('index.html') + +if __name__ == '__main__': + app.debug = True + app.run() +" + echo "$FLASK_TEMPLATE" > app.py +} + +function weather() { + LOCATION=milwaukee + + curl wttr.in/$LOCATION +} diff --git a/dictionary.txt.gz b/dictionary.txt.gz new file mode 100644 index 0000000..7b122a0 Binary files /dev/null and b/dictionary.txt.gz differ diff --git a/install.conf.yaml b/install.conf.yaml index a0fa467..1fe3dfd 100644 --- a/install.conf.yaml +++ b/install.conf.yaml @@ -7,6 +7,7 @@ - link: ~/.dotfiles: '' ~/.vim: vim + ~/.dotfile_util: util ~/.vimrc: vimrc ~/.vimrc_vundle: vimrc_vundle ~/.zpreztorc: zpreztorc @@ -16,6 +17,8 @@ ~/.bash_prompt: bash_prompt ~/.git_prompt.sh: git_prompt.sh ~/.git-completion.bash: git-completion.bash + ~/.dictionary.txt.gz: dictionary.txt.gz + ~/.common_shell_functions: common_shell_functions - shell: - [git submodule update --init --recursive, Installing submodules] diff --git a/util/pwgen.py b/util/pwgen.py new file mode 100755 index 0000000..4b58a81 --- /dev/null +++ b/util/pwgen.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +import sys +import os +import gzip +import random + +if __name__ == "__main__": + if len(sys.argv) > 1: + word_length = int(sys.argv[1]) + else: + word_length = 3 + + dictfile = os.path.expanduser('~/.dictionary.txt.gz') + with gzip.open(dictfile) as f: + lines = f.readlines() + rand_engine = random.SystemRandom() + result = '' + words = [] + for _ in range(0, word_length): + word = rand_engine.choice(lines).strip().decode() + while len(word) > 10: + word = rand_engine.choice(lines).strip().decode() + result += word + words.append(word) + print(result) + print("From words: {}".format(', '.join(words))) diff --git a/zshrc b/zshrc index a034e55..01cdc64 100644 --- a/zshrc +++ b/zshrc @@ -49,46 +49,6 @@ alias vi='vim' #alias en4ip="ifconfig | grep -A1 en4 | tail -n1 | awk 'BEGIN { FS=\" \" }; {print \$2}'" alias en4ip="ifconfig | grep -Eo '169.254.\d{1,3}.\d{1,3}' | head -n1" -function local_pi() { -LOCAL_PI_IP=$(en4ip) -ssh -b $LOCAL_PI_IP pi@169.254.100.100 -} - -#################### Project Initialization Tools ################### -function download_bootstrap() { - mkdir -p static - mkdir -p static/css - mkdir -p static/js - - cd static/css - wget "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" - cd ../ - cd js - wget "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" - cd ../.. -} - -function init_flask() { - mkdir -p templates - touch templates/index.html - curl "https://raw.githubusercontent.com/lewagon/bootstrap-boilerplate/gh-pages/index.html" > templates/index.html - FLASK_TEMPLATE="from flask import Flask, render_template, request - -app = Flask(__name__) - -@app.route('/') -def index(): - return render_template('index.html') - -if __name__ == '__main__': - app.debug = True - app.run() -" - echo "$FLASK_TEMPLATE" > app.py -} - -function weather() { - LOCATION=milwaukee - - curl wttr.in/$LOCATION -} +if [ -f ~/.common_shell_functions ]; then + . ~/.common_shell_functions +fi