Skip to content

Instantly share code, notes, and snippets.

@Torvaney
Last active March 6, 2023 11:31
Show Gist options
  • Save Torvaney/975db8c50112e5489f9bc514473a87ff to your computer and use it in GitHub Desktop.
Save Torvaney/975db8c50112e5489f9bc514473a87ff to your computer and use it in GitHub Desktop.
Some useful(?) stuff for a various profile files
## Git
# Add highlighting by default
alias ls='ls -G'
# Show git branch in prompt.
export PS1="\[\033[1;32m\]\u\[\033[01;33m\] \w \[\033[36m\]\`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\\\\\*\ \(.+\)$/\(\\\\\\\\\1\)\ /\`\[\033[37m\]$\[\033[00m\] "
# Git autocompletion
# Also need to `brew install bash-completion`
if [ -f `brew --prefix`/etc/bash_completion.d/git-completion.bash ]; then
. `brew --prefix`/etc/bash_completion.d/git-completion.bash
fi
# gitignore.io command line tool
function gi() { curl -L -s https://www.gitignore.io/api/$@ ;}
## R
# Do the R repl the right way
alias R="$(/usr/bin/which R) --no-save --no-restore-data"
alias r="$(/usr/bin/which r) --no-save --no-restore-data"
# Compile r package from source (could be unnecessary??)
rpkg () { Rscript -e "install.packages('$1', repos = NULL, type = 'source')"; }

This gist contains some useful stuff for profiles.

Currently:

  • bash
  • R
  • Visual Studio code

This file is named such that the gist shares the same name

# To use this file, just run the following in R (at your own risk)
# source("https://git.io/JD4u3"); .update_global_rprofile()
# To find the original:
# https://gist.github.com/Torvaney/975db8c50112e5489f9bc514473a87ff
#
## Pipe df to clipboard ----------------------------
if (interactive()) {
# Probably don't need this anymore, but will leave
# it in for the sake of muscle memory
to_clipboard <- clipr::write_clip
}
## Clear/exit repl ---------------------------------
if (interactive()) {
exit <- structure(list(), class = "exit_command")
print.exit_command <- function(...) {
cat("Bye! 👋\n\n")
q("no")
}
clear <- structure(list(), class = "clear_command")
print.clear_command <- function(...) {
purrr::walk(c("\f", "\033[2J", "\033[0;0H"), cat)
}
}
## Update file from remote source (gist) -----------
if (interactive()) {
.update_global_rprofile <- function() {
download.file("https://git.io/JD4u3", "~/.Rprofile")
}
}
## Devtools ----------------------------------------
.First <- function() {
options(
repos = c(CRAN = "https://cran.rstudio.com/"),
browserNLdisabled = TRUE,
deparse.max.lines = 2,
dplyr.summarise.inform = FALSE
)
}
if (interactive()) {
suppressMessages(require(devtools))
}
cat("Hello! 👋\n")
{
"workbench.startupEditor": "newUntitledFile",
"workbench.settings.editor": "json",
"workbench.statusBar.feedback.visible": false,
"window.zoomLevel": 0,
"editor.fontFamily": "FiraCode-Light, Menlo, Monaco",
"editor.fontLigatures": true,
"editor.rulers": [
80,
100
],
"editor.fontSize": 12,
"editor.insertSpaces": true,
"editor.renderWhitespace": "all",
"files.trimTrailingWhitespace": true,
"files.trimFinalNewlines": true,
"files.insertFinalNewline": true,
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 500,
"terminal.integrated.fontFamily": "FiraCode-Light",
"terminal.integrated.fontSize": 12,
"haskell.hlint.executablePath": "hlint",
"liveServer.settings.donotVerifyTags": true,
"liveServer.settings.donotShowInfoMsg": true,
"python.dataScience.sendSelectionToInteractiveWindow": false,
"[elm]": {
"editor.formatOnSave": true
},
"breadcrumbs.enabled": true,
"[python]": {
"editor.formatOnType": true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment