leopolicastro
10/22/2019 - 12:11 AM

bash aliases

## Custom Aliases
#
#   Make sure to paste this snippet in your ~/.bashrc
#
# if [ -e $HOME/.bash_aliases ]; then
#     source $HOME/.bash_aliases
# fi

alias c='clear'
alias ..='cd ..'
alias ...='cd .. && cd ..'

# LS but sorting by filesize
alias lt='ls --human-readable --size -1 -S --classify'
alias ll="ls -lhA"

# View only mounted drives
alias mnt="mount | awk -F' ' '{ printf \"%s\t%s\n\",\$1,\$3; }' | column -t | egrep ^/dev/ | sort"

# We can find files in our current directory easily by setting this alias:
alias fhere="find . -name "

# How about we make our process table searchable. We can create an alias that searches our process for an argument we’ll pass:
alias psg="ps aux | grep -v grep | grep -i -e VSZ -e"

# Git aliases
alias gad='git add .'
alias gcm='git commit -m'
alias gst='git status'
alias gco='git checkout'

# Swith to repos directory
alias repos='cd /home/leo/Desktop/repos && lt'

# Jupyter notebook
alias jn='jupyter notebook'

# cat ssh key
alias catssh='cat ~/.ssh/id_rsa.pub | pbcopy'

# Tmux Aliases
alias tmuxls='tmux list-sessions'

#If the last character of the alias value is a blank, then the next command word following the alias is also checked for alias expansion.
alias sudo='sudo '

# Grep modifications
alias grep='grep --color'
alias grepp="grep -P --color"

# Copy and paste aliases
# alias pbcopy='xclip -selection clipboard'
# alias pbpaste='xclip -selection clipboard -o'

# Random aliases
alias mkdir="mkdir -p"
alias histg="history | grep"
alias du="ncdu"

alias myip="curl http://ipecho.net/plain; echo"

alias up='sudo apt-get update && sudo apt-get upgrade -y'

# spin up app locally
alias yarns='yarn start'
alias yarnd='yarn dev'
alias railss='rails s'
alias cat='bat'

# Custom functions

# CD into a directory and ls it.
function cl() {
    DIR="$*";
        # if no DIR given, go home
        if [ $# -ll 1 ]; then
                DIR=$HOME;
    fi;
    builtin cd "${DIR}" && \
    # use your preferred ls command
        ls -F --color=auto
}

# Make dir and cd into it
mkcdr () {
    mkdir "$1" && cd "$1"
}