Skip to content

Instantly share code, notes, and snippets.

@cderv
Last active October 9, 2024 09:22
Show Gist options
  • Save cderv/883729f079e487d09b6b52f20e978963 to your computer and use it in GitHub Desktop.
Save cderv/883729f079e487d09b6b52f20e978963 to your computer and use it in GitHub Desktop.
New computer setup
# installed by winget
winget install PowerShell-Preview
winget install git
git config --global user.name "Christophe Dervieux"
git config --global user.email christophe.dervieux@gmail.com
winget install rstudio
winget install vscode
winget install -e R
winget install Github.GithubDesktop
winget install Notepad++
winget install notion
winget install Chrome
winget install SumatraPDF
winget install autohotkey
winget install fork  

## Visual Studio Build Tool
## https://visualstudio.microsoft.com/fr/visual-cpp-build-tools/
## /!\ VERY LONG INSTALLATION /!\
winget install Microsoft.VisualStudio.BuildTools

# install scoop
iwr -useb get.scoop.sh | iex
scoop checkup
scoop install 7zip
scoop install innounp
scoop install dark
scoop install sudo

sudo Add-MpPreference -ExclusionPath 'C:\Users\chris\scoop'
sudo Add-MpPreference -ExclusionPath 'C:\ProgramData\scoop'
sudo Set-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1

# installed with scoop
scoop bucket add extras
scoop install keypirinha
keypirinha.exe
scoop install pandoc
scoop install pandoc-crossref
scoop install everything
scoop install hugo-extended
scoop install jq
scoop install ffmpeg
scoop install gifski
scoop install screentogif
scoop install joplin
scoop install optipng
scoop install age

# Prefer Oh My Posh
# scoop install pshazz
# sudo Set-Service ssh-agent -StartupType Manual
# scoop install concfg
# concfg export console-backup.json
# concfg import solarized-dark

scoop install aria2
scoop install nano

scoop install gh
# add autocompletion
# (handled with chezmoi)
Add-Content -Path (echo $profile) -Value 'try { $null = gcm gh -ea stop; Invoke-Expression -Command $(gh completion -s powershell | Out-String) } catch { }'

scoop install bit
# add autocompletion
bit complete

scoop install bat
scoop install less
scoop install tldr

## Rust
scoop install rustup

## Nodejs
scoop install nvm
nvm install lts
nvm use lts
npm install -g gitmoji-cli
npm install -g standard



# Fonts
scoop bucket add nerd-fonts
sudo scoop install -g FiraCode FiraCode-NF FiraMono-NF FiraMono-NF-Propo Cascadia-Code CascadiaCode-NF CascadiaCode-NF-Mono CascadiaCode-NF-Mono Iosevka-NF Iosevka-NF-Mono JetBrainsMono Lekton-NF

# r-bucket
scoop bucket add r-bucket https://github.com/cderv/r-bucket.git

scoop install rig
rig add release
rig system make-links 
rig system update-rtools40
rig system setup-user-lib
rig system add-pak
rig system rtools add

scoop install rstudio-daily
scoop install positron

scoop install quarto
scoop install quarto-prerelease

# chezmoi
scoop install chezmoi
## Some docs: 
##  - https://haril.dev/en/blog/2023/04/08/chezmoi-basic-settings
##  - https://budimanjojo.com/2021/12/13/managing-dotfiles-with-chezmoi/

# Installing Julia
winget install --id Julialang.Juliaup

# Configure powershell
## Powerline setup https://docs.microsoft.com/en-us/windows/terminal/tutorials/powerline-setup
Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser
Install-Module -Name PSReadLine -Scope CurrentUser -Force -SkipPublisherCheck
Install-Module -Name Terminal-Icons -Repository PSGallery

Set-PowerLinePrompt -PowerLineFont
Add-Content -Path (echo $PROFILE) -Value '# Powerline setup'
Add-Content -Path (echo $PROFILE) -Value 'Import-Module posh-git'
Add-Content -Path (echo $PROFILE) -Value 'Import-Module oh-my-posh'
Add-Content -Path (echo $PROFILE) -Value 'Set-Theme Paradox'

# Use starship instead (https://starship.rs)
scoop install starship

## Deactivate conda prompt
conda config --set changeps1 False

# Activate WSL 
## * https://docs.microsoft.com/fr-fr/windows/wsl/install-win10)
## * https://support.rstudio.com/hc/en-us/articles/360049776974-Using-RStudio-Server-in-Windows-WSL2
sudo dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
## WSL 2
sudo dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
## restart
## update kernel : https://docs.microsoft.com/fr-fr/windows/wsl/wsl2-kernel
sudo wsl --set-default-version 2
## Install ubuntu from winstore and run it to install

## Share env var (https://devblogs.microsoft.com/commandline/share-environment-vars-between-wsl-and-windows/)
setx WSLENV

ON WSL UBUNTU

## Configure RStudio Server on WSL
sudo apt-get update
sudo apt-get upgrade -y
## Add repo
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo add-apt-repository 'deb https://cloud.r-project.org/bin/Linux/ubuntu focal-cran40/'
## install R and dependencies
sudo apt install -y r-base r-base-core r-recommended r-base-dev gdebi-core build-essential libcurl4-gnutls-dev libxml2-dev libssl-dev
wget https://rstudio.org/download/latest/stable/server/bionic/rstudio-server-latest-amd64.deb
sudo gdebi rstudio-server-latest-amd64.deb

## Install tools
wget https://github.com/cli/cli/releases/download/v0.11.1/gh_0.11.1_linux_amd64.deb

## Install bit
## https://github.com/chriswalz/bit#using-curl-simplest-way-to-install
curl -sf https://gobinaries.com/chriswalz/bit | sh;
bit complete;

## install rust - https://www.rust-lang.org/tools/install
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

cargo install natls

## Add to ~/.bashrc
if [ -d "$HOME/.cargo/bin" ] ; then
    export PATH=$PATH:$HOME/.cargo/bin
fi

On WSL ARCH LINUX

Installation of distro

Install with Scoop

scoop install archwsl

Other resources:

Setup

Updating keys

Useful when issue about corrupt keys https://ostechnix.com/fix-invalid-corrupted-package-pgp-signature-error-arch-linux/

sudo pacman -S archlinux-keyring

Packages

pacman -Syyu 
pacman -S base-devel
pacman -S p7zip unzip pygmentize vim htop git jq openssh rsync

pacman -S github-cli
gh auth login

pacman -S bat

Python config

pacman -S pyenv # https://github.com/pyenv/pyenv

Configure AUR

nano /etc/pacman.conf

Insert

[archlinuxfr]
SigLevel = Never
Server = http://repo.archlinux.fr/$arch

Windows Terminal

Add Git Bash to Windows Terminal

managed by chezmoi now

Generate a new GUID in Powershell [guid]::NewGuid() the use it to add this to the settings, like

            {
                "guid": "{984211b2-e509-4709-91bd-814957a997f8}",
                "name": "Git-Bash",
                "commandline": "%PROGRAMFILES%\\Git\\bin\\bash.exe",
                "icon": "%PROGRAMFILES%\\Git\\mingw64\\share\\git\\git-for-windows.ico",
                "startingDirectory" : "~"
             }

Add PS7 as default

Change the GUID of default profile to the settings of Windows Terminal

GIT Verified Commit

Keybase for SSH

Could be useful:

# Export as public key to local gpg keyring
keybase pgp pull
# check keys
gpg --list-keys --keyid-format LONG
# if missing do
keybase pgp export | gpg --import

On windows

Use Git Bash, as Git For Windows includes gpg. It is the easiest as already included and used by git itself.

gpg --full-generate-key
gpg --list-secret-keys --keyid-format LONG
gpg --list-keys --keyid-format LONG

# add another email
# <id> can be email 
gpg --edit-key <id>
> adduid
> save

git config --global user.signingkey <KEY>
git config --global commit.gpgsign true
git config --global gpg.program gpg

gpg --armor --export <key>

Then put in Github: https://github.com/settings/keys

in WSL - Ubuntu 20

From https://blog.jmorbegoso.com/post/configure-github-gpg-key-in-windows-and-wsl/

$gnupgPath = (gcm gpg).Source
$gnupgWslPath = wsl wslpath $gnupgPath
wsl -d "Ubuntu-22.04" git config --global commit.gpgsign true
wsl -d "Ubuntu-22.04" git config --global user.signingkey "[email protected]" # email act as GPG alias here

To set the program path it can't be set from command because of escaping whe (x86) is in the name

It should have been

wsl -d "Ubuntu-22.04" git config --global gpg.program "`"" + $gnupgWslPath + "`""
wsl -d "Ubuntu-22.04" ~/.gitconfig 

but it does not work.

So

  • Connect to WSL distro

  • Type the command directly

    [gpg]
          program = "/mnt/c/Program Files (x86)/GnuPG/bin/gpg.exe"
    

Credential store

WINDOWS 10

Included in git for windows

Ubuntu WSL

Use Git Credential Core - Built in Git for Windows But setup for WSL with https://docs.microsoft.com/fr-fr/windows/wsl/tutorials/wsl-git#git-credential-manager-setup

  • Install deps
sudo apt install gpg pass

Latest Git version

Ubuntu

Source: https://itsfoss.com/install-git-ubuntu/

sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git

For add-apt-repository, do sudo apt install software-properties-common

GH COPILOT CLI

https://docs.github.com/fr/copilot/github-copilot-in-the-cli/using-github-copilot-in-the-cli

gh extension install github/gh-copilot
gh extension upgrade gh-copilot

Miniconda

 winget install --id Anaconda.Miniconda3
# Install boxstarter:
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
#
# You might need to set: Set-ExecutionPolicy RemoteSigned
#
# Run this boxstarter by calling the following from an **elevated** command-prompt:
# start http://boxstarter.org/package/nr/url?<URL-TO-RAW-GIST>
# OR
# Install-BoxstarterPackage -PackageName <URL-TO-RAW-GIST> -DisableReboots
#
# Learn more: http://boxstarter.org/Learn/WebLauncher
### Disable UAC for Session
Disable-UAC
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions -EnableShowFullPathInTitleBar -EnableOpenFileExplorerToQuickAccess -EnableShowRecentFilesInQuickAccess -EnableShowFrequentFoldersInQuickAccess -EnableExpandToOpenFolder -EnableShowRibbon -EnableItemCheckBox
Enable-RemoteDesktop
$ErrorActionPreference = "Continue"
Write-Host $(winget --version)
## Install from winget
## Install scoop
if (-not (Get-Command scoop -ea SilentlyContinue)) {
Invoke-Expression "& {$(Invoke-RestMethod get.scoop.sh)} -RunAsAdmin"
}
Write-Host "Installing Scoop packages..."
# Add some buckets
scoop bucket add extras
# Install some packages
scoop install 7zip
scoop install age
scoop install agg
scoop install archwsl
scoop install aria2
scoop install bat
scoop install converseen
scoop install dark
scoop install deno
scoop install depends
scoop install difftastic
scoop install direnv
scoop install everything
scoop install fd
scoop install ffmpeg
scoop install file
scoop install flameshot
scoop install fq
scoop install fvim
scoop install fx
scoop install fzf
scoop install ghostscript
scoop install gifski
scoop install go
scoop install graphviz
scoop install grep
scoop install innounp
scoop install jq
scoop install just
scoop install keypirinha
scoop install less
scoop install libxml2
scoop install make
scoop install nano
scoop install neovim
scoop install neovim-qt
scoop install obsidian
scoop install optipng
scoop install pandoc
scoop install pasteboard
scoop install pdf2svg
scoop install pdftk
scoop install pelook
scoop install perl
scoop install pet
scoop install pipx
scoop install plantuml
scoop install podman
scoop install poppler
scoop install portfolio-performance
scoop install PSFzf
scoop install regscanner
scoop install ripgrep
scoop install sed
scoop install sharex
scoop install simple-http-server
scoop install starship
scoop install sudo
scoop install tidy
scoop install tldr
scoop install touch
scoop install typst
scoop install unlocker
scoop install unzip
scoop install ussf
scoop install vim
scoop install watchman
scoop install wezterm
scoop install windirstat
scoop install winrar
scoop install wkhtmltopdf
scoop install wsl2-distro-manager
scoop install yt-dlp
scoop install ZLocation
## JAVA
scoop bucket add java
scoop add openjdk
## Rust
scoop install rustup
## Node
scoop install nvm
nvm install lts
nvm use lts
npm install -g gitmoji-cli
npm install -g standard
scoop bucket add r-bucket https://github.com/cderv/r-bucket.git
## R
scoop install rig
rig add release
rig system make-links
rig system update-rtools40
rig system setup-user-lib
rig system add-pak
rig system rtools add
scoop install rstudio-daily
scoop install positron
scoop install qvm
scoop install quarto
scoop install quarto-prerelease
## Fonts
scoop bucket add nerd-fonts
sudo scoop install -g FiraCode FiraCode-NF FiraMono-NF FiraMono-NF-Propo Cascadia-Code CascadiaCode-NF CascadiaCode-NF-Mono CascadiaCode-NF-Mono Iosevka-NF Iosevka-NF-Mono JetBrains-Mono Lekton-NF

Requirements

  • Install Scoop : https://github.com/ScoopInstaller/Scoop#installation

  • Run:

    # Set Windows defender exception
    sudo Add-MpPreference -ExclusionPath 'C:\Users\chris\scoop'
    sudo Add-MpPreference -ExclusionPath 'C:\ProgramData\scoop'
    
  • Check winget: winget --version

  • Install chezmoi: scoop install chezmoi & chezmoi init

  • Run chezmoi: chezmoi apply

How I set up my keypirinha

About

Install packages

Using pkgControl: https://github.com/ueffel/Keypirinha-PackageControl

  • Open Keypirinha then F2 and
import keypirinha as kp,keypirinha_net as kpn,os;p="PackageControl.keypirinha-package";d=kpn.build_urllib_opener().open("https://github.com/ueffel/Keypirinha-PackageControl/releases/download/1.0.2/"+p);pb=d.read();d.close();f=open(os.path.join(kp.installed_package_dir(),p),"wb");f.write(pb);f.close()

Installed packages

See list https://ue.spdns.de/packagecontrol/

  • Windows App
  • Recent Items
  • Windows Terminal Profiles
  • Git
  • todo-markdown
  • snippet
  • winsys
  • url-shortener
  • kill

Configure Extension

File Catalog

RStudio Profile for Rproj project

[profile/RStudio]
activate = yes
path = ${var:KNOWNFOLDER_DOCUMENTS}\**
filters = ext: Rproj
file_item_label = {profile}: {clean_name}
# Use Package Manager
cat('options(repos = c(CRAN = "https://packagemanager.rstudio.com/all/__linux__/focal/latest"))', file = "~/.Rprofile", append = TRUE)
install.packages("remotes")
remotes::install_cran("devtools")
remotes::install_cran("tinytex")
tinytex::install_tinytex()
# use renv for the setup to take advantage of the cahcing mechanism
install.packages("renv")
renv::install("usethis")
renv::install("devtools")
renv::install("rmarkdown")
renv::install("tinytex")
tinytex::install_tinytex()
# setup GITHUB
## Github PAT
usethis::browse_github_pat()
usethis::edit_r_environ()
usethis::git_sitrep()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment