Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Bash Updates #1

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
101 changes: 101 additions & 0 deletions home/.aliases
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#!/usr/bin/env bash
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between this file and the bash_alias file? Seems like duplication of efforts.


# Easier navigation: .., ..., ...., ....., ~ and -
alias cd..="cd .."
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."

# Shortcuts
alias d="cd ~/Documents/Dropbox"
alias dl="cd ~/Downloads"
alias dt="cd ~/Desktop"
alias p="cd ~/Projects"

# JFV: Not sure what to do about colors, add this as a placeholder
# Detect which `ls` flavor is in use
if ls --color > /dev/null 2>&1; then # GNU `ls`
colorflag="--color"
# export LS_COLORS='no=00:fi=00:di=01;31:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:'
else # macOS `ls`
colorflag="-G"
# export LSCOLORS='BxBxhxDxfxhxhxhxhxcxcx'
fi

# Directory listings
# LS_COLORS='no=01;37:fi=01;37:di=07;96:ln=01;36:pi=01;32:so=01;35:do=01;35:bd=01;33:cd=01;33:ex=01;31:mi=00;05;37:or=00;05;37:'
# -G Add colors to ls
# -l Long format
# -h Short size suffixes (B, K, M, G, P)
# -p Postpend slash to folders
# -F add one char of */=>@| to enteries
# alias ls='ls -G -h -p '
alias ll="ls -l -G -h -p"

# List all files colorized in long format with short size buffers postpend /
alias ll="ls -l ${colorflag} -h -p"
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this overriding the above alias?


# List all files colorized in long format
alias l="ls -lF ${colorflag}"

# List all files colorized in long format, excluding . and ..
alias la="ls -lAF ${colorflag}"

# List only directories
alias lsd="ls -lF ${colorflag} | grep --color=never '^d'"

# Always use color output for `ls` or JFV preference
alias ls="command ls ${colorflag}"
alias ls="ls -F"
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this overriding the above alias?


# Always enable colored `grep` output
# Note: `GREP_OPTIONS="--color=auto"` is deprecated, hence the alias usage.
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'

# Enable aliases to be sudo’ed
alias sudo='sudo '

# Get week number
alias week='date +%V'

# Show/hide hidden files in Finder
alias show="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
alias hide="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"

# Hide/show all desktop icons (useful when presenting)
alias hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"

# Lock the screen (when going AFK)
alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"

# Print each PATH entry on a separate line
alias path='echo -e ${PATH//:/\\n}'

# Disable Spotlight
alias spotoff="sudo mdutil -a -i off"
# Enable Spotlight
alias spoton="sudo mdutil -a -i on"

# https://www.npmjs.com/package/buzzphrase
# git commit -m "$(buzzphrase 2)"

# Flush the DNS on Mac
alias dnsflush="dscacheutil -flushcache"

# Flush Directory Service cache
alias flush="dscacheutil -flushcache && killall -HUP mDNSResponder"

# Google Chrome
alias chrome='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'
alias canary='/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary'

# Recursively delete `.DS_Store` files
alias cleanupDS="find . -type f -name '*.DS_Store' -ls -delete"

# JFV Unsure of usage, comment out for now
# URL-encode strings
# alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"'
65 changes: 63 additions & 2 deletions home/.bash_aliases
Original file line number Diff line number Diff line change
@@ -1,17 +1,66 @@
#!/usr/bin/env bash

# Easier navigation: .., ..., ...., ....., ~ and -
alias cd..="cd .."
alias ..="cd .."
alias ll="ls -lhA"
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."

# Shortcuts
alias d="cd ~/Documents/Dropbox"
alias dl="cd ~/Downloads"
alias dt="cd ~/Desktop"
alias p="cd ~/Projects"

# JFV: Not sure what to do about colors, add this as a placeholder
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to add initials. Each line in a file is tracked by git and your user is associated with that change. Git has a 'blame' report that shows who wrote or modified every line and when the change happened. You can jump back to old commits and get a sense of the history from there.

So this is an old pattern. Embrace git. No need to leave your name in the files.

# Detect which `ls` flavor is in use
if ls --color > /dev/null 2>&1; then # GNU `ls`
colorflag="--color"
# export LS_COLORS='no=00:fi=00:di=01;31:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:'
else # macOS `ls`
colorflag="-G"
# export LSCOLORS='BxBxhxDxfxhxhxhxhxcxcx'
fi

# Directory listings
# LS_COLORS='no=01;37:fi=01;37:di=07;96:ln=01;36:pi=01;32:so=01;35:do=01;35:bd=01;33:cd=01;33:ex=01;31:mi=00;05;37:or=00;05;37:'
# -G Add colors to ls
# -l Long format
# -h Short size suffixes (B, K, M, G, P)
# -p Postpend slash to folders
# -F add one char of */=>@| to enteries
# alias ls='ls -G -h -p '
alias ll="ls -l -G -h -p"

# List all files colorized in long format with short size buffers postpend /
alias ll="ls -l ${colorflag} -h -p"

# List all files colorized in long format
alias l="ls -lF ${colorflag}"

# List all files colorized in long format, excluding . and ..
alias la="ls -lAF ${colorflag}"

# List only directories
alias lsd="ls -lF ${colorflag} | grep --color=never '^d'"

# Always use color output for `ls` or JFV preference
alias ls="command ls ${colorflag}"
alias ls="ls -F"

# Always enable colored `grep` output
# Note: `GREP_OPTIONS="--color=auto"` is deprecated, hence the alias usage.
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'

# Enable aliases to be sudo’ed
alias sudo='sudo '

# Get week number
alias week='date +%V'

# Show/hide hidden files in Finder
alias show="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
alias hide="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
Expand All @@ -24,7 +73,7 @@ alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && k
alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"

# Print each PATH entry on a separate line
alias path="echo -e ${PATH//:/\\n}"
alias path='echo -e ${PATH//:/\\n}'

# Disable Spotlight
alias spotoff="sudo mdutil -a -i off"
Expand All @@ -37,4 +86,16 @@ alias spoton="sudo mdutil -a -i on"
# Flush the DNS on Mac
alias dnsflush="dscacheutil -flushcache"

# Flush Directory Service cache
alias flush="dscacheutil -flushcache && killall -HUP mDNSResponder"

# Google Chrome
alias chrome='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'
alias canary='/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary'

# Recursively delete `.DS_Store` files
alias cleanupDS="find . -type f -name '*.DS_Store' -ls -delete"

# JFV Unsure of usage, comment out for now
# URL-encode strings
# alias urlencode='python -c "import sys, urllib as ul; print ul.quote_plus(sys.argv[1]);"'
17 changes: 12 additions & 5 deletions setup/homebrew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ command -v xcode-select >/dev/null 2>&1 || {
}

# Install Homebrew if it is not currently available.
command -v brew >/dev/null 2>&1 || {
command -v xcode-selectcommand -v brew >/dev/null 2>&1 || {
echo >&2 "Installing Homebrew"; \
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)";
}

# Clean up all the things.
brew update
brew upgrade
brew prune
# JFV:brew prune is ddepricated and now runs as part of cleanup
# brew prune
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to be a hard habit for you to break. Everything is under version control, so there is no need to explain your changes within a file or to keep depricated code. Commented out code is pretty frowned upon now days as no one trusts its or plans to use it.

Instead, just make the change and commit the change with a git commit message. git commit -m "Removing depricated brew prune as it now runs in cleanup."

Of course it's too late to do that now. But in the future, small commits with meaningful messages are very helpful to understand the history of a file.

brew cleanup
brew doctor

Expand All @@ -32,15 +33,21 @@ brew install coreutils

# Install GNU find, locate, updatedb, and xargs.
# https://www.gnu.org/software/findutils/
brew install findutils --with-default-names
# JFV: removed --with-default-names, option deprecated
# Must add PATH="/usr/local/opt/findutils/libexec/gnubin:$PATH"
Copy link
Owner Author

@nJim nJim May 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Careful. You've made an assumption of the file location which could change from computer or computer. Instead of /usr/local I would suggest executing brew --prefix.

Also, this is a very prescriptive path. I believe homebrew creates a central place with symlinks to all executables. So you can simply add something like: PATH=$(brew --prefix)/bin:$(brew --prefix)/sbin:$PATH.

I didn't test the thing above. But something like that should work for any brew executable.

brew install findutils

# GNU sed has several differences and supports -i.
# https://www.gnu.org/software/sed/
brew install gnu-sed --with-default-names
# JFV: removed --with-default-names, option deprecated; add to $PATH
# Must add PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
brew install gnu-sed

# GNU grep is significantly faster and supports -P.
# https://www.gnu.org/software/grep/
brew install grep --with-default-names
# JFV: removed --with-default-names, option deprecated; add to $PATH
# Must add PATH="/usr/local/opt/grep/libexec/gnubin:$PATH"
brew install grep

###############################################################################
# Updated Versions of Utilities on OSX #
Expand Down