Useful BASH functions

Ever get tired of writing the same commands over and over again?

The easiest way to load these functions is from the ~/.bashrc file that is loaded at login

Find command in history

Syntax:
# h text_string_to_search_for
Function:
h() { history | grep ${*} ; }

Follow a log-file

Syntax:
# t messages
# t *log
Function:
t() { tail -f /var/log/${*} ; }

Use vim for safe encryption

Vim has built in support for file encryption but the standard settings are insecure, here is a function that creates a separate vimrc-file to harden the security.

Syntax:

# vimcrypt filename.txt

Function:

vimcrypt() {
        [[ ! -f ~/.vimcryptrc ]] && echo -e "set cryptmethod=blowfish2\nset nobackup\nset noswapfile\nset nowritebackup" > ~/.vimcryptrc
        vim -u ~/.vimcryptrc -x $1
}
Categorized as Bash