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):

[user]
  name = Frank Siler
  email = me@franksiler.com

[alias]
  alias = ! git config --get-regexp ^alias\\. | sed -e s/^alias\\.// -e s/\\ /\\ =\\ /
  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"
  wt=worktree
  wa="worktree add"
  wl="worktree list"

[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

Bash

export PROMPT_COMMAND='history -a'
shopt -s histappend
export HISTSIZE=1000000
unset rc
alias cdr='cd $(git root)'
alias l="ls -lA --color"
alias sd="screen -D -R"
alias gw=gradlew
alias wt="git wt"
alias wl="git wl"
alias wa="git wa"
unalias gm 2>/dev/null

alias h="helm"
alias hls="helm ls -Aa"
alias k="kubectl"
alias ka="kubectl get all"
alias kd="kubectl describe"
alias kdf="kubectl df-pv"
alias kdp="kubectl describe pod"
alias kdrain="k drain --delete-emptydir-data --ignore-daemonsets"
alias kgc="kubectl config get-contexts"
alias kn="kubectl get nodes"
alias kno="kubectl get nodes -o wide"
alias kp="k get pods"
alias kp="kubectl get pods"
alias kpw="kubectl get pods --watch"
alias krmp="kubectl delete pod --force"
alias ks="kubectl get services"
alias ku="kubectl config use-context"
alias kw="kubectl get pods -o wide"
alias ns="kubectl config set-context --current --namespace"

Shell functions (needs cleanup)

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
}
newk8sconfig () {
	KUBECONFIG=~/.kube/config:~/Downloads/kube.conf kubectl config view --flatten > ~/.kube/config.new
	grm ~/Downloads/kube.conf
	mv ~/.kube/config ~/.kube/config.backup
	mv ~/.kube/config.new ~/.kube/config
	chmod 600 ~/.kube/config
}
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
}

### MANAGED BY RANCHER DESKTOP START (DO NOT EDIT)
export PATH="/Users/DT235813/.rd/bin:$PATH"
### MANAGED BY RANCHER DESKTOP END (DO NOT EDIT)
export PATH=$HOME/bin:$PATH
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"

unalias grm
alias l="ls -Alh"
alias cdr='cd $(git root)'

export PATH=$HOME/build/venv/bin:/opt/homebrew/opt/openjdk/bin:$PATH
function rdp() { ssh jump.ssnc-corp.cloud -L 3389:$1:3389 }
function rdp2() { ssh jump.ssnc-corp.cloud -L 3390:$1:3389 }
function rdp3() { ssh jump.ssnc-corp.cloud -L 3391:$1:3389 }
alias tfip='tf output --json|jq -r ".result.value[]|{name, ip}"'
alias rm=grm
function newk8sconfig() {
  KUBECONFIG=~/.kube/config:~/Downloads/kube.conf kubectl config view --flatten > ~/.kube/config.new

  rm ~/Downloads/kube.conf
  mv ~/.kube/config ~/.kube/config.backup
  mv ~/.kube/config.new ~/.kube/config
  chmod 600 ~/.kube/config
}

#alias tf=tofu
#alias tdd="tofu destroy -auto-approve"
#alias tdd="until tofu destroy -auto-approve; do sleep $SLEEPDELAY; done"
#alias tda="until tofu destroy -auto-approve; do sleep $SLEEPDELAY; done; tf init -upgrade; until tofu apply -auto-approve; do sleep $SLEEPDELAY; done"
#alias ti="tf init -upgrade"
#alias ta="tofu apply -auto-approve"
#alias taa="until tofu apply -auto-approve; do sleep $SLEEPDELAY; done"
#alias to="tofu output"
alias tf=terraform
alias tdd="terraform destroy -auto-approve"
alias tdd="until terraform destroy -auto-approve; do sleep $SLEEPDELAY; done"
alias tda="until terraform destroy -auto-approve; do sleep $SLEEPDELAY; done; tf init -upgrade; until terraform apply -auto-approve; do sleep $SLEEPDELAY; done"
alias ti="tf init -upgrade"
alias ta="terraform apply -auto-approve"
alias taa="until terraform apply -auto-approve; do sleep $SLEEPDELAY; done"
alias to="terraform output"
alias p="git push"


alias uu="brew upgrade"
alias flushdns="dscacheutil -flushcache; sudo killall -HUP mDNSResponder"
prompt_dir() {
  prompt_segment blue $CURRENT_FG '%2~'
}
#PROMPT=' %{$fg[cyan]%}%2%{$reset_color%} $(git_prompt_info)'
export REPORTTIME=20


# Load Angular CLI autocompletion.
#source <(ng completion script)
unalias gm
export MC_INSECURE=true
jr(){ssh -J jump.ssnc-corp.cloud 10-222-102-57.ssnc-corp.cloud}
function pf() { ssh jump.ssnc-corp.cloud -L $2:$1:$2 }

# Added by LM Studio CLI (lms)
export PATH="$PATH:/Users/DT235813/.lmstudio/bin"
# End of LM Studio CLI section

Powershell (copy-paste into admin terminal)

Set-ExecutionPolicy Bypass

if (!(Test-Path -Path $PROFILE)) {
    New-Item -ItemType File -Path $PROFILE -Force | Out-Null
}

@'
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 optipng 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
}
remove-item alias:wget

#end global config
'@ | Set-Content -Path $PROFILE -Encoding UTF8

Write-Host "✅ PowerShell profile installed at $PROFILE"
Write-Host "Restart PowerShell to apply your new profile."

Tricks

Windows

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)
  • Log off: Windows + x, u, i
  • Sleep machine: Windows + x, u, s
  • Install less for Powershell: Find-Package pscx | Install-package -scope currentuser -allowclobber
  • Get current edition:
    DISM /Online /Get-CurrentEdition
  • Get available editions:
    DISM /Online /Get-TargetEditions
  • Change Win2025 from eval to datacenter license:
    DISM /Online /set-edition:serverdatacenter /productkey:D764K-2NDRG-47T6Q-P8T8W-YP6DF /accepteula
  • 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