Minimal Vim (~/.vimrc or $env:userprofile/_vimrc on Windows):
runtime! ftplugin/man.vim color darkblue syntax on set hls ic is scs si et ts=2 sts=2 sw=2 et sr wmnu ru sbr=BR: ls=2 match error /\s\+$\|\t\|TODO\|XXX\|BUG/ set stl+=\ %{\ line2byte(line(\"$\")+1)-1\ }B\ %F%R%M\ %l:%c noremap :W :w noremap :Q :q "set list listchars=tab:▸\ ,eol:¬ "set clipboard= guifont=Inconsolata\ NF:h14 """ Windows
Git (git config --edit --global):
# This is Git's per-user configuration file. [user] name = Frank Siler email = me@franksiler.com [alias] alias="! git config --get-regexp ^alias\\. | sed -e s/^alias\\.// -e s/\\ /\\ =\\ /" branches=branch -a c=commit ce=config --edit --global ci="!f() { git pull --rebase=false && git commit \"$@\"; }; f" cl=clone co=checkout forget=rm --cached l=log --oneline p=!sh -c 'git pull && git push' paths=remote -v root=rev-parse --show-toplevel s=status st=status -vv sw=switch unstash="stash apply" [push] autoSetupRemote = true [pull] rebase = true [fetch] prune = true [diff] colorMoved = zebra [credential "helperselector"] selected = manager
Screen (.screenrc)
I’m fairly sure I got this from John King circa 2004, and I think he based it on Mike Perry’s.
vbell off #vbell_msg "Ding Ding" #bell "%c bell -> %n%f %t^G" bind s select zsh #activity "%c activity -> %n%f %t" #verbose on #shell zsh # detach on hangup autodetach on startup_message off defscrollback 5000 defutf8 on backtick 1 600 600 hostname -s # terminfo and termcap for nice 256 color terminal # allow bold colors - necessary for some reason attrcolor b ".I" # tell screen how to set colors. AB = background, AF=foreground termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm' termcapinfo xterm-256color 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm' # erase background with current bg color defbce "on" #term screen-256color termcapinfo xterm* ti@:te@ # setup the caption hardstatus alwayslastline "%1` %{-b gk}%-w%{+b kg}%50>%n %t%{-b gk}%+w%< %=%Y%m%d %0c"
youtube-dl (~/.config/youtube-dl/config)
-f bestvideo[height<=?1080][height>?720][ext=mp4]+bestaudio/bestvideo[ext=mp4]+bestaudio/best[ext=mp4]/best -o "~/Movies/%(title)s %(id)s %(uploader)s.ytd.%(ext)s" --cookies ~/.config/youtube-dl/ytcookies.txt --default-search ytsearch --mark-watched --sub-lang en --write-auto-sub --write-sub --embed-subs --add-metadata --xattrs
Shell functions
dockertags () { wget -q https://registry.hub.docker.com/v1/repositories/$1/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}' } dockeru () { docker images | grep -v REPOSITORY | awk '{print $1}' | xargs -L1 docker pull docker image prune -f }
Powershell (notepad $PROFILE)
Set-PSReadlineKeyHandler -Key Tab -Function Complete Set-PSReadlineKeyHandler -Key ctrl+d -Function ViExit Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) $isAdmin = $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) function l { get-childitem -force } function uu { if($isAdmin) { choco upgrade all } else { sudo choco upgrade all } } New-Alias -force which get-command if ($isAdmin -and (Get-Command "choco" -ErrorAction SilentlyContinue) -eq $null) { $InstallDir="$env:userprofile\build\choco" mkdir -force -ErrorAction SilentlyContinue (split-path $InstallDir) $env:ChocolateyInstall="$InstallDir" [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) choco feature enable -n allowGlobalConfirmation choco feature enable -n useFipsCompliantChecksums choco feature enable -n useRememberedArgumentsForUpgrades choco upgrade all choco install sudo tree jq bind-toolsonly yq sqlite firefox googlechrome foxitreader git libreoffice choco install vim --params '/NoDesktopShortcuts /NoDefaultVimrc /RestartExplorer' python -m pip install azure-cli requests az config set extension.use_dynamic_install=yes_without_prompt } if ($isAdmin -and (Get-Command "less" -ErrorAction SilentlyContinue) -eq $null) { Find-Package pscx | Install-package -scope currentuser -allowclobber } function sleepDisplays() { (Add-Type -MemberDefinition "[DllImport(""user32.dll"")]`npublic static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);" -Name "Win32SendMessage" -Namespace Win32Functions -PassThru)::SendMessage(0xffff, 0x0112, 0xF170, 2) } function AddToPath($dirToAdd, $context="user", [switch]$addToBeginning=$false) { if(!$dirToAdd -Or -Not (Test-Path -Path $dirToAdd)) { "sorry, that path isn't good"; return } $regPath = if($context -eq "user") { 'Registry::HKEY_CURRENT_USER\Environment' } elseif ($context -eq "system") { 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' } else { throw 'need valid context: user or system'; return } $existingPath = (Get-ItemProperty -Path $regPath -Name PATH).path $newPath = if($addToBeginning) { "$dirToAdd;$existingPath" } else { "$existingPath;$dirToAdd" } Set-ItemProperty -Path $regPath -Name oldPATH -Value $existingPath Set-ItemProperty -Path $regPath -Name PATH -Value $newPath } #end global config
Tricks
Windows
- SleepDisplays.cmd: powershell (Add-Type '[DllImport(\"user32.dll\")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::SendMessage(-1,0x0112,0xF170,2)
Thanks to Eugene Loy for this one. - Log off: Windows + x, u, i
- Sleep machine: Windows + x, u, s
- Install less for Powershell: Find-Package pscx | Install-package -scope currentuser -allowclobber
- Activate Win2022 in Hyper-V
DISM /Online /Set-Edition:ServerDatacenter /acceptEula /ProductKey:WX4NM-KYWYW-QJJR4-XV3QB-6VM33
AVMA:
W3GNR-8DDXR-2TFRP-H8P33-DV9BG
- Activate Win2019 in Hyper-V (AVMA)
DISM /Online /Set-Edition:ServerDatacenter /acceptEula /ProductKey:H3RNG-8C32Q-Q8FRX-6TDXV-WMBMW
- Activate Win2016 in Hyper-V
DISM /Online /Set-Edition:ServerDatacenter /acceptEula /ProductKey:TMJ3Y-NTRTM-FJYXT-T22BY-CWG3J
Mac
- Sleep displays: Ctrl + Shift + Eject
- Sleep machine: Option + Cmd + Eject
Python
- upgrade pip:
pipu () { python3 -m pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 python3 -m pip install -U --user }
- IPython (vim ~/.ipython/profile_default/ipython_config.py; docs):
c = get_config() c.TerminalInteractiveShell.confirm_exit = False c.TerminalInteractiveShell.autoformatter = None
systemd
Dump stdout/stderr to files:
StandardOutput=append:/var/log/consul.log StandardError=append:/var/log/consul.err
Scripts
removeline – removes specified lines from a file. Courtesy ChatGPT.
#!/bin/bash # Assign the arguments to variables file=$1 shift lines=$@ # Create a backup file cp $file $file.bak # Loop over the lines to remove and delete them using sed for line in $lines do if [[ $line == *-* ]]; then start=$(echo $line | cut -d'-' -f1) end=$(echo $line | cut -d'-' -f2) sed -i "${start},${end}d" $file else sed -i "${line}d" $file fi done