Compare commits

..

No commits in common. "9015815872a39fcdb01257db87be40d6d9423968" and "cffe18cb65fa5c05dda820f5c533e3816d38cf4f" have entirely different histories.

8 changed files with 41 additions and 264 deletions

10
copy.sh
View File

@ -31,6 +31,11 @@ require git wget curl find jq
mkdir -p "$HOME/.tmp" || exit 1
if command -v sudo &> /dev/null && ! command -v sofi &> /dev/null && ! test -f /usr/bin/sofi; then
echo -e '#!/bin/bash\n$HOME/.sofi.sh --launch' | sudo tee /usr/bin/sofi
sudo chmod +x /usr/bin/sofi
fi
git submodule init
git submodule update
@ -77,11 +82,6 @@ if [[ "$1" == "--files-only" ]]; then
exit 0
fi
if command -v sudo &> /dev/null && ! command -v sofi &> /dev/null && ! test -f /usr/bin/sofi; then
echo -e '#!/bin/bash\n$HOME/.sofi.sh --launch' | sudo tee /usr/bin/sofi
sudo chmod +x /usr/bin/sofi
fi
if ! command -v cargo &> /dev/null; then
echo "Rust is not installed. Installing..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

View File

@ -1,4 +1,5 @@
format = """
$git_status\
${custom.username}\
$hostname\
$shlvl\
@ -42,11 +43,11 @@ $cmake\
$nix_shell\
$conda\
$memory_usage\
$aws\
$gcloud\
$openstack\
$env_var\
$crystal\
$git_status\
$line_break\
$lua\
$jobs\
@ -66,11 +67,10 @@ truncate_to_repo = false
truncation_length = 0
[nodejs]
format = "$symbol$version"
format = "$symbol"
[java]
symbol = ""
format = "$symbol $version "
format = "$symbol"
[time]
disabled = true
@ -117,12 +117,12 @@ format = '[$ssh_symbol](bold blue) [$hostname](bold dimmed green) '
conflicted = "=conflicted "
ahead = "⇡ahead "
behind = "⇣behind "
diverged = "⇕dvrgd "
untracked = "?untrckd "
stashed = "\\$tashed "
modified = "!mdfd "
diverged = "⇕diverged "
untracked = "?untracked "
stashed = "\\$stashed "
modified = "!modified "
staged = "[++($count)](green)"
renamed = "»rnmd "
deleted = "✘dltd "
format = "[$all_status]($style)"
style = 'black dimmed'
renamed = "»renamed "
deleted = "✘deleted "
format = "[$all_status]($style)\n"
style = 'red dimmed'

View File

@ -17,7 +17,7 @@
branch="$(git rev-parse --abbrev-ref HEAD)"
if [ "$branch" = "master" ]; then
# I've assumed that personal repos (where I might care less about PRs and such) will use 'main' instead of 'master'
# I've assumed that personal repos (where I might care less about PRs and such) will use main instead of master
echo "You can't commit directly to master branch"
exit 1
fi

View File

@ -44,10 +44,3 @@ command! QA action CloseAllUnmodifiedEditors
" Save with sudo
cnoremap w!! execute 'silent! write !sudo tee % >/dev/null' <bar> edit!
set ideajoin
" Include entire beginning of block's first line
" Useful when using K&R (or adjacent) indentation schemes
vnoremap aa{ a{o0
vnoremap aa[ a[o0
vnoremap aa< a<o0
vnoremap aa( a(o0

View File

@ -13,23 +13,6 @@ alias _slides="$(which slides 2> /dev/null || echo "echo 'slides not installed'"
CASCH_DIR="$HOME/.casch"
CASCH_MAP="$CASCH_DIR/.base-map.json"
_vim="$(which vim)"
function vim {
if command -v nvim && [[ "$1" =~ ".*.lua" ]]; then
nvim "$1"
else
"$_vim" "$1"
fi
}
function vim-temp {
rm ~/.vim-temp-file &> /dev/null
vim ~/.vim-temp-file
cat ~/.vim-temp-file
}
alias vimtemp='vim-temp'
function git-worked {
author="$1"
since="$2"
@ -102,26 +85,11 @@ function cache-run {
alias cr='cache-run'
function json-or-str {
echo "$1" | jq 2>/dev/null || echo "$1" | jq -R
}
function arr {
local json="["
for var in "$@"
do
json="$json$(json-or-str "$var"),"
done
json=${json:0:-1}
json="$json]"
echo "$json" | jq --indent 0
}
function arrs {
local json="["
echo "$@" | sed 's/\s\+/\n/g' | while read -r var
do
json="$json$(json-or-str "$var"),"
json="$json$(echo "$var" | jq -R),"
done
json=${json:0:-1}
json="$json]"
@ -212,7 +180,6 @@ function pwgen {
}
alias k='kubectl'
alias kick='kubectl rollout restart deployment'
function kube-pod-name {
local pods="$(kubectl get pods | grep "$1")"
@ -232,24 +199,6 @@ function kubetty {
kubectl exec "$(kube-pod-name $@)" -i -t -- bash
}
function kubejob {
if ishelp $1; then
echo 'Run and log the given job (cronjob/$1) in -n cronjob with a random hash-based name'
return
fi
local id="$(shortuuid)"
local name="$1-$id"
kubectl create job -n cronjob --from="cronjob/$1" "$name" || exit $?
local pods=""
echo "Waiting for job to complete..."
while ! pods="$(kubectl get pods -n cronjob | grep "$name" | grep Completed)"; do
sleep 3
done
echo "Fetching job logs for $name..."
local podname="$(echo "$pods" | awk '{print $1}')" || exit $?
kubectl logs -n cronjob -f "pod/$podname"
}
function undelete {
local filename="$1"
if test -f "$filename"; then
@ -283,7 +232,6 @@ alias vin='curl -s "http://randomvin.com/getvin.php?type=real"'
alias diff='diff -u'
alias tmux="tmux attach || tmux"
alias shortuuid="uuidgen | sed 's/-.*//'"
alias caddyfile="sudo vim /etc/caddy/Caddyfile"
alias cf="sudo vim /etc/caddy/Caddyfile"
@ -446,44 +394,6 @@ alias du='du -sh'
alias tags='ctags --exclude=node_modules -f newtags -R . && mv newtags tags'
function js {
local input="$(cat)"
local commText=""
while [ "$#" -gt 0 ]; do
case "$1" in
-h | --help)
echo "Reads stdin as a string passes it to the given function."
return 0
;;
*)
commText="$commText$1"
shift 1
;;
esac
done
local callback=""
if [[ "$commText" == "" ]]; then
echo -n "js> "
load_nvm
while IFS= read -r line </dev/tty && [[ "$line" != "" ]]; do
commText="$(echo -E "$commText"; echo -E "$line")"
echo -n "js> "
done
# TODO: Append to a histfile of some kind?
else
load_nvm
fi
echo "$input" | node -e "const stdin = process.openStdin(); let data = \"\"; stdin.on(\"data\", chunk => data += chunk); stdin.on(\"end\", () => console.log(JSON.stringify(($commText)(data), null, 2)));"
# TODO? Write actual JS into bash history with a HEREDOC?
# fc -W
# fc -R
}
function roll {
local count=1
if [[ "$2" != "" ]]; then
@ -500,6 +410,17 @@ function roll {
fi
}
function arr {
local json="["
for var in "$@"
do
json="$json$(echo "$var" | jq -R),"
done
json=${json:0:-1}
json="$json]"
echo "$json" | jq --indent 0
}
alias d4='roll 4'
alias 4='roll 4'
@ -518,93 +439,6 @@ alias 12='roll 12'
alias d20='roll 20'
alias 20='roll 20'
function has-diff {
! diff "$1" "$2"
}
function until-no-change {
local regex="$1"
local file="$2"
echo
echo perl -0pe "$regex" "$file"
perl -0pe "$regex" "$file" > .tmp
while has-diff .tmp "$file" &> /dev/null; do
perl -0pe "$regex" ".tmp" > "$file"
perl -0pe "$regex" "$file" > .tmp
done
mv .tmp "$file"
}
function external-above-internal {
local file="$1"
local regex="s#((?:import.*'(?:\.|@/).*\n)+)\n?((?:import.*'([a-z]|@[^/]).*\n)+)#\2\1#gm;"
until-no-change "$regex" "$file"
}
function absolute-above-relative {
local file="$1"
local regex="s#((?:import.*'\..*\n)+)\n?((?:import.*'@/.*\n)+)#\2\1#gm"
until-no-change "$regex" "$file"
}
function fix-imports {
local file="$1"
external-above-internal "$file"
absolute-above-relative "$file"
}
function fix-all-imports {
find -type f \( -name '*.ts' -o -name "*.js" -o -name "*.jsx" -o -name "*.tsx" \) | grep -v 'node_modules\|generated\|jest' | while read -r file; do
fix-imports "$file"
done
}
function lazy-nvm-use {
local target="$1"
if ! node --version | sed 's/^v//' | grep "^$target" &> /dev/null; then
nvm use "$target"
fi
}
function cd {
builtin cd $@ || return $?
local ret="$?"
if ! test -f Makefile; then
return 0
fi
local build_env="$(make get-build-environment 2> /dev/null)"
case "$build_env" in
NODE_*)
load_nvm
lazy-nvm-use "$(echo "$build_env" | sed 's/NODE_//')"
;;
JAVA_*)
local java_version="$(echo "$build_env" | sed 's/[^0-9]//g')"
if [[ "$java_version" != "" ]]; then
# If anyone puts malicious scripts into get-build-environment, we're screwed.
export JAVA_HOME="$(eval "echo \$JAVA_$java_version")"
else
export JAVA_HOME="$JAVA_8"
fi
;;
*)
if test -d node_modules && test -d package.json; then
load_nvm; lazy-nvm-use 14
elif test -f pom.xml; then
export JAVA_HOME="$JAVA_8"
fi
;;
esac
return 0
}
if [[ "$@" != "" ]]; then
$@
fi

View File

@ -1,46 +1,3 @@
#!/bin/bash
FRIEND="world"
usage() {
cat <<- EOF
Usage: $0 [OPTION]...
Greets the given friend.
With no friend provided, prints "Hello, world!"
-f, --friend set the name of the friend to greet
-h, --help print this help text
EOF
}
# parse argv variables
while [ "$#" -gt 0 ]; do
case "$1" in
-f | --friend)
FRIEND="$2"
shift 2
;;
-f=* | --friend=*)
FRIEND="${1#*=}"
shift 1
;;
-h | --help)
usage
exit 0
;;
*)
echo "Unrecognized argument ${1#*=}"
echo
usage
exit 1
;;
esac
done
echo "Hello, $FRIEND!"
echo "Hello, world!"

View File

@ -11,20 +11,16 @@ set tags=./tags;/ " Search up to / for tags file
set updatetime=100
set clipboard=unnamedplus " Use system clipboard
if ! has('nvim')
if empty($DISPLAY) && empty($SSH_CONNECTION)
colorscheme monokai
syntax enable
else
set termguicolors
if $TERMINAL_EMULATOR != "JetBrains-JediTerm"
let &t_8f = "\<Esc>[38:2:%lu:%lu:%lum"
let &t_8b = "\<Esc>[48:2:%lu:%lu:%lum"
endif
colorscheme monokai
syntax enable
endif
endif
let mapleader=" "
"nnoremap <Leader>w yiwq:PIe `~/.shell_aliases ws <Esc>

View File

@ -324,9 +324,7 @@ function _getdot {
}
function getdot {
if ping -c 1 -i 2 git.sagev.space; then
lockfor "$SYNC_LOCK_FILE" 90 _getdot $@
fi
}
if [[ "$OS" != "Windows_NT" ]] && which starship &> /dev/null; then
@ -349,7 +347,6 @@ export nvm_loaded=false
alias nvm="load_nvm; nvm"
alias npm="load_nvm; npm"
alias npx="load_nvm; npx"
alias node="load_nvm; node"
alias standard="load_nvm; standard"
alias lf="load_nvm; standard --fix"