Advertisement
Guest User

sh function for "tree" command

a guest
Apr 13th, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.43 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement