Some refactor

- Change way to show commands from set -x to function that shows command
  and then executes it
- Now it tries to find ~/.oh-my-zsh/oh-my-zsh.sh before reinstalling
- Now it installs git repos with --depth 1 and removes .git folders
master
Plaza521 2023-10-27 21:18:58 +03:00
parent 70aa3be5d7
commit b44cb1b970
Signed by untrusted user who does not match committer: nakidai
GPG Key ID: 914675D395210A97
1 changed files with 18 additions and 8 deletions

View File

@ -1,5 +1,11 @@
#!/bin/sh #!/bin/sh
function showcom()
{
echo "- ${@/eval/}"
"$@"
}
# Check if necessary things are installed # Check if necessary things are installed
if [ ! command -v git &> /dev/null ] || [ ! command -v zsh &> /dev/null ]; then if [ ! command -v git &> /dev/null ] || [ ! command -v zsh &> /dev/null ]; then
echo "This script requires git and zsh" echo "This script requires git and zsh"
@ -7,16 +13,20 @@ if [ ! command -v git &> /dev/null ] || [ ! command -v zsh &> /dev/null ]; then
fi fi
# Asking if user really want to install # Asking if user really want to install
read -p 'This script will replace ~/.zshrc and ~/.oh-my-zsh with its own. If you still want to run it, type "y": ' -n 1 -r read -p 'This script will replace ~/.zshrc with its own. If you still want to run it, type "y": ' -n 1 -r
echo echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1 exit 1
fi fi
# Installing echo "Installing..."
set -x if ! test -f ~/.oh-my-zsh/oh-my-zsh.sh; then
rm -rf ~/.oh-my-zsh showcom eval "rm -rf ~/.oh-my-zsh"
git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh > /dev/null 2>&1 showcom eval "git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh --depth 1 > /dev/null 2>&1"
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting > /dev/null 2>&1 showcom eval "rm -rf ~/.oh-my-zsh/.git"
wget -O ~/.zshrc https://nakidai.ddns.net/nakidai/dotfiles/raw/branch/master/zsh/.zshrc > /dev/null 2>&1 fi
wget -O ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/headline.zsh-theme https://nakidai.ddns.net/nakidai/dotfiles/raw/branch/master/zsh/headline.zsh-theme > /dev/null 2>&1 showcom eval "git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting --depth 1 > /dev/null 2>&1"
showcom eval "rm -rf ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting/.git"
showcom eval "wget -O ~/.zshrc https://nakidai.ddns.net/nakidai/dotfiles/raw/branch/master/zsh/.zshrc > /dev/null 2>&1"
showcom eval "wget -O ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/headline.zsh-theme https://nakidai.ddns.net/nakidai/dotfiles/raw/branch/master/zsh/headline.zsh-theme > /dev/null 2>&1"
echo "Done"