nvim and cheat

This commit is contained in:
2025-08-25 07:31:55 -04:00
parent 6e3a38a722
commit a71c14b9f6
7 changed files with 177 additions and 14 deletions

30
.config/cheat/glowpager.sh Executable file
View File

@@ -0,0 +1,30 @@
#! /bin/bash
# Create a temporary file
FILENAME=$(mktemp)
# Save the original file name in our temp file
cat > $FILENAME
# make sure variables exist and set default values otherwise
export LHOST="${LHOST:-$(command ip a | grep eth1 | grep inet | awk '{print($2)}' | cut -d '/' -f 1)}"
export LHOST="${LHOST:-$(command ip a | grep tun0 | grep inet | awk '{print($2)}' | cut -d '/' -f 1)}"
export LHOST="${LHOST:-\$LHOST}"
export LPORT="${LPORT:-\$LPORT}"
if [ $USER = "kali" ]; then
unset USER
fi
export USER="${USER:-\$USER}"
export PASS="${PASS:-\$PASS}"
export DOMAIN="${DOMAIN:-\$DOMAIN}"
export DCIP="${DCIP:-\$DCIP}"
export DC="${DC:-\$DC}"
# Get the file content and substitute environment variables
TEMPCONTENT=$(command cat $FILENAME | envsubst '$LPORT' | envsubst '$LHOST' | envsubst '$USER' | envsubst '$PASS' | envsubst '$DOMAIN' | envsubst '$DC' | envsubst '$DCIP' )
# Delete the tempfile again
rm $TEMPFILE
# Output the content as markdown with glow
echo "$TEMPCONTENT" | glow --style "$XDG_CONFIG_HOME/glow/dark.json" | sed 's/\\x1b/\x1b/g'