-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kai Chen
committed
Mar 26, 2024
1 parent
dd437cb
commit c173ec5
Showing
2 changed files
with
47 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Usage | ||
1. Install [oh-my-zsh](https://ohmyz.sh/#install) and set zsh as your default shell | ||
2. `source setup.sh` which will setup symbolic links for you. When you update this repo, the file contents will be updated | ||
3. Open a new terminal to check for the updated config, enjoy! |
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,43 @@ | ||
#!/bin/bash | ||
|
||
# Automatically get the directory from which the script is run | ||
REPO_DIR=$(pwd) | ||
|
||
# Define the location of the files in the home directory | ||
VIMRC="$HOME/.vimrc" | ||
TMUX_CONF="$HOME/.tmux.conf" | ||
|
||
# Backup .vimrc if it exists | ||
if [ -f "$VIMRC" ]; then | ||
echo "Backing up .vimrc to .vimrc.bak" | ||
cp "$VIMRC" "${VIMRC}.bak" | ||
fi | ||
|
||
# Backup .tmux.conf if it exists | ||
if [ -f "$TMUX_CONF" ]; then | ||
echo "Backing up .tmux.conf to .tmux.conf.bak" | ||
cp "$TMUX_CONF" "${TMUX_CONF}.bak" | ||
fi | ||
|
||
# Backup .zshrc if it exists | ||
if [ -f "$HOME/.zshrc" ]; then | ||
echo "Backing up .zshrc to .zshrc.bak" | ||
cp "$HOME/.zshrc" "$HOME/.zshrc.bak" | ||
fi | ||
|
||
# Create symbolic links for .vimrc and .tmux.conf | ||
ln -sf "$REPO_DIR/config/.vimrc" "$HOME/.vimrc" | ||
ln -sf "$REPO_DIR/config/.tmux.conf" "$HOME/.tmux.conf" | ||
|
||
# Replace the ZSH_CUSTOM line with the correct path | ||
ZSHRC="$REPO_DIR/config/.zshrc" | ||
ZSH_CUSTOM_LINE="ZSH_CUSTOM=$REPO_DIR/config" | ||
sed -i "/^ZSH_CUSTOM=/c\\$ZSH_CUSTOM_LINE" "$ZSHRC" || echo "$ZSH_CUSTOM_LINE" >> "$ZSHRC" | ||
|
||
# Create a symbolic link for .zshrc | ||
ln -sf "$ZSHRC" "$HOME/.zshrc" | ||
|
||
# Ignore changes in .zshrc in the future | ||
git update-index --assume-unchanged "config/.zshrc" | ||
|
||
echo "Setup completed successfully." |