Last active
December 30, 2022 16:46
-
-
Save sinamics/fad5ebbb62f57e0ef9966e20613dcf2e to your computer and use it in GitHub Desktop.
personal preferances for bashrc
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
# | |
# Download | |
# wget -N https://gist.githubusercontent.com/sinamics/fad5ebbb62f57e0ef9966e20613dcf2e/raw/.bash_aliases | |
# | |
# Install | |
# source .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 dc='runDockerCommand "Docker Compose" "docker-compose"' | |
alias dcb='runDockerCommand "Build containers" "docker-compose build"' | |
alias dcps='runDockerCommand "List all containers" "docker-compose ps"' | |
alias dcu='runDockerCommand "Bringing UP all containers" "docker-compose up"' | |
alias dcd='runDockerCommand "Bringing down containers" "docker-compose down"' | |
alias dcr='runDockerCommand "Restarting Docker services" "docker-compose restart"' | |
alias dcs='runDockerCommand "Stopping Docker services" "docker-compose stop"' | |
alias dcur='runDockerCommand "Force re-creating containers" "docker-compose up -d --force-recreate"' | |
# 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 $3 | |
# 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 check80='sudo netstat -nlp | grep 80' | |
alias lso='ls -o' | |
# 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