From 8fc442eb914f558b5d6c856412ecaad833fcf873 Mon Sep 17 00:00:00 2001 From: Artem Sapegin Date: Thu, 19 Sep 2013 21:38:15 +0400 Subject: [PATCH] myip alias. --- includes/bash_aliases.bash | 2 ++ includes/bash_functions.bash | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/bash_aliases.bash b/includes/bash_aliases.bash index 1a81f09..23b0e58 100644 --- a/includes/bash_aliases.bash +++ b/includes/bash_aliases.bash @@ -40,6 +40,8 @@ alias rm="rm -i" # Gzip-enabled `curl` #alias gurl="curl --compressed" +alias myip="ifconfig | grep 'inet ' | grep -v 127.0.0.1 | awk '{print \$2}'" + # Software/libraries update alias update="source "$HOME/dotfiles/setup/update.sh"" diff --git a/includes/bash_functions.bash b/includes/bash_functions.bash index b277123..da54ae9 100644 --- a/includes/bash_functions.bash +++ b/includes/bash_functions.bash @@ -290,6 +290,8 @@ EOF # Usage: server [port] function server() { local port="${1:-8000}" + echo "Access from network: http://$(myip):$port" + echo open "http://localhost:${port}/" # Set the default Content-Type to `text/plain` instead of `application/octet-stream` # And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files) @@ -301,6 +303,6 @@ function sayit() { } # Add special aliases that will copy result to clipboard (escape → escape+) -for cmd in password hex2hsl hex2rgb escape codepoint ssh-key; do +for cmd in password hex2hsl hex2rgb escape codepoint ssh-key myip; do eval "function $cmd+() { $cmd \$@ | c; }" done