3 ms·
My most useful zsh functions: # a visual recursive list of all files and directories function tree() { find . | sed -e 's/[^\/]*\//|--/g' -e 's/-- |/
by uggedal 17y ago
My most useful zsh functions:
# a visual recursive list of all files and directories
function tree()
{
find . | sed -e 's/[^\/]*\//|--/g' -e 's/-- |/ |/g' | $PAGER
}
# recursive text search (ack is also nifty)
function f()
{
find . -name '*' | xargs grep -l $1
}
# recursive search and replace (ignoring hidden files and dirs), example: replace foo bar
function replace()
{
find . \( ! -regex '.*/\..*' \) -type f | xargs perl -pi -e "s/$1/$2/g"
}
- nibrahim 17y agoPerhaps Python specific but I use this a lot epy () { cmd="import $1 as a ; print a.__file__.endswith('.pyc') and a.__file__[:-1] or a.__file__" file=$(/usr/bin/env python -c $cmd) echo $file emacsclient --no-wait $file }