Skip to content

Instantly share code, notes, and snippets.

@deleugpn
Last active July 24, 2018 09:17
Show Gist options
  • Save deleugpn/b38c6b7b8ffb25d9a506e02f7dab81ce to your computer and use it in GitHub Desktop.
Save deleugpn/b38c6b7b8ffb25d9a506e02f7dab81ce to your computer and use it in GitHub Desktop.
# .bashrc
# User specific aliases and functions
[ -r /etc/bashrc ] && source /etc/bashrc
[ -r /etc/bash_completion ] && source /etc/bash_completion
[ -r ~/.git-completion.bash ] && source ~/.git-completion.bash
[ -r ~/.git-prompt.sh ] && source ~/.git-prompt.sh
[ -r /usr/local/rvm/scripts/rvm ] && source /usr/local/rvm/scripts/rvm
__has_parent_dir () {
# Utility function so we can test for things like .git/.hg without firing up a
# separate process
test -d "$1" && return 0;
current="."
while [ ! "$current" -ef "$current/.." ]; do
if [ -d "$current/$1" ]; then
return 0;
fi
current="$current/..";
done
return 1;
}
__vcs_name() {
if [ -d .svn ]; then
echo "-[svn]";
elif __has_parent_dir ".git"; then
echo "-[$(__git_ps1 'git %s')]";
elif __has_parent_dir ".hg"; then
echo "-[hg $(hg branch)]"
fi
}
black=$(tput -Txterm setaf 0)
red=$(tput -Txterm setaf 1)
green=$(tput -Txterm setaf 2)
yellow=$(tput -Txterm setaf 3)
dk_blue=$(tput -Txterm setaf 4)
pink=$(tput -Txterm setaf 5)
lt_blue=$(tput -Txterm setaf 6)
bold=$(tput -Txterm bold)
reset=$(tput -Txterm sgr0)
# Nicely formatted terminal prompt
export PS1='\n\[$bold\]\[$black\][\[$dk_blue\]\@\[$black\]]-[\[$green\]\u\[$yellow\]@\[$green\]\h\[$black\]]-[\[$pink\]\w\[$black\]]\[\033[0;33m\]$(__vcs_name) \[\033[00m\]\[$reset\]\n\[$reset\]\$ '
alias ls='ls -F --color=always'
alias dir='dir -F --color=always'
alias ll='ls -l'
alias cp='cp -iv'
alias rm='rm -i'
alias mv='mv -iv'
alias grep='grep --color=auto -in'
alias ..='cd ..'
alias vim='gvim'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias cls='printf "\033c"'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
# Git
alias nah="git reset --hard;git clean -df;"
# PHP 7.2
alias php-build='docker build /home/deleu/docker/php-cli/ -t php:cli-local'
alias php-ssh='docker run -it --rm -v $(pwd):/app -v /home/deleu/composer-cache:/root/.composer/cache -w /app php:cli-local bash'
alias php-container='docker run --rm -v $(pwd):/app -v /home/deleu/composer-cache:/root/.composer/cache -w /app php:cli-local'
alias php='php-container php '
# PHPUnit
alias phpunit-build='docker build /home/deleu/docker/phpunit/ -t phpunit'
alias phpunit='docker run --rm -v $(pwd):/app -v /home/deleu/composer-cache:/root/.composer/cache -w /app phpunit phpunit '
# Laravel
alias laravel-installer='php-container sh -c "composer create-project laravel/laravel --prefer-dist installation && mv installation/* ./ && mv installation/.* ./"'
# Docker
alias rm-docker='docker rm $(docker ps -a -q)'
alias rmi-docker='docker rmi $(docker images -f "dangling=true" -q)'
alias stop-docker='docker stop $(docker ps -a -q)'
dssh() {
PROJECT=$1
docker exec -it $(docker ps | grep $PROJECT | awk '{print $1}' | sed 's/.*://') bash
}
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment