Skip to content

Commit

Permalink
.functions: Add fs
Browse files Browse the repository at this point in the history
…and remove the `fs` alias from `.aliases`.

Ref. mathiasbynens#125.
  • Loading branch information
porada authored and mathiasbynens committed Aug 23, 2012
1 parent acfad0c commit 1b7314b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
9 changes: 0 additions & 9 deletions .aliases
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,6 @@ alias c="tr -d '\n' | pbcopy"
# Recursively delete `.DS_Store` files
alias cleanup="find . -type f -name '*.DS_Store' -ls -delete"

# File size
if stat -c '' . > /dev/null 2>&1; then
# GNU `stat`
alias fs="stat -c \"%s bytes\""
else
# OS X `stat`
alias fs="stat -f \"%z bytes\""
fi

# ROT13-encode text. Works for decoding, too! ;)
alias rot13='tr a-zA-Z n-za-mN-ZA-M'

Expand Down
14 changes: 14 additions & 0 deletions .functions
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ function mkd() {
mkdir -p "$@" && cd "$@"
}

# Determine size of a file or total size of a directory
function fs() {
if du -shb /dev/null > /dev/null 2>&1; then
local arg=-sbh
else
local arg=-skh
fi
if [[ -n "$@" ]]; then
du $arg -- "$@"
else
du $arg .[^.]* *
fi
}

# Use Git’s colored diff when available
hash git &>/dev/null
if [ $? -eq 0 ]; then
Expand Down

0 comments on commit 1b7314b

Please sign in to comment.