dots/tmux_zsh_install.sh

80 lines
2.0 KiB
Bash

#!/bin/bash
#set -x
sudo apt-get update
sudo apt-get install -y curl git tmux zsh zsh-syntax-highlighting
# Tmux config
curl --create-dirs -fLo \
~/.config/tmux/tmux.conf \
https://git.da2001.ru/da2001/dots/raw/branch/main/.config/tmux/tmux.conf
# Install Oh My Zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
sed -i 's/^ZSH_THEME=.*/ZSH_THEME="tjkirch"/g' ~/.zshrc
# Install zsh-syntax-highlighting
echo "source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
# Install zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
sed -i 's/^plugins=.*[^\)]/& zsh-autosuggestions/g' ~/.zshrc
# Aliases
echo "Create => .aliases"
cat << EOF >> ~/.aliases
alias ip='ip --color=auto'
alias ssht='ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
alias gp="git add -A && git commit -m \"modify: $(date)\" && git push"
EOF
echo "Add link .aliases to .bashrc"
cat << EOF >> ~/.bashrc
if [ -f ~/.aliases ]; then
. ~/.aliases
fi
EOF
echo "Add link .aliases to .zshrc"
cat << EOF >> ~/.zshrc
source ~/.aliases
EOF
# Git config
if [ ! -f ~/.gitconfig ]; then
echo "Add aliases to .gitconfig"
cat << EOF >> ~/.gitconfig
[alias]
co = checkout
ci = commit
st = status
sw = switch
br = branch
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
hi = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
type = cat-file -t
t = cat-file -t
dump = cat-file -p
d = cat-file -p
undo = reset HEAD~1 --mixed
u = reset HEAD~1 --mixed
wipe = !git reset --hard
send = !git push origin HEAD
lo = log --all --oneline --graph
l = log --all --oneline --graph
EOF
else
echo "File \"~/.gitconfig\" exists, skip adding"
fi
# Shell to zsh
echo "Change shell for $USER"
sudo -k chsh -s "$(which zsh)" "$USER" # -k forces the password prompt
echo "ALL Done. Relogin for apply settings."