Last active
July 26, 2024 21:53
-
-
Save emilh91/9542a179beace3e2f68698da75888a97 to your computer and use it in GitHub Desktop.
Automation of Ubuntu droplet setup
This file contains hidden or 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
# Run using the following command: | |
# curl -L https://gist.github.com/emilh91/9542a179beace3e2f68698da75888a97/raw | bash ; source ~/.bashrc | |
##### install utils | |
sudo apt-get update | |
sudo apt-get install -y git vim curl tmux lsof build-essential python3-pip unzip nginx | |
##### allocate swap file | |
sudo fallocate -l 1G /swapfile | |
sudo chmod 600 /swapfile | |
sudo mkswap /swapfile | |
sudo swapon /swapfile | |
sudo cp /etc/fstab /etc/fstab.bak | |
echo "/swapfile none swap sw 0 0" | sudo tee -a /etc/fstab | |
##### .bashrc config | |
sed -i "s/^#\(force_color_prompt=yes\)/\1/" ~/.bashrc | |
echo "" >> ~/.bashrc | |
echo "export EDITOR=vim" >> ~/.bashrc | |
echo "export TIME_STYLE=long-iso" >> ~/.bashrc | |
echo "" >> ~/.bashrc | |
echo "# to prevent nested tmux sessions" >> ~/.bashrc | |
echo "if [ \"\$SHLVL\" = \"2\" ]; then" >> ~/.bashrc | |
echo " tmux a -t 0" >> ~/.bashrc | |
echo "fi" >> ~/.bashrc | |
##### some aliases | |
echo "alias cls=\"clear && printf '\033[3J'\"" >> ~/.bash_aliases | |
echo "alias env=\"/usr/bin/env | sort\"" >> ~/.bash_aliases | |
echo "alias sp=\"source ~/.bashrc\"" >> ~/.bash_aliases | |
echo "alias ep=\"vim ~/.bashrc\"" >> ~/.bash_aliases | |
echo "alias glog=\"git log --color=always --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit | less -r\"" >> ~/.bash_aliases | |
echo "alias gp=\"git pull --autostash --rebase\"" >> ~/.bash_aliases | |
echo "alias gfp=\"git fetch --all --prune\"" >> ~/.bash_aliases | |
##### vim config | |
echo "highlight SignColumn ctermbg=white" >> ~/.vimrc | |
echo "highlight LineNr ctermbg=darkgrey ctermfg=white" >> ~/.vimrc | |
echo "" >> ~/.vimrc | |
echo "set mouse=a" >> ~/.vimrc | |
echo "set number" >> ~/.vimrc | |
echo "set cursorline" >> ~/.vimrc | |
echo "set showmatch" >> ~/.vimrc | |
echo "set shiftwidth=4" >> ~/.vimrc | |
echo "set tabstop=4" >> ~/.vimrc | |
echo "set incsearch" >> ~/.vimrc | |
echo "set hlsearch" >> ~/.vimrc | |
echo "set expandtab" >> ~/.vimrc | |
echo "syntax enable" >> ~/.vimrc | |
##### tmux config | |
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm | |
echo "# Set the prefix from \`C-b\` to \`C-a\`" >> ~/.tmux.conf | |
echo "set -g prefix C-a" >> ~/.tmux.conf | |
echo "" >> ~/.tmux.conf | |
echo "# Free the original \`Ctrl-b\` prefix keybinding" >> ~/.tmux.conf | |
echo "unbind C-b" >> ~/.tmux.conf | |
echo "" >> ~/.tmux.conf | |
echo "# Ensure that we can send \`Ctrl-a\` to other apps" >> ~/.tmux.conf | |
echo "bind C-a send-prefix" >> ~/.tmux.conf | |
echo "" >> ~/.tmux.conf | |
echo "# Bind prefix-r to reload the file" >> ~/.tmux.conf | |
echo "bind r source-file ~/.tmux.conf \; display \"Reloaded tmux configuration!\"" >> ~/.tmux.conf | |
echo "" >> ~/.tmux.conf | |
echo "# Use F11 and F12 to switch between windows" >> ~/.tmux.conf | |
echo "bind-key -n F11 previous-window" >> ~/.tmux.conf | |
echo "bind-key -n F12 next-window" >> ~/.tmux.conf | |
echo "" >> ~/.tmux.conf | |
echo "# Highlight current window border using specified color" >> ~/.tmux.conf | |
echo "set -g pane-active-border-fg red" >> ~/.tmux.conf | |
echo "" >> ~/.tmux.conf | |
echo "# Highlight current window using specified color" >> ~/.tmux.conf | |
echo "setw -g window-status-current-bg red" >> ~/.tmux.conf | |
echo "" >> ~/.tmux.conf | |
echo "#set -g history-limit 3000" >> ~/.tmux.conf | |
echo "" >> ~/.tmux.conf | |
echo "# Bind Alt+arrow keys to switch panes" >> ~/.tmux.conf | |
echo "bind -n M-Left select-pane -L" >> ~/.tmux.conf | |
echo "bind -n M-Right select-pane -R" >> ~/.tmux.conf | |
echo "bind -n M-Up select-pane -U" >> ~/.tmux.conf | |
echo "bind -n M-Down select-pane -D" >> ~/.tmux.conf | |
echo "" >> ~/.tmux.conf | |
echo "# Mouse support" >> ~/.tmux.conf | |
echo "set -g mouse on" >> ~/.tmux.conf | |
#echo "set -g mode-mouse on" >> ~/.tmux.conf | |
#echo "set -g mouse-select-pane on" >> ~/.tmux.conf | |
#echo "set -g mouse-resize-pane on" >> ~/.tmux.conf | |
#echo "set -g mouse-select-window on" >> ~/.tmux.conf | |
##### timezone config (default is UTC) | |
sudo rm /etc/localtime | |
sudo ln -s /usr/share/zoneinfo/US/Eastern /etc/localtime | |
sudo service cron restart | |
##### install nvm (Node Version Manager) | |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash | |
nvm install --lts # or just "nvm install node" ? | |
##### nginx config | |
mkdir -p /etc/nginx/ssl | |
##### ssh key | |
ssh-keygen -t ed25519 -C "[email protected]" | |
##### git config | |
git config --global user.name "Emil Huseynaliev" | |
git config --global user.email "[email protected]" | |
git config --global push.default current | |
git config --global core.excludesfile ~/.gitignore_global | |
git config --global gpg.format ssh | |
git config --global user.signingkey ~/.ssh/id_ed25519.pub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment