# HG changeset patch # User Oleksandr Gavenko # Date 1410307497 -10800 # Node ID e1347fd8085386ae899154ad991270a4c18cdb5d # Parent fc68054903262f6ac5e785c7e20d265a9467a7e0 myfind and mypath interactive bash session helper function. diff -r fc6805490326 -r e1347fd80853 .bashrc --- a/.bashrc Wed Aug 27 23:32:53 2014 +0300 +++ b/.bashrc Wed Sep 10 03:04:57 2014 +0300 @@ -107,6 +107,24 @@ # make and change to a directory md () { mkdir -p "$1" && cd "$1"; } +myfind() { find . -iname "$1"; } +mypath() { + local var="$2" + [[ -z $var ]] && var=PATH + local delim="$3" + [[ -z $delim ]] && delim=: + local split + IFS="$delim" command eval "read -ra split <<< \"\${$var}\"" + for dir in "${split[@]}"; do + [[ -z "$dir" ]] && continue + if [[ -f "$dir"/"$1" ]]; then + echo "$dir"/"$1" + else + ls -d "$dir"/$1 2>/dev/null | cat + fi + done +} + # LANG=C for speed. alias grep='GREP_COLOR="31;47" LANG=C grep -n --color=auto' alias ls='ls --color=auto'