Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wahalulu/bfb02efdbf6660aaad94c5ed3ece9b23 to your computer and use it in GitHub Desktop.
Save wahalulu/bfb02efdbf6660aaad94c5ed3ece9b23 to your computer and use it in GitHub Desktop.

App Install Plan

Critical

R

  • R

  • RSwitch

  • RStudio

  • Packages

    # Install and setup {pak}
    install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/")
    pak::pak_setup()
    
    # Install tidyverse
    pak::pkg_install("tidyverse")
    
    # and lots of other things...
    pak::pkg_install(c("usethis", "devtools", "here", "styler", "remotes"))
    pak::pkg_install(c("xaringan", "blogdown", "bookdown", "pagedown"))
      
    my_packages <- c("xaringanExtra", "js4shiny", "shrtcts", "rsthemes", "ermoji", "regexplain")
    pak::pkg_install(paste0("gadenbuie/", my_packages))
      
    # more RStudio addins
    pak::pkg_install(c(
      "daattali/addinslist",
      "seasmith/AlignAssign",
      "MilesMcBain/datapasta",
      "MilesMcBain/gistfo"
    ))

Utilities

Apps

Command Line Tools

General Utilities

Node & npm

Fish Shell

Configuration

General Things

Stuff I've done that probably doesn't need to be done in any order.

  • Set Flycut clipboard navigator shortcut to Cmd + Option + V
  • Turn on Dock hiding
  • Rename computer: System Prefs > Sharing > Computer Name
  • Add RSwitch to Login Items
  • Alias ll to natls -l: fish> alias -s ll="natls -l"
  • System Preferences > Accessibility
    • Zoom > ☑️ Use scroll gesture with Control keys
    • Enable Hover Text > ☑️ Enable Hover Text with Command

R Config

RSwitch has a command-line tool, which can be symlinked into /usr/local/bin for easy switching on from the terminal. See Using RSwitch.

ln -s /Applications/RSwitch.app/Contents/Resources/rswitch-cmd /usr/local/bin/rswitch

I'm not exactly sure what went wrong with the R install, but it seems like R and Rscript aren't found. I reinstalled both versions but that didn't work.

From the RSwitch docs I learned that R lives in

/Library/Frameworks/R.framework/Resources/bin/R

so I linked the binary into /usr/local/bin with

ln -s /Library/Frameworks/R.framework/Resources/bin/R /usr/local/bin/R
ln -s /Library/Frameworks/R.framework/Resources/bin/Rscript /usr/local/bin/Rscript

and that fixed R and Rscript from the command line. I wonder if I should do the same for Rcmd, but I guess I'll find out later.

New SSH Key

Run with defaults to add key to ~/.ssh/id_rsa

ssh-keygen

Copy ~/.ssh/id_rsa.pub

cat ~/.ssh/id_rsa.pub | pbcopy

and add to GitHub to authenticate SSH connections at https://github.com/settings/ssh/new.

Add GitHub PAT to R

library(usethis)
browse_github_pat()
# choose scopes
edit_r_environ()
# copy paste PAT

Setup GitHub and gh

# follow instructions
gh auth login

# set default protocol to ssh
gh config set git_protocol ssh

.dotfiles

I ended up creating a .dotfiles repo and I put these files into it for now.

.
├── bin
│   └── create.r
├── git
│   ├── gitconfig
│   └── gitignore
├── iterm2
│   └── Profiles.json
├── r
│   ├── .Rprofile
│   └── .shrtcts.R
├── rstudio
│   ├── keybindings
│   └── rstudio-prefs.json
└── vim
    ├── .viminfo
    └── .vimrc

Create work, play, notes folders

I put my things into ~/work, ~/play and ~/notes.

  • work is for work projects and deliverables.
  • play is for side work projects and experiments
  • notes is for reprexes, tests, keeping track of learning projects

I also typically create a default RStudio project so that it's easy to launch a "scratchpad" R session. It also makes it easy to open the experimental session in a new RStudio window. The project lives in ~/notes/default/.

Mouse Size Service

Once installed, I can switch to Finder and click Finder > Services > Big Mouse to enlarge the mouse for presentations or screen recording

  • Open Automator and create a new Quick Action.
  • Search for AppleScript and then drop Run AppleScript into the workflow.
  • Set the workflow to receive no input
  • Paste the AppleScript code below to replace (* Your script goes here *)
  • Edit the mouse size to a number between 1 (normal) and 4 (big). I pick 4 for big mouse.
  • Save the workflow as "Big Mouse"
  • Duplicate the workflow and adjust the mouse size number to normal size
  • Save this new workflow as "Normal Mouse"
  • Switch to Finder, click Finder in menu bar, then Services, then run "Big Mouse".
  • Give Finder accessibility permissions if the workflow fails
tell application "System Preferences"
	activate
	reveal anchor "Seeing_Display" of pane id "com.apple.preference.universalaccess"
end tell

tell application "System Events"
	tell process "System Preferences"
		repeat until exists radio button "Cursor" of tab group 1 of group 1 of window 1
			delay 0.1
		end repeat
		click radio button "Cursor" of tab group 1 of group 1 of window 1
		repeat until exists slider "Cursor Size:" of tab group 1 of group 1 of window 1
			delay 0.1
		end repeat
		set theSlider to slider "Cursor Size:" of tab group 1 of group 1 of window 1
		set stash to value of theSlider
		set value of theSlider to 1.0
		stash
	end tell
end tell

Debugging AppleScript: this link was essential to determine which UI elements and buttons needed to be scripted in AppleScript (things changed in Big Sur).

Fonts

brew install --cask \
  font-fantasque-sans-mono font-fantasque-sans-mono-nerd-font \
  font-noto-sans font-noto-serif font-noto-mono font-noto-mono-for-powerline font-noto-emoji \
  font-hasklug-nerd-font font-anonymice-nerd-font font-meslo-lg-nerd-font \
  font-fira-code font-fira-mono font-fira-sans font-fira-sans-condensed \
  font-pt-mono font-pt-sans font-pt-sans-narrow font-pt-serif font-pt-sans-caption font-pt-serif-caption
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment