(no title)
neontomo | 1 year ago
syntax:
projects <project-name> <match index>
alias: function projects() {
if [ -z "$1" ]; then
echo "please provide a project name"
return
fi
local allMatches=$(find ~/Documents/projects -maxdepth 2 -type d -name "*$1*" -print)
local firstMatch=$(echo "$allMatches" | head -n ${2:-1} | tail -n 1)
if [ -z "$firstMatch" ]; then
echo "no matches found"
return
else
if [ $(echo "$allMatches" | wc -l) -gt 1 ]; then
echo "matches found:"
echo "$allMatches" | awk '{print NR ") " $0}'
fi
cd "$firstMatch"
fi
}
No comments yet.