Skip to content

Instantly share code, notes, and snippets.

@Gabelbombe
Last active June 23, 2017 19:44
Show Gist options
  • Save Gabelbombe/2bbf1ea6874bdbc5ca2964c584e3cac6 to your computer and use it in GitHub Desktop.
Save Gabelbombe/2bbf1ea6874bdbc5ca2964c584e3cac6 to your computer and use it in GitHub Desktop.

Commands that are required to be ran in order to set up a Mac

Install Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Get generator
if ! hash pwgen 2>/dev/null ; then
  brew install pwgen
fi
Generate STRONG passwords
## Generate strong password, default: 32 chars
function genpass()
{
  LEN=${1:-32} ; pwgen -syBv -1 $LEN |head -c -1 |pbcopy ; echo -e '[info] Random pass generated and copied..'
}
#!/bin/bash
## Add reader to profile
echo -e '# Load .bashrc if it exists\ntest -f ~/.bashrc && source ~/.bashrc' >> ~/.bash_profile
## Make config dir and shell exec
mkdir -p ~/.config/shell/bash
cat >~/.bashrc <<EOL
[ -z "$PS1" ] && return # If not running interactively, don't do anything
declare -x USR_DIR='/Users/erickquintanar'
declare -x CNF_DIR="$USR_DIR/.config"
declare -a BS_CONFS=($(ls -l $USR_DIR/.config/shell/bash |awk -v CFG=$USR_DIR/.config/shell/bash '{
printf("%s/%s\n", CFG, $9) ;
}' |tail -n +2))
## include bash confighuration files on the fly..
for CONFIG in ${BS_CONFS[@]} ; do
if [[ $(grep -A1 '## +' $CONFIG) ]] ; then
echo -e "Sourcing: ${CONFIG}"
START=$(date +%s) ; . $CONFIG ; END=$(date +%s)
echo -e "Expended: $(echo $((END-START)) |awk '{printf "%d:%02d:%02d", $1/3600, ($1/60)%60, $1%60}')\n"
unset START END
fi
done
unset BS_CONFS CONFIG
## History manipulation
shopt -s histappend # append to the history file, don't overwrite it
HISTCONTROL=ignoredups:ignorespace # don't put duplicate lines in the history. See bash(1) for more options ... or force ignoredups and ignorespace
HISTSIZE=1000 # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTFILESIZE=2000
EOL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment