Skip to content

Instantly share code, notes, and snippets.

@pcarrier
Last active April 2, 2021 19:30
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pcarrier/80d9b5f51f4965ba41cf62f8a965a325 to your computer and use it in GitHub Desktop.
Save pcarrier/80d9b5f51f4965ba41cf62f8a965a325 to your computer and use it in GitHub Desktop.
Windows setup
function safe { Set-Variable WhatIfPreference $true -Scope Global };
function unsafe { Set-Variable WhatIfPreference $false -Scope Global -WhatIf:$false };
function isAdmin {
$user = [Security.Principal.WindowsIdentity]::GetCurrent();
(New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator);
}
function shell { Start-Process powershell -WorkingDirectory $PWD -ArgumentList "-NoLogo" };
function admin { Start-Process powershell -ArgumentList "-NoLogo" -Verb RunAs };
if ($host.Name -eq 'ConsoleHost') {
Import-Module posh-git;
Start-SshAgent;
$GitPromptSettings.BeforeText=' '
$GitPromptSettings.AfterText=''
$GitPromptSettings.EnableWindowTitle=$false
Set-Alias cd Push-Location -Option AllScope
Set-Alias l Get-ChildItem
Remove-Item alias:ls
function ls { ls.exe -lF --color=auto $args };
function which($cmd) { (Get-Command $cmd)[0].Source }
Import-Module PSReadline;
Set-PSReadlineKeyHandler -Chord Ctrl+a BeginningOfLine;
Set-PSReadlineKeyHandler -Chord Ctrl+e EndOfLine;
Set-PSReadlineKeyHandler -Chord Ctrl+w BackwardKillWord;
Set-PSReadLineKeyHandler -Chord Ctrl+d DeleteCharOrExit;
if (isAdmin) { $promptChar = "#"; safe } else { $promptChar = "$" };
function global:prompt {
If (-Not ($?)) { Write-Host -NoNewLine -ForegroundColor Red ("" + $LastExitCode + " ") };
Write-Host -ForegroundColor Blue (Get-Date).ToString();
Write-Host -NoNewLine -ForegroundColor Yellow $($executionContext.SessionState.Path.CurrentLocation);
Write-VcsStatus
$promptColor = If ($WhatIfPreference) { "Green" } else { "Red" };
Write-Host -NoNewLine -ForegroundColor $promptColor " $($promptChar * ($nestedPromptLevel + 1))";
" "
}
}
#!/bin/zsh
[[ -n $PROFILED ]] && return
export HISTSIZE=1048576 SAVEHIST=1048576 HISTFILE="$HOME/.history"
autoload -U colors && colors
export NINJA_STATUS="${fg[blue]}rem:%u run:%r fin:%f time:%e${reset_color} "
# Don't forget `disable -r time` :]
export TIME=\
"${fg_no_bold[red]}time "\
"${fg_no_bold[blue]}elapsed${reset_color}=%E "\
"${fg_no_bold[blue]}user${reset_color}=%U "\
"${fg_no_bold[blue]}system${reset_color}=%S "\
"${fg_no_bold[blue]}cpu${reset_color}=%P "\
"${fg_no_bold[red]}rss "\
"${fg_no_bold[blue]}max${reset_color}=%M\n"\
"${fg_no_bold[red]}fs "\
"${fg_no_bold[blue]}in${reset_color}=%I "\
"${fg_no_bold[blue]}out${reset_color}=%O "\
"${fg_no_bold[red]}faults "\
"${fg_no_bold[blue]}major${reset_color}=%F "\
"${fg_no_bold[blue]}minor${reset_color}=%R "\
"${fg_no_bold[red]}ctx "\
"${fg_no_bold[blue]}asked${reset_color}=%w "\
"${fg_no_bold[blue]}forced${reset_color}=%c"
env=~/.ssh/agent.env
agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }
agent_start () {
(umask 077; ssh-agent -s >| "$env")
. "$env" >| /dev/null ; }
agent_load_env
agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?)
if [ -z "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then
agent_start
ssh-add
elif [ -n "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then
ssh-add
fi
unset env
[[ "$PWD" = '/c/Windows/system32' ]] && cd
export PROFILED=1
#!/bin/zsh
[ -n "$PROFILED" ] || . ~/.zprofile
disable -r time
zmodload -a autocomplete
autoload -U age && age
autoload -Uz compinit && compinit
setopt interactivecomments
setopt autocd autopushd pushdminus pushdsilent pushdtohome
setopt HIST_REDUCE_BLANKS HIST_IGNORE_SPACE SHARE_HISTORY HIST_FCNTL_LOCK inc_append_history
setopt no_clobber print_exit_value #no_hup
setopt extendedglob glob_dots
setopt correct
setopt no_complete_aliases
setopt prompt_subst
autoload -U colors && colors
bindkey -e
bindkey '^[[1;5C' emacs-forward-word
bindkey '^[[1;5D' emacs-backward-word
branch() {
b=$(git symbolic-ref --short HEAD 2>/dev/null)
[[ -n "$b" ]] && print -n "${b} "
}
PS1="%(0?..%{$fg_no_bold[red]%}%? )"\
"%(1j.%{$fg_no_bold[yellow]%}%jj .)"\
"%{$fg_no_bold[green]%}%~ "\
"%{$fg_no_bold[yellow]%}%20<…<\$(branch)%<<"\
"%{$fg_no_bold[blue]%}%#%{$reset_color%} "
title() {
local a=${(V)1//\%/\%\%}
a=$(print -Pn "%30>…>$a"|tr -d "\n")
case $TERM in
screen*)
print -Pn "\e]2;$a (%~)\a" # plain xterm title
print -Pn "\ek$a (%~)\e\\" # screen title (in ^A")
;;
xterm*|rxvt*|cygwin)
print -Pn "\e]0;$a (%~)\a"
;;
esac
}
function precmd() { title "zsh" }
function preexec() { title "$1" }
lf() { awk -F '{print $NF;}'; }
mkcd() { mkdir -p "$1"; cd "$1"; }
sp() { curl -F 'sprunge=<-' http://sprunge.us; }
gr() { git rebase "$@"; }
grc() { git rebase --continue; }
gri() { git rebase --interactive "$@"; }
gra() { git rebase --abort; }
grf() { git show $(<.git/rebase-merge/stopped-sha); }
dl() { aria2c --force-sequential --continue -j16 -x16 --stream-piece-selector=inorder --min-split-size=1M "$@"; }
ls() { command ls -lF --color=auto "$@"; }
ag() { command ag --search-files "$@"; }
p() { cygpath -aw "$@"; }
dig() { drill @8.8.8.8 "$@"; }
find() { /usr/bin/find "$@"; }
m() { winpty meteor.bat "$@"; }
ping() { PING.EXE "$@"; }
g() {
suffix="$1"; shift
"galaxy${suffix}" "$@";
}
gcd() {
local p="/c/projects/${1:t:r}"
[[ ! -e "$p" ]] && git clone "$1" "$p"
cd "$p"
}
ghcd() { gcd "git@github.com:$1"; }
pcd() { ghcd "pcarrier/$1"; }
mcd() { ghcd "meteor/$1"; }
acd() { ghcd "apollostack/$1"; }
#gcloud() { python2 /c/opt/google-cloud-sdk/lib/gcloud.py "$@"; }
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\DOS Devices]
"D:"="\\??\\C:\\Users\\pcarrier\\Downloads"
"H:"="\\??\\C:\\Users\\pcarrier"
"U:"="\\??\\C:\\tools\\msys64"
"P:"="\\??\\C:\\Projects"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\D\DefaultLabel]
@="Downloads"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\H\DefaultLabel]
@="Home"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\U\DefaultLabel]
@="msys2"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\DriveIcons\P\DefaultLabel]
@="Projects"
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]
"_NT_SYMBOL_PATH"="srv*c:\\symbols*https://msdl.microsoft.com/download/symbols"
"DEPLOY_HOSTNAME"="galaxy.meteor.com"
"GOPATH"="P:\\Go"
"GOROOT"="C:\\Go"
"LANG"="en_US.UTF-8"
"LC_COLLATE"="C"
"MSYS"="winsymlinks:nativestrict"
"MSYS2_PATH_TYPE"="inherit"
"PYTHONIOENCODING"="utf-8"
"VISUAL"="subl -w"
$ cat ~\.IntelliJIdea2016.1\idea.properties
editor.zero.latency.typing=true
$ cat ~\.IntelliJIdea2016.1\idea.exe.vmoptions
-server
-Xms1g
-Xmx1g
-XX:MaxPermSize=250m
-XX:ReservedCodeCacheSize=240m
-XX:+UseG1GC
-XX:SoftRefLRUPolicyMSPerMB=50
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-XX:-OmitStackTraceInFastThrow
-XX:+UseStringDeduplication
-XX:MaxGCPauseMillis=10
-XX:+CMSIncrementalPacing
{
"auto_find_in_selection": true,
"default_line_ending": "unix",
"draw_white_space": "all",
"font_face": "PragmataPro",
"font_options": ["directwrite"],
"font_size": 12,
"ignored_packages":
["Go", "Vintage"],
"rulers": [80, 100],
"shift_tab_unindent": true
}
{
"editor.fontFamily": "PragmataPro",
"editor.fontLigatures": true,
"editor.renderWhitespace": true,
"editor.glyphMargin": true,
"editor.rulers": [80, 100],
"editor.wrappingIndent": "indent",
"editor.formatOnType": true,
"files.autoSave": "onFocusChange",
"go.buildOnSave": true,
"go.lintOnSave": true,
"go.vetOnSave": true,
"go.formatOnSave": true,
"go.formatTool": "goreturns"
}
syn on
set noswapfile
$ Get-InstalledModule|%{$_.Name}
posh-git
$ choco list -lo|?{$_ -notlike "* packages installed."}|%{$_.Split(' ')[0]}
7zip
7zip.install
aria2
chocolatey
ConEmu
dependencywalker
msys2
nodejs
nodejs.install
sharex
sqlitebrowser
windirstat
$ pacman -Qqt
bsdcpio
bsdtar
crypt
file
filesystem
gawk
grep
man-db
mingw-w64-x86_64-ag
mingw-w64-x86_64-gcc-ada
mingw-w64-x86_64-gcc-fortran
mingw-w64-x86_64-gcc-objc
mingw-w64-x86_64-gdb
mingw-w64-x86_64-jq
mingw-w64-x86_64-ldns
mingw-w64-x86_64-libmangle-git
mingw-w64-x86_64-libsigc++
mingw-w64-x86_64-make
mingw-w64-x86_64-mpv
mingw-w64-x86_64-oniguruma
mingw-w64-x86_64-pkg-config
mingw-w64-x86_64-python2-pip
mingw-w64-x86_64-ruby
mingw-w64-x86_64-sqlite3
mingw-w64-x86_64-tools-git
mintty
mosh
pkgfile
rsync
tig
time
tmux-git
unzip
util-linux
zsh
C:\ProgramData\Oracle\Java\javapath;C:\Users\pcarrier\bin;C:\Users\pcarrier\.gem\ruby\2.3.0\bin;C:\Users\pcarrier\.npm;C:\projects\mdgscripts\bin;%GOPATH%\bin;%GOROOT%\bin;C:\opt\meteor;C:\opt\subl;C:\opt\vscode\bin;C:\opt\msys64\usr\local\bin;C:\opt\msys64\usr\bin;C:\opt\msys64\mingw64\bin;C:\opt\msys64\mingw32\bin;C:\opt\sysinternals;C:\Program Files\Git\cmd;C:\Program Files\Docker\Docker\Resources\bin;%AllUsersProfile%\Oracle\Java\javapath;%ProgramFiles(x86)%\Windows Kits\10\Windows Performance Toolkit;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files (x86)\Skype\Phone\
AquaSnap
Charles
Discord
Ditto
Docker
f.lux
Keypirinha
Go Programming Language
Google Chrome
InputMapper
IntelliJ IDEA
LogMeIn Hamachi
Meteor
Microsoft Visual Studio Code
Microsoft Visual Studio Community 2015
MongoChef
paint.net
Potplayer
Quassel
Screenhero
SharpKeys
Slack
snes9x
Sublime Text 3
- Dockerfile Syntax HL
- GoGuru
- GoRename
- GoSublime
- PowerShell
- SublimeGit
- Terraform
Xming
Xpadder
SetWorkingDir %UserProfile%
#^k:: FileRecycleEmpty
#^t:: Run mintty.exe
db_enum: cache builtin
db_home: windows
db_shell: /usr/bin/zsh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment