From e47ef872e374cb5627fa8ae719d16653968eaf3b Mon Sep 17 00:00:00 2001 From: Peter Kingswell Date: Sun, 14 Aug 2022 12:29:46 -0400 Subject: [PATCH] funky color + updates --- .vscode/settings.json | 24 +++++++++++++++++++-- classkick-functions.zsh | 43 ++++++++++++++++++++++++++++++++++++ lib/functions.zsh | 48 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 classkick-functions.zsh diff --git a/.vscode/settings.json b/.vscode/settings.json index 68aaf0e37..0d81460eb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,5 +2,25 @@ "python.testing.promptToConfigure": false, "python.testing.pytestEnabled": false, "python.testing.unittestEnabled": false, - "python.testing.nosetestsEnabled": false -} \ No newline at end of file + "python.testing.nosetestsEnabled": false, + "workbench.colorCustomizations": { + "activityBar.activeBackground": "#fbed80", + "activityBar.activeBorder": "#06b9a5", + "activityBar.background": "#fbed80", + "activityBar.foreground": "#15202b", + "activityBar.inactiveForeground": "#15202b99", + "activityBarBadge.background": "#06b9a5", + "activityBarBadge.foreground": "#15202b", + "sash.hoverBorder": "#fbed80", + "statusBar.background": "#f9e64f", + "statusBar.foreground": "#15202b", + "statusBarItem.hoverBackground": "#f7df1e", + "statusBarItem.remoteBackground": "#f9e64f", + "statusBarItem.remoteForeground": "#15202b", + "titleBar.activeBackground": "#f9e64f", + "titleBar.activeForeground": "#15202b", + "titleBar.inactiveBackground": "#f9e64f99", + "titleBar.inactiveForeground": "#15202b99" + }, + "peacock.color": "#f9e64f" +} diff --git a/classkick-functions.zsh b/classkick-functions.zsh new file mode 100644 index 000000000..35361b2d1 --- /dev/null +++ b/classkick-functions.zsh @@ -0,0 +1,43 @@ + +function run_cicd_test_containers() { + echo "Starting local CI/CD tests at `date`" + echo "Running bandit..." + docker-compose run --no-deps --rm clever-sync-api python -m bandit -r . -x /tests/ + RES2=$? + echo "Running black..." + docker-compose run --no-deps --rm clever-sync-api black . --check --line-length=120 + RES4=$? + echo "Running flake8..." + docker-compose run --no-deps --rm clever-sync-api flake8 --config /app/dev-tools-config/.flake8 . + RES3=$? + # echo "Running pylint..." + # docker-compose run --no-deps --rm clever-sync-api pylint --rcfile /app/dev-tools-config/.pylintrc classkick + # RES2=$? + echo "Running isort..." + docker-compose run --no-deps --rm clever-sync-api isort . --profile black --line-length=120 --check + RES1=$? + echo "Running coverage..." + docker-compose run --no-deps --rm clever-sync-api pytest --cov . + RES5=$? + echo "Finished local CI/CD tests at `date`" + + if [[ $RES1 -ne 0 || $RES2 -ne 0 || $RES3 -ne 0 || $RES4 -ne 0 || $RES5 -ne 0 ]] + then + return 1 + fi + + return 0 +} + +function run_cicd_fix_containers() { + echo "Starting CI/CD containers in 'fix mode' at `date`." + echo "Are you sure you want to continue?" + read + + echo "Running black..." + docker-compose run --no-deps --rm clever-sync-api black . --line-length=120 + RES4=$? + echo "Running isort..." + docker-compose run --no-deps --rm clever-sync-api isort . --profile black --line-length=120 + RES1=$? +} diff --git a/lib/functions.zsh b/lib/functions.zsh index 0adbca1b5..709cd24c6 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -1,3 +1,5 @@ +source ~/.oh-my-zsh/classkick-functions.zsh + function zsh_stats() { fc -l 1 \ | awk '{ CMD[$2]++; count++; } END { for (a in CMD) print CMD[a] " " CMD[a]*100/count "% " a }' \ @@ -324,7 +326,7 @@ function gfind-all() { # $1 is search term, $2 is path # rg --no-ignore --hidden "$@" # even better is ag / silver searcher https://github.com/ggreer/the_silver_searcher - ag-no-pager --ignore-case --all-types --hidden --unrestricted --ignore-case --pager bat "$@" + ag-no-pager --ignore-case --hidden --ignore-case --pager bat "$@" } # the ol' gfind. Doesn't take a file pattern. @@ -391,12 +393,18 @@ function clean-slate() { alias clr=clean-slate alias cls=clean-slate +function print-hashes() { + repeat $1 echo -n "#" ; echo +} + function h() { + print-hashes 60 NUM_LINES=$1 if [ -z "$NUM_LINES" ]; then NUM_LINES=35 fi \history -$NUM_LINES + print-hashes 60 } function psgr() { @@ -458,6 +466,12 @@ function git-show-all-stashes() { git stash list | awk -F: '{ print "\n\n\n\n"; print $0; print "\n\n"; system("git stash show -p " $1); }' } +# Check whether the supplied file is under SCM/git. +# Check whether the supplied file is under SCM/git. +function git-status() { + git ls-files | grep $1 +} + # kill most recent container instance alias docker-kill-latest='docker ps -l --format="{{.Names}}" | xargs docker kill' @@ -685,3 +699,35 @@ alias grep-ps-interactive="ppgrep" alias interactive-kill="ppkill" alias kill-interactive="ppkill" alias kill-percol="ppkill" + +# From https://apple.stackexchange.com/a/432408/100202 - sets the current iterm2 +# tab to a random color +PRELINE="\r\033[A" + +function random { + echo -e "\033]6;1;bg;red;brightness;$((1 + $RANDOM % 255))\a"$PRELINE + echo -e "\033]6;1;bg;green;brightness;$((1 + $RANDOM % 255))\a"$PRELINE + echo -e "\033]6;1;bg;blue;brightness;$((1 + $RANDOM % 255))\a"$PRELINE +} + +function color { + case $1 in + green) + echo -e "\033]6;1;bg;red;brightness;57\a"$PRELINE + echo -e "\033]6;1;bg;green;brightness;197\a"$PRELINE + echo -e "\033]6;1;bg;blue;brightness;77\a"$PRELINE + ;; + red) + echo -e "\033]6;1;bg;red;brightness;270\a"$PRELINE + echo -e "\033]6;1;bg;green;brightness;60\a"$PRELINE + echo -e "\033]6;1;bg;blue;brightness;83\a"$PRELINE + ;; + orange) + echo -e "\033]6;1;bg;red;brightness;227\a"$PRELINE + echo -e "\033]6;1;bg;green;brightness;143\a"$PRELINE + echo -e "\033]6;1;bg;blue;brightness;10\a"$PRELINE + ;; + *) + random + esac +}