nvim and cheat
This commit is contained in:
30
.config/cheat/glowpager.sh
Executable file
30
.config/cheat/glowpager.sh
Executable 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'
|
||||
|
||||
Reference in New Issue
Block a user