Home

shell aliases

If a command is a alias, you can unalias it

# Add color to command outputs
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias diff='diff --color=auto'

alias dir='dir --color=auto' # is equivalent to ls -Cb
alias vdir='vdir --color=auto' # is equivalent to ls -l -b
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'


alias g='git'
# Don't use these often enough
# alias t='touch'
# alias c='clear' # better name: cl

alias rmi='rm -i' # Remove files with confirmation

# -----------------------------------------------------
# Listing. ls, du
# -----------------------------------------------------
# ls
# -A, --almost-all: do not list implied . and ..
# -h, --human-readable: with -l and -s, print sizes like 1K 234M 2G etc
# -l: Use long listing format.
# -t: Sort by time (newest first).
# --time=birth: Sort by creation time.
# -----------------------------------------------------

# List dir including: permissions, users, groups, size, date
alias ls-detail='ls -lhA'
alias l='ls -lah' # List files with details

# Include hidden files
alias ls-hidden='ls -a'

# Only list directories
#alias lsdir='ls -d */'
alias ls-dir='ls -d */'

# List files by creation date
alias ls-bycreationdate='ls -lt --time=birth'
# List files by creation date. Newest at the bottom
alias ls-bycreationdate-rev='ls -lt --time=birth -r'

# Will display the sizes of all directories (and files) in the current directory, sorted by size with the largest at the bottom
# du: Disk usage command
#     -s: Summarize the total size of each argument (directory).
#     -h: Display sizes in a human-readable format (e.g., K, M, G).
#     *: List all files and directories in the current directory.
# sort: Sorts lines of text.
#     -h: Sorts human-readable numbers (like 1K, 234M, 2G) correctly.
alias ls-bysize='du -sh * | sort -h'
# only list directories
alias dir-bysize='du -sh */ | sort -h'

# count files in directory. List total files in directory

# -----------------------------------------------------
# Search for text in files
# -----------------------------------------------------

# -I: ignore binary files
# node directories: {node_modules,build} {package-lock.json}
alias grep='grep --exclude-dir={.bzr,CVS,.git,.hg,.svn,venv,node_modules,build} --exclude=\*.{o,png,jpg,jpeg,gif,webp,mp3,flac,pdf,xcf,package-lock.json} -I'

# -----------------------------------------------------
# Search for files and directories
# -----------------------------------------------------

alias find_file='_findf() { find . -type f -iname "$1" ;}'
alias ff='_ff() { find . -type f -iname "$1" ;}'

# Easy navigation to code repositories
# To do. Navigate and do a git fetch
alias name_of_project1='cd /bla/bla'
alias name_of_project2='cd /foo/foo'

Date:

Screen Dimensions