Add a Windows install script
This commit is contained in:
		
							parent
							
								
									55c29f1813
								
							
						
					
					
						commit
						90be84e992
					
				
							
								
								
									
										129
									
								
								install
									
									
									
									
									
								
							
							
						
						
									
										129
									
								
								install
									
									
									
									
									
								
							|  | @ -1,47 +1,29 @@ | ||||||
| #!/bin/bash | #!/bin/bash | ||||||
| 
 | 
 | ||||||
| source "$HOME/.dotfiles/script_helpers/all.sh" | source "script_helpers/printing.sh" | ||||||
| 
 | source "script_helpers/core.sh" | ||||||
| set -e | source "script_helpers/platform.sh" | ||||||
|  | source "script_helpers/file_ops.sh" | ||||||
| 
 | 
 | ||||||
| cwd=$PWD | cwd=$PWD | ||||||
| platform=`uname` | platform=`uname` | ||||||
| 
 | confirm_link=0 | ||||||
| echo platform: $platform |  | ||||||
| 
 |  | ||||||
| os_is_windows is_windows | os_is_windows is_windows | ||||||
|  | 
 | ||||||
| if [[ $is_windows -eq 1 ]]; then | if [[ $is_windows -eq 1 ]]; then | ||||||
|   error "This is only supported on Linux or MacOS.\n" |     # Check for admin permissions. | ||||||
|   exit 1 |     net session &>/dev/null | ||||||
|  |     admin_error=$? | ||||||
|  |     if [[ ! $admin_error -eq 0 ]]; then | ||||||
|  |         fatal "You need to run this in an admin shell!" | ||||||
|  |     fi | ||||||
| fi | fi | ||||||
| 
 | 
 | ||||||
| setup_dotfile_repo() { | set -e | ||||||
|   if [ ! -d "$HOME/.dotfiles" ]; then |  | ||||||
|     printf "${YELLOW}Creating dotfiles symlink${NORMAL}\n" |  | ||||||
|     ln -s $cwd $HOME/.dotfiles |  | ||||||
|   fi |  | ||||||
| 
 | 
 | ||||||
|   # Used by various things (e.g. vim history) | #################################################################################################### | ||||||
|   mkdir -p $HOME/tmp | # Helpers | ||||||
| } | #################################################################################################### | ||||||
| 
 |  | ||||||
| link() { |  | ||||||
|   file=$1 |  | ||||||
|   link_file "$HOME/.dotfiles/$file" "$HOME/.$file" 0 |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| setup_git() { |  | ||||||
|   printf "Setting up git...\n" |  | ||||||
| 
 |  | ||||||
|   FILES=() |  | ||||||
|   FILES+=('gitconfig') |  | ||||||
|   FILES+=('githelpers') |  | ||||||
| 
 |  | ||||||
|   for file in "${FILES[@]}" |  | ||||||
|   do |  | ||||||
|     link "$file" |  | ||||||
|   done |  | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| setup_zsh() { | setup_zsh() { | ||||||
|   printf "Setting up zsh...\n" |   printf "Setting up zsh...\n" | ||||||
|  | @ -68,52 +50,59 @@ setup_zsh() { | ||||||
| 
 | 
 | ||||||
|   for file in "${FILES[@]}" |   for file in "${FILES[@]}" | ||||||
|   do |   do | ||||||
|     link "$file" |     setup_file "$file" | ||||||
|   done |   done | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| setup_vim() { | #################################################################################################### | ||||||
|   printf "Setting up vim...\n" | # Setup | ||||||
|  | #################################################################################################### | ||||||
| 
 | 
 | ||||||
|   FILES=() | pushd "$HOME" &>/dev/null | ||||||
|   FILES+=('vim') |  | ||||||
|   FILES+=('vimrc') |  | ||||||
| 
 | 
 | ||||||
|   for file in "${FILES[@]}" | ######################### | ||||||
|   do | # Setup root dirs | ||||||
|     link "$file" | ######################### | ||||||
|   done | setup_dir $cwd .dotfiles | ||||||
| } | setup_dir .dotfiles/vim .vim | ||||||
| 
 | 
 | ||||||
| setup_misc() { | ######################### | ||||||
|   printf "Setting up misc...\n" | # Setup root files | ||||||
|  | ######################### | ||||||
|  | FILES=() | ||||||
|  | FILES+=('aliases') | ||||||
|  | FILES+=('functions') | ||||||
|  | FILES+=('gitconfig') | ||||||
|  | FILES+=('githelpers') | ||||||
|  | FILES+=('vimrc') | ||||||
|  | FILES+=('curlrc') | ||||||
| 
 | 
 | ||||||
|   FILES=() | for file in "${FILES[@]}" | ||||||
|   FILES+=('curlrc') | do | ||||||
|  |     setup_file .dotfiles/$file .$file | ||||||
|  | done | ||||||
| 
 | 
 | ||||||
|   for file in "${FILES[@]}" | ######################### | ||||||
|   do | # Setup non-root files | ||||||
|     link "$file" | ######################### | ||||||
|   done | if [[ $is_windows -eq 1 ]]; then | ||||||
| } |     setup_file .dotfiles/bash/bashrc .bashrc | ||||||
|  |     setup_file .dotfiles/bash/bash_profile .bash_profile | ||||||
|  |     setup_file .dotfiles/bash/inputrc .inputrc | ||||||
|  |     setup_file .dotfiles/windows/gitconfig.platform .gitconfig.platform | ||||||
|  | fi | ||||||
| 
 | 
 | ||||||
| # //////////////////////////////////////////////////////////////////////////////////////// | curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o .git-completion.bash | ||||||
| # OSX |  | ||||||
| 
 | 
 | ||||||
| setup_osx() { | if [[ $is_windows -eq 0 ]]; then | ||||||
|   ./osx/install.sh |     setup_zsh | ||||||
| } | fi | ||||||
| 
 |  | ||||||
| # //////////////////////////////////////////////////////////////////////////////////////// |  | ||||||
| # Run |  | ||||||
| 
 |  | ||||||
| setup_dotfile_repo |  | ||||||
| setup_git |  | ||||||
| setup_zsh |  | ||||||
| setup_vim |  | ||||||
| setup_misc |  | ||||||
| 
 | 
 | ||||||
| if [[ $platform == 'Darwin' ]]; then | if [[ $platform == 'Darwin' ]]; then | ||||||
|   printf "\n${BOLD}Running the OS X installer${NORMAL}\n" |     printf "\n${BOLD}Running the OS X installer${NORMAL}\n" | ||||||
|   setup_osx |     ./osx/install.sh | ||||||
| fi | fi | ||||||
|  | 
 | ||||||
|  | popd "$HOME" &>/dev/null | ||||||
|  | 
 | ||||||
|  | printf "${BOLD}${GREEN}Done!${NORMAL}\n" | ||||||
|  |  | ||||||
|  | @ -213,3 +213,23 @@ link_file() { | ||||||
|     eval $link_cmd |     eval $link_cmd | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | function setup_file() { | ||||||
|  |     src=$1 | ||||||
|  |     dest=$2 | ||||||
|  |     if [ ! -f $dest ]; then | ||||||
|  |         link_file $src $dest $confirm_link | ||||||
|  |     else | ||||||
|  |         printf "${BOLD}*${NORMAL} ${YELLOW}'$dest'${NORMAL} already linked to ${YELLOW}'$src'${NORMAL}\n" | ||||||
|  |     fi | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function setup_dir() { | ||||||
|  |     src=$1 | ||||||
|  |     dest=$2 | ||||||
|  |     if [ ! -d $dest ]; then | ||||||
|  |         link_file $src $dest $confirm_link | ||||||
|  |     else | ||||||
|  |         printf "${BOLD}*${NORMAL} ${YELLOW}'$dest'${NORMAL} already linked to ${YELLOW}'$src'${NORMAL}\n" | ||||||
|  |     fi | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  |  | ||||||
|  | @ -23,6 +23,12 @@ error() { | ||||||
|   printf "${BOLD}${RED}$1${NORMAL}" |   printf "${BOLD}${RED}$1${NORMAL}" | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | fatal() { | ||||||
|  |     msg=$1 | ||||||
|  |     printf "${RED}${msg}${NORMAL}\n" | ||||||
|  |     exit 1 | ||||||
|  | } | ||||||
|  | 
 | ||||||
| log() { | log() { | ||||||
|   msg="$1" |   msg="$1" | ||||||
|   value="$2" |   value="$2" | ||||||
|  |  | ||||||
|  | @ -111,7 +111,7 @@ processor time and is generally useless. | ||||||
|     * Now you can make a system32 cmd line shortcut that will be used to launch the batch file. e.g. |     * Now you can make a system32 cmd line shortcut that will be used to launch the batch file. e.g. | ||||||
|       * `target:` `%windir%\System32\cmd.exe /k drive:\path-to-bat-file\shell-64.bat` |       * `target:` `%windir%\System32\cmd.exe /k drive:\path-to-bat-file\shell-64.bat` | ||||||
|       * `start in:` `drive:\some-path` |       * `start in:` `drive:\some-path` | ||||||
| * Setup git completions for bash: | * Setup git completions for bash (note: shouldn't have to do this if you ran the install script): | ||||||
|   * `curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash` |   * `curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash` | ||||||
| 
 | 
 | ||||||
| ### 32-bit dev tools | ### 32-bit dev tools | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user