| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- #!/bin/bash
- # Location: $HOME/dots
- # User Scope: user
- # Run as: ./setup.sh <arg>
- # Script to setup terminal environment
- if [ $# -ne 1 ]; then
- echo "::[Dots Setup Script]::"
- echo "Usage: setup.sh <prompt to use: seafly|parrot|powerline>"
- exit 1
- fi
- host=$(hostname)
- hostname="${host^^}"
- repo_directory="/opt/qconfig"
- main_user=$USER
- user_prompt="$1"
- # Set Permissions
- chmod 660 $(find ./ -type f)
- chmod 660 $(find "$HOME/.bashrc" -type f)
- chmod 770 $(find "$HOME/dots" -type d)
- function add_string_to_file() {
- # Checks if a string is in a file
- # adds it if it isn't in that file
- local file="$1"
- local string="$2"
- if ! grep -q "$string" "$file"; then
- echo "$string" >> "$file"
- fi
- }
- # Bashrc
- add_string_to_file "$HOME/.bashrc" "source $HOME/dots/default_aliases"
- add_string_to_file "$HOME/.bashrc" "source $HOME/dots/$user_prompt-prompt"
- # Bashrc for control
- if [ $main_user == "control" ]; then
- add_string_to_file "$HOME/.bashrc" "bash $HOME/dots/life.sh 1993-07-21 control"
- fi
- # NVIM
- mkdir -p "$HOME/.config/nvim/"
- cp "./nvim" "$HOME/.config/nvim/init.vim"
- # TMUX
- cp "./tmux.conf" "$HOME/.tmux.conf"
- # PATH VARS
- if [ -f "$HOME/.dots/user_paths" ]; then
- chmod 660 "$HOME/.dots/user_paths"
- add_string_to_file "$HOME/.bashrc" "source $HOME/.dots/user_paths"
- fi
- if [ -f "$HOME/.dots/user_aliases" ]; then
- chmod 660 "$HOME/.dots/user_aliases"
- add_string_to_file "$HOME/.bashrc" "source $HOME/.dots/user_aliases"
- fi
- if [ -f "$repo_directory/user_paths" ]; then
- chmod 660 "$repo_directory/user_paths"
- add_string_to_file "$HOME/.bashrc" "source $repo_directory/user_paths"
- fi
- if [ -f "$repo_directory/user_aliases" ]; then
- chmod 660 "$repo_directory/user_aliases"
- add_string_to_file "$HOME/.bashrc" "source $repo_directory/user_aliases"
- fi
- # Set System Aliases
- cp -f "/home/$main_user/dots/system_aliases" "/etc/system_aliases"
- add_string_to_file "/etc/bash.bashrc" "source /etc/system_aliases"
- # Source
- source "$HOME/.bashrc"
|