File tree Expand file tree Collapse file tree 3 files changed +28
-2
lines changed
Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change 3737
3838# open current dir in Finder
3939alias here='open .'
40- # get machine IP
41- alias myip='ipconfig getifaddr en0'
4240# list all TCP ports
4341alias ports='lsof -iTCP -sTCP:LISTEN -n -P'
4442# stop all containers
Original file line number Diff line number Diff line change @@ -190,4 +190,30 @@ size() {
190190
191191 echo "Size:"
192192 du -sh "$1" 2>/dev/null
193+ }
194+
195+ # Return the machine public IP
196+ myip() {
197+ if command -v ip >/dev/null 2>&1; then
198+ # Linux
199+ ip route get 1 | awk '{print $7}'
200+ elif command -v ifconfig >/dev/null 2>&1; then
201+ # macOS and other Unix systems
202+ ifconfig | grep -E 'inet (192|10|172)' | head -1 | awk '{print $2}'
203+ else
204+ # Fallback for systems without ip/ifconfig
205+ echo "Error: Neither 'ip' nor 'ifconfig' command found"
206+ return 1
207+ fi
208+ }
209+
210+ myip-global() {
211+ # Try multiple methods to get public IP
212+ if command -v curl >/dev/null 2>&1; then
213+ curl -s https://api.ipify.org
214+ else
215+ # Fallback to local IP if no external tools available
216+ echo "Error: please install 'curl'"
217+ return 1
218+ fi
193219}
Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ brew install --quiet tree
3636brew install --quiet nvim
3737brew install --quiet bash-completion
3838brew install --quiet ffmpeg
39+ brew install --quiet nmap
40+ brew install --quiet curl
3941
4042# Clean brew
4143brew cleanup
You can’t perform that action at this time.
0 commit comments