summaryrefslogtreecommitdiff
path: root/zsh/utils.zsh
diff options
context:
space:
mode:
authorSkladnayazebra <skladnayazebra@gmail.com>2025-10-12 15:11:47 +0200
committerSkladnayazebra <skladnayazebra@gmail.com>2025-10-12 15:11:47 +0200
commited47d3f0da1581d3df04d2e506abbbf3686085e9 (patch)
treefe54a12dc573980cfd190f096c58de7908b02015 /zsh/utils.zsh
parente207122a6487ea7b8a57b6f065397490cfdfd370 (diff)
zsh config
Diffstat (limited to 'zsh/utils.zsh')
-rw-r--r--zsh/utils.zsh132
1 files changed, 132 insertions, 0 deletions
diff --git a/zsh/utils.zsh b/zsh/utils.zsh
new file mode 100644
index 0000000..111a2fb
--- /dev/null
+++ b/zsh/utils.zsh
@@ -0,0 +1,132 @@
+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
+}
+
+# opens PR on bitbucket
+bb() {
+ repoUrl=$(npm repo --browser=false | grep http)
+ branch=$(git rev-parse --abbrev-ref HEAD | jq -sRr @uri)
+ xdg-open "$repoUrl/pull-requests/new?source=$branch"
+}
+
+# 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
+}
+
+lsproj2() {
+ 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%F{white}%K{green} $line %k%f%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\n|$branch\n|"
+ }
+ }
+ done
+}
+
+lsproj_watch() {
+ while true;
+ do {
+ output=$(lsproj)
+ clear;
+ print $output;
+ sleep 1;
+ }
+ done;
+}
+
+# TEMP
+
+chkt() {
+ ls | while read line;
+ do {
+ fill_count=$((32 - ${#line}))
+ filler=$(for i in {1..$fill_count}; do printf "·"; done)
+ is_git_repo=$(git -C $line rev-parse --abbrev-ref HEAD 2> /dev/null)
+ if [[ $is_git_repo ]] {
+ print "%B%F{white}%K{green} $line %k%f%b"
+ git -C $line branch
+ }
+ }
+ done
+}
+
+fore() {
+ while read proj;
+ do {
+ echo $proj
+ git -C $proj branch -d feature/update-arf-toolkit 2> /dev/null && echo "OK"
+ }
+ done
+}
+
+
+multiupd() {
+ echo $1
+ start_path=$(pwd)
+ while read proj;
+ do {
+ cd $start_path/$proj
+ print -P "%K{green}%F{white}%B update to $1 in $start_path/$proj %b%f%k"
+
+ if [[ -f yarn.lock ]]; then
+ yarn add $1 -E -W 2> >(grep -v warning 1>&2)
+ git add yarn.lock
+ elif [[ -f pnpm-lock.yaml ]]; then
+ pnpm i $1 -E
+ git add pnpm-lock.yaml
+ elif [[ -f package-lock.json ]]; then
+ npm i $1 -E
+ git add package-lock.json
+ fi
+ git add package.json
+ }
+ done
+
+ cd $start_path
+}
+
+createbr() {
+ start_path=$(pwd)
+ while read proj;
+ do {
+ cd $start_path/$proj
+ print -P "%K{green}%F{white}%B $start_path/$proj %b%f%k"
+ git co -b feature/update-arf-toolkit
+ git ci -m "@arf/toolkit 0.16.5"
+ git push
+ bb 2> /dev/null || echo "PR is not open: $proj"
+ }
+ done
+}