Completely reset dotfiles (#2)
This commit is contained in:
parent
4abd1a6ffc
commit
bf26003ab3
38 changed files with 305 additions and 1101 deletions
|
@ -1,2 +0,0 @@
|
|||
alias google-chrome="open -a Google\ Chrome"
|
||||
alias fixbar="killall ControlStrip"
|
32
zsh/.config/zsh/.zshrc
Normal file
32
zsh/.config/zsh/.zshrc
Normal file
|
@ -0,0 +1,32 @@
|
|||
typeset -U PATH
|
||||
|
||||
source $ZDOTDIR/aliases
|
||||
source $ZDOTDIR/functions
|
||||
|
||||
source $ZDOTDIR/prompt
|
||||
|
||||
# Larger history
|
||||
HISTSIZE=20000
|
||||
HISTFILE=~/.zsh_history
|
||||
SAVEHIST=20000
|
||||
|
||||
# be like vim
|
||||
bindkey -v
|
||||
|
||||
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
|
||||
|
||||
setopt auto_cd
|
||||
|
||||
if which direnv > /dev/null; then
|
||||
eval "$(direnv hook zsh)"
|
||||
fi
|
||||
|
||||
if which rbenv > /dev/null; then
|
||||
eval "$(rbenv init --no-rehash -)"
|
||||
(rbenv rehash &) 2> /dev/null
|
||||
fi
|
||||
|
||||
if which nodenv > /dev/null; then
|
||||
eval "$(nodenv init --no-rehash -)"
|
||||
(nodenv rehash &) 2> /dev/null
|
||||
fi
|
|
@ -1,9 +1,4 @@
|
|||
alias zbm="/usr/bin/time zsh -i -c exit"
|
||||
|
||||
alias ..="cd .."
|
||||
alias ...="cd ../.."
|
||||
alias ....="cd ../../.."
|
||||
alias .....="cd ../../../.."
|
||||
alias a="ls -l --human-readable --all --color=auto"
|
||||
alias agc="ag-count"
|
||||
alias agh="ag --hidden"
|
||||
|
@ -14,21 +9,16 @@ alias be="bundle exec"
|
|||
alias bea="bundle exec rails"
|
||||
alias ber="bundle exec rake"
|
||||
alias bet="test-rails"
|
||||
alias betd="bundle exec rspec --format documentation"
|
||||
alias c="clear"
|
||||
alias dc="docker compose"
|
||||
alias dft="docker run --rm --privileged alpine hwclock -s"
|
||||
alias g="g" # overwrite g alias in git plugin so function will work
|
||||
alias cs="toggle-color-mode"
|
||||
alias dc="docker-compose-call"
|
||||
alias g="g" # overwrite g alias
|
||||
alias ga="git add"
|
||||
alias gaa="git add --all"
|
||||
alias gap="git add --patch"
|
||||
alias gb="git branch"
|
||||
alias gbc="git-branch-cleanup"
|
||||
alias gbda="git branch | grep -v master | xargs git branch -D"
|
||||
alias gbdm="git-branch-delete-merged"
|
||||
alias gc="git commit"
|
||||
alias gca="git commit --amend"
|
||||
alias gcm="echo Do not specify message at command line. Use gc"
|
||||
alias gcn="git commit --allow-empty --message 'noop'"
|
||||
alias gco="git checkout"
|
||||
alias gcp="git cherry-pick"
|
||||
|
@ -37,11 +27,7 @@ alias gct="git commit -m '( ͡° ͜ʖ ͡°)'"
|
|||
alias gd="git diff"
|
||||
alias gdc="git diff --cached"
|
||||
alias gds="git diff --stat"
|
||||
alias gdss="git diff --shortstat"
|
||||
alias gfa="git-date-added"
|
||||
alias gfl="git log --patch"
|
||||
alias gg="hub gist create --browse"
|
||||
alias gi="gitignore-io"
|
||||
alias gl="git fancy-graph"
|
||||
alias ghi="git hist"
|
||||
alias ghd="git hist-details"
|
||||
|
@ -63,40 +49,19 @@ alias grbi="git rebase --interactive"
|
|||
alias grc="git rm --cached"
|
||||
alias grh="git reset --hard"
|
||||
alias grm="git rm"
|
||||
alias gs="git status"
|
||||
alias gu="git undo"
|
||||
alias gup="git-branch-delete-merged"
|
||||
alias gw="git diff --check"
|
||||
alias Grep='grep'
|
||||
alias l="ls"
|
||||
alias ll="ls -lv --human-readable --color=auto"
|
||||
alias ls="ls --color=auto"
|
||||
alias m="more"
|
||||
alias md="cd ~/dotfiles > /dev/null 2>&1; make; cd -1 > /dev/null 2>&1"
|
||||
alias mf="mkdir"
|
||||
alias mw="tmux new-session -A -s work"
|
||||
alias ne="npm-exec"
|
||||
alias pf="port-forward"
|
||||
alias mw="tmux attach || tmux -f $HOME/.config/tmux/tmux.conf"
|
||||
alias pwdgen="password-generator"
|
||||
alias r="ssh"
|
||||
alias rd="popd"
|
||||
alias s="cd ~/Source"
|
||||
alias sci="ssh-copy-id -i .ssh/id_rsa.pub"
|
||||
alias sd="pwd | pushd"
|
||||
alias subl="code"
|
||||
alias sw="stopwatch"
|
||||
alias sz="source ~/.zshrc"
|
||||
alias pf="port-forward"
|
||||
alias t="tmux new-session -A -s"
|
||||
alias sz="source $ZDOTDIR/.zshrc"
|
||||
alias tf="terraform"
|
||||
alias tls="tmux list-sessions"
|
||||
alias ts="tmuxinator start"
|
||||
alias v="$EDITOR"
|
||||
alias w="ruby -rwebrick -e'WEBrick::HTTPServer.new(:Port => 8000, :DocumentRoot => Dir.pwd).start'"
|
||||
alias w="ruby -rwebrick -e'WEBrick::HTTPServer.new(Port: 8000, DocumentRoot: Dir.pwd).start'"
|
||||
alias wo="curl 'http://wttr.in/48823'"
|
||||
alias y="yarn"
|
||||
alias ya="yarn add"
|
||||
alias yad="yarn add --dev"
|
||||
alias ye="yarn-exec"
|
||||
alias yi="yarn-install-like-bundle"
|
||||
alias x="exit"
|
78
zsh/.config/zsh/functions
Normal file
78
zsh/.config/zsh/functions
Normal file
|
@ -0,0 +1,78 @@
|
|||
function ag-count {
|
||||
if [ $# -lt 1 ]; then
|
||||
echo Usage: ag-count SEARCHTERM
|
||||
else
|
||||
searchterm=$1; shift
|
||||
|
||||
ag --stats $searchterm | tail -n5
|
||||
fi
|
||||
}
|
||||
|
||||
function aws-profile {
|
||||
if [ $# -eq 0 ]; then
|
||||
echo Current AWS Profile: $AWS_DEFAULT_PROFILE
|
||||
else
|
||||
export AWS_DEFAULT_PROFILE=$1
|
||||
export AWS_PROFILE=$1
|
||||
fi
|
||||
}
|
||||
|
||||
function docker-compose-call {
|
||||
if docker compose > /dev/null 2>&1; then
|
||||
docker compose $@
|
||||
else
|
||||
docker-compose $@
|
||||
fi
|
||||
}
|
||||
|
||||
function g {
|
||||
if [[ $# > 0 ]]; then
|
||||
git $@
|
||||
else
|
||||
git status
|
||||
fi
|
||||
}
|
||||
|
||||
function git-date-added {
|
||||
if [ $# -eq 0 ]; then
|
||||
echo Usage: git-date-added FILENAME
|
||||
else
|
||||
git log --format=%aD $1 | tail -1
|
||||
fi
|
||||
}
|
||||
|
||||
function password-generator {
|
||||
if [ -x "$(command -v openssl)" ]; then
|
||||
password=$(
|
||||
openssl rand -base64 32 \
|
||||
| head -c 32
|
||||
)
|
||||
else
|
||||
password=$(
|
||||
date +%s \
|
||||
| sha256sum \
|
||||
| base64 \
|
||||
| head -c 32
|
||||
)
|
||||
fi
|
||||
|
||||
echo $password
|
||||
}
|
||||
|
||||
function test-rails {
|
||||
if bundle exec rspec --help > /dev/null 2>&1; then
|
||||
if [ -d spec ]; then
|
||||
bundle exec rspec $@
|
||||
else
|
||||
ruby *_test.rb
|
||||
fi
|
||||
elif bundle exec rails version > /dev/null 2>&1; then
|
||||
bundle exec rails test $@
|
||||
else
|
||||
if [[ $# > 0 ]]; then
|
||||
ruby $@
|
||||
else
|
||||
ruby *_test.rb
|
||||
fi
|
||||
fi
|
||||
}
|
4
zsh/.config/zsh/prompt
Normal file
4
zsh/.config/zsh/prompt
Normal file
|
@ -0,0 +1,4 @@
|
|||
local current_dir='%~%f'
|
||||
local result="%B%(?.%F{green}✓%b.%F{red}✗)%b%f"
|
||||
|
||||
PROMPT="${current_dir} ${result} "
|
169
zsh/.functions
169
zsh/.functions
|
@ -1,169 +0,0 @@
|
|||
function ag-count {
|
||||
if [ $# -lt 1 ]; then
|
||||
echo Usage: ag-count SEARCHTERM
|
||||
else
|
||||
searchterm=$1; shift
|
||||
|
||||
ag --stats $searchterm | tail -n5
|
||||
fi
|
||||
}
|
||||
|
||||
function aet-bin-exec {
|
||||
local readonly script=$1; shift
|
||||
|
||||
./aet-bin/$script $@
|
||||
}
|
||||
|
||||
function aws-profile {
|
||||
if [ $# -eq 0 ]; then
|
||||
echo Current AWS Profile: $AWS_DEFAULT_PROFILE
|
||||
else
|
||||
export AWS_DEFAULT_PROFILE=$1
|
||||
export AWS_PROFILE=$1
|
||||
fi
|
||||
}
|
||||
|
||||
function fix-permissions {
|
||||
find . -type d -print0 | xargs -0 chmod 0755
|
||||
find . -type f -print0 | xargs -0 chmod 0644
|
||||
}
|
||||
|
||||
function g {
|
||||
if [[ $# > 0 ]]; then
|
||||
git $@
|
||||
else
|
||||
git status
|
||||
fi
|
||||
}
|
||||
|
||||
function git-branch-cleanup {
|
||||
if [ $# -eq 0 ]; then
|
||||
branch=master
|
||||
else
|
||||
branch=$1
|
||||
fi
|
||||
|
||||
git branch --merged $branch | grep -v $branch | xargs git branch -d
|
||||
}
|
||||
|
||||
function git-branch-delete-merged {
|
||||
git branch --merged \
|
||||
| grep -v "\*" \
|
||||
| grep -v master \
|
||||
| grep -v staging \
|
||||
| grep -v development \
|
||||
| xargs -n 1 git branch -d
|
||||
}
|
||||
|
||||
function git-date-added {
|
||||
if [ $# -eq 0 ]; then
|
||||
echo Usage: git-date-added FILENAME
|
||||
else
|
||||
git log --format=%aD $1 | tail -1
|
||||
fi
|
||||
}
|
||||
|
||||
function gitignore-io {
|
||||
curl https://www.gitignore.io/api/$@
|
||||
}
|
||||
|
||||
function insert-sudo {
|
||||
zle beginning-of-line
|
||||
zle -U "sudo "
|
||||
}
|
||||
|
||||
function npm-exec {
|
||||
(PATH=$(npm bin):$PATH; eval $@;)
|
||||
}
|
||||
|
||||
function password-generator {
|
||||
if [ -x "$(command -v openssl)" ]; then
|
||||
password=$(
|
||||
openssl rand -base64 32 \
|
||||
| head -c 32
|
||||
)
|
||||
else
|
||||
password=$(
|
||||
date +%s \
|
||||
| sha256sum \
|
||||
| base64 \
|
||||
| head -c 32
|
||||
)
|
||||
fi
|
||||
|
||||
echo $password
|
||||
}
|
||||
|
||||
function port-forward {
|
||||
if [ $# -lt 2 ]; then
|
||||
echo Usage: port-forward HOST LOCAL_PORT \[REMOTE_PORT\]
|
||||
else
|
||||
ssh $1 -R ${3:-$2}":localhost:"$2 -g
|
||||
fi
|
||||
}
|
||||
|
||||
function run {
|
||||
if [ $# -lt 2 ]; then
|
||||
echo Usage: run NUMBER COMMAND
|
||||
else
|
||||
number=$1; shift
|
||||
|
||||
for i in `seq $number`; do
|
||||
eval "$@"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function stopwatch {
|
||||
date1=`date +%s`
|
||||
while true; do
|
||||
echo -ne "$(date -u --date @$((`date +%s` - $date1)) +%H:%M:%S)\r"
|
||||
sleep 0.1
|
||||
done
|
||||
}
|
||||
|
||||
function test-rails {
|
||||
if bundle exec rspec --help > /dev/null 2>&1; then
|
||||
if [ -d spec ]; then
|
||||
bundle exec rspec $@
|
||||
else
|
||||
ruby *_test.rb
|
||||
fi
|
||||
elif bundle exec rails version > /dev/null 2>&1; then
|
||||
bundle exec rails test $@
|
||||
else
|
||||
if [[ $# > 0 ]]; then
|
||||
ruby $@
|
||||
else
|
||||
ruby *_test.rb
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function true-colors {
|
||||
awk 'BEGIN{
|
||||
s="/\\/\\/\\/\\/\\"; s=s s s s s s s s;
|
||||
for (colnum = 0; colnum<77; colnum++) {
|
||||
r = 255-(colnum*255/76);
|
||||
g = (colnum*510/76);
|
||||
b = (colnum*255/76);
|
||||
if (g>255) g = 510-g;
|
||||
printf "\033[48;2;%d;%d;%dm", r,g,b;
|
||||
printf "\033[38;2;%d;%d;%dm", 255-r,255-g,255-b;
|
||||
printf "%s\033[0m", substr(s,colnum+1,1);
|
||||
}
|
||||
printf "\n";
|
||||
}'
|
||||
}
|
||||
|
||||
function yarn-exec {
|
||||
(PATH=$(yarn bin):$PATH; eval $@;)
|
||||
}
|
||||
|
||||
function yarn-install-like-bundle {
|
||||
if [ -f yarn.lock ]; then
|
||||
yarn install --pure-lockfile
|
||||
else
|
||||
yarn install
|
||||
fi
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
#compdef ,
|
||||
local bin_dir="aet-bin"
|
||||
local found_bin_dir=""
|
||||
|
||||
current_dir=$(pwd)
|
||||
found_bin_dir=$current_dir/$bin_dir
|
||||
while [ ! -d $found_bin_dir ]; do
|
||||
if [[ $current_dir == $HOME ]]; then
|
||||
found_bin_dir=$HOME/bin
|
||||
break
|
||||
fi
|
||||
|
||||
current_dir=$(realpath "$current_dir/..")
|
||||
found_bin_dir=$current_dir/$bin_dir
|
||||
done
|
||||
|
||||
_files -g "^," -W $found_bin_dir
|
|
@ -1,30 +0,0 @@
|
|||
local current_time="[%B%D{%T}%b]"
|
||||
local current_dir='%B%F{blue}%~%f%b'
|
||||
|
||||
# user
|
||||
local user="%F{green}%n%f"
|
||||
|
||||
# host
|
||||
local host=""
|
||||
if [[ -n "$SSH_CLIENT" || -n "$SSH2_CLIENT" ]]; then
|
||||
host='%F{yellow}%M%f' #SSH
|
||||
else
|
||||
host='%F{green}%M%f' # no SSH
|
||||
fi
|
||||
|
||||
# vcs
|
||||
precmd() {
|
||||
setopt promptsubst
|
||||
autoload -Uz vcs_info
|
||||
|
||||
zstyle ':vcs_info:*' enable git hg svn
|
||||
zstyle ':vcs_info:*:prompt:*' nvcsformats ""
|
||||
zstyle ':vcs_info:*:prompt:*' formats "[%F{cyan}%b%f%u%c]"
|
||||
vcs_info 'prompt'
|
||||
}
|
||||
local vcs='${vcs_info_msg_0_}'
|
||||
|
||||
local prompt="%B%(?.%F{green}✓%b.%F{red}✗)%b%f"
|
||||
|
||||
PROMPT="${current_time} ${user}@${host} ${current_dir} ${vcs}
|
||||
$prompt "
|
33
zsh/.zshenv
33
zsh/.zshenv
|
@ -1,40 +1,13 @@
|
|||
PERSONAL_BIN_PATH="$HOME/bin"
|
||||
|
||||
NODENV_PATH="$HOME/.nodenv/bin"
|
||||
RBENV_PATH="$HOME/.rbenv/bin"
|
||||
|
||||
LOCAL_HOME_BIN_PATH="$HOME/.local/bin"
|
||||
PERSONAL_BIN_PATH="$HOME/bin"
|
||||
PERSONAL_COMPLETIONS_PATH="$HOME/.zsh-completions"
|
||||
ZDOTDIR=$HOME/.config/zsh
|
||||
|
||||
GNU_TOOLS_PATH="/opt/homebrew/opt/coreutils/libexec/gnubin"
|
||||
GNU_TOOLS_MAN_PATH="/opt/homebrew/opt/coreutils/libexec/gnuman"
|
||||
|
||||
if [[ "$OSTYPE" == darwin* ]]; then
|
||||
HOMEBREW_PREFIX="/opt/homebrew";
|
||||
HOMEBREW_CELLAR="/opt/homebrew/Cellar";
|
||||
HOMEBREW_REPOSITORY="/opt/homebrew";
|
||||
|
||||
# Added by .zprofile that we've moved
|
||||
PATH="/usr/local/bin:/Library/Apple/usr/bin:$PATH"
|
||||
|
||||
PATH="/opt/homebrew/bin:/opt/homebrew/sbin${PATH+:$PATH}";
|
||||
MANPATH="/opt/homebrew/share/man${MANPATH+:$MANPATH}:";
|
||||
INFOPATH="/opt/homebrew/share/info:${INFOPATH:-}";
|
||||
|
||||
[[ -d "$GNU_TOOLS_PATH" ]] && PATH="$GNU_TOOLS_PATH:$PATH"
|
||||
[[ -d "$GNU_TOOLS_MAN_PATH" ]] && MANPATH="$GNU_TOOLS_MAN_PATH:$MANPATH"
|
||||
|
||||
GO_DIR="/usr/local/opt/go/libexec"
|
||||
else
|
||||
GO_DIR="/usr/local/go/bin"
|
||||
fi
|
||||
|
||||
# BIN
|
||||
[[ -d "$RBENV_PATH" ]] && PATH="$RBENV_PATH:$PATH"
|
||||
[[ -d "$NODENV_PATH" ]] && PATH="$NODENV_PATH:$PATH"
|
||||
|
||||
[[ -d "$LOCAL_HOME_BIN_PATH" ]] && PATH="$LOCAL_HOME_BIN_PATH:$PATH"
|
||||
[[ -d "$PERSONAL_BIN_PATH" ]] && PATH="$PERSONAL_BIN_PATH:$PATH"
|
||||
[[ -d "$PERSONAL_COMPLETIONS_PATH" ]] && FPATH="$PERSONAL_COMPLETIONS_PATH:$FPATH"
|
||||
|
||||
# EDITOR
|
||||
EDITOR=vim
|
||||
|
|
73
zsh/.zshrc
73
zsh/.zshrc
|
@ -1,73 +0,0 @@
|
|||
GPG_TTY=$(tty)
|
||||
export GPG_TTY
|
||||
|
||||
# clean up duplicate paths
|
||||
typeset -U PATH
|
||||
|
||||
# Larger history
|
||||
HISTSIZE=20000
|
||||
HISTFILE=~/.zsh_history
|
||||
SAVEHIST=20000
|
||||
|
||||
# Make sure C-s works in vim
|
||||
stty start undef
|
||||
stty stop undef
|
||||
|
||||
# Aliases/Functions files
|
||||
source $HOME/.aliases
|
||||
source $HOME/.functions
|
||||
|
||||
source $HOME/.zsh/prompt
|
||||
|
||||
if [[ "$OSTYPE" == darwin* ]]; then
|
||||
source $HOME/.aliases-mac
|
||||
fi
|
||||
|
||||
# vim mode
|
||||
bindkey -v
|
||||
|
||||
# Bind insert_sudo function
|
||||
zle -N insert-sudo
|
||||
bindkey "^z" insert-sudo
|
||||
|
||||
# init rbenv
|
||||
if which rbenv > /dev/null; then
|
||||
eval "$(rbenv init --no-rehash -)"
|
||||
(rbenv rehash &) 2> /dev/null
|
||||
fi
|
||||
|
||||
# init nodenv
|
||||
if which nodenv > /dev/null; then
|
||||
eval "$(nodenv init --no-rehash -)"
|
||||
(nodenv rehash &) 2> /dev/null
|
||||
fi
|
||||
|
||||
# init direnv
|
||||
if which direnv > /dev/null; then
|
||||
eval "$(direnv hook zsh)"
|
||||
fi
|
||||
|
||||
# completion
|
||||
autoload -U compinit
|
||||
autoload bashcompinit && bashcompinit
|
||||
|
||||
autoload compinit -Uz
|
||||
setopt EXTENDEDGLOB
|
||||
if [[ -n ${ZDOTDIR}/.zcompdump(#qN.mh+24) ]]; then
|
||||
compinit
|
||||
else
|
||||
compinit -C
|
||||
fi
|
||||
unsetopt EXTENDEDGLOB
|
||||
|
||||
setopt completeinword
|
||||
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
|
||||
|
||||
# directory
|
||||
setopt auto_cd
|
||||
|
||||
# better word definition
|
||||
autoload -U select-word-style
|
||||
select-word-style bash
|
||||
|
||||
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
|
Loading…
Add table
Add a link
Reference in a new issue