From 4e0b364555813e8673417594f4212e5fc2fd29dc Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Wed, 16 Aug 2017 09:50:12 -0400 Subject: [PATCH] Update dotfiles for new macbook --- bin/archive_git.sh | 7 --- bin/last_status.py | 70 ++++++++++++++++++++++++ bin/packages/homebrew.txt | 3 +- bin/wha.scpt | 1 - git_template/hooks/post-checkout | 6 +-- git_template/hooks/post-merge | 6 +-- git_template/hooks/pre-push | 30 +++++------ gitconfig | 8 ++- tmux.conf | 10 +--- tmux/plugins/tmux-battery | 2 +- vimrc | 2 + zpreztorc | 5 +- zshrc | 92 ++------------------------------ zshrc.local | 3 ++ 14 files changed, 113 insertions(+), 132 deletions(-) delete mode 100755 bin/archive_git.sh create mode 100644 bin/last_status.py delete mode 100755 bin/wha.scpt diff --git a/bin/archive_git.sh b/bin/archive_git.sh deleted file mode 100755 index e752609..0000000 --- a/bin/archive_git.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -git checkout $1 -git tag archive/$1 $1 -git push origin --tags -git checkout - -git branch -D $1 -git push origin :$1 diff --git a/bin/last_status.py b/bin/last_status.py new file mode 100644 index 0000000..12639c1 --- /dev/null +++ b/bin/last_status.py @@ -0,0 +1,70 @@ +import argparse +import json +import os +import pylast +from slacker import Slacker +from sys import platform as _platform +import time + + +LASTFM_USER= os.environ['LASTFM_USER'] +LASTFM_API_KEY = os.environ['LASTFM_API_KEY'] +LASTFM_API_SECRET = os.environ['LASTFM_API_SECRET'] +SLACK_OAUTH_TOKEN = os.environ['SLACK_OAUTH_TOKEN'] + +# You have to have your own unique two values for API_KEY and API_SECRET +# Obtain yours from http://www.last.fm/api/account/create for Last.fm +SESSION_KEY_FILE = os.path.join(os.path.expanduser("~"), ".lastfm_session_key") + +def set_status(text, emoji=''): + for token in SLACK_OAUTH_TOKEN.split(" "): + slack = Slacker(token) + # print slack.users.profile.get() + status = json.dumps({'status_text':text, u'status_emoji':emoji}) + # print status + slack.users.profile.set(profile=status) + +def get_session_key(): + if not os.path.exists(SESSION_KEY_FILE): + skg = pylast.SessionKeyGenerator(network) + url = skg.get_web_auth_url() + + print( + "Please authorize the scrobbler " + "to scrobble to your account: %s\n" % url) + import webbrowser + webbrowser.open(url) + + while True: + try: + session_key = skg.get_web_auth_session_key(url) + fp = open(SESSION_KEY_FILE, "w") + fp.write(session_key) + fp.close() + break + except pylast.WSError: + time.sleep(1) + else: + session_key = open(SESSION_KEY_FILE).read() + return session_key + + +if __name__ == '__main__': + network = pylast.LastFMNetwork(LASTFM_API_KEY, LASTFM_API_SECRET) + + network.session_key = get_session_key() + user = network.get_user(LASTFM_USER) + playing_track = None + + try: + new_track = user.get_now_playing() + title = new_track.get_title() + artist = new_track.get_artist().name + text = "{}: {}".format(artist, title) + print(text) + + set_status(text, ':musical_note:') + + except Exception as e: + print(e) + set_status('', '') diff --git a/bin/packages/homebrew.txt b/bin/packages/homebrew.txt index 617a718..fa2c3d7 100644 --- a/bin/packages/homebrew.txt +++ b/bin/packages/homebrew.txt @@ -7,7 +7,7 @@ gnu-sed graphviz homebrew/versions/gnupg21 htop-osx -mariadb +mariadb@10.1 mtr nmap openssl @@ -20,3 +20,4 @@ vim watch wget zsh-completions +diff-so-fancy diff --git a/bin/wha.scpt b/bin/wha.scpt deleted file mode 100755 index 573191b..0000000 --- a/bin/wha.scpt +++ /dev/null @@ -1 +0,0 @@ -display notification \"Your free upgrade to Windows 10 is ready. Please click here to start the download.\" with title \"Microsoft\" diff --git a/git_template/hooks/post-checkout b/git_template/hooks/post-checkout index 50a0859..0b12578 100755 --- a/git_template/hooks/post-checkout +++ b/git_template/hooks/post-checkout @@ -1,4 +1,4 @@ #!/bin/bash -if [ -e bin/update_dependencies.sh ]; then - bin/update_dependencies.sh -fi +#if [ -e bin/update_dependencies.sh ]; then +# bin/update_dependencies.sh +#fi diff --git a/git_template/hooks/post-merge b/git_template/hooks/post-merge index 50a0859..0b12578 100755 --- a/git_template/hooks/post-merge +++ b/git_template/hooks/post-merge @@ -1,4 +1,4 @@ #!/bin/bash -if [ -e bin/update_dependencies.sh ]; then - bin/update_dependencies.sh -fi +#if [ -e bin/update_dependencies.sh ]; then +# bin/update_dependencies.sh +#fi diff --git a/git_template/hooks/pre-push b/git_template/hooks/pre-push index 2726a73..b8970e8 100755 --- a/git_template/hooks/pre-push +++ b/git_template/hooks/pre-push @@ -1,17 +1,17 @@ #!/bin/bash -protected_branch='master' -current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') - -if [ $protected_branch = $current_branch ] -then - read -p "You're about to push master, is that what you intended? [y|n] " -n 1 -r < /dev/tty - echo - if echo $REPLY | grep -E '^[Yy]$' > /dev/null - then - exit 0 # push will execute - fi - exit 1 # push will not execute -else - exit 0 # push will execute -fi +#protected_branch='master' +#current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') +# +#if [[ $current_branch = *"$protected_branch"* ]] +#then +# read -p "You're about to push $current_branch, is that what you intended? [y|n] " -n 1 -r < /dev/tty +# echo +# if echo $REPLY | grep -E '^[Yy]$' > /dev/null +# then +# exit 0 # push will execute +# fi +# exit 1 # push will not execute +#else +# exit 0 # push will execute +#fi diff --git a/gitconfig b/gitconfig index 4f82ff7..1ab4e90 100644 --- a/gitconfig +++ b/gitconfig @@ -3,7 +3,9 @@ [user] email = tyrelsouza@gmail.com name = Tyrel Souza - signingkey = 8A2DDEE2 + signingkey = C30AEAC0 +[includeIf "gitdir:/code/addgene/"] + path = ~/.gitconfig-addgene [commit] gpgsign = true [color] @@ -19,9 +21,11 @@ ab = "diff --name-only origin/master" alias = "!git config -l | grep alias | cut -c 7-" # show all these aliases bc = !git branch --merged master | grep -v master | xargs git branch -d # delete all merged branches + bcc = !git branch -vv | grep ': gone' | cut -d' ' -f1-3 | grep -v master | xargs git branch -D d = diff --color-words # prettier diffs dsf = "!f() { [ \"$GIT_PREFIX\" != \"\" ] && cd "$GIT_PREFIX"; git diff --color $@ | diff-so-fancy | less --tabs=4 -RFX; }; f" # Diff so fancy! files = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat # Show files modified per commit + lf = "!git diff --name-only origin/master | grep -v .tsv | grep -v .sql" ll = log --stat --abbrev-commit # Way more information on git log lb = log --stat --no-merges origin/master.. logtree= "log --graph --oneline --decorate --all" # show a tree with branches merging @@ -30,6 +34,8 @@ p = push pr = !"pr() { git fetch origin pull/$1/head:pr-$1; git checkout pr-$1; }; pr" recent = "!git for-each-ref --format=\"%(committerdate:relative) | %(refname)\" --sort=-committerdate refs/heads | sed '/master/d' | head -n 15" # get the most 10 recent branches worked on + rd = !git diff $(git describe --tags --abbrev=0 --match v*) + rl = !git log $(git describe --tags --abbrev=0 --match v*).. scrum = log --since='1 day ago' --author='Tyrel Souza' --oneline st = status # alias like `hg st`, because I like st, shorter is nice! tabs = "!git diff --color | sed 's/\t/⌑/g'" # show tabs with ⌑ replacing tabs diff --git a/tmux.conf b/tmux.conf index a6eb8be..c3ed830 100644 --- a/tmux.conf +++ b/tmux.conf @@ -3,18 +3,12 @@ set -g @plugin 'tmux-plugins/tpm' set -g @plugin 'tmux-plugins/tmux-sensible' set -g @plugin 'jimeh/tmux-themepack' set -g @plugin 'tmux-plugins/tmux-battery' +set -g @plugin 'tmux-plugins/tmux-ressurect' # Configs set -g @themepack 'powerline/double/cyan' -# Other examples: -# set -g @plugin 'github_username/plugin_name' -# set -g @plugin 'git@github.com/user/plugin' -# set -g @plugin 'git@bitbucket.com/user/plugin' - - - set -g status-right '#{battery_status_bg} Batt: #{battery_icon} #{battery_percentage} #{battery_remain} | %a %h-%d %H:%M ' set -g @batt_charged_icon "😎" @@ -23,7 +17,5 @@ set -g @batt_discharging_icon "👎" set -g @batt_attached_icon "😐" - - # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) run '~/.tmux/plugins/tpm/tpm' diff --git a/tmux/plugins/tmux-battery b/tmux/plugins/tmux-battery index 9a4e6ef..8fa3b62 160000 --- a/tmux/plugins/tmux-battery +++ b/tmux/plugins/tmux-battery @@ -1 +1 @@ -Subproject commit 9a4e6ef8e467a1f78aa881018f5ed4efca88f6ef +Subproject commit 8fa3b627b6acc8fb2560b843c47927514bc5fa1d diff --git a/vimrc b/vimrc index 61ce780..7a2cac6 100644 --- a/vimrc +++ b/vimrc @@ -162,3 +162,5 @@ let g:session_autoload = 'no' let g:airline#extensions#tabline#fnamemod = ':.' let g:ctrlp_working_path_mode = 0 let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|git|.pyc' + +set timeoutlen=100 ttimeoutlen=10 diff --git a/zpreztorc b/zpreztorc index 58686ff..310f353 100644 --- a/zpreztorc +++ b/zpreztorc @@ -7,9 +7,10 @@ zstyle ':prezto:load' pmodule \ 'history-substring-search' \ 'utility' \ 'completion' \ - 'tmux' \ 'git' \ - 'prompt' + 'python' \ + 'prompt' \ + 'tmux' zstyle ':prezto:module:autosuggestions:color' found '' zstyle ':prezto:module:editor' key-bindings 'emacs' diff --git a/zshrc b/zshrc index 331ecc5..f273caf 100644 --- a/zshrc +++ b/zshrc @@ -1,92 +1,6 @@ -export ZSH=$HOME/.oh-my-zsh -plugins=(git sudo github django python pip cp vagrant virtualenv nmap rvm) -if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then - ZSH_THEME="soliah" -else - ZSH_THEME="tyrel" - export VIRTUAL_ENV_DISABLE_PROMPT=1 +if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then + source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" fi -export EDITOR=vim -export GOPATH=$HOME/go -export LANG=en_US.UTF-8 -export LC_ALL=en_US.UTF-8 -export LESS=' -R ' -export LESSOPEN="| /usr/local/bin/src-hilite-lesspipe.sh %s" -export NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH" -export NPM_PACKAGES="${HOME}/.npm-packages" -export PHP_AUTOCONF="/usr/local/bin/autoconf" +source ~/.zshrc.local -# Virtualenv + Wrapper -export PROJECT_HOME=$HOME/AddGeneProjects -export WORKON_HOME=$HOME/.virtualenvs -if [ -e $HOME/.local/bin/virtualenvwrapper.sh ];then - source $HOME/.local/bin/virtualenvwrapper.sh -fi -if [ -e /usr/local/bin/virtualenvwrapper.sh ]; then - source /usr/local/bin/virtualenvwrapper.sh -fi - - -export PATH="$NPM_PACKAGES/bin:$GOPATH/bin:$HOME/bin:$PATH" -if [[ $OSTYPE == "*darwin*" ]];then - export PATH="/usr/local/opt/gnupg/libexec/gpgbin:$PATH" -fi - - - -# -if [ -z "$SSH_AUTH_SOCK" ] ; then - eval `ssh-agent -s` - ssh-add ~/.ssh/id_rsa -fi -# -if [ -e ~/.ssh/id_addgene ];then - ssh-add ~/.ssh/id_addgene -fi - - -export MP_FULLNAME="Tyrel Souza" - -function adg () { - workon addgene-core -} -function ipa(){ - ifconfig | grep inet -} -function cpbr () { - if branch=$(git symbolic-ref --short -q HEAD) - then - printf "$branch" | pbcopy - osascript -e "display notification \"$branch copied to clipboard\" with title \"cpbr\"" - else - echo "no branch, can't copy" - fi -} -function hidden() { ls -a "$@" | grep '^\.'; } - -if [ -e ~/.zshrc.local ];then - source ~/.zshrc.local -fi - -# Sourcing aliases -source ~/.bash_aliases -source $HOME/.profile -if [ -e $HOME/.credentials ];then - source $HOME/.credentials -fi -export PYTHONSTARTUP=$HOME/.pythonstartup.py - -function adtest () { - no_slashes="$(echo "$1" | sed -e 's/\//\./g')"; - a_test="$(echo "$no_slashes" | sed -e 's/.py//g')"; - a_project=$(echo -n "$a_test" | python -c "import sys; print sys.stdin.read().split('.', 1)[0]"); - run_test=$(echo "bin/manage_$a_project.py test $a_test"); - echo "Evaling $run_test"; - eval $run_test; -} - -function dots(){ - cd $(dirname `readlink ~/.zshrc`) -} -eval "$(pyenv init -)" diff --git a/zshrc.local b/zshrc.local index 56359d3..c225761 100644 --- a/zshrc.local +++ b/zshrc.local @@ -34,6 +34,9 @@ if [[ $OSTYPE == "darwin*" ]];then export LDFLAGS="-L/usr/local/opt/icu4c/lib" export CPPFLAGS="-I/usr/local/opt/icu4c/include" export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig" + #LDFLAGS: -L/usr/local/opt/mariadb@10.1/lib + #CPPFLAGS: -I/usr/local/opt/mariadb@10.1/include + #PKG_CONFIG_PATH: /usr/local/opt/mariadb@10.1/share/pkgconfig fi export PATH="$HOME/.Pokemon-Terminal:$PATH"