Skip to content

Instantly share code, notes, and snippets.

@tappoz
Last active October 25, 2021 08:00
Show Gist options
  • Save tappoz/9c8ff2f02513d58c4c180f8fae28ba8f to your computer and use it in GitHub Desktop.
Save tappoz/9c8ff2f02513d58c4c180f8fae28ba8f to your computer and use it in GitHub Desktop.
command line tricks

How to find and list all the symbolic links created for a particular file?

$ ls -li
# take note of the symlink ID
$ find / -follow -inum 5097642 2>/dev/null
# you'll have a list of symlink to that inode

Useful bash configuration

These could be added to .bashrc, .bash_profile or similar configuration files.

# lower case UUIDs
alias uuidlc='uuidgen | tr "[:upper:]" "[:lower:]"'
# formatted date-time
alias datefmt='date +"%F %T"'
# increasing the soft limit of open files (cfr. the node.js/grunt warning/error "Warning: spawn EMFILE")
ulimit -Sn 10000

alias ll="ls -lah"
alias grep="grep --color=always"

Vim settings

Put the following in .vimrc inside your home directory (~).

" to highlight the syntax of a programming language
syntax on
" to show line numbers on the left
set nu
" to highlight the searched string inside the content 
set hlsearch
" to hightlight the syntax of a JSON/javascript file based on the file extension
autocmd BufNewFile,BufRead *.json set ft=javascript

As an alternative, specific filetype settings could be put in ~/.vim/filetype.vim, e.g.:

" to highlight the Groovy syntax for Gradle files 
au BufNewFile,BufRead *.gradle setf groovy

Find your public IP address via bash

export WHAT_IS_MY_PUBLIC_IP=$(dig +short myip.opendns.com @resolver1.opendns.com)

Get the private IP address of eth0

export WHAT_IS_MY_PRIVATE_IP=$(ifconfig eth0 | grep 'inet addr' | awk '{print $2 }' | sed 's/addr://g')

Pull requests lifecycle

cf. https://coderwall.com/p/z5rkga/github-checkout-a-pull-request-as-a-branch

git fetch origin refs/pull/611/head:pull_611
git checkout pull_611

Bash for loop to uninstall Pip packages

Uninstall all the pip packages with a name starting with azure-:

for i in `pip list | awk '/azure-/ {print $1}'`; do pip uninstall -y $i ; done

Check where's the disk space being eaten

Rank directories by disk space usage e.g. in $HOME:

cd $HOME && ncdu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment