From: Simon Ruderich Date: Sun, 10 Mar 2013 22:54:45 +0000 (+0100) Subject: setup.sh,shell/aliases: Only use `column -t` if it's available. X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=b7b6b679a7fda0ff3a6643618cd86278083b663f;p=config%2Fdotfiles.git setup.sh,shell/aliases: Only use `column -t` if it's available. --- diff --git a/setup.sh b/setup.sh index 3a5e7f2..6bede11 100755 --- a/setup.sh +++ b/setup.sh @@ -95,14 +95,23 @@ else ls_env= ls_color= fi + +# Also check if `column -t` is available. +if echo test | column -t >/dev/null 2>&1; then + column=' | column -t' +else + column= +fi + generate perl shell/aliases \ -e 'while () { s/\bLS_ENV\b/$ARGV[0]/; s/\bLS_PATH\b/$ARGV[1]/; s/\bLS_COLOR\b/$ARGV[2]/; + s/\bCOLUMN\b/$ARGV[3]/; print; }' \ - "$ls_env" "$ls_path" "$ls_color" + "$ls_env" "$ls_path" "$ls_color" "$column" # Check if grep supports --color=auto. if echo test | grep --color=auto test >/dev/null 2>&1; then diff --git a/shell/aliases.in b/shell/aliases.in index f86eba8..27ce92c 100644 --- a/shell/aliases.in +++ b/shell/aliases.in @@ -68,11 +68,14 @@ alias :q='echo "This is not Vim!" >&2' # Automatically use unified diffs. alias diff='diff -u' +# COLUMN is set to `| column -t` if it's available, empty otherwise. + # Display all files (-s), use human readable sizes (-h) and display the # complete size (-c). alias du='du -shc' -# Use human readable sizes. -alias df='df -h' +# Use human readable sizes and format it nicely, thanks to climagic +# (http://twitter.com/climagic/status/49623386762129408). +alias df='df -hP COLUMN' # Highlight matched strings. Doesn't work with a pager! alias grep='grep --color=auto'