-
Notifications
You must be signed in to change notification settings - Fork 1
/
utils.sh
74 lines (50 loc) · 1.71 KB
/
utils.sh
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
###
# @?: *********************************************************************
# @Author: Weidows
# @Date: 2022-08-12 18:53:31
# @LastEditors: Weidows
# @LastEditTime: 2023-12-20 23:08:59
# @FilePath: \Blog-privated:\Repos\Weidows-projects\Keeper\utils.sh
# @Description:
# 此文件换行符需要用LF, CRLF是Windows下的
# TODO 迁移 bat 到 sh
# @!: *********************************************************************
###
# ==================================================================
# Initialization
# ==================================================================
BACKUP_DIR=
# dirname $0 脚本所在路径
if [ ! "$BACKUP_DIR" ]; then BACKUP_DIR=$(dirname "$0")/Programming-Configuration; fi
# if [ -d "$HOME/backup" ]; then
# BACKUP_DIR="$HOME/backup"
# else
# BACKUP_DIR="$HOME/backup"
# fi
# if [ ! -d "${BACKUP_DIR}" ]; then
# mkdir -p ${BACKUP_DIR}
# cd ${BACKUP_DIR}
# ==================================================================
# 备份
# ==================================================================
backup (){
mkdir -p "${BACKUP_DIR}" && cd "${BACKUP_DIR}" || exit
# lists
mkdir lists & cd lists || exit
# Homebrew
brew list > pkgs/brew-list.bak
cd ..
# 其他
mkdir others & cd others || exit
cp /etc/hosts hosts/hosts.mac
cd ..
# ~/
mkdir dotfiles & cd dotfiles || exit
# 会覆盖掉之前的
cp ~/.zshrc .
}
# ==================================================================
# main入口, shell 函数只能定义后调用, 且不调用不执行
# ==================================================================
# backup() 加括号调用会报错
backup