Skip to content

Commit

Permalink
feat: add linux compatibility (#147)
Browse files Browse the repository at this point in the history
* feat: add Dockerfile for testing linux install
* feat: add shell and terminfo installer commands
* refactor: decouple insalled location from installation/zsh
* fix: only alias vim to nvim if nvim is installed
* fix: change zsh path from brew to zsh if brew no installed
* refactor: change '! -z' to '-n'
* feat: add all option to installer
* fix: add backup and macos to installer script
* fix: create ~/.vim-tmp on shell start
* refactor: rename installer to install.sh and remove install directory
* fix dotfiles path issue in zshenv
* fix(install): clean duplicated and misspelled code
* refactor(docker): condense install commands in one
* fix(tmux): remove reattach-to-user-namespace
* refactor: remove reattach-to-user-namespace as it no longer appears to be necessary.
* refactor: remove login-shell as it is no longer required
* refactor(git): remove personal info from gitconfig
* refactor: remove name, email, and github username from gitconfig. These are now stored in ~/.gitconfig-local, which is outside of version control.
* fix(install): set values in local-system config
* refactor: rename function to not conflict with actual git
* refactor: direct config to ~/.gitconfig-local instead of the global config
* feat(install): colorize output of install script
* refactor(install): normalize function names
* refactor(docker): remove commented out code
* feat(zsh): add linuxbrew to path
* fix(docker): update apt in Dockerfile
* fix(zsh): sourcing homebrew and z.sh
* fix(install): show macos warning on linux
  • Loading branch information
nicknisi committed Aug 19, 2020
1 parent c1290af commit 4c01a73
Show file tree
Hide file tree
Showing 14 changed files with 421 additions and 455 deletions.
126 changes: 62 additions & 64 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,67 @@
# taps
if OS.mac?
# taps
tap "homebrew/cask"
tap "homebrew/cask-fonts"

brew "mas"
brew "noti"
brew "trash"

# Applications
cask "kitty"
cask "imageoptim"
cask "notion"
cask "hazel"
cask "anybar"
cask "istat-menus"
cask "textbar"
cask "rocket"
cask "cleanshot"
cask "vmware-fusion"
cask "timing"
cask "choosy"
cask "soundsource"
cask "farrago"
cask "loopback"
cask "audio-hijack"
cask "paw"
cask "postman"

# Browsers
cask "firefox"
cask "google-chrome"

# Fonts
cask "font-fira-code"
cask "font-jetbrains-mono"
cask "font-cascadia-mono"
cask "font-3270-nerd-font"

# macOS App Store
mas "Affinity Photo", id: 824183456
mas "Affinity Designer", id: 824171161
mas "FruitJuice", id: 671736912
mas "Drafts", id: 1435957248
mas "Airmail", id: 918858936
mas "Logic Pro X", id: 634148309
mas "Fantastical", id: 975937182
mas "Xcode", id: 497799835
mas "Reeder", id: 1449412482
mas "Final Cut Pro", id: 424389933
mas "Deliveries", id: 924726344
mas "Shush", id: 496437906
mas "Pixelmator Pro", id: 1289583905
mas "Magnet", id: 441258766
mas "Octotree Pro", id: 1457450145
mas "Coca", id: 1000808993
mas "MindNode", id: 1289197285
mas "ColorSlurp", id: 1287239339
mas "Bear", id: 1091189122
mas "1Blocker", id: 1107421413
end

tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/core"
tap "homebrew/cask-fonts"
tap "schniz/tap"

# packages
Expand All @@ -25,78 +84,17 @@ brew "jq"
brew "lazydocker"
brew "lazygit"
brew "markdown"
brew "mas"
brew "neofetch"
brew "neovim"
brew "nmap"
brew "noti"
brew "python"
brew "reattach-to-user-namespace"
brew "ripgrep"
brew "schniz/tap/fnm"
brew "shellcheck"
brew "the_silver_searcher"
brew "tig"
brew "tldr"
brew "tmux"
brew "trash"
brew "tree"
brew "vim"
brew "wdiff"
brew "wget"
brew "youtube-dl"
brew "z"
brew "zsh"

# Applications
cask "kitty"
cask "imageoptim"
cask "notion"
cask "hazel"
cask "anybar"
cask "istat-menus"
cask "textbar"
cask "rocket"
cask "cleanshot"
cask "vmware-fusion"
cask "timing"
cask "choosy"
cask "soundsource"
cask "farrago"
cask "loopback"
cask "audio-hijack"
cask "paw"
cask "postman"

# Browsers
cask "firefox"
cask "google-chrome"

# Fonts
cask "font-fira-code"
cask "font-jetbrains-mono"
cask "font-cascadia-mono"
cask "font-3270-nerd-font"

# macOS App Store
mas "Affinity Photo", id: 824183456
mas "Affinity Designer", id: 824171161
mas "FruitJuice", id: 671736912
mas "Drafts", id: 1435957248
mas "Airmail", id: 918858936
mas "Logic Pro X", id: 634148309
mas "Fantastical", id: 975937182
mas "Xcode", id: 497799835
mas "Reeder", id: 1449412482
mas "Final Cut Pro", id: 424389933
mas "Deliveries", id: 924726344
mas "Shush", id: 496437906
mas "Pixelmator Pro", id: 1289583905
mas "Magnet", id: 441258766
mas "Octotree Pro", id: 1457450145
mas "Coca", id: 1000808993
mas "MindNode", id: 1289197285
mas "ColorSlurp", id: 1287239339
mas "Bear", id: 1091189122
mas "1Blocker", id: 1107421413

32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM ubuntu

# Update the apt repository
RUN apt update

# Install dependencies
RUN apt-get update
RUN apt-get install -y build-essential file zsh git sudo ruby curl vim language-pack-en

# take an SSH key as a build argument
ARG PRIVATE_KEY
ARG PUBLIC_KEY

# Create a test user
RUN useradd -ms /bin/bash user && \
echo "user ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/user && \
chmod 0440 /etc/sudoers.d/user

USER user:user

WORKDIR /home/user
RUN touch .bash_profile
RUN mkdir -p .ssh
RUN echo "$PRIVATE_KEY" > .ssh/id_rsa
RUN echo "$PUBLIC_KEY" > .ssh/id_rsa.pub
RUN chmod 600 .ssh/id_rsa
RUN chmod 600 .ssh/id_rsa.pub
RUN ssh-keyscan github.com >> .ssh/known_hosts

RUN mkdir -p code

CMD ["/bin/bash"]
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,21 @@ I am currently using [Operator Mono](http://www.typography.com/fonts/operator/st

Tmux is a terminal multiplexor which lets you create windows and splits in the terminal that you can attach and detach from. I use it to keep multiple projects open in separate windows and to create an IDE-like environment to work in where I can have my code open in vim/neovim and a shell open to run tests/scripts. Tmux is configured in [~/.tmux.conf](tmux/tmux.conf.symlink), and in [tmux/theme.sh](tmux/theme.sh), which defines the colors used, the layout of the tmux bar, and what what will be displayed, including the time and date, open windows, tmux session name, computer name, and current iTunes song playing. If not running on macOS, this configuration should be removed.

When tmux starts up, [login-shell](bin/login-shell) will be run and if it determines you are running this on macOS, it will call reattach-to-user-namespace, to fix the system clipboard for use inside of tmux.
## Docker Setup

A Dockerfile exists in the repository as a testing ground for linux support. To set up the image, make sure you have Docker installed and then run the following command.

```bash
docker build -t dotfiles --force-rm --build-arg PRIVATE_KEY="$(cat ~/.ssh/id_rsa)" --build-arg PUBLIC_KEY="$(cat ~/.ssh/id_rsa.pub)" .
```

This should create a `dotfiles` image which will set up the base environment with the dotfiles repo cloned. To run, execute the following command.

```bash
docker run -it --rm dotfiles
```

This will open a bash shell in the container which can then be used to manually test the dotfiles installation process with linux.

## Questions

Expand Down
10 changes: 0 additions & 10 deletions bin/login-shell

This file was deleted.

21 changes: 21 additions & 0 deletions bin/manage
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

set -e

case "$1" in
start)
docker run -v "$DOTFILES":/home/user/code/dotfiles -it --rm dotfiles
;;
build)
priv_key=$(cat ~/.ssh/id_rsa)
pub_key=$(cat ~/.ssh/id_rsa.pub)
docker build -t dotfiles \
--force-rm \
--build-arg PRIVATE_KEY="$priv_key" \
--build-arg PUBLIC_KEY="$pub_key" \
"$DOTFILES"
;;
*)
echo $"Usage: $(basename "$0") {start|build}"
;;
esac
8 changes: 2 additions & 6 deletions git/gitconfig.symlink
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
# gitconfig
[user]
name = Nick Nisi
email = nick@nisi.org
[github]
user = nicknisi
[init]
templatedir = ~/.dotfiles/git/templates
defaultBranch = main
[include]
# A local gitconfig, outside of version control.
# If the file doesn't exist it is silently ignored
path = ~/.gitconfig-local
[alias]
# list all aliases
Expand Down
Loading

0 comments on commit 4c01a73

Please sign in to comment.