Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions 1bash-win.d/functions.sh
Original file line number Diff line number Diff line change
@@ -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]*'
}

35 changes: 35 additions & 0 deletions 1bash.d/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <file>
# Based on http://dotfiles.org/~pseup/.bashrc
function extract {
Expand Down Expand Up @@ -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
}

38 changes: 19 additions & 19 deletions 1bash.d/prompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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() {
Expand Down
19 changes: 17 additions & 2 deletions 1bash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😮 😆

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:))))))

. $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