-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backup on: Wed Sep 28 16:29:40 CST 2022
- Loading branch information
小翊
committed
Sep 28, 2022
1 parent
613644e
commit 1fde6de
Showing
6 changed files
with
127 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,36 @@ | ||
#! /bin/bash | ||
|
||
# 全局变量,填入项目地址 | ||
# HEAD | ||
DIR=$HOME/dotfiles | ||
export git=/usr/bin/git | ||
|
||
switch_branch(){ | ||
echo "dir: $DIR" | ||
# brew_backup | ||
git checkout -b main > /tmp/tmplog | ||
if grep -q "fatal: A branch named" /tmp/tmplog ; then | ||
echo "create new branch" | ||
else | ||
echo "checkout to main" | ||
git checkout main | ||
fi | ||
# backup my config | ||
backup() { | ||
echo "Backup ~/.zshrc to ~/dotfiles/macos/$(whoami)/zshrc" | ||
cp ~/.zshrc ~/dotfiles/macos/$(whoami)/zshrc | ||
|
||
echo "Backup brew bundle to ~/dotfiles/macos/$(whoami)/Brewfile" | ||
brew bundle dump --describe --force --no-upgrade --file="~/dotfiles/macos/$(whoami)/Brewfile" | ||
|
||
# echo "Backup brew to ~/dotfiles/brew/backup" | ||
# sh -c $HOME/dotfiles/brew/backup.sh | ||
|
||
# code --list-extensions > ~/dotfiles/_rc/exts.txt | ||
} | ||
|
||
# > Backup to Github | ||
backup_to_github(){ | ||
msg='Backup on: '`date` | ||
# echo $msg | ||
|
||
git add $DIR | ||
git add $DIR/macos | ||
git commit -m "$msg" | ||
git push --set-upstream origin main | ||
git push | ||
} | ||
|
||
# switch_branch | ||
# 备份 | ||
backup | ||
# 备份到 github 要最后运行 | ||
backup_to_github | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#! /bin/bash | ||
|
||
# 全局变量 | ||
WD=`pwd` | ||
# > 安装自动备份脚本到 contab | ||
install_to_crontab() { | ||
script="bash $WD/backup.sh" | ||
# echo $script | ||
crontab -l > /tmp/crontab_conf | ||
if grep -q "no crontab" /tmp/crontab_conf ; then | ||
# echo /tmp/crontab_conf | ||
# manual | ||
echo "自动添加失败,请尝试手动添加: " | ||
echo | ||
echo SHELL=$SHELL > crontab_conf | ||
echo PATH=$PATH >> crontab_conf | ||
echo "00 12 * * * $script > /tmp/dotfiles_Backup.log && osascript -e 'display notification \"$WD/brew/backup\" with title \"dotfiles 备份成功, 已上传至 GitHub\" '" >> crontab_conf | ||
echo "运行 \$ crontab -e" | ||
|
||
echo "插入以下内容: " | ||
cat crontab_conf | ||
exit 1 | ||
else | ||
# echo "hav crontab" | ||
# auto | ||
crontab -l > crontab_conf | ||
echo SHELL=$SHELL >> crontab_conf | ||
echo PATH=$PATH >> crontab_conf | ||
echo "00 12 * * * $script > /tmp/dotfiles_Backup.log && osascript -e 'display notification \"$WD/backup\" with title \"dotfiles 备份成功, 已上传至 GitHub\" '" >> crontab_conf | ||
crontab crontab_conf && rm -f crontab_conf | ||
|
||
echo "🎉 自动化备份脚本安装完成" | ||
echo | ||
echo "目前的 crontab 配置" | ||
echo | ||
crontab -l | ||
exit 0 | ||
fi | ||
} | ||
|
||
install_to_crontab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,37 @@ | ||
tap "1password/tap" | ||
tap "bigwig-club/brew" | ||
tap "buo/cask-upgrade" | ||
tap "cloudflare/cloudflare" | ||
tap "github/gh" | ||
tap "homebrew/bundle" | ||
tap "homebrew/cask" | ||
tap "homebrew/cask-fonts" | ||
tap "homebrew/cask-versions" | ||
tap "homebrew/core" | ||
tap "homebrew/services" | ||
# Shell extension to jump to frequently used directories | ||
brew "autojump" | ||
# Get a file from an HTTP, HTTPS or FTP server | ||
brew "curl" | ||
# View disk space usage and delete unwanted data, fast | ||
brew "dua-cli" | ||
# Distributed revision control system | ||
brew "git" | ||
# Development kit for the Java programming language | ||
brew "openjdk" | ||
# Interpreted, interactive, object-oriented programming language | ||
brew "[email protected]" | ||
# Fast and simple Node.js version manager | ||
brew "fnm" | ||
# User interface to the TELNET protocol | ||
brew "telnet" | ||
# Internet file retriever | ||
brew "wget" | ||
# Command-line helper for the 1Password password manager | ||
cask "1password-cli" | ||
cask "account-switcher" | ||
# Transfer files from and to an Android smartphone | ||
cask "android-file-transfer" | ||
# Android SDK component | ||
cask "android-platform-tools" | ||
# Application uninstaller | ||
cask "appcleaner" | ||
# Tool to flash OS images to SD cards & USB drives | ||
cask "balenaetcher" | ||
# Tool to list all active shortcuts of the current application | ||
cask "cheatsheet" | ||
# Rule-based custom proxy with GUI based on clash | ||
cask "clashx-pro" | ||
# Voice and text chat software | ||
cask "discord" | ||
# Typeface made for developers | ||
cask "font-jetbrains-mono" | ||
# Developer targeted fonts with a high number of glyphs | ||
cask "font-jetbrains-mono-nerd-font" | ||
# GIT client | ||
cask "fork" | ||
# Tool to set light or dark appearance on a per-app basis | ||
cask "gray" | ||
# Free and open-source media player | ||
cask "iina" | ||
# Terminal emulator as alternative to Apple's Terminal app | ||
cask "iterm2" | ||
# File archiver | ||
cask "keka" | ||
# Helper application for the Keka file archiver | ||
cask "kekaexternalhelper" | ||
# Switch input method per application | ||
cask "keyboardholder" | ||
# Open-source firewall to block unknown outgoing connections | ||
cask "lulu" | ||
# Simple and elegant markdown editor | ||
cask "mark-text" | ||
# Tool to control external monitor brightness & volume | ||
|
@@ -72,9 +42,6 @@ cask "mos" | |
cask "ngrok" | ||
# App to write, plan, collaborate, and get organized | ||
cask "notion" | ||
cask "paper" | ||
# Tool for uploading images | ||
cask "picgo" | ||
# QuickLook plug-in that renders source code with syntax highlighting | ||
cask "qlcolorcode" | ||
# Display image info and preview unsupported formats in QuickLook | ||
|
@@ -90,26 +57,14 @@ cask "quicklook-json" | |
cask "quicklookase" | ||
# Control your tools with a few keystrokes | ||
cask "raycast" | ||
# Tool to reverse the direction of scrolling | ||
cask "scroll-reverser" | ||
# Screenshot measurement and annotation tool | ||
cask "shottr" | ||
# Snip or pin screenshots | ||
cask "snipaste" | ||
# Music streaming service | ||
cask "spotify" | ||
# Network toolbox | ||
cask "surge" | ||
# System monitor for the menu bar | ||
cask "stats" | ||
# App to switch hosts | ||
cask "switchhosts" | ||
# Terminal emulator, SSH and serial client | ||
cask "tabby" | ||
# Messaging app with a focus on speed and security | ||
cask "telegram" | ||
# Finder extension for opening a terminal from the current directory | ||
cask "termhere" | ||
# General-purpose text editor | ||
cask "textmate" | ||
# Remote desktop application focusing on security | ||
cask "vnc-viewer" | ||
# Rust-based terminal | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#! /bin/bash | ||
|
||
# 全局变量,填入项目地址 | ||
# HEAD | ||
DIR=$HOME/dotfiles | ||
export git=/usr/bin/git | ||
|
||
switch_branch(){ | ||
echo "dir: $DIR" | ||
# brew_backup | ||
git checkout -b main > /tmp/tmplog | ||
if grep -q "fatal: A branch named" /tmp/tmplog ; then | ||
echo "create new branch" | ||
else | ||
echo "checkout to main" | ||
git checkout main | ||
fi | ||
} | ||
|
||
# > Backup to Github | ||
backup_to_github(){ | ||
msg='Backup on: '`date` | ||
# echo $msg | ||
|
||
git add $DIR | ||
git commit -m "$msg" | ||
git push --set-upstream origin main | ||
git push | ||
} | ||
|
||
# switch_branch | ||
# 备份到 github 要最后运行 | ||
backup_to_github | ||
exit 0 |