File tree Expand file tree Collapse file tree 10 files changed +91
-5
lines changed
Expand file tree Collapse file tree 10 files changed +91
-5
lines changed Original file line number Diff line number Diff line change 22wit
33NotIn
44notin
5+ fo
Original file line number Diff line number Diff line change 9292 exclude : >
9393 (?x)^(
9494 zsh-core.plugin.zsh$|
95+ pkg/helper/core.zsh$|
9596 .+\.provision/git/hooks/prepare-commit-msg$|
9697 .+\.tpl.sh$|
9798 )$
@@ -104,4 +105,4 @@ repos:
104105 - --verbose
105106 - id : hadolint
106107 args :
107- - --config=.ci/linters/.hadolint.yaml
108+ - --config=.ci/linters/.hadolint.yaml
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ export CORE_MESSAGE_YAY="Please install Yay or use antibody bundle hadenlabs/zsh
66export CORE_MESSAGE_RVM=" Please install rvm or use antibody bundle hadenlabs/zsh-rvm"
77export CORE_MESSAGE_RUST=" Please install rust or use antibody bundle hadenlabs/zsh-rust"
88export CORE_MESSAGE_NVM=" Please install nvm or use antibody bundle hadenlabs/zsh-nvm"
9+ export CORE_PROJECTS_BACKUP_PATH=" ${HOME} /backup"
910
1011export ANDROID_HOME=" ${HOME} /Library/Android/sdk"
1112export ANDROID_PLATFORM_VERSION=" 35"
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env ksh
2+ # -*- coding: utf-8 -*-
3+
4+ function core::internal::backup::snapshot {
5+ if [[ -z " $CORE_PROJECTS_BACKUP_PATH " ]]; then
6+ core::internal::message::error " ❌ CORE_PROJECTS_BACKUP_PATH is not set"
7+ return 1
8+ fi
9+
10+ local module_path
11+ module_path=" $( core::internal::git::get_module_path) "
12+
13+ local branch=" no-git"
14+ if git rev-parse --is-inside-work-tree > /dev/null 2>&1 ; then
15+ branch=" $( git rev-parse --abbrev-ref HEAD | tr ' /' ' -' ) "
16+ fi
17+
18+ local dest=" ${CORE_PROJECTS_BACKUP_PATH} /${module_path} /${branch} "
19+
20+ core::internal::message::info " 📦 Syncing backup → ${dest} "
21+
22+ mkdir -p " ${dest} "
23+
24+ rsync -avhP --delete \
25+ --exclude=" .git" \
26+ --exclude=" .task" \
27+ --exclude=" .terraform" \
28+ --exclude=" .venv" \
29+ --exclude=" __pycache__" \
30+ --exclude=" .mypy_cache" \
31+ --exclude=" .pytest_cache" \
32+ --exclude=" node_modules" \
33+ --exclude=" .DS_Store" \
34+ ./ " ${dest} "
35+
36+ core::internal::message::success " ✅ Backup saved to ${dest} "
37+ }
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env ksh
2+ # -*- coding: utf-8 -*-
3+ #
4+ function core::internal::git::get_module_path {
5+ if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1 ; then
6+ echo " unknown/unknown/$( basename " $( pwd) " ) "
7+ return
8+ fi
9+
10+ local remote_url
11+ remote_url=" $( git config --get remote.origin.url) "
12+
13+ if [[ " $remote_url " =~ ^git@ ([^:]+):(.+)\. git$ ]]; then
14+ # [email protected] :hadenlabs/zsh-core.git → github.com/hadenlabs/zsh-core 15+ echo " ${BASH_REMATCH[1]} /${BASH_REMATCH[2]} "
16+ elif [[ " $remote_url " =~ ^https? ://([^/]+)/(.+)\. git$ ]]; then
17+ # https://github.com/hadenlabs/zsh-core.git → github.com/hadenlabs/zsh-core
18+ echo " ${BASH_REMATCH[1]} /${BASH_REMATCH[2]} "
19+ else
20+ echo " unknown/unknown/$( basename " $( pwd) " ) "
21+ fi
22+ }
Original file line number Diff line number Diff line change @@ -16,6 +16,12 @@ function core::internal::main::factory {
1616 esac
1717 # shellcheck source=/dev/null
1818 source " ${ZSH_CORE_PATH} " /internal/helper.zsh
19+
20+ # shellcheck source=/dev/null
21+ source " ${ZSH_CORE_PATH} " /internal/git.zsh
22+
23+ # shellcheck source=/dev/null
24+ source " ${ZSH_CORE_PATH} " /internal/backup.zsh
1925}
2026
21- core::internal::main::factory
27+ core::internal::main::factory
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env ksh
2+ # -*- coding: utf-8 -*-
3+
4+ function core::snapshot {
5+ core::internal::backup::snapshot
6+ }
Original file line number Diff line number Diff line change 182182function net {
183183 # check connection
184184 ping 8.8.8.8 | grep -E --only-match --color=never ' [0-9\.]+ ms'
185- }
185+ }
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env ksh
2+ # -*- coding: utf-8 -*-
3+
4+ function core::pkg::helper::factory {
5+ # shellcheck source=/dev/null
6+ source " ${ZSH_CORE_PATH} " /pkg/helper/backup.zsh
7+
8+ # shellcheck source=/dev/null
9+ source " ${ZSH_CORE_PATH} " /pkg/helper/core.zsh
10+ }
11+
12+ core::pkg::helper::factory
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ function core::pkg::main::factory {
1515 ;;
1616 esac
1717 # shellcheck source=/dev/null
18- source " ${ZSH_CORE_PATH} " /pkg/helper.zsh
18+ source " ${ZSH_CORE_PATH} " /pkg/helper/main .zsh
1919
2020 # shellcheck source=/dev/null
2121 source " ${ZSH_CORE_PATH} " /pkg/docker.zsh
@@ -24,4 +24,4 @@ function core::pkg::main::factory {
2424 source " ${ZSH_CORE_PATH} " /pkg/alias.zsh
2525}
2626
27- core::pkg::main::factory
27+ core::pkg::main::factory
You can’t perform that action at this time.
0 commit comments