All things bash: some of my most used alias 

Published 2018-02-26 on

category | code programming macos linux terminal git bash

Since starting my work as a professional iOS developer i’ve become more and more fond with just using the terminal. Wether it’s a ninety-days git-via-terminal challenge or simply trying to become a keyboard-ninja: there are things only the terminal can do.

In 2016 i’ve open-sourced my bash-config and i want to use this opportunity to highlight some of the commands inside it.

Quickly toggle hidden-files visibility in finder

# macOS Control
alias show_hidden_files='defaults write AppleShowAllFiles YES && killall Finder'
alias hide_hidden_files='defaults write AppleShowAllFiles NO && killall Finder'

Every so-often you’ll need access to some hidden files not inside the terminal, but inside finder. However some of macOS commands are just plan hard to remember and googling this things every time i needed this toggle just made things unnecessary hard.

Rapid archive + sync

# Archiving
alias tarball='tar -cvf' # outputfilename + directory to tar
alias sync='rsync -azvhW --progress'

Since i replaced public clouds with physical drives and Seafile Pro i ran into the task of quickly moving and/or synching large directories between multiple sources and destinations. These (chainable) commands speed things up a bit.

Quickly exhanging an AES 256 encrypted file with someone else

alias encryptFile='gpg --symmetric --cipher-algo aes256 --digest-algo sha256 --compress-algo none -z 0 --armour' # file name need to be specified

“Please send me that sensitive file via Slack.”   Note: Requires GPG Tools to be installed.

Gimme a 3GB ramdisk

alias ramdisk='read -p "GB size for RAMdisk: " answer && sudo diskutil erasevolume HFS+ "ramdisk" `hdiutil attach -nomount ram://$(( $answer * 2097152))`'

Some file-r/w actions just should not happen on a physical disk. This alias prompts for a ramdisk size in GB, formats and mounts it.

All things GIT

## GIT Command substitution
alias gBranch='git branch -a -v -v'
alias gFetch='git fetch && git branch -a -v -v'
alias gTree='git log --graph --oneline'
alias gTreeFancy='git log --graph --pretty=format:"%C(yellow)%h %Cred%ad %Cblue%an %Cgreen%d %Creset%s" --date=short'
alias gListTags='git log --date-order --graph --tags --simplify-by-decoration --pretty=format:"%ai %h %d"'

GIT command-line syntax is just stupid. And sometimes, i need a colorful network-list of all commits in the repo. :)

A gift from my side: .vimrc

syn on
set incsearch
set tabstop=4
set showmatch
set autoindent
set nocindent
set backspace=2

If you got any additional ideas on awesome terminal alias, feel free to reach out to me! I’m happy to learn.