Skip to content

Instantly share code, notes, and snippets.

@witt3rd
Last active July 12, 2018 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save witt3rd/a546173223252c554eb621c680b24baf to your computer and use it in GitHub Desktop.
Save witt3rd/a546173223252c554eb621c680b24baf to your computer and use it in GitHub Desktop.

Bash Config

  • OSX: .bash_profile
  • Linux: .bashrc

Powerline Shell

https://github.com/banga/powerline-shell

SSH

Create a key

ssh-keygen -t rsa

opy key to destination server

ssh-copy-id -i ~/.ssh/id_rsa.pub username@server

Bash Tricks

GNU Commandline Tools for OSX

On OSX, the standard *nix commands (e.g., sed, awk, grep, ...) are based on the BSD variant. The GNU Core Utilities and the many individual commands are available via Homebrew. The following blogs are useful reads (but a bit outdated):

brew install findutils --with-default-names
brew install gnu-sed --with-default-names
brew install gnu-tar --with-default-names
brew install gnu-which --with-default-names
brew install gnutls --with-default-names
brew install grep --with-default-names
brew install coreutils
brew install binutils
brew install diffutils
brew install gzip
brew install watch
brew install tmux 
brew install wget
brew install nmap
brew install gpg
brew install htop

Get a list of subdirectories containing a file, excluding some subdirectories

e.g., all subdirectories containing git repos, except those in 'node_modules/*'

find . -type d -name '.git' | sed -r 's|/[^/]+$||' |sort |uniq |grep -v -F '/node_modules/'

Run a command on each line of a another command's output: xargs

ls -l | xargs -t -I % ls %'/.git' 

xargs with multiple commands

ls -l | xargs -t -I % sh -c 'cd %; git pull' 

Combining multiple commands into a single step

(cd scratch/ && git pull)

Apt

Fix broken install

sudo apt-get -o Dpkg::Options::="--force-overwrite" install --fix-broken -y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment