Skip to content

Commit

Permalink
bashrc: skip last '/' in 'c' function's argument
Browse files Browse the repository at this point in the history
  • Loading branch information
phd committed Sep 9, 2024
1 parent 160cd74 commit 40add66
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions .bashrc-phd
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ function cd {

function c {
local args="$@"
args="${args%/}"
local matches=$(find . -maxdepth 1 -mindepth 1 -type d -name "*${args}*" -printf "%P\n" | sort)
if [ -z "${matches}" ] || [ $(wc -l <<< "${matches}") -gt '1' ]; then
echo "${matches}" | ( [ -n "${args}" ] && GREP_COLORS='ms=01;37;42' grep --color=always "${args}" || cat ) | decorate '' '/'
Expand Down

0 comments on commit 40add66

Please sign in to comment.