Skip to content

Instantly share code, notes, and snippets.

@gitfool
Last active September 4, 2026 05:41
Show Gist options
  • Select an option

  • Save gitfool/3aa0467597e9f49e11a7549e9ac4c4b8 to your computer and use it in GitHub Desktop.

Select an option

Save gitfool/3aa0467597e9f49e11a7549e9ac4c4b8 to your computer and use it in GitHub Desktop.
dotfiles
export HISTCONTROL=ignoreboth
export HISTSIZE=100000
export HISTFILESIZE=200000
export AWS_PAGER=
export EDITOR=vi
export PATH=$HOME/.dotnet/tools:$PATH
shopt -s histappend
alias h='history'
alias l='ls -aF'
alias ll='ls -ahlF'
alias ls='ls --color=auto --group-directories-first'
eval "$(starship init bash)"
# Disable double-escape completion quirk
"\e\e": ""
"\e[A": history-substring-search-backward
"\e[B": history-substring-search-forward
# shell-style everywhere so "word" always means whitespace-delimited
# Forward lands at word-end (readline has no next-word-start function)
"\e[1;5D": shell-backward-word
"\e[1;5C": shell-forward-word
"\eb": shell-backward-word
"\ef": shell-forward-word
"\ed": shell-kill-word
export ZSH="/home/sean/.oh-my-zsh"
ZSH_THEME=""
COMPLETION_WAITING_DOTS="true"
plugins=(
aws
# brew
# docker
# git
# helm
history-substring-search
k9s
kubectl
zsh-autosuggestions
zsh-syntax-highlighting
)
source $ZSH/oh-my-zsh.sh
HISTSIZE=100000
SAVEHIST=100000
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_SPACE
setopt HIST_REDUCE_BLANKS
setopt HIST_VERIFY
setopt SH_WORD_SPLIT
autoload -Uz compinit && compinit -C
autoload -Uz bashcompinit && bashcompinit
autoload -Uz select-word-style && select-word-style whitespace
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
export AWS_PAGER=
export GPG_TTY=$TTY
export HOMEBREW_NO_ASK=1
export PATH="$HOME/.local/bin:$(brew --prefix node)/bin:$(brew --prefix python@3.14)/libexec/bin:$PATH"
export HELM_DIFF_USE_UPGRADE_DRY_RUN=true
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
export PNPM_HOME="$HOME/.local/share/pnpm"
export PATH="$PNPM_HOME/bin:$PATH"
alias as='aws-sso'
alias asc='aws-sso console'
alias asi='printenv | sort | grep AWS_ | grep -v AWS_PAGER && aws sts get-caller-identity'
alias asl='aws-sso list'
alias asla='aws-sso list --prefix=RoleName=admin'
alias asp='aws-sso-profile'
alias aspc='aws-sso-clear'
alias chrome='_chrome_url() { "/c/Program Files/Google/Chrome/Application/chrome.exe" "http://${2:-localhost}:${1:-80}"; }; _chrome_url'
alias code='"/c/Users/sean/AppData/Local/Programs/Microsoft VS Code/bin/code"'
alias l='ls -aF'
alias ll='ls -ahlF'
alias ls='ls --color=auto --group-directories-first'
alias op='/c/Users/sean/scoop/shims/op.exe'
# BEGIN_AWS_SSO_CLI
__aws_sso_profile_complete() {
local _args=${AWS_SSO_HELPER_ARGS:- -L error}
_multi_parts : "($(/home/linuxbrew/.linuxbrew/bin/aws-sso ${=_args} list --csv Profile))"
}
aws-sso-profile() {
local _args=${AWS_SSO_HELPER_ARGS:- -L error}
local _sso=""
local _profile=""
if [ -n "$AWS_PROFILE" ]; then
echo "Unable to assume a role while AWS_PROFILE is set"
return 1
fi
# Parse arguments
while [ $# -gt 0 ]; do
case "$1" in
-S|--sso)
shift
if [ -z "$1" ]; then
echo "Error: -S/--sso requires an argument"
return 1
fi
_sso="$1"
shift
;;
-*)
echo "Unknown option: $1"
echo "Usage: aws-sso-profile [-S|--sso <sso-instance>] <profile>"
return 1
;;
*)
if [ -z "$_profile" ]; then
_profile="$1"
else
echo "Error: Multiple profiles specified"
return 1
fi
shift
;;
esac
done
if [ -z "$_profile" ]; then
echo "Usage: aws-sso-profile [-S|--sso <sso-instance>] <profile>"
return 1
fi
# Build and execute the eval command with optional SSO flag
if [ -n "$_sso" ]; then
eval $(/home/linuxbrew/.linuxbrew/bin/aws-sso ${=_args} -S "$_sso" eval -p "$_profile")
else
eval $(/home/linuxbrew/.linuxbrew/bin/aws-sso ${=_args} eval -p "$_profile")
fi
if [ "$AWS_SSO_PROFILE" != "$_profile" ]; then
return 1
fi
}
aws-sso-clear() {
local _args=${AWS_SSO_HELPER_ARGS:- -L error}
if [ -z "$AWS_SSO_PROFILE" ]; then
echo "AWS_SSO_PROFILE is not set"
return 1
fi
eval $(/home/linuxbrew/.linuxbrew/bin/aws-sso ${=_args} eval -c)
}
compdef __aws_sso_profile_complete aws-sso-profile
complete -C /home/linuxbrew/.linuxbrew/bin/aws-sso aws-sso
# END_AWS_SSO_CLI
eval "$(starship init zsh)"
function Aws-Sso-Console
{
aws-sso console
}
function Aws-Sso-Identity
{
Get-ChildItem env: | Sort-Object Name | Where-Object Name -match '^AWS_' | Where-Object Name -ne 'AWS_PAGER'
aws sts get-caller-identity
}
function Aws-Sso-List
{
aws-sso list
}
function Aws-Sso-List-Admin
{
aws-sso list --prefix=RoleName=admin
}
function Aws-Sso-Profile($name)
{
aws-sso eval -p $name | Invoke-Expression
}
function Aws-Sso-Profile-Clear
{
aws-sso eval -c | Invoke-Expression
}
function Cake-Build
{
dotnet tool restore && dotnet cake --verbosity=verbose --publish=true $args
}
function Git-CommitDateVersion
{
$branch = git rev-parse --abbrev-ref HEAD
if ($branch -eq "HEAD")
{
$branch = git name-rev --name-only --refs=refs/heads/* --no-undefined --always HEAD
}
$branchSlug = [System.Text.RegularExpressions.Regex]::Replace($branch.ToLowerInvariant(), "[^0-9a-z-]", "-").Trim('-')
$defaultBranch = $($args[1] ?? "main")
$isDefaultBranch = $branch -eq $defaultBranch
$isReleaseBranch = $isDefaultBranch -or [System.Text.RegularExpressions.Regex]::IsMatch($branch, "^support/")
$commit = git rev-parse $($args[0] ?? "HEAD")
$baseCommit = !$isDefaultBranch ? (git merge-base $defaultBranch $commit) : $commit
$commits = !$isDefaultBranch ? (git rev-list --count --first-parent "$baseCommit..$commit") : 0
$commitDate = git -c log.showSignature=false show --format="%cI" -s $baseCommit
$versionDate = [System.DateTimeOffset]::Parse($commitDate, $null, [System.Globalization.DateTimeStyles]::AdjustToUniversal)
$version = $versionDate.ToString("yyMM.dHH.mss")
$version = [System.Text.RegularExpressions.Regex]::Replace($version, "(?<=\.)0+(?=\d)", "")
$versionMatch = [System.Text.RegularExpressions.Regex]::Match($version, "^(?<Major>\d+)\.(?<Minor>\d+)\.(?<Patch>\d+)$")
$versionMajor = [int]$versionMatch.Groups["Major"].Value
$versionMinor = [int]$versionMatch.Groups["Minor"].Value
$versionPatch = [int]$versionMatch.Groups["Patch"].Value + ($isReleaseBranch ? $commits : 1)
$version = $isReleaseBranch ? "$versionMajor.$versionMinor.$versionPatch+branch.$branchSlug.sha.$commit" : "$versionMajor.$versionMinor.$versionPatch-branch.$branchSlug.$commits+sha.$commit"
$version
}
function KubeCtl-Config-GetContexts
{
kubectl config get-contexts
}
function KubeCtl-Config-UseContext
{
kubectl config use-context $args
}
function Which-Command($command)
{
$commandInfo = $command -is [System.Management.Automation.CommandInfo] ? $command : (Get-Command -Name $command -ErrorAction SilentlyContinue)
if (!$commandInfo)
{
Write-Output "$command not found"
return
}
switch ($commandInfo.CommandType)
{
"Alias"
{
$commandInfo | Format-List CommandType,DisplayName
Write-Output "=>"
Which-Command $commandInfo.ReferencedCommand
}
"Application"
{
$commandInfo | Format-List CommandType,Name,Path,Version,FileVersionInfo
}
"Cmdlet"
{
$path = @{ Name = "Path"; Expression = { $commandInfo.DLL } }
$fileVersionInfo = @{ Name = "FileVersionInfo"; Expression = { [System.Diagnostics.FileVersionInfo]::GetVersionInfo($commandInfo.DLL) } }
$commandInfo | Select-Object *,$path,$fileVersionInfo | Format-List CommandType,Name,Definition,HelpUri,Module,ImplementingType,Path,Version,FileVersionInfo
}
"Function"
{
$path = @{ Name = "Path"; Expression = { $commandInfo.ScriptBlock.File } }
$commandInfo | Select-Object *,$path | Format-List CommandType,Name,Definition,Path
}
default
{
$commandInfo | Format-List *
}
}
}
New-Alias as aws-sso
New-Alias asc Aws-Sso-Console
New-Alias asi Aws-Sso-Identity
New-Alias asl Aws-Sso-List
New-Alias asla Aws-Sso-List-Admin
New-Alias asp Aws-Sso-Profile
New-Alias aspc Aws-Sso-Profile-Clear
New-Alias cake Cake-Build
New-Alias diff 'C:\Users\Sean\scoop\apps\git\current\usr\bin\diff.exe' -Force
New-Alias gcdv Git-CommitDateVersion
New-Alias gitbash 'C:\Users\sean\scoop\apps\git\current\bin\bash.exe'
New-Alias grep 'C:\Users\sean\scoop\apps\git\current\usr\bin\grep.exe'
New-Alias kcgc KubeCtl-Config-GetContexts
New-Alias kcuc KubeCtl-Config-UseContext
New-Alias less 'C:\Users\sean\scoop\apps\git\current\usr\bin\less.exe'
New-Alias l ls
New-Alias ll ls
New-Alias msbuild 'C:\Program Files\Microsoft Visual Studio\18\Professional\MSBuild\Current\Bin\MSBuild.exe'
New-Alias which Which-Command
Set-PSReadLineOption -EditMode Emacs
Set-PSReadLineOption -AddToHistoryHandler { param($line) return ($line -notmatch '^\s') }
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
Set-PSReadLineOption -MaximumHistoryCount 100000
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineKeyHandler -Key Ctrl+d -Function DeleteCharOrExit
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
# Use Shell*Word everywhere so "word" always means whitespace-delimited
Set-PSReadLineKeyHandler -Key Ctrl+LeftArrow -Function ShellBackwardWord
Set-PSReadLineKeyHandler -Key Ctrl+RightArrow -Function ShellNextWord
Set-PSReadLineKeyHandler -Key Ctrl+Shift+LeftArrow -Function SelectShellBackwardWord
Set-PSReadLineKeyHandler -Key Ctrl+Shift+RightArrow -Function SelectShellNextWord
Set-PSReadLineKeyHandler -Key Alt+b -Function ShellBackwardWord
Set-PSReadLineKeyHandler -Key Alt+f -Function ShellNextWord
Set-PSReadLineKeyHandler -Key Alt+B -Function SelectShellBackwardWord
Set-PSReadLineKeyHandler -Key Alt+F -Function SelectShellNextWord
Set-PSReadLineKeyHandler -Key Ctrl+w -Function ShellBackwardKillWord
Set-PSReadLineKeyHandler -Key Alt+d -Function ShellKillWord
Invoke-Expression (&starship init powershell)
# https://starship.rs/config
"$schema" = "https://starship.rs/config-schema.json"
add_newline = false
command_timeout = 1000
format = """$cmd_duration
$username\
$hostname\
$localip\
$shlvl\
$singularity\
$kubernetes\
$directory\
$vcsh\
$fossil_branch\
$fossil_metrics\
$git_branch\
$git_commit\
$git_state\
$git_metrics\
$git_status\
$hg_branch\
$pijul_channel\
$docker_context\
$package\
$c\
$cmake\
$cobol\
$daml\
$dart\
$deno\
$dotnet\
$elixir\
$elm\
$erlang\
$fennel\
$gleam\
$golang\
$guix_shell\
$haskell\
$haxe\
$helm\
$java\
$julia\
$kotlin\
$gradle\
$lua\
$nim\
$nodejs\
$ocaml\
$opa\
$perl\
$php\
$pulumi\
$purescript\
$python\
$quarto\
$raku\
$rlang\
$red\
$ruby\
$rust\
$scala\
$solidity\
$swift\
$terraform\
$typst\
$vlang\
$vagrant\
$zig\
$buf\
$nix_shell\
$conda\
$meson\
$spack\
$memory_usage\
$aws\
$gcloud\
$openstack\
$azure\
$nats\
$direnv\
$env_var\
$crystal\
$custom\
$sudo\
$line_break\
$jobs\
$battery\
$time\
$status\
$os\
$container\
$shell\
$character"""
[aws]
disabled = true
symbol = " "
[cmd_duration]
format = "took [$duration]($style)\n"
[directory]
style = "bold blue"
read_only = ""
read_only_style = "dimmed red"
truncation_length = 8
truncation_symbol = "… "
truncate_to_repo = false
before_repo_root_style = "dimmed bold blue"
repo_root_style = "bold blue"
[dotnet]
format = "via [$symbol($version )( $tfm )]($style)"
style = "blue"
symbol = " "
heuristic = true
[git_branch]
symbol = " "
[git_status]
style = "bold purple"
ahead = "⇡${count}"
behind = "⇣${count}"
diverged = "⇡${ahead_count}⇣${behind_count}"
windows_starship = "/c/users/user/scoop/apps/starship/current/starship.exe"
[helm]
symbol = "⎈ "
[java]
style = "dimmed purple"
[kubernetes]
symbol = "⎈ "
[line_break]
disabled = false
[nodejs]
style = "dimmed green"
[package]
style = "dimmed white"
[rust]
style = "dimmed red"
[shell]
disabled = false
format = "[$indicator]($style)"
style = "bold green"
bash_indicator = "bash"
cmd_indicator = "cmd"
powershell_indicator = "ps"
pwsh_indicator = "pwsh"
zsh_indicator = "zsh"
[shlvl]
disabled = false
format = "[$symbol]($style) "
repeat = true
repeat_offset = 1
symbol = "❯"
@gitfool

gitfool commented Apr 25, 2020

Copy link
Copy Markdown
Author

Windows Prerequisites

Download patched Fira Code v3.5.1, extract and install all the TrueType fonts, matching name FiraCodeNerdFont-*.ttf, for all users. Currently Bold, Light, Medium, Regular, Retina and SemiBold variants.

  • Configure Windows Terminal to use this font:
{ "profiles": { "defaults": { "font": { "face": "FiraCode Nerd Font" } } } }
  • Install Chocolatey (FAQ) package manager using an elevated PowerShell:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
  • Install Starship (FAQ) cross-shell prompt using Chocolately:
choco install starship

@gitfool

gitfool commented Apr 20, 2024

Copy link
Copy Markdown
Author

Using Scoop instead of Chocolatey (comparison)

  • Install Scoop (FAQ) using a non-elevated PowerShell:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression
scoop install aria2
# scoop config aria2-enabled false
# scoop config aria2-warning-enabled false
scoop install gsudo
gsudo config PathPrecedence true
sudo status
  • Install FiraCode Nerd Font
scoop bucket add nerd-fonts
scoop install nerd-fonts/FiraCode-NF
scoop install starship
scoop install clink
clink autorun install
clink set clink.autoupdate off
clink set clink.default_bindings bash
clink set clink.logo short
clink set cmd.ctrld_exits true
clink set history.dupe_mode ignore
clink set history.max_lines 100000
# init starship; https://chrisant996.github.io/clink/clink.html#starship
  • Update scoop and apps
scoop status
scoop update && scoop update --all && scoop cleanup --all --cache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment