summaryrefslogtreecommitdiff
path: root/zsh/utils.zsh
blob: 85d533893965d762762315bafffd1b00179c5eba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
deps() {
    if [[ -f yarn.lock ]]; then
        yarn list --pattern "@arf/|@arjs/|@dt/|@grapecity/|@mescius/|barcodejs|js-expressions" --depth=0 -s 
    elif [[ -f pnpm-lock.yaml ]]; then
        pnpm list @arf/* @arjs/* @dt/* @grapecity/* @mescius/* barcodejs js-expressions
    elif [[ -f package-lock.json ]]; then
        echo "NPM does not support dependencies filtering, here's the full list:"
        npm list
    else
        echo "No package manager in this directory"
        return 1
    fi
}

# git -C $line describe --tags HEAD [latest tag]
# git -C $line tag --points-at HEAD [latest tagS]

# shows project list
lsproj() {
    ls | while read line;
    do {
        fill_count=$((32 - ${#line}))
        filler=$(repeat $fill_count printf "·")
        is_git_repo=$(git -C $line rev-parse --abbrev-ref HEAD 2> /dev/null)
        if [[ $is_git_repo ]] {
            project_dir="%B%K{green} $line $filler %k%b"
            branch=" %F{blue} $(git -C $line rev-parse --abbrev-ref HEAD)%f"
            tag=$(git -C $line describe --tags HEAD 2> /dev/null)
            print -P "$project_dir$branch [$tag]";
        }
    }
    done
}

lsproj_watch() {
    while true;
    do {
        output=$(lsproj)
        clear;
        print $output;
        sleep 1;
    }
    done;
}