diff --git a/bash_aliases b/bash_aliases index f47193a..2ed255c 100644 --- a/bash_aliases +++ b/bash_aliases @@ -1,30 +1,17 @@ #!/usr/local/bin/zsh - # Aliases -alias adg="workon addgene-core" -alias adocs='cd $ADDGENE_CORE_REPO_DIR/docs && make html && open $ADDGENE_CORE_REPO_DIR/docs/build/html/index.html' -alias aenv='env | sort | grep ADDGENE' alias ag='\ag --pager="less"' +alias cat='bat' alias cg='cd "$(git rev-parse --show-toplevel)"' alias ctags="`brew --prefix`/bin/ctags" alias dots="cd $(dirname `readlink ~/.vim`)" alias g='git' alias gp='git push' -alias pdb="python -m pdb" alias ppjson="python -m json.tool" alias shrug="echo -n '¯\_(ツ)_/¯' | pbcopy" -alias sl="source local.env" -alias stabbats='sudo killall VDCAssistant && open https://appear.in/stab-bats' +alias httpie="http" # Functions -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 cpbr () { if branch=$(git symbolic-ref --short -q HEAD) then @@ -43,9 +30,30 @@ function h () { history | egrep "$@" fi } +settitle() { + printf "\033k$1\033\\" +} + + +tide() { + for var in "$@" + do + tmux new-window -c "/code/tidelift/$var" -n "$var" + printf "\033k$var\033\\" + done + +} # options export LESS=-RFX export PAGER="less" alias love="/Applications/love.app/Contents/MacOS/love" + +pullall (){ + for d in ./*/ ; do (cd "$d" && pwd && git pull); done +} + +new_dock_space (){ + defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'; killall Dock +} diff --git a/bin/SC b/bin/SC index cd83333..9ca96d6 100755 --- a/bin/SC +++ b/bin/SC @@ -2,7 +2,7 @@ set -e FILENAME="/Users/tyrel/tmp/screenshot.png" -screencapture -i $FILENAME +screencapture -io $FILENAME sleep 1 diff --git a/bin/old.py b/bin/old.py new file mode 100644 index 0000000..3974488 --- /dev/null +++ b/bin/old.py @@ -0,0 +1,56 @@ +import os + +def get_ssh_keys(): + key_out = os.popen('ssh-add -l').read() + keylist = key_out.split("\n")[:-1] + keys = [] + for key in keylist: + key = key.split(" ")[2] + keys.append(key) + return keys + + +def _map_list_to_numbers(option): + """Get a dictionary of strings mapping to indexes of the list.""" + enumerated_options = [] + index = 1 + indexMapping = {} + for i, appname in enumerate(option): + enumerated_options.append('{0:3d} - {1}'.format(index, appname)) + indexMapping[str(index)] = i + index += 1 + return indexMapping, "\n".join(enumerated_options) + + +def _keys(): + keys = get_ssh_keys() + if len(keys) == 1: + return keys, None, None + + mapping, key_strings = _map_list_to_numbers(keys) + return keys, mapping, key_strings + + +def _prompt_key(): + """ Prompt for which heroku app, retries if fails""" + + options, mapping, option_strings = _keys() + if not options: + return None + + if len(options) == 1: + print "Using SSH Private Key {0}".format(options[0]) + return options[0] + + print option_strings + while True: + try: + index = raw_input( + "Work with which Private Key? (Type a number) (Ctrl+C to cancel): ").rstrip("\n") + option = options[mapping[index]] + except KeyError: + print "Invalid Option, try again (Ctrl+C to cancel)" + continue + break + return option + diff --git a/bin/pre-commit b/bin/pre-commit new file mode 120000 index 0000000..9e87488 --- /dev/null +++ b/bin/pre-commit @@ -0,0 +1 @@ +/Users/tyrel/.pre-commit-venv/bin/pre-commit \ No newline at end of file diff --git a/bin/startemacs.sh b/bin/startemacs.sh new file mode 100755 index 0000000..dac3447 --- /dev/null +++ b/bin/startemacs.sh @@ -0,0 +1,2 @@ +#!/bin/bash +emacsclient --create-frame --alternate-editor="" diff --git a/bin/upload_and_copy b/bin/upload_and_copy index 4ed8ead..2a7ef17 100755 --- a/bin/upload_and_copy +++ b/bin/upload_and_copy @@ -3,7 +3,7 @@ set -e MD5=($(md5 -q "$@")) fname=$MD5."${1##*.}" -scp -rp "$1" vpsimgs:/var/www/html/screenshots/$fname; +scp -rp "$1" vps:/www/tyrelsouza.com/screenshots/$fname; osascript -e "display notification \"Uploaded $1 to https://tyrelsouza.com/screenshots/$fname\" with title \"Tyrel Upload\"" echo https://tyrelsouza.com/screenshots/$fname | pbcopy rm "$1" diff --git a/gitconfig b/gitconfig index 1ab4e90..3a5283a 100644 --- a/gitconfig +++ b/gitconfig @@ -1,13 +1,12 @@ [core] - excludesfile = ~/.gitignore_global + excludesfile = /Users/tyrel/.gitignore_global [user] email = tyrelsouza@gmail.com name = Tyrel Souza signingkey = C30AEAC0 -[includeIf "gitdir:/code/addgene/"] - path = ~/.gitconfig-addgene [commit] gpgsign = true + template = /Users/tyrel/.stCommitMsg [color] ui = auto # covers diff = true, status = auto, branch = auto interactive = auto @@ -18,42 +17,59 @@ [format] pretty = format:%C(auto)%h %C(green)%G? %C(red)%<(15,trunc)%aN %C(cyan)%<(15,trunc)%ar %C(white)%<(60,trunc)%s %C(auto)%d [alias] + comit = commit 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 + 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" + lf = "!git diff --name-only origin/master" # Show all file differing from origin/master 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 - ob = "!$EDITOR $(git diff --name-only origin/master | grep -v .tsv | grep -v .sql | grep -v static)" - od = "!$EDITOR $(git diff --name-only HEAD | grep -v .tsv | grep -v .sql | grep -v static)" + logtree= "log --graph --oneline --decorate --all" # show a tree with branches merging + ob = "!$EDITOR $(git diff --name-only origin/master)" # Open all files in editor that differ between origin/master and staged/unstaged + oscar = "!git commit --amend --author='Oscar Spencer '" + od = "!$EDITOR $(git diff --name-only HEAD)" # Open all changed files differ from current HEAD 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 + 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 v=describe --tags --match 'v*' # show the current version tag + + # rd = !git diff $(git describe --tags --abbrev=0 --match v*) + # rl = !git log $(git describe --tags --abbrev=0 --match v*).. + # pr = !"pr() { git fetch origin pull/$1/head:pr-$1; git checkout pr-$1; }; pr" + # dsf = "!f() { [ \"$GIT_PREFIX\" != \"\" ] && cd "$GIT_PREFIX"; git diff --color $@ | diff-so-fancy | less --tabs=4 -RFX; }; f" # Diff so fancy! [filter "lfs"] clean = git-lfs clean %f smudge = git-lfs smudge %f required = true [color "diff-highlight"] - oldNormal = red bold - oldHighlight = red bold 52 - newNormal = green bold - newHighlight = green bold 22 + oldNormal = red bold + oldHighlight = red bold 52 + newNormal = green bold + newHighlight = green bold 22 [init] - templatedir = ~/.git_template + templatedir = ~/.git_template [difftool "sourcetree"] cmd = opendiff \"$LOCAL\" \"$REMOTE\" path = [mergetool "sourcetree"] - cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\" + cmd = /Applications/Sourcetree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\" trustExitCode = true +[diff] + tool = meld +[difftool] + prompt = false +[difftool "meld"] + trustExitCode = true + cmd = open -W -a Meld --args \"$LOCAL\" \"$REMOTE\" +[merge] + tool = meld +[mergetool] + prompt = false +[mergetool "meld"] + trustExitCode = true + cmd = open -W -a Meld --args --auto-merge \"$LOCAL\" \"$BASE\" \"$REMOTE\" --output=\"$MERGED\" diff --git a/gitignore b/gitignore index 626be82..0c9b301 100644 --- a/gitignore +++ b/gitignore @@ -1,3 +1,4 @@ +.idea *.DS_Store .tags .tags_sorted* @@ -15,3 +16,4 @@ release_package.sh local.fish local.env vim/sessions +.vs/ diff --git a/tmux.conf b/tmux.conf index c3ed830..f1a2c64 100644 --- a/tmux.conf +++ b/tmux.conf @@ -4,6 +4,7 @@ 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' +set -g @plugin 'tmux-plugins/tmux-continuum' # Configs @@ -19,3 +20,15 @@ set -g @batt_attached_icon "😐" # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) run '~/.tmux/plugins/tpm/tpm' + +bind '"' split-window -c "#{pane_current_path}" +bind % split-window -h -c "#{pane_current_path}" +bind c new-window -c "#{pane_current_path}" +bind | split-window -h -c "#{pane_current_path}"# Split panes horizontal +bind - split-window -v -c "#{pane_current_path}"# Split panes vertically + +set -g @continuum-restore 'on' + +set-option -g default-command "reattach-to-user-namespace -l zsh" +set-option -g set-titles on + diff --git a/tmux/plugins/tmux-continuum b/tmux/plugins/tmux-continuum new file mode 160000 index 0000000..90f4a00 --- /dev/null +++ b/tmux/plugins/tmux-continuum @@ -0,0 +1 @@ +Subproject commit 90f4a00c41de094864dd4e29231253bcd80d4409 diff --git a/tmux/plugins/tmux-sensible b/tmux/plugins/tmux-sensible index 526110e..e91b178 160000 --- a/tmux/plugins/tmux-sensible +++ b/tmux/plugins/tmux-sensible @@ -1 +1 @@ -Subproject commit 526110eb9b60825d3276afba97ffa4cedb4b0ab9 +Subproject commit e91b178ff832b7bcbbf4d99d9f467f63fd1b76b5 diff --git a/tmux/plugins/tpm b/tmux/plugins/tpm index c8ac32a..95f7833 160000 --- a/tmux/plugins/tpm +++ b/tmux/plugins/tpm @@ -1 +1 @@ -Subproject commit c8ac32a085d382c43190bda4fb5972e531f501fd +Subproject commit 95f78336c3972f3e6648b7b3db754f2224320a5e diff --git a/zpreztorc b/zpreztorc index daee4d9..65c0f27 100644 --- a/zpreztorc +++ b/zpreztorc @@ -8,6 +8,7 @@ zstyle ':prezto:load' pmodule \ 'utility' \ 'completion' \ 'git' \ + 'ruby' \ 'prompt' \ 'tmux' diff --git a/zprofile.local b/zprofile.local new file mode 100644 index 0000000..e69de29 diff --git a/zshrc b/zshrc index f273caf..eb9cdc5 100644 --- a/zshrc +++ b/zshrc @@ -4,3 +4,42 @@ fi source ~/.zshrc.local + +# Add RVM to PATH for scripting. Make sure this is the last PATH variable change. +export EDITOR="vim" +eval "$(direnv hook zsh)" +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm + + +autoload -U add-zsh-hook +load-nvmrc() { + local node_version="$(nvm version)" + local nvmrc_path="$(nvm_find_nvmrc)" + + if [ -n "$nvmrc_path" ]; then + local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")") + + if [ "$nvmrc_node_version" = "N/A" ]; then + nvm install + elif [ "$nvmrc_node_version" != "$node_version" ]; then + nvm use + fi + elif [ "$node_version" != "$(nvm version default)" ]; then + echo "Reverting to nvm default version" + nvm use default + fi +} +add-zsh-hook chpwd load-nvmrc +load-nvmrc + +[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh +eval "$(pyenv init -)" + +export PATH="$HOME/.rvm/bin:$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" + +# The next line updates PATH for the Google Cloud SDK. +if [ -f '/Users/tyrel/Downloads/google-cloud-sdk/path.zsh.inc' ]; then . '/Users/tyrel/Downloads/google-cloud-sdk/path.zsh.inc'; fi + +# The next line enables shell command completion for gcloud. +if [ -f '/Users/tyrel/Downloads/google-cloud-sdk/completion.zsh.inc' ]; then . '/Users/tyrel/Downloads/google-cloud-sdk/completion.zsh.inc'; fi diff --git a/zshrc.local b/zshrc.local index 6c2efc5..89c8302 100644 --- a/zshrc.local +++ b/zshrc.local @@ -21,7 +21,7 @@ export PYTHONSTARTUP=$HOME/.pythonstartup.py # Node stuff export NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH" export NPM_PACKAGES="${HOME}/.npm-packages" -export PATH="$NPM_PACKAGES/bin:$GOPATH/bin:$HOME/bin:$PATH" +export PATH="$HOME/bin:$PATH" export PATH="/usr/local/opt/python/libexec/bin:$PATH" # Go Stuff @@ -45,3 +45,9 @@ fi source ~/.bash_aliases unsetopt share_history export PATH=/usr/local/bin:$PATH + +# The next line updates PATH for the Google Cloud SDK. +if [ -f '/Users/tyrel/Downloads/google-cloud-sdk/path.zsh.inc' ]; then source '/Users/tyrel/Downloads/google-cloud-sdk/path.zsh.inc'; fi + +# The next line enables shell command completion for gcloud. +if [ -f '/Users/tyrel/Downloads/google-cloud-sdk/completion.zsh.inc' ]; then source '/Users/tyrel/Downloads/google-cloud-sdk/completion.zsh.inc'; fi