Last active
October 15, 2015 09:42
-
-
Save rantoniuk/1bb14afe27afd26b5727 to your computer and use it in GitHub Desktop.
.bash_profile with docker aliases and nice prompt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To install: | |
# curl -s https://gist.githubusercontent.com/warden/1bb14afe27afd26b5727/raw/gistfile1.txt > ~/.bash_profile_gist && grep -q -F 'bash_profile_gist' ~/.bashrc || sed -i '1s/^/. ~\/.bash_profile_gist \n/' ~/.bashrc | |
# | |
# For MAC users (as sed on MAC OS X is stupid ;) ): | |
# curl -s https://gist.githubusercontent.com/warden/1bb14afe27afd26b5727/raw/gistfile1.txt > ~/.bash_profile_gist && grep -q -F 'bash_profile_gist' ~/.bashrc || sed -i -e '~' '1s/^/. ~\/.bash_profile_gist\'$'\n/' ~/.bash_profile \'$'\n | |
alias update-bash-profile='curl -s https://gist.githubusercontent.com/warden/1bb14afe27afd26b5727/raw/gistfile1.txt > ~/.bash_profile_gist && grep -q -F "bash_profile_gist" ~/.bashrc || sed -i "1s/^/. ~\/.bash_profile_gist \n/" ~/.bashrc' | |
## SSH AGENT ## | |
SSH_ENV=$HOME/.ssh/environment | |
function start_agent { | |
echo "Initialising new SSH agent..." | |
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > ${SSH_ENV} | |
echo succeeded | |
chmod 600 ${SSH_ENV} | |
. ${SSH_ENV} > /dev/null | |
/usr/bin/ssh-add; | |
} | |
# Source SSH settings, if applicable | |
if [ -f "${SSH_ENV}" ]; then | |
. ${SSH_ENV} > /dev/null | |
#ps ${SSH_AGENT_PID} doesn't work under cywgin | |
ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || { | |
start_agent; | |
} | |
else | |
start_agent; | |
fi | |
## FUNCTIONS ## | |
function prompt { | |
local BLUE="\[\033[0;34m\]" | |
local DARK_BLUE="\[\033[1;34m\]" | |
local RED="\[\033[0;31m\]" | |
local DARK_RED="\[\033[1;31m\]" | |
local NO_COLOR="\[\033[0m\]" | |
case $TERM in | |
xterm*|rxvt*) | |
TITLEBAR='\[\033]0;\u@\h:\w\007\]' | |
;; | |
*) | |
TITLEBAR="" | |
;; | |
esac | |
PS1="\u@\h [\t] \w> " | |
PS1="${TITLEBAR} $BLUE\u@\h $RED[\t] \w ->$NO_COLOR " | |
PS2='continue-> ' | |
PS4='$0.$LINENO+ ' | |
} | |
prompt # run it | |
mysqlgrants() | |
{ | |
mysql -B -N $@ -e "SELECT DISTINCT CONCAT( | |
'SHOW GRANTS FOR ''', user, '''@''', host, ''';' | |
) AS query FROM mysql.user" | \ | |
mysql $@ | \ | |
sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/## \1 ##/;/##/{x;p;x;}' | |
} | |
## DOCKER | |
docker-ip() { | |
boot2docker ip 2> /dev/null | |
} | |
docker-vmip() { | |
docker inspect --format '{{ .NetworkSettings.IPAddress }}' "$@" | |
} | |
docker-bash(){ | |
docker exec -it "$@" bash | |
} | |
docker-exec(){ | |
docker exec -it "$1" $2 | |
} | |
alias docker-clear-unused-images='docker rmi $(docker images -q --filter "dangling=true")' | |
alias docker-remove-all-containers='docker rm $(docker ps -a -q)' | |
alias docker-remove-all-images='docker rmi $(docker images -q)' | |
alias docker-build="docker build -t $(basename $(pwd)) ." | |
alias drmit="docker run --rm -it --name " | |
## Git Aliases (for master) | |
alias git-unpushed="git log origin/master..HEAD" | |
## OTHER | |
alias ll="ls -Al" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment