# shellcheck shell=bash #region common functions for working with directories # --------------------------------------------- # shortcuts for moving around # --------------------------------------------- alias ..='cd ..' alias ...='cd ../..' alias ....='cd ../../..' # --------------------------------------------- # shortcuts for creating and removing folders # --------------------------------------------- alias md='mkdir -p' alias rd='rmdir' # --------------------------------------------- # more shortcuts for listing files # --------------------------------------------- alias ls='ls --color=auto' alias la='ls --color=auto -Alh' # show hidden files alias ll='ls --color=auto -lh' # sort by size human readable alias lr='ls --color=auto -lR' # recursive ls alias lt='ls --color=auto -ltr' # sort by date # --------------------------------------------- # shortcuts for showing human-readable fs info # --------------------------------------------- # short and human-readable file listing alias dud='du -d 1 -h' # short and human-readable directory listing alias duf='du -sh *' #endregion #region common functions for working with file permissions # --------------------------------------------- # --------------------------------------------- alias perm='stat --printf "%a %n \n "' # perm: show permission of target in number # --------------------------------------------- # --------------------------------------------- alias 000='chmod 000' # ---------- (user: -, group: -, other: -) alias 640='chmod 640' # -rw-r----- (user: rw, group: r, other: -) alias 644='chmod 644' # -rw-r--r-- (user: rw, group: r, other: -) alias 755='chmod 755' # -rwxr-xr-x (user: rwx, group: rx, other: x) alias 775='chmod 775' # -rwxrwxr-x (user: rwx, group: rwx, other: rx) # --------------------------------------------- # --------------------------------------------- alias ux='chmod u+x' # ---x------ (user: --x, group: -, other: -) alias mx='chmod a+x' # ---x--x--x (user: --x, group: --x, other: --x) #endregion #region common preferred default implementation # 'wget' with resume download alias wget='wget -c --no-hsts' # just use color, please alias grep='grep --color=auto' alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias xzegrep='xzegrep --color=auto' alias xzfgrep='xzfgrep --color=auto' alias xzgrep='xzgrep --color=auto' alias zegrep='zegrep --color=auto' alias zfgrep='zfgrep --color=auto' alias zgrep='zgrep --color=auto' #endregion # path: echo all executable paths alias path='echo -e ${PATH//:/\\n}' # cs: clear terminal display alias cs='clear' # ed: editd file in default editor alias ed='${EDITOR}' # se: editd file in default editor with sudo rigths alias se='sudoedit' # src: reload .bashrc file alias src='source ~/.bashrc' # qfind: quickly search for file alias qfind='find . -name ' # ip just color my ip command alias ip='ip -c' # Mirror stdout to stderr, useful for seeing data going through a pipe alias peek='tee >(cat 1>&2)' function open() { command xdg-open "${@:-"${PWD}"}" >/dev/null 2>&1; } function code() { command codium "${@:-"${PWD}"}" >/dev/null 2>&1; } function mcd() { mkdir -p "$1" && cd "$1" || return; } # Execute a command in a specific directory function xin() ( cd "${1}" && shift && "${@}"; )