How to clone all Github repositories for a given user

It’s a hack, but it’ll work. You’ll need either:

  • Linux
  • OSX
  • Windows, running the git-bash app (highly recommended). Download it here: Git – Downloads




Using LS_COLORS to colorize your shell by filename / filetype

Messing with LS_COLORS


Before and after

Small steps

I’ll first set LS_COLOR='' Below, you’ll see that nothing is colored, except for the directories which are blue, because of another environment variable called DIR_COLORS. We are going to learn how to tell LS_COLORS to colorize files by name.

I usually had colored by files by whether or not they were executable, a symbolic link, etc, which something like LS_COLORS='di=96:fi=0:ln=33:ex=1;92' which sets

  • directories to 96 (cyan)
  • files to 0 (default)
  • links to 33 (yellow)
  • executables to 92 (green)

and so on.




Go further

I realized recently you can set LS_COLORS to colorize files by name. This is useful in times where you know many types of files will be present in a directory and you want to see what they are right away. Or even if its not that useful, it’s still pretty cool.

Here I know I have .tex, .aux, .log, .bib, .png, .zip, and .pdf all in this directory. I do LS_COLORS='*.png=96:*.aux=90:*.bib=94:*.log=1;90:*.pdf=1;93:*.tex=93:*.zip=91:di=1;94'




Notice how you can set bold and a color with 1;COLOR.

 

Extreme Measures

Since you can take this to extremes, I did.  I quite like it – I use colored pens in real life, so when I discovered this, I just had to …

LS_COLORS='di=96:fi=0:ln=33:pi=5:so=5:bd=5:cd=5:or=37:mi=0:ex=91:*.rpm=90:*.deb=92:*.run=1;92:*.png=34:*.jpg=94:*.JPG=94:*.JPEG=94:*.xcf=34:*.tiff=1;34:*.TIFF=1;34:*.gif=1;94:*.aux=90:*.bib=34:*.log=1;90:*.pdf=1;93:*.tex=33:*.zip=31:*.tar.gz=91:*.tar.bz2=91:*.exe=1;94;100:*.doc=1;94;100:*.xlsx=1;94;100:*.xls=1;94;100:*.pptx=1;94;100:*.nb=31:*.math=91:*.m=31:*.py=93:*.sh=92:*.rb=95:*.pl=1;94:*.c=31:*.h=91:*.md=1;33:*README=1;33:*LICENSE=33:*.txt=93:*.ipynb=1;33:*.mp3=31:*.mp4=91:*.mov=1;91:*.html=95:*.js=35:*.css=1;95:*rc=32:*config=1;32:*makefile=1;91'

🙂 Enjoy the pretty prompts!



Useful shell aliases

Redo the last command as if I had sudoed

alias please='sudo $(fc -ln -1)'

Use this all the time

(Ubuntu) Install a package I don’t have but tried to use

alias ok='eval $($(fc -ln -1) 2>&1 | sed -n 2p)'

Go back to previous directory


alias back='cd $OLDPWD'

I use this one most of all when copying files to destinations outside of the current directory, especially if the paths involved are pretty long. Sometimes after copying, I may follow the file to the destination just to check what I just did by changing directory to the destination directory. ‘back’ lets me return to where I was before pretty effortlessly. This alias takes advantage of the OLDPWD environment variable.

Free up system memory

alias freemem='echo "echo 1 > /proc/sys/vm/drop_caches" | sudo sh'

For this example, I started to copy a 4 GB file so that I knew my ram would start to be used up. Here, you can see my memory available on the left is decreasing as I hit enter for purposes of demonstration. (displaying my system memory is done using the PROMPT_COMMAND environment variable). You can see when I use freemem, I get my memory back.

Colorize cat!

alias dog='pygmentize -g'




This works like cat in that it dumps the contents of a file to the screen. It does not concatenate files. But it does read the shebang and print the code with syntax highlighting, if it can. Requires python-pygmentize

Find a file or directory in working dir matching a string.

I use this one a LOT! Ignores case and prints line number.

alias lsg='ls -la| grep -ni'

I have many variants of this one, most notably to do this recursively through directories beneath you: ls -laR | grep -in




If you don’t have pygmentize for my dog alias, make installing it a breeze

(Ubuntu) obviously

alias gimme='sudo apt-get install'