Skip to content

Instantly share code, notes, and snippets.

@k5njm
Created August 28, 2023 01:07
Show Gist options
  • Save k5njm/96f3c3d87aaa843547276e4739e7c0d4 to your computer and use it in GitHub Desktop.
Save k5njm/96f3c3d87aaa843547276e4739e7c0d4 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Get the number of rows available in the terminal
ROWS=$(tput lines)
# Generate your nmcli content
CONTENT=$(nmcli -f SSID,RATE,CHAN,SIGNAL,BARS dev wifi list | awk '!seen[$1]++')
# Check if the content exceeds the available rows
if [ $(echo "$CONTENT" | wc -l) -gt $ROWS ]; then
# If it exceeds, display using 'less'
echo "$CONTENT" | less
else
# Otherwise, just display it normally
echo "$CONTENT"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment