From 269e41ba6b2bc1788c8999544631afbd73888b7c Mon Sep 17 00:00:00 2001 From: har0ke Date: Sun, 5 Sep 2021 11:47:37 +0200 Subject: [PATCH] Add winfo --- .winfo.sh | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ .zshrc | 3 ++- install.sh | 10 ++++++---- 3 files changed, 61 insertions(+), 5 deletions(-) create mode 100755 .winfo.sh diff --git a/.winfo.sh b/.winfo.sh new file mode 100755 index 0000000..dfe3219 --- /dev/null +++ b/.winfo.sh @@ -0,0 +1,53 @@ + +default_limit=40 +limited_folders="\ + $HOME \ + $HOME/Downloads|60" + +max_entries="" + +print_warnings() { + headline=$1 + warnings=$2 + if [[ "$warnings" != "" ]]; then + echo -e "\033[0;33m$headline:" + echo -e "$warnings\033[0m" + fi + +} + +warnings="" +for folder in $limited_folders; do + limit="$default_limit" + if [[ "$folder" =~ "|" ]]; then + limit="$(echo "$folder" | cut -d '|' -f2)" + folder="$(echo "$folder" | cut -d '|' -f1)" + fi + n=$(ls -l "$folder" | wc -l) + if [[ "$n" -gt $limit ]]; then + warnings="$warnings\tMany files ($n > $limit) in '$folder'\n" + fi +done + +print_warnings "Folders to clean" "$warnings" +warnings="" + +for d in ~/projects/*; do + if [[ -e "$d/.git" ]]; then + if [ ! -z "git -C "$d" status --porcelain)" ]; then + warnings="$warnings\t$d is not clean\n" + else + let days="($(date +%s) - $(date +%s -d $(git log HEAD^..HEAD --format=%aI))) / 3600 / 24" + if [[ "$days" -gt "31" ]]; then + warnings="$warnings\tNo commits in $days days for $d" + fi + fi + else + warnings="$warnings\t$d is not a git repository\n" + fi +done + +print_warnings "Folders to clean" "$warnings" +warnings="" + + diff --git a/.zshrc b/.zshrc index ef1babc..869694a 100644 --- a/.zshrc +++ b/.zshrc @@ -100,4 +100,5 @@ source $ZSH/oh-my-zsh.sh # alias zshconfig="mate ~/.zshrc" # alias ohmyzsh="mate ~/.oh-my-zsh" # -alias create_venv3="python3 -m venv --system-site-packages .venv; source .venv/bin/activate; pip install -I -r requirements.txt" + +alias winfo=$HOME/.winfo.sh diff --git a/install.sh b/install.sh index 7a9fa1f..580d051 100755 --- a/install.sh +++ b/install.sh @@ -5,7 +5,7 @@ run_as_user() { echo "Run with user $1: ${@:2}" sudo -u $@ } -set -e +set -e link_with_bkp() { SRC=$2 DEST=$3 @@ -46,11 +46,13 @@ cpu_name="$(lscpu | grep "Model name" | cut -f2 -d: | xargs)" if [ "$cpu_name" == "Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz" ]; then echo "It's my XPS15" specific_files=$xps15 -fi +fi terminal_only="\ .oh-my-zsh/themes/oke.zsh-theme \ - .zshrc" + .zshrc \ + .vimrc + .winfo.sh" workstation="\ .config/i3/config \ @@ -91,7 +93,7 @@ fi for f in $files; do BASE="$HOME/" USER=$(whoami) - if [[ "$f" =~ ":" ]]; then + if [[ "$f" =~ ":" ]]; then BASE=$(echo "$f" | cut -f2 -d:) USER=$(echo "$f" | cut -f3 -d:) f=$(echo "$f" | cut -f1 -d:)