diff --git a/1bash-win.d/functions.sh b/1bash-win.d/functions.sh new file mode 100644 index 0000000..01077e1 --- /dev/null +++ b/1bash-win.d/functions.sh @@ -0,0 +1,26 @@ +# get rid of git lf warning in windows +function gitlf { + git config --global core.autocrlf true +} + +# whois a domain or a URL +function whois { + local domain=$(echo "$1" | awk -F/ '{print $3}') # get domain from URL + if [ -z $domain ] ; then + domain=$1 + fi + echo "Getting whois record for: $domain …" + + # avoid recursion + # this is the best whois server + # strip extra fluff + /mingw64/bin/whois.exe $domain whois.internic.net | awk '/Domain Name/,/>>>/' +} + + +function localip { + local adapter + adapter=$(netsh interface ipv4 show interface | grep -i eth | awk 'BEGIN {-F$'\t'} ; {print $5}') + netsh interface ip show addresses $adapter | grep -i ip | grep -Eo '([0-9]*\.){3}[0-9]*' +} + diff --git a/1bash.d/functions.sh b/1bash.d/functions.sh index 93ba47b..77686e2 100644 --- a/1bash.d/functions.sh +++ b/1bash.d/functions.sh @@ -72,6 +72,12 @@ function csvpreview { sed 's/,,/, ,/g;s/,,/, ,/g' "$@" | column -s, -t | less -#2 -N -S } +# get public ip information +function publicip { + curl -s ipinfo.io +} + + # Extract archives - use: extract # Based on http://dotfiles.org/~pseup/.bashrc function extract { @@ -157,3 +163,32 @@ nameserver 178.22.122.100 nameserver 94.232.174.194 EOF } + +# network speed test +function speedtest { + curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python - +} + +# completion prompt +function complete { + case $1 in + -h) + echo "pass argument (docker, docker-compose, git, kubectl, git-flow) for completion";; + docker) + source /c/Users/mohammad.kahani/1bash/1bash.d/completion.d/docker + echo "docker done!" ;; + docker-compose) + source /c/Users/mohammad.kahani/1bash/1bash.d/completion.d/docker-compose + echo "docker-compose done!" ;; + git) + source /c/Users/mohammad.kahani/1bash/1bash.d/completion.d/git + echo "git done!" ;; + git-flow) + source /c/Users/mohammad.kahani/1bash/1bash.d/completion.d/git-flow + echo "git-flow done!" ;; + kubectl) + source /c/Users/mohammad.kahani/1bash/1bash.d/completion.d/kubectl + echo "kubectl done!" ;; + esac +} + diff --git a/1bash.d/prompt.sh b/1bash.d/prompt.sh index 4891ace..6b5d2ae 100644 --- a/1bash.d/prompt.sh +++ b/1bash.d/prompt.sh @@ -26,28 +26,28 @@ set_prompts() { local dateCmd="" - if [ -x /usr/bin/tput ] && tput setaf 1 &> /dev/null; then + # if [ -x /usr/bin/tput ] && tput setaf 1 &> /dev/null; then - tput sgr0 # Reset colors + # tput sgr0 # Reset colors - bold=$(tput bold) - reset=$(tput sgr0) + # bold=$(tput bold) + # reset=$(tput sgr0) - # Solarized colors - # (https://github.com/altercation/solarized/tree/master/iterm2-colors-solarized#the-values) - black=$(tput setaf 0) - blue=$(tput setaf 33) - cyan=$(tput setaf 37) - green=$(tput setaf 190) - orange=$(tput setaf 172) - purple=$(tput setaf 141) - red=$(tput setaf 124) - violet=$(tput setaf 61) - magenta=$(tput setaf 9) - white=$(tput setaf 8) - yellow=$(tput setaf 136) + # # Solarized colors + # # (https://github.com/altercation/solarized/tree/master/iterm2-colors-solarized#the-values) + # black=$(tput setaf 0) + # blue=$(tput setaf 33) + # cyan=$(tput setaf 37) + # green=$(tput setaf 190) + # orange=$(tput setaf 172) + # purple=$(tput setaf 141) + # red=$(tput setaf 124) + # violet=$(tput setaf 61) + # magenta=$(tput setaf 9) + # white=$(tput setaf 8) + # yellow=$(tput setaf 136) - else + # else bold="" reset="\e[0m" @@ -64,7 +64,7 @@ set_prompts() { white="\e[1;37m" yellow="\e[1;33m" - fi + # fi # Only show username/host if not default function usernamehost() { diff --git a/1bash.sh b/1bash.sh index 0519a27..7a73759 100644 --- a/1bash.sh +++ b/1bash.sh @@ -21,8 +21,23 @@ if [ ! -d "$ONE_BASH/1bash.d" ]; then fi for i in $ONE_BASH/1bash.d/*.sh; do - if [ -r $i ]; then - . $i + if [ -r $i ]; then + if [ "$i" != "/c/Users/mohammad.kahani/1bash/1bash.d/completion.sh" ]; then + . $i + fi fi done unset i + + +# adjust to windows envirnment +if [ "$OS" = "Windows_NT" ]; then + for i in $ONE_BASH/1bash-win.d/*.sh; do + if [ -r $i ]; then + . $i + fi + done + unset i +fi + +