Skip to content

Instantly share code, notes, and snippets.

@micrub
Last active October 6, 2021 01:34
Show Gist options
  • Save micrub/f5c1e806ef7c3a2ee723348a8e1ae93f to your computer and use it in GitHub Desktop.
Save micrub/f5c1e806ef7c3a2ee723348a8e1ae93f to your computer and use it in GitHub Desktop.
open ports on macos cli alias

base

stole from how-can-i-list-my-open-network-ports-with-netstat

netstat -Watnlv | grep LISTEN | awk '{"ps -o comm= -p " $9 | getline procname;colred="\033[01;31m";colclr="\033[0m"; print colred "proto: " colclr $1 colred " | addr.port: " colclr $4 colred " | pid: " colclr $9 colred " | name: " colclr procname;  }' | column -t -s "|"

quote wrapped for usage as an alias in zsh

alias listening="netstat -Watnlv | grep LISTEN | awk '{\"ps -o comm= -p \" \$9 | getline procname;colred=\"\033[01;31m\";colclr=\"\033[0m\"; print colred \"proto: \" colclr \$1 colred \" | addr.port: \" colclr \$4 colred \" | pid: \" colclr \$9 colred \" | name: \" colclr procname;  }' | column -t -s \"|\""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment