瀏覽代碼

Update scripts

Bryan Roessler 8 月之前
父節點
當前提交
d6e0511545
共有 8 個文件被更改,包括 167 次插入142 次删除
  1. 3 0
      .gitignore
  2. 163 0
      dotfiles/.zshrc
  3. 1 1
      hartmanlab
  4. 0 0
      shell/history-clean
  5. 0 28
      shell/install-codimd
  6. 0 0
      shell/random-word-pair
  7. 0 107
      shell/smart-tests
  8. 0 6
      shell/sync-htpc-new

+ 3 - 0
.gitignore

@@ -0,0 +1,3 @@
+.vscode/
+setup/
+hartmanlab/

+ 163 - 0
dotfiles/.zshrc

@@ -0,0 +1,163 @@
+### SHELL OPTIONS ###
+setopt autocd correct globdots extendedglob nomatch notify
+unsetopt beep
+bindkey -e
+
+### AUTOCOMPLETION ###
+autoload -Uz compinit
+compinit
+zstyle ':completion::complete:*' gain-privileges 1
+zstyle ':completion:*' menu select
+
+### HISTORY ###
+setopt share_history inc_append_history hist_expire_dups_first hist_reduce_blanks hist_find_no_dups
+HISTFILE=~/.histfile
+HISTSIZE=10000000
+SAVEHIST=100000
+HISTCONTROL=ignorespace
+
+# History search
+autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
+zle -N up-line-or-beginning-search
+zle -N down-line-or-beginning-search
+[[ -n "${key[Up]}"   ]] && bindkey -- "${key[Up]}"   up-line-or-beginning-search
+[[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-beginning-search
+
+### PROMPT ###
+autoload -Uz promptinit
+promptinit
+
+if [[ $USER == "root" ]]; then
+    user_color="red"
+else
+    user_color="white"
+fi
+
+# Work in default toolbox (no hostname set)
+if [[ -v TOOLBOX_PATH ]]; then
+    host_color=magenta
+else
+  case $HOSTNAME in;
+    laptop)
+      host_color=green
+      ;;
+    workstation)
+      host_color=red
+      ;;
+    bryan-pc)
+      host_color=cyan
+      ;;
+    time4vps)
+      host_color=blue
+      ;;
+    racknerd)
+      host_color=yellow
+      ;;
+    htpc)
+      host_color=blue
+      ;;
+    hartmanlab)
+      host_color=magenta
+      ;;
+  esac
+fi
+
+PS1="[%F{${user_color}}%n%F{white}@%{%F{${host_color}}%}%m%F{white}]%~$ "
+case $TERM in
+    xterm*)
+        precmd () {print -Pn "\e]0;${PWD/$HOME/\~}\a"}
+        ;;
+esac
+### PATH ###
+typeset -U PATH path
+BINPATH="$HOME/bin"
+GOPATH="$HOME/go"
+path+=("${GOPATH//://bin:}/bin" "$HOME/Documents/develop/scripts/shell" "$HOME/.local/bin" "$HOME/.local/bin/*")
+export PATH
+
+### ALIASES ###
+alias vmd='vmd -nt'
+alias -g dnf-list-files='dnf repoquery -l'
+alias -g gedit='gnome-text-editor'
+alias -g dnf='dnf5'
+# alias xclip="xclip -selection c" # shouldn't need this on wayland, use wl-copy instead
+alias -g pdoman="podman"
+alias virtualenv-workon="workon"
+alias git-list="git ls-tree -r master --name-only"
+
+### KEYBINDINGS ###
+# create a zkbd compatible hash;
+# to add other keys to this hash, see: man 5 terminfo
+typeset -g -A key
+
+key[Home]="${terminfo[khome]}"
+key[End]="${terminfo[kend]}"
+key[Insert]="${terminfo[kich1]}"
+key[Backspace]="${terminfo[kbs]}"
+key[Delete]="${terminfo[kdch1]}"
+key[Up]="${terminfo[kcuu1]}"
+key[Down]="${terminfo[kcud1]}"
+key[Left]="${terminfo[kcub1]}"
+key[Right]="${terminfo[kcuf1]}"
+key[PageUp]="${terminfo[kpp]}"
+key[PageDown]="${terminfo[knp]}"
+key[ShiftTab]="${terminfo[kcbt]}"
+
+# setup key accordingly
+[[ -n "${key[Home]}"      ]] && bindkey -- "${key[Home]}"      beginning-of-line
+[[ -n "${key[End]}"       ]] && bindkey -- "${key[End]}"       end-of-line
+[[ -n "${key[Insert]}"    ]] && bindkey -- "${key[Insert]}"    overwrite-mode
+[[ -n "${key[Backspace]}" ]] && bindkey -- "${key[Backspace]}" backward-delete-char
+[[ -n "${key[Delete]}"    ]] && bindkey -- "${key[Delete]}"    delete-char
+[[ -n "${key[Up]}"        ]] && bindkey -- "${key[Up]}"        up-line-or-history
+[[ -n "${key[Down]}"      ]] && bindkey -- "${key[Down]}"      down-line-or-history
+[[ -n "${key[Left]}"      ]] && bindkey -- "${key[Left]}"      backward-char
+[[ -n "${key[Right]}"     ]] && bindkey -- "${key[Right]}"     forward-char
+[[ -n "${key[PageUp]}"    ]] && bindkey -- "${key[PageUp]}"    beginning-of-buffer-or-history
+[[ -n "${key[PageDown]}"  ]] && bindkey -- "${key[PageDown]}"  end-of-buffer-or-history
+[[ -n "${key[ShiftTab]}"  ]] && bindkey -- "${key[ShiftTab]}"  reverse-menu-complete
+
+# Finally, make sure the terminal is in application mode, when zle is
+# active. Only then are the values from $terminfo valid.
+if (( ${+terminfo[smkx]} && ${+terminfo[rmkx]} )); then
+	autoload -Uz add-zle-hook-widget
+	function zle_application_mode_start {
+		echoti smkx
+	}
+	function zle_application_mode_stop {
+		echoti rmkx
+	}
+	add-zle-hook-widget -Uz zle-line-init zle_application_mode_start
+	add-zle-hook-widget -Uz zle-line-finish zle_application_mode_stop
+fi
+
+# Functions
+function podman-update-images () {
+    podman images |grep -v REPOSITORY|awk '{print $1}'|xargs -L1 podman pull
+}
+
+function extract()
+{
+     if [ -f $1 ] ; then
+         case $1 in
+             *.tar.bz2)   tar xvjf $1     ;;
+             *.tar.gz)    tar xvzf $1     ;;
+             *.bz2)       bunzip2 $1      ;;
+             *.rar)       unrar x $1      ;;
+             *.gz)        gunzip $1       ;;
+             *.tar)       tar xvf $1      ;;
+             *.tbz2)      tar xvjf $1     ;;
+             *.tgz)       tar xvzf $1     ;;
+             *.zip)       unzip $1        ;;
+             *.Z)         uncompress $1   ;;
+             *.7z)        7z x $1         ;;
+             *)           echo "'$1' cannot be extracted via >extract<" ;;
+         esac
+     else
+         echo "'$1' is not a valid file"
+     fi
+}
+
+function buildah-prune() {
+    buildah containers | cut -d" " -f 1 | tail -n +2| xargs buildah rm
+}

+ 1 - 1
hartmanlab

@@ -1 +1 @@
-Subproject commit 2efeb4e8874c21536a24d980ba398633b7305574
+Subproject commit 868d4cf7b9bf8eb655657bbd2a6823c7b57799b7

+ 0 - 0
shell/history-clean


+ 0 - 28
shell/install-codimd

@@ -1,28 +0,0 @@
-#!/usr/bin/env bash
-# This script will install a codiMD container and associated systemd services on CentOS 7 using podman
-# Copyright 2022 Bryan C. Roessler
-# 
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-# 
-#     http://www.apache.org/licenses/LICENSE-2.0
-# 
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-database_dir="/var/lib/postgresql/data"
-
-[[ ! -d $database_dir ]] && sudo mkdir -p "$database_dir"
-
-sudo chcon -t container_file_t -R "$database_dir"
-
-podman pod create codiMD
-podman run --name codidb --pod codiMD -p 3000:3000 -v database-data:/var/lib/postgresql/data docker.io/postgres:11.6-alpine --restart=always
-podman run --name codidb --pod codiMD -p 3000:3000 -v database-data:/var/lib/postgresql/data docker.io/hackmdio/hackmd:2.4.1 --restart=always
-
-
-podman generate systemd 

+ 0 - 0
shell/random-word-pair


+ 0 - 107
shell/smart-tests

@@ -1,107 +0,0 @@
-#!/usr/bin/env bash
-# This script will report S.M.A.R.T. stats and perform tests on all available disks
-# Copyright 2021 Bryan C. Roessler
-
-init() {
-
-    if [[ $EUID != 0 ]]; then
-        echo "Must run as root!" && exit 1
-    fi
-
-    [[ ! -x $(command -v smartctl) ]] && echo "smartctl not found! Please install smartmontools." && exit 1
-
-    if _input=$(getopt -o +slihatd -l short,long,info,health,all,temp,daemon,help -- "$@"); then
-        eval set -- "$_input"
-        while true; do
-            case "$1" in
-                --short|-s)
-                    SHORT="true"
-                    ;;
-                --long|-l)
-                    LONG="true"
-                    ;;
-                --info|-i)
-                    INFO="true"
-                    ;;
-                --health|-h)
-                    HEALTH="true"
-                    ;;
-                --all|-a)
-                    ALL="true"
-                    ;;
-                --temp|-t)
-                    TEMP="true"
-                    ;;
-                --daemon|-d)
-                    DAEMON="true"
-                    ;;                                                         
-                --help)
-                    printhelp
-                    ;;
-                --)
-                    shift
-                    break
-                    ;;
-            esac
-            shift
-        done
-    else
-        echo "Error: incorrect option provided" && printhelp && exit 1
-    fi
-}
-
-
-printhelp() {
-
-    cat <<- 'EOF'
-		USAGE:
-		    smart-tests [OPTION]...
-
-		OPTIONS
-		    --short,-s
-		        Perform S.M.A.R.T short self-test
-		    --long,-l
-		        Perform S.M.A.R.T long self-test
-		    --info,-i
-		        Print S.M.A.R.T info
-		    --health,-h
-		        Perform S.M.A.R.T health assessment
-		    --temp,-t
-		        Report disk temperatures
-		    --daemon,-d
-		        Run in daemon mode for automatic health checks
-		    --all,-a
-		        Run on all drives (default)
-		    --help
-		        Print this help dialog and exit
-	EOF
-}
-
-
-main() {
-
-    mapfile -t drives_scanned < <(smartctl --scan)
-
-    for drive in "${drives_scanned[@]}"; do
-
-        name=$(echo "$drive" | cut -f1 -d" ")
-        type=$(echo "$drive" | cut -f3 -d" ")
-
-        echo "$name ($type)"
-
-        suffix=("-d" "$type" "$name")
-
-        [[ -v SHORT ]] && smartctl -t short "${suffix[@]}"
-        [[ -v LONG ]] && smartctl -t long "${suffix[@]}"
-        [[ -v INFO ]] && smartctl -i "${suffix[@]}"
-        [[ -v HEALTH ]] && smartctl -H "${suffix[@]}"
-        [[ -v ALL ]] && smartctl -a "${suffix[@]}"
-        [[ -v TEMP ]] && smartctl -a "${suffix[@]}" | grep "Current Drive Temperature:"
-        [[ -v DAEMON ]] && smartctl -t short "${suffix[@]}"
-
-    done
-}
-
-
-init "$@"
-main "$@"

+ 0 - 6
shell/sync-htpc-new

@@ -1,6 +0,0 @@
-#!/usr/bin/env bash
-rsync -av --info=progress2 --delete htpc.lan:/mnt/m/Movies/ htpc.lan:/mnt/n/Movies/ /mnt/array/movies/ && \
-rsync -av --info=progress2 --delete htpc.lan:/mnt/m/TV/ htpc.lan:/mnt/n/TV/ /mnt/array/tv/ && \
-rsync -av --info=progress2 --delete laptop.lan:/home/bryan/documents ~/documents && \
-rsync -av --info=progress2 --delete laptop.lan:/home/bryan/media/music /mnt/array/music
-