Skip to content

Commit

Permalink
Mostly renames but starting to get ready for setting up via PATH (bas…
Browse files Browse the repository at this point in the history
…ically a reset) or a local Dotfiles repo
  • Loading branch information
TimTr committed Nov 23, 2023
1 parent 5dbdce6 commit 08b50ad
Show file tree
Hide file tree
Showing 17 changed files with 113 additions and 144 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions Mac/dot-zshrc.sh → Mac/Root/dot-zshrc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ message ".zshrc" "Launched $SHELL' at ${TIMENOW}."
# Warn about installing Homebrew if it is not yet present
which -s brew &> /dev/null
if [[ $? != 0 ]] ; then
error "Missing Homebrew" "Run install-brew.sh"
error "Missing Homebrew" "Run setup-brew.sh"
else
message "Found Homebrew" "Installed brew tools supercede system tools (e.g. Ruby)"
fi
Expand Down Expand Up @@ -52,13 +52,13 @@ source $HOME/local.sh
# *** NOTE: Removing rbenv - switched to simple `brew install ruby`
#
# This `rbenv` setting needs to be hard-coded into .zshrc by default
# If you get a "command not found" for rbenv, run `install-ruby`
# If you get a "command not found" for rbenv, run `setup-ruby`
#
# To read more about installing rbenv see: https://github.com/rbenv/rbenv
# eval "$(rbenv init - zsh)"
# which -s rbenv &> /dev/null
# if [[ $? != 0 ]] ; then
# error "Missing rbenv" "Run install-ruby.sh"
# error "Missing rbenv" "Run setup-ruby.sh"
# else
# eval "$(rbenv init -)"
# export PATH="${HOME}/.rbenv/bin:$PATH"
Expand Down
18 changes: 0 additions & 18 deletions Mac/Scripts/install-ruby.sh

This file was deleted.

64 changes: 0 additions & 64 deletions Mac/Scripts/update-ruby.sh

This file was deleted.

4 changes: 2 additions & 2 deletions Mac/Scripts/install-brew.sh → Mac/setup-brew.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/zsh
#
# install-brew.sh -- macOS version
# setup-brew.sh -- macOS version
#
# ==============================================================================

# TODO: this is not yet setup for Homebrew, just a copy of Ruby installer!

source ~/.functions

message "install-brew.sh" "Installing Homebrew using default script"
message "setup-brew.sh" "Installing Homebrew using default script"

which -s brew &> /dev/null
if [[ $? != 0 ]] ; then
Expand Down
55 changes: 27 additions & 28 deletions Mac/setup-macos.sh → Mac/setup-dotfiles.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/zsh
#
# setup-macos.sh - the macOS version
source "$DOTFILES_ROOT/Mac/dot-functions.sh"

# TODO: This needs to adapt to whether this is a FRESH install or re-run from PATH
source "$DOTFILES_ROOT/Mac/Root/dot-functions.sh"
echo
message "setup-macos.sh -- setting up for macOS via ${DOTFILES_ROOT}"

Expand Down Expand Up @@ -48,47 +50,44 @@ sudo chmod 766 $HOME/Developer
sudo chmod 777 /opt/homebrew/bin
sudo chmod 777 /usr/local/bin


# ==============================================================================
message "Copying scripts into ~/Developer" "These scripts are now in PATH"
# Put some files in these directories just to validate
cp ${DOTFILES_ROOT}/readme.md $HOME/Developer

# ==============================================================================
message "Copying dotfiles" "Overwriting existing versions of these files"
cp $DOTFILES_ROOT/Mac/dot-zshrc.sh $HOME/.zshrc
cp $DOTFILES_ROOT/Mac/dot-zshenv.sh $HOME/.zshenv
cp $DOTFILES_ROOT/Mac/dot-aliases.sh $HOME/.aliases
cp $DOTFILES_ROOT/Mac/dot-functions.sh $HOME/.functions
# Don't copy with -R for the primary PATH files
cp -R $DOTFILES_ROOT/Mac/* $HOME/Developer/


# Copy app preferences
cp $DOTFILES_ROOT/Mac/Preferences/* $HOME/Library/Preferences/

# TODO: FEATURE - Install from ~/Developer if run from PATH, or DOTFILES if fresh install

# ==============================================================================
message "Installing root dotfiles" "Overwriting existing versions of these files"
cp $DOTFILES_ROOT/Mac/Root/dot-zshrc.sh $HOME/.zshrc
cp $DOTFILES_ROOT/Mac/Root/dot-zshenv.sh $HOME/.zshenv
cp $DOTFILES_ROOT/Mac/Root/dot-aliases.sh $HOME/.aliases
cp $DOTFILES_ROOT/Mac/Root/dot-functions.sh $HOME/.functions

# Copy Git and other config files
cp $DOTFILES_ROOT/Mac/dot-gitconfig $HOME/.gitconfig
cp $DOTFILES_ROOT/Mac/dot-gitignore $HOME/.gitignore
cp $DOTFILES_ROOT/Mac/dot-vimrc $HOME/.vimrc
cp $DOTFILES_ROOT/Mac/Root/dot-gitconfig $HOME/.gitconfig
cp $DOTFILES_ROOT/Mac/Root/dot-gitignore $HOME/.gitignore
cp $DOTFILES_ROOT/Mac/Root/dot-vimrc $HOME/.vimrc

# Register gitignore and other git stuff
git config --global core.excludesfile ~/.gitignore

message "Installing app preferences" "Overwriting Terminal, Xcode, and other settings"
# Copy app settings
cp $DOTFILES_ROOT/Mac/Preferences/* $HOME/Library/Preferences/

# Copy Xcode preferences
mkdir -p $HOME/Library/Developer/Xcode/UserData/FontAndColorThemes
cp -R $DOTFILES_ROOT/Mac/Xcode/* $HOME/Library/Developer/Xcode/UserData/FontAndColorThemes/



# ==============================================================================
message "Copying scripts into ~/Developer" "These scripts are now in PATH"
cp -R $DOTFILES_ROOT/Mac/Demos/* $HOME/Developer/
cp -R $DOTFILES_ROOT/Mac/Scripts/* $HOME/Developer/
# Don't copy with -R for the root files, to avoid copyin
cp $DOTFILES_ROOT/Mac/* $HOME/Developer/

# These files are copied into Developer subfolders, not into the PATH
mkdir -p $HOME/Developer/Settings
cp -R $DOTFILES_ROOT/Mac/Settings/* $HOME/Developer/Settings/

mkdir -p $HOME/Developer/Xcode
cp -R $DOTFILES_ROOT/Mac/Xcode/* $HOME/Developer/Xcode/



# ==============================================================================
Expand Down Expand Up @@ -156,8 +155,8 @@ echo
message "Restart terminal" "After restart, you can run the following commands:"
bullet "git config --global user.name \"Your Name\""
bullet "git config --global user.email \"[email protected]\""
bullet "install-brew.sh <-- install and setup Homebrew"
bullet "install-ruby.sh <-- install a newer version of Ruby via Homebrew"
bullet "setup-brew.sh <-- install or update Homebrew"
bullet "setup-ruby.sh <-- setup a newer version (or update) of Ruby via Homebrew"
echo

exit 0
Expand Down
47 changes: 47 additions & 0 deletions Mac/setup-ruby.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/zsh
#
# setup-ruby.sh -- macOS version (simple version, installs latest)

source ${HOME}/.functions
message "setup-ruby.sh" "Running [brew install ruby] instead of [rbenv]"
bullet "The latest Ruby is installed via this script and put first in PATH"

which -s brew
if [[ $? != 0 ]] ; then
error "Missing Homebrew" "Must first install Homebrew before installing Ruby"
exit 0
fi

brew install ruby

# Update to the latest version of Ruby Gems installers
sudo gem update



# TODO: the below may require Terminal is restarted one before it succeeds?

# ==============================================================================
# Install some gems (Jekyll and Bundler to start)
which -s bundler &> /dev/null
if [[ $? != 0 ]] ; then
bullet "Installing Bundler" "Installing the Bundler gem for the first time"
sudo gem install bundler
else
message "Updating Bundler" "Updating the Bundler gem to latest version"
sudo gem update bundler
fi

which -s jekyll &> /dev/null
if [[ $? != 0 ]] ; then
bullet "Installing Jekyll" "Installing the Jekyll gem for the first time"
sudo gem install jekyll
else
bullet "Updating Jekyll" "Updating the Jekyll gem to latest version"
sudo gem update jekyll
fi



# ==============================================================================
exit 0
37 changes: 14 additions & 23 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,39 @@

Documentation for these `dotfiles` can be [found here](https://timtr.github.io/Dotfiles/Docs/).

On a Mac, first install Xcode or the command line tools package. Then run:
On a Mac, first install Xcode or the command line tools, then run:

```
git clone https://github.com/timtr/Dotfiles.git
cd Dotfiles
./setup.sh
```

Alternately, type `./setup.sh reset` to override custom files like `./local.sh` and to blow-away settings for tools like Xcode that you may otherwise not want to modify.
You can also type `./setup.sh reset` to override custom files like `./local.sh` and to blow-away settings for tools like Xcode that you may otherwise not want to modify.

Run `setup.sh` from within a local `Dotfiles` folder instance. Once installed, quit Terminal and relaunch. Finish install by typing:
The first install requires that you run `setup.sh` from within the local `Dotfiles` folder. Once installed, quit Terminal and relaunch. Finish install by typing:

```
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
install-brew.sh
install-ruby.sh
setup-brew.sh
setup-ruby.sh
```

A tool called `help.sh` is runable from the shell for additional help.
Once installed, a tool called `help.sh` is runable from the PATH for additional help.


## Features

Files ending in .sh are often renamed to be prefix by a `"."` with the `.sh` extension removed. This makes these files easier to edit during creation of this project, and also makes it clear which are "source" versions of these files, versus the installed versions.
**local.sh** - Installs a file called `~/local.sh` (if doesn't exist) that you can customize with settings that do not belong checked into GitHub, for instance set certain keys, or environment variables. This is also the file to add things like feature flags during development, add a Swift toolchain, or to enable secret build settings.

**ZSH settings** - sets up the prompt, `PATH`, and other basic settings. Note that `.zshenv` sets up the PATH so it works even when there is no interactive terminal session, and `.zshrc` will source this file for a consistent PATH for terminal windows.

**local.sh** - Installs a file called `~/local.sh` (if doesn't exist) that you can customize with settings that do not belong checked into GitHub, for instance set certain keys, or environment variables. This is also the file to add things like feature flags during development, add a Swift toolchain, or to enable secret build settings.
Files ending in `.sh` are often renamed to have a "dot" prefix and no extension (`.sh` removed). The the `.sh` extension hints to text editors to highlight like a shell script, and also makes it clear which are "source" versions of these files, versus the installed no-extension versions.


### Other smaller features
### Other small features

- Creates a symlink from ~/Dropbox to the new ~/Library/CloudStorage directory if it exists

Expand All @@ -48,20 +49,10 @@ For reference, `zsh` config files are loaded in the following order:
.zprofile -- if login (not using this file in current setup)
```

### Known Issues and ToDo items

- TODO: report the current `git config --global user.name "your name"` info, or if not set then report how to set it. Same for the setting for `git config --global user.email \"[email protected]\"`



## Setup a custom Swift toolchain

You can download new Swift toolchains from [Swift.org](https://swift.org/download/#snapshots) and set them up to be used by default. There is a new alias installed by these dotfiles called `swift-alt` that will run the `swift` command line interface using the alternate toolchain, once installed.

This dotfiles install will install a file called `.swift-settings.sh` at the user's root, enabling feature flags and adding the `swift-alt` alias. You will likely need to edit this file to enter the bundle ID of the installed toolchain you would like to use. As a result, the dotfiles `setup.sh` script will not overwrite this file once installed, so as to not blow away your customizations. If you want to re-install this file, simply delete it and re-run the dotfiles `setup.sh` to install a fresh version.

To get the correct toolchain bundle ID, in the format `org.swift.cXXXXXXX` you will need to go to the folder `/Library/Something/Toolchains` after installed, show package contents of one of the toolchains, and open the `Info.plist` file. From there, you should see a Bundle ID entry, matching the format.

You can download new Swift toolchains from [Swift.org](https://swift.org/download/#snapshots) and set them up to be used by default. The `~/local.sh` file is perfect to place to configure these settings rather than make the changes to the main Dotfile repo since it is likely to be a per-machine configuration.


## Overview
Expand All @@ -72,14 +63,14 @@ The scripts are designed to work in `zsh`, although they rarely use advanced fea

The setup will create a custom folder `$HOME/bin/` that is added to the PATH variable and useful for putting random stuff in the path. For Homebrew and related tools support, it also adds `/usr/local/bin` (for Intel) and `/opt/homebrew/bin` (for Apple) to the PATH.

There are a few aliases added that make it easy to install Homebrew and other tools, rather than trying to do the installs directly from `setup.sh`. Mostly this is because the install is a multi-step process, and it is just a lot easier to run the full setup, then manually type `install-brew` when everything else looks to be working.
There are a few aliases added that make it easy to install Homebrew and other tools, rather than trying to do the installs directly from `setup.sh`. Mostly this is because the install is a multi-step process, and it is just a lot easier to run the full setup, then manually type `setup-brew.sh` when everything else looks to be working.


## Demos

Once installed, you can install Homebrew and run demos. For example, run `demo-homebrew.sh` from the PATH to show a Terminal screen of software being downloaded, built, installed, and erased (in a repeating loop). Hit `CONTROL-Z` to quit that demo.
Once installed, you can install Homebrew and run demos. For example, run `demo-homebrew.sh` from the PATH to show a Terminal screen of software being downloaded, built, installed, and erased (in a repeating loop). Hit `CONTROL-Z` to quit that demo.

You can also open the `./Developer/demo-safari-cycle.html` file to launch Safari and begin cycling through many web pages, implying a sort of automated web test harness.
You can also open the `~/Developer/demo-safari-cycle.html` file to launch Safari and begin cycling through many web pages, implying a sort of automated web test harness.


## License
Expand Down
14 changes: 12 additions & 2 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fi
DOTFILES_ROOT=${0:a:h}
DOTFILES_SETUP=${0:a}
export DOTFILES_RESET=0
export DOTFILES_FRESH=1


# Display usage information if no commands are entered
Expand All @@ -34,13 +35,22 @@ if [[ "$1" = "reset" ]]; then
export DOTFILES_RESET=1
fi

# Handle the "reset" command if entered
if [[ "$1" = "fresh" ]]; then
echo "\n \033[1mFresh install\033[0m: Type setup-dotfiles.sh to re-run setup from PATH"
read -s -k
export DOTFILES_FRESH=1
fi




# This script will run either the Linux or macOS installer
# (yes, one day may need more options than this, but for now...)
if [[ $OSTYPE == darwin* ]]; then
source $DOTFILES_ROOT/Mac/setup-macos.sh
source $DOTFILES_ROOT/Mac/setup-dotfiles.sh
else
source $DOTFILES_ROOT/Linux/setup-linux.sh
source $DOTFILES_ROOT/Linux/setup-dotfiles.sh
fi


Expand Down
Loading

0 comments on commit 08b50ad

Please sign in to comment.