Setup

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/\\ /\\ =\\ /
  ce=config --edit --global
  ci="!f() { git pull --rebase=false && git commit \"$@\"; }; f"
  cl=clone
  co=checkout
  p=!sh -c 'git pull && git push'
  root=rev-parse --show-toplevel
  s=status
  st=status -vv
  unstash="stash apply"

[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

PowerShell (vim $profile):

Set-PSReadlineKeyHandler -Key Tab -Function Complete
Set-PSReadlineKeyHandler -Key ctrl+d -Function ViExit

New-Alias -force l dir
New-Alias -force which get-command

if ((Get-Command "choco" -ErrorAction SilentlyContinue) -eq $null) {
  $InstallDir='$env:userprofile\build\choco'
  mkdir $InstallDir
  $env:ChocolateyInstall="$InstallDir"
  iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
  choco feature enable -n allowGlobalConfirmation
}

if ((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

Mac

  • Sleep displays: Ctrl + Shift + Eject
  • Sleep machine: Option + Cmd + Eject