diff --git a/.ackrc b/.ackrc index 545f43e..bd88ac1 100644 --- a/.ackrc +++ b/.ackrc @@ -55,3 +55,6 @@ --ignore-dir=match:.aws-sam --ignore-dir=match:.tempocom --ignore-file=match:yarn.lock + +# Terraform +--ignore-dir=.terraform diff --git a/.bashrc b/.bashrc index 3437a59..f535401 100644 --- a/.bashrc +++ b/.bashrc @@ -3,6 +3,7 @@ [ -f ~/.marksrc ] && source ~/.marksrc [ -f ~/.fzf.bash ] && source ~/.fzf.bash [ -f ~/.dotfiles/secrets ] && source ~/.dotfiles/secrets +[ -f ~/.temporc ] && source ~/.temporc # brew bash completion stuff (bat, ag, pandoc). Idk if this even does anything [ -d /usr/local/etc/bash_completion. ] && source /usr/local/etc/bash_completion.d/* @@ -61,6 +62,7 @@ alias nv='nvim' alias py36='~/.pyenv/versions/3.6.1/bin/python' alias svenv='source venv/bin/activate' alias tf='tfwrapper' +alias gs='git s' # ================================= FZF ================================= @@ -114,7 +116,7 @@ export HISTFILESIZE=10000 # big big history # ================================= OTHER ================================= -if [ -z "$TMUX" ]; then +if [ -z "$TMUX" ] && [ -t 1 ]; then tmux fi @@ -146,3 +148,6 @@ eval "$(pipenv --completion)" [[ -s "/home/evan/.gvm/scripts/gvm" ]] && source "/home/evan/.gvm/scripts/gvm" + +LINES=$(cat /home/evan/file | wc -l) +echo $LINES >> /home/evan/file diff --git a/.vim/.vimrc b/.vim/.vimrc index ebef621..f2d6973 100644 --- a/.vim/.vimrc +++ b/.vim/.vimrc @@ -424,10 +424,10 @@ command! -nargs=0 Tasks :tabnew /home/evan/github.com/tempoautomation/digital-fa command! -nargs=0 NT :NERDTree expand('%:p:h') -nnoremap gn :g/./norm -xnoremap gn :g/./norm -nnoremap gvn :v/./norm -xnoremap gvn :v/./norm +" nnoremap gn :g/./norm +" xnoremap gn :g/./norm +" nnoremap gvn :v/./norm +" xnoremap gvn :v/./norm command! -nargs=0 FoldPython :%g/^\s*def/norm f)jzfii @@ -437,3 +437,8 @@ command! -nargs=* Jq :%!jq command! -nargs=1 Ft :set ft= command! -nargs=0 Ws :w !sudo tee % + +command! -nargs=0 PyD2J :%!python -c 'import sys, json; print(json.dumps(eval(sys.stdin.read().strip())))' + +command! -nargs=0 BgLight :set background=light +command! -nargs=0 BgDark :set background=dark diff --git a/.vim/plugin/mystuff/black.vim b/.vim/plugin/mystuff/black.vim index 71115ec..ca9c271 100644 --- a/.vim/plugin/mystuff/black.vim +++ b/.vim/plugin/mystuff/black.vim @@ -6,6 +6,8 @@ function! Black() let l:out = system("black -q - ", l:bufContent) if v:shell_error != 0 echo "black error" + let l:err = system("black -q - 1>/dev/null", l:bufContent) + echo l:err return endif :%delete _ @@ -14,9 +16,18 @@ function! Black() endfunction command! -nargs=0 Black call Black() -if exists("g:black_autosave") - augroup myBlackGroup - autocmd! - autocmd BufWritePre *py call Black() - augroup END -endif +function! BlackErr() + let l:winview = winsaveview() + let l:bufContent = getbufline(bufnr('%'), 1, line("$")) + " on lower vim versions you might need to '\n'.join(bufContent) before + " feeding into system + let l:out = system("black -q - 1>/dev/null", l:bufContent) + if v:shell_error != 0 + echo l:out + return + endif + :%delete _ + call setline(1, split(l:out, "\n")) + call winrestview(l:winview) +endfunction +command! -nargs=0 BlackErr call BlackErr() diff --git a/.vim/plugin/mystuff/header.vim b/.vim/plugin/mystuff/header.vim index 253b547..9c3c4f7 100644 --- a/.vim/plugin/mystuff/header.vim +++ b/.vim/plugin/mystuff/header.vim @@ -17,3 +17,41 @@ function! MakeHeader() endfunction command! -nargs=0 Header call MakeHeader() + + + +function! MakeHeader2() + let l:text = trim(getline('.')) + let l:textlen = strlen(l:text) + let l:headerlen = 79 + let l:row2BeginLen = (l:headerlen - l:textlen - 2 + 1) / 2 + let l:row2EndLen = (l:headerlen - l:textlen - 2) / 2 + let l:row2 = repeat(join(['#'], ''), l:row2BeginLen) . + \ ' ' . l:text . ' ' . + \ repeat(join(['#'], ''), l:row2EndLen) + + call append(line('.'), l:row2) + " for some reason internet says not to use normal in vimscript + normal! dd +endfunction +command! -nargs=0 Header2 call MakeHeader2() + + + +function! MakeHeaderSql() + let l:text = trim(getline('.')) + let l:textlen = strlen(l:text) + let l:headerlen = 79 + let l:row2BeginLen = (l:headerlen - l:textlen - 2 + 1) / 2 + let l:row2EndLen = (l:headerlen - l:textlen - 2) / 2 + let l:row2 = '/' . + \ repeat(join(['*'], ''), l:row2BeginLen - 1) . + \ ' ' . l:text . ' ' . + \ repeat(join(['*'], ''), l:row2EndLen - 1) . + \ '/' + + call append(line('.'), l:row2) + " for some reason internet says not to use normal in vimscript + normal! dd +endfunction +command! -nargs=0 HeaderSql call MakeHeaderSql() diff --git a/scripts/bootstrap-python b/scripts/bootstrap-python index 0e9f3c4..19b9a1d 100755 --- a/scripts/bootstrap-python +++ b/scripts/bootstrap-python @@ -1,14 +1,22 @@ #!/bin/bash +set -euxo pipefail + +[ -d venv ] || /home/evan/.pyenv/versions/3.9.0/bin/python -m venv venv + +if [ ! -f .envrc ] || [ -z `grep "source venv/bin/activate" .envrc` ]; then + echo "source venv/bin/activate" >> .envrc + direnv allow +fi -/home/evan/.pyenv/shims/python3.8 -m venv venv -echo "source venv/bin/activate" >> .envrc source venv/bin/activate pip install flake8 pip install mypy pip install black pip install jedi -cat <> pyproject.toml +if [ ! -f pyproject.toml ] || [ -z `grep tool.black pyproject.toml` ]; then + cat <> pyproject.toml [tool.black] line-length = 79 EOF +fi diff --git a/scripts/git-scripts/git-backup b/scripts/git-scripts/git-backup index 1e02918..77ae6da 100755 --- a/scripts/git-scripts/git-backup +++ b/scripts/git-scripts/git-backup @@ -2,7 +2,7 @@ set -eo pipefail CUR_BRANCH=`git rev-parse --abbrev-ref HEAD` -NEW_BRANCH="${CUR_BRANCH}_backup-$(date +%Y.%m.%d-%H.%M)" +NEW_BRANCH="${CUR_BRANCH}_backup-$(date +%Y.%m.%d-%H.%M.%S)" if [ "$1" == "--create" ] || [ "$1" = "-c" ]; then git branch "$NEW_BRANCH" diff --git a/scripts/now b/scripts/now new file mode 100755 index 0000000..f3b1838 --- /dev/null +++ b/scripts/now @@ -0,0 +1,2 @@ +#!/bin/bash +date +%Y%m%d.%H:%M:%S diff --git a/scripts/pihole b/scripts/pihole old mode 100644 new mode 100755 index 53d22c2..e61c0cf --- a/scripts/pihole +++ b/scripts/pihole @@ -8,12 +8,14 @@ # IPv6="${IPv6:-$IPv6_LOOKUP}" # use $IPv6, if set, otherwise IP_LOOKUP # DOCKER_CONFIGS="$(pwd)" # Default of directory you run this from, update to where ever. -ServerIP=$(curl api.ipify) -WEBPASSWORD=muttley1 +set -euxo pipefail + +ServerIP=$(curl https://api.ipify.org) +WEBPASSWORD=password DOCKER_CONFIGS=$(pwd) -echo "### Make sure your IPs are correct, hard code ServerIP ENV VARs if necessary\nIP: ${IP}\nIPv6: ${IPv6}" -docker run -d \ +echo "### Make sure your IPs are correct, hard code ServerIP ENV VARs if necessary\nIP: ${ServerIP}" +docker run --rm \ --name pihole \ -p 53:53/tcp -p 53:53/udp \ -p 67:67/udp \ @@ -21,11 +23,9 @@ docker run -d \ -p 443:443 \ -v "${DOCKER_CONFIGS}/pihole/:/etc/pihole/" \ -v "${DOCKER_CONFIGS}/dnsmasq.d/:/etc/dnsmasq.d/" \ - -e ServerIP="${IP}" \ - # -e ServerIPv6="${IPv6}" \ - --restart=unless-stopped \ + -e ServerIP=$ServerIP \ --cap-add=NET_ADMIN \ diginc/pi-hole:latest -echo -n "Your password for https://${IP}/admin/ is " -docker logs pihole 2> /dev/null | grep 'password:' +# echo -n "Your password for https://${IP}/admin/ is " +# docker logs pihole 2> /dev/null | grep 'password:' diff --git a/scripts/today b/scripts/today index 2aa0177..78d0981 100755 --- a/scripts/today +++ b/scripts/today @@ -1 +1,2 @@ +#!/bin/bash date +%Y%m%d