cd 目录增强


function cdd() {
    local dir=$1
    if [ "$dir" = ".." ]; then
        cd ..
        return
    fi
    local matches=$(ll | awk '{print $9}' | grep "$dir")
    local match_count=$(echo "$matches" | wc -l)
    if [ $match_count -eq 0 ]; then
        echo "未找到匹配的目录: $dir"
    elif [ $match_count -eq 1 ]; then
        cd "$matches"
    else
        choice=$(echo "$matches" | fzf)
        if [ -n "$choice" ]; then
            cd "$choice"
        fi
    fi
}

评论