Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Commonly used bash aliases
#!/bin/bash
# Colors
RED='\033[0;31m'
BLACK='\033[0;30m'
DARK_GRAY='\033[1;30m'
LIGHT_RED='\033[1;31m'
GREEN='\033[0;32m'
LIGHT_GREEN='\033[1;32m'
BROWN_ORANGE='\033[0;33m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
LIGHT_BLUE='\033[1;34m'
PURPLE='\033[0;35m'
LIGHT_PURPLE='\033[1;35m'
CYAN='\033[0;36m'
LIGHT_CYAN='\033[1;36m'
LIGHT_GRAY='\033[0;37m'
WHITE='\033[1;37m'
NC='\033[0m' # No Color
# Keep 1000 lines in .bash_history (default is 500)
export HISTSIZE=1000
export HISTFILESIZE=1000
export PATH="$PATH:$HOME/.config/composer/vendor/bin"
# Clear the terminal
alias cl='clear'
# List PATHs
alias path="echo -e ${PATH//:/\\n}"
# Become system administrator
alias god='sudo -i'
alias root='sudo -i'
# Disk free in human terms
alias df='df -h'
# Aliases maintaining
alias reload="echo $'\n${GREEN}Reloading .bashrc file...${NC}\n'; source ~/.bashrc"
alias ea='subl ~/.bash_aliases'
# Git
alias gs='git status'
alias gitlog='git log --graph --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" --abbrev-commit'
# Docker
alias d='docker'
alias c='docker-compose'
alias dr='runDockerCommand "Restarting Docker services" "docker-compose restart"'
alias dp='runDockerCommand "Stopping Docker services" "docker-compose stop"'
alias ds='runDockerCommand "Starting Docker services" "docker-compose up -d nginx mysql phpmyadmin"'
alias drb='runDockerCommand "Rebuilding Docker services" "docker-compose up -d --build nginx mysql phpmyadmin"'
# to have files created as your host's user.
alias condoc='runDockerCommand "Connecting Docker workspace container as normal user" "docker-compose exec --user=laradock workspace bash"'
alias condocroot='runDockerCommand "Connecting Docker workspace container as root user" "docker-compose exec workspace bash"'
# alias ds='echo "Starting Docker..."; docker start server'
# alias dp='echo "Stopping Docker..."; docker stop server'
# alias dr='echo "Restarting Docker..."; docker restart server'
# alias condoc='docker exec -ti server su docker'
# alias condocroot='docker exec -ti server bash'
# alias docrun='docker run -d --name=server -v ~/workspace/projects:/web -v ~/workspace/domains:/etc/nginx/sites-enabled -v ~/workspace/db:/var/lib/mysql -p 127.0.0.1:80:80 -p 3306:3306 tolik505/docker-lemp'
# docker-compose requires config file in working directory
# this small function goes to docker root dir, runs command
# and returns back to current user directory
function runDockerCommand {
local CURRENT_DIR=`pwd`
local DOCKER_COMPOSE_DIR=~/workspace/mydock/
echo -e "${PURPLE}"
echo $1"..."
echo -e "${NC}"
cd $DOCKER_COMPOSE_DIR
eval $2
cd $CURRENT_DIR
}
# Code & Log visualization
# sudo apt install gource
alias vizgit="gource -1920x1080 --seconds-per-day 0.25 --auto-skip-seconds 1 --font-size 19 --title 'Visualization' --colour-images"
# sudo apt install logstalgia
alias vizlog="logstalgia -1920x1080 --simulation-speed 20"
# Other
alias ..='cd ..'
alias gohome='cd ~'
alias govar='cd ~/workspace/projects'
alias go='goToDir'
alias godomains='cd ~/workspace/domains'
alias gomydock='cd ~/workspace/mydock'
alias check80='sudo netstat -nlp | grep 80'
alias lso='ls -o'
alias checkgpu="sudo update-pciids && lspci -nn | grep '\[03'"
# Disable webcam
alias camoff="sudo modprobe -r uvcvideo"
# Enable webcam
alias camon="sudo modprobe uvcvideo"
# this function checks if directory exist in projects and switch to it, if it is.
function goToDir {
local BASE_DIR=~/workspace/projects/
local FULL_DIR=$BASE_DIR$1
if ! [[ -d $FULL_DIR && ! -L $FULL_DIR ]]; then
echo -e "${RED}'$1' not found in projects dir! ${NC}"
else
echo -e "${GREEN}'$1' is found, switching to dir... ${NC}"
cd $FULL_DIR
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.