Skip to content

Commit

Permalink
Refactor: Update scripts and README for clarity and options
Browse files Browse the repository at this point in the history
- bootstrap: Rename `1st` script to `bootstrap` for clarity
- back: Add basic, all options and update option usage
- setup: Add basic option and update option usage and Rename `setup.zsh` to `setup` for conciseness
- README.md: Update to clarify usage of backup and restore scriptsj
  • Loading branch information
ujinyng committed Sep 15, 2024
1 parent ceeb616 commit d1912b5
Show file tree
Hide file tree
Showing 6 changed files with 321 additions and 187 deletions.
61 changes: 0 additions & 61 deletions 1st

This file was deleted.

76 changes: 56 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,76 @@
# Dotfiles for Backup and Restore

This repository is designed to back up Mac configuration files (dotfiles), other settings, plugins, and scripts used for installation and convenience. Most of the files here are automatically saved and synced to Dropbox, so these files are optional backups. The following instructions include steps for restoring files from Dropbox as well.


## Backup

To back up your environment, use the back command with `rsync`. `rsync` can be installed via Homebrew. The command format is:

```
$ back _<option>
```
If command
$ back _<tool>
```
$ back _all
For detailed usage of the back command, refer to the following help message:
```
backup zsh, vim, tmux, git, fzf, nodejs, py, brew, etc, karabiner
$ back help
Usage: back [OPTIONS] [GROUP_NAME]
`_all` is not contain rclone and gdb
Back up the specified dotfile groups to the dotfiles repository using rsync with -azvhrubRL options.
### other option
Groups:
_git, _brew, _zsh, _vim, _fzf, _tmux, _gdb, _yarn, _python, _karabiner
Options:
-A, --all, all Back up all groups
-B, --basic, basic Back up a predefined set of essential groups
(git, brew, zsh, vim, fzf, tmux, karabiner)
```

option: zsh, vim, tmux, git, fzf, nodejs, py, brew, etc, karabiner, rclone, gdb

## Restore

First,
To restore, run `bootstrap` and `setup`, which internally rely on `mackup` and `stow` for the restoration process. `mackup` and `stow` are installed as part of the `bootstrap` process, so there is no need to install them separately. Both tools can be installed via Homebrew."

To restore your environment, follow these steps:

1. Install essential tools and software:

```
$ 1st _install
$ bootstrap
```
then, install brew, oh-my-zsh and nvm, yarn,
set git config

Second, restore. There are two option
This will install Homebrew and reinstall all previously managed software using Homebrew. Next, run 'mackup restore' to restore settings such as .vimrc and other dotfiles related to git, zsh, vim, and others. Also, install oh-my-zsh, nodejs and yarn.
Currently, the software may be set to use either specific versions or the latest versions, depending on the setup. It would be beneficial to allow for selection between these options in the future.

1) Restore all from **Dropbox** using Mackup
2. Selectively restore **dotfiles**:

```
$ mackup restore
```
2) Selectively restore from **dotfiles** using stow by script
Use the `setup` command to create symbolic links for dotfiles, or alternatively, copy them individually using `stow`, `rsync` or other methods.

```
$ setup.zsh
$ setup _<tools>
```

To learn more about using the back command, check the help option:
```
$ setup -h
Usage: setup [OPTIONS] [GROUP_NAME]...
Restore specified dotfile groups using stow. Groups are symlinked to $HOME.
Multiple groups can be listed separated by spaces.
Use 'setup --basic' or 'setup -B' for a predefined set of essential groups.
Groups:
_vim, _zsh, _tmux, _git, _gdb, _fzf, _yarn, _python, _karabiner, _rclone
Options:
-B, --basic, basic Restore a predefined set of essential groups
(_vim, _zsh, term)
Example:
setup _vim _zsh _tmux # Restores vim, zsh, and tmux configurations
setup -B # Restores the basic configuration groups
```



Each folder in this repo is structured for use with `stow`. Some files, like those in dotfiles, are stored both in Dropbox and in this repository, allowing you to choose the source for restoration. However, currently, `1st` prioritizes fetching files from Dropbox first due to considerations for installation order and synchronization convenience. This means that symbolic links are created for files found in Dropbox. If a file is not present in Dropbox—whether intentionally omitted or missing—it will be obtained from the dotfiles repository.
148 changes: 92 additions & 56 deletions back
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,44 @@
#rsync option
#-v : print log
#-h : human readable
#-a : archive mode : -r, -t(타입스탬프 보존), -l (심볼릭 링크 보존), -p(permission 보존), -g(g그룹 보존), -o(소유자 보존 - root 만 가능), -D(device, special 파일 보존)과 동일
#-a : archive mode : -r, -t(타임스탬프 보존), -l (심볼릭 링크 보존), -p(permission 보존), -g(g그룹 보존), -o(소유자 보존 - root 만 가능), -D(device, special 파일 보존)과 동일
#-z : compress
#-r : recurse into directories
#-b : backup --suffix ~
#-u : skip files that are newer on the receiver
#-R : use relative path naems
#-L : symbolic link를 따라가서 원본 파일을 복제

help(){
echo "back _[GROUP_NAME]
GROUP: zsh, vim, tmux, git, fzf, docker, yarn, py, etc, brew, karabiner, (gdb)
or 'all' in place of GROUP for principal things
"
echo "Usage: back [OPTIONS] [GROUP_NAME]
Back up the specified dotfile groups to the dotfiles repository using rsync with -azvhrubRL options.
Groups:
_git, _brew, _zsh, _vim, _fzf, _tmux, _gdb, _yarn, _python, _karabiner
Options:
-A, --all, all Back up all groups
-B, --basic, basic Back up a predefined set of essential groups
(_git, _brew, _zsh, _vim, _fzf, _tmux, _karabiner)"
}

(){
help
_git(){
# cp -Riv --parents ~/.gitconfig ~/dotfiles/git/.gitconfig
# cp -Riv --parents ~/.gitignore_global ~/dotfiles/git/.gitignore_global
rsync -azvhrubR -L ~/./.gitconfig ~/dotfiles/_git
rsync -azvhrubR -L ~/./.gitignore_global ~/dotfiles/_git
}

_karabiner(){
rsync -azvhrubR -L ~/./.config/karabiner/assets ~/dotfiles/_karabiner
rsync -azvhrubR -L ~/./.config/karabiner/karabiner.json ~/dotfiles/_karabiner
_brew(){
rm ~/dotfiles/Brewfile~
rm ~/dotfiles/Brewmas~
mv ~/dotfiles/Brewfile ~/dotfiles/Brewfile~
mv ~/dotfiles/Brewmas ~/dotfiles/Brewmas~
brew bundle dump --force --file=~/./Brewfile
brew bundle --mas dump --force --file=~/./Brewmas
rsync -azvhrubR -L ~/./Brewfile ~/dotfiles/Brewfile
rsync -azvhrubR -L ~/./Brewmas ~/dotfiles/Brewmas
}

_zsh(){
Expand All @@ -39,36 +56,29 @@ _zsh(){

_vim(){
rsync -azvhrubR -L ~/./.vimrc ~/dotfiles/_vim
rsync -azvhrubR -L ~/./.vim/autoload/ ~/dotfiles/_vim
# rsync -azvhrubR -L ~/./.vim/autoload/ ~/dotfiles/_vim
rsync -azvhrubR -L ~/./.vim/plugged/ ~/dotfiles/_vim
rsync -azvhrubR -L ~/./.config/coc/extensions ~/dotfiles/_vim
# rsync -azvhrubR -L ~/./.config/coc/extensions ~/dotfiles/_vim
rsync -azvhrubR -L ~/./.config/nvim/ ~/dotfiles/_vim
rsync -azvhrubR -L ~/./.local/share/nvim/session/ ~/dotfiles/_vim
rsync -azvhrubR -L ~/./.NERDTreeBookmarks ~/dotfiles/_vim
# rsync -azvhrubR -L ~/./.local/share/nvim/site ~/dotfiles/vim
# rsync -azvhrubR -L ~/./.viminfo/ ~/dotfiles/vim
}

_tmux(){
# cp -Riv --parents ~/.tmux.conf ~/dotfiles/tmux/.tmux.conf
rsync -azvhrubR -L ~/./.tmux.conf ~/dotfiles/_tmux
# rsync -azvhrubR -L ~/./.tmux/plugins/ ~/dotfiles/tmux
}

_git(){
# cp -Riv --parents ~/.gitconfig ~/dotfiles/git/.gitconfig
# cp -Riv --parents ~/.gitignore_global ~/dotfiles/git/.gitignore_global
rsync -azvhrubR -L ~/./.gitconfig ~/dotfiles/_git
rsync -azvhrubR -L ~/./.gitignore_global ~/dotfiles/_git
}

_fzf(){
# cp -Riv --parents ~/.fzfignore ~/dotfiles/fzf/.fzfignore
# cp -Riv --parents ~/.fzf.zsh ~/dotfiles/fzf/.fzf.zsh
rsync -azvhrubR -L ~/./.fzfignore/ ~/dotfiles/_fzf
rsync -azvhrubR -L ~/./.fzf.zsh/ ~/dotfiles/_fzf
}

_tmux(){
# cp -Riv --parents ~/.tmux.conf ~/dotfiles/tmux/.tmux.conf
rsync -azvhrubR -L ~/./.tmux.conf ~/dotfiles/_tmux
# rsync -azvhrubR -L ~/./.tmux/plugins/ ~/dotfiles/tmux
}

_gdb(){
# cp -Riv --parents ~/.gdbinit ~/dotfiles/gdb/.gdbinit
# cp -Riv --parents ~/gdb.xml ~/dotfiles/gdb/gdb.xml
Expand All @@ -88,58 +98,84 @@ _yarn(){
# rsync -azvhrubR -L ~/./.nvm/ ~/dotfiles/_yarn
rsync -azvhrubR -L ~/./.yarn/yarn.lock ~/dotfiles/_yarn
rsync -azvhrubR -L ~/./.yarn/package.json ~/dotfiles/_yarn
rsync -azvhrubR -L ~/./.yarnrc ~/dotfiles/_yarn
# rsync -azvhrubR -L ~/./.yarnrc ~/dotfiles/_yarn
# rsync -azvhrubR -L ~/./.config/gatsby/ ~/dotfiles/_yarn
# rsync -azvhrubR -L ~/./.config/configstore/ ~/dotfiles/_yarn
}

_py(){
rsync -azvhrubR -L ~/./.pyenv/version/ ~/dotfiles/_py
# rsync -azvhrubR -L ~/./piplist ~/dotfiles/_py
_python(){
rsync -azvhrubR -L ~/./.pyenv/version/ ~/dotfiles/_python
# rsync -azvhrubR -L ~/./piplist ~/dotfiles/_python
}

_karabiner(){
rsync -azvhrubR -L ~/./.config/karabiner/assets ~/dotfiles/_karabiner
rsync -azvhrubR -L ~/./.config/karabiner/karabiner.json ~/dotfiles/_karabiner
}

_docker(){
rsync -azvhrubR -L ~/./.docker/ ~/dotfiles/_docker
}

_rclone(){
rsync -azvhrubR -L ~/./rclone_mount.sh ~/dotfiles/_rclone
rsync -azvhrubR -L ~/./rclone_umount.sh ~/dotfiles/_rclone
rsync -azvhrubR -L ~/./.config/rclone ~/dotfiles/_rclone
}

_etc(){
echo "etc"
# rsync -azvhrubR -L ~/./.fasd ~/dotfiles/_etc
# rsync -azvhrubR -L ~/./.notable.json/ ~/dotfiles/_etc
# rsync -azvhrubR -L ~/./.skhdrc ~/dotfiles/_etc
# rsync -azvhrubR -L ~/./.yabairc ~/dotfiles/_etc
}

_brew(){
rm ~/dotfiles/Brewfile~
rm ~/dotfiles/Brewmas~
mv ~/dotfiles/Brewfile ~/dotfiles/Brewfile~
mv ~/dotfiles/Brewmas ~/dotfiles/Brewmas~
brew bundle dump --force --file=~/./Brewfile
brew bundle --mas dump --force --file=~/./Brewmas
rsync -azvhrubR -L ~/./Brewfile ~/dotfiles/Brewfile
rsync -azvhrubR -L ~/./Brewmas ~/dotfiles/Brewmas

}

_rclone(){
rsync -azvhrubR -L ~/./rclone_mount.sh ~/dotfiles/_rclone
rsync -azvhrubR -L ~/./rclone_umount.sh ~/dotfiles/_rclone
rsync -azvhrubR -L ~/./.config/rclone ~/dotfiles/_rclone
}

_all(){
# _rclone
all(){
_git
_brew
_etc
_py
_yarn
# _gdb
_fzf
_zsh
_vim
_git
_fzf
_tmux
_gdb
_yarn
_python
_rclone
_etc
}

basic(){
_git
_brew
_zsh
_vim
_fzf
_tmux
_karabiner
}
$@

main(){
if [ $# -eq 0 ]; then
help
elif [ $# -gt 0 ]; then
case $1 in
-h|--help|help)
help
return 0
;;
-B|--basic|basic)
basic
;;
-A|--all|all)
all
;;
*)
"$@"
;;
esac
shift
fi
}

main "$@"
Loading

0 comments on commit d1912b5

Please sign in to comment.