# Search all directories for this directory name. dname() { [ $# -eq 0 ] && echo "$0 'dir_name'" && return 1 fd --hidden --follow --exclude .git --type directory "$*" } # Search all files for this filename. fname() { [ $# -eq 0 ] && echo "$0 'file_name'" && return 1 fd --hidden --follow --exclude .git --type file "$*" } # Find and replace with a pattern and replacement sub() { [ $# -ne 2 ] && echo "$0 'pattern' 'replacement'" && return 1 pattern="$1" replace="$2" command rg -0 --files-with-matches "$pattern" --hidden --glob '!.git' | xargs -0 perl -pi -e "s|$pattern|$replace|g" } # Uses z and fzf, if there's a match then jump to it. If not, bring up a list via fzf to fuzzy search. unalias z 2> /dev/null z() { [ $# -gt 0 ] && _z "$*" && return cd "$(_z -l 2>&1 | sed 's/^[0-9,.]* *//' | fzf)" }