This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

sh function for "tree" command

By: a guest on Apr 13th, 2012  |  syntax: Bash  |  size: 0.43 KB  |  views: 37  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # Add this to your .bashrc or .zshrc or wherever
  2. # Copyright (C) 2012 by Adam Katz <http://www.khopis.com/scripts>, GPLv3+
  3. # see also http://www.commandlinefu.com/commands/view/10592/
  4. function tree() {
  5.   local dirs_only=''
  6.   case $1 in
  7.     -d )   dirs_only="-type d"; shift ;;
  8.     -?* )  [ ! -r "$1" ] && echo "Usage: tree [-d] [PATH...]" && return 1 ;;
  9.   esac
  10.   find "${@:-.}" $dirs_only |sed 's:[^-][^/]*/:--:g; s/^-/ |/'
  11. }
clone this paste RAW Paste Data