Skip to content

Commit 746ce51

Browse files
committed
dotfiles updates
1 parent 7c75dea commit 746ce51

2 files changed

Lines changed: 85 additions & 3 deletions

File tree

pages/configs/linux.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,12 @@ git config --global alias.last "log -1 HEAD"
4848
git config --global alias.unstage "reset HEAD --"
4949
git config --global alias.branch "branch -vv"
5050
git config --global alias.graph "log --graph --abrev-commit --decorate=short --all --format=oneline"
51+
git config --global alias.diffw "diff --word-diff"
52+
git config --global alias.pushf "push --force-with-lease"
53+
git config --global rerere.enabled true
54+
git config --global rerere.autoUpdate true
55+
git config --global branch.sort -committerdate
56+
git config --global column.ui auto
57+
git config --global gpg.format ssh
58+
git config --global user.signingKey "~/..."
5159
```

pages/configs/windows.md

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ title: Windows
3131
- Follow the [instructions here](https://github.com/seagull/disable-automaticrestarts/issues/4#issuecomment-521382489)
3232
- Alternatively, go into advanced power plan options and disable wake timers
3333

34-
### PowerShell Profile
34+
### PowerShell Profile and Utilities
3535

36-
```PowerShell
36+
```powershell
37+
Set-StrictMode -Version Latest
3738
if ($(Get-Location).Path -eq 'C:\WINDOWS\system32') {
3839
Set-Location $Env:USERPROFILE
3940
}
@@ -46,14 +47,46 @@ Set-PSReadLineKeyHandler -Chord Ctrl+Shift+RightArrow SelectForwardWord
4647
$PSDefaultParameterValues['*:Encoding'] = 'utf8'
4748
$Env:PYTHONIOENCODING = 'utf-8'
4849
49-
function b {
50+
# window title https://stackoverflow.com/q/29211928
51+
if (-not (Get-Variable _windowTitleDefault -ValueOnly -ErrorAction SilentlyContinue)) {
52+
$global:_windowTitleDefault = $host.ui.rawui.WindowTitle
53+
}
54+
function prompt {
55+
$host.ui.rawui.WindowTitle = "$_windowTitleDefault : $($executionContext.SessionState.Path.CurrentLocation | Split-Path -Leaf)"
56+
return "PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) ";
57+
}
58+
Set-PSReadLineKeyHandler -Key Enter `
59+
-BriefDescription RunWithTitle `
60+
-LongDescription "Set the console title to the command, then run the command" `
61+
-ScriptBlock {
62+
param($key, $arg)
63+
64+
$line = $null
65+
$cursor = $null
66+
[Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$line, [ref]$cursor)
67+
if ($line.Length -gt 1023) {
68+
$Host.UI.RawUI.WindowTitle = $line.Substring(0,1023)
69+
}
70+
else {
71+
$Host.UI.RawUI.WindowTitle = $line
72+
}
73+
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
74+
}
75+
76+
if ($PSEdition -eq 'Core'){
77+
$PSStyle.Progress.View = 'Classic'
78+
}
79+
80+
function Set-DisplayBrightness {
5081
param(
5182
[Parameter(Position=0,Mandatory=$true)]
5283
[int]
5384
$Brightness
5485
)
86+
# https://www.nirsoft.net/utils/control_my_monitor.html
5587
controlmymonitor /SetValue Primary 10 $Brightness
5688
}
89+
Set-Alias b Set-DisplayBrightness
5790
5891
function Set-SuspendState {
5992
param(
@@ -68,4 +101,45 @@ function Set-SuspendState {
68101
[System.Windows.Forms.Application]::SetSuspendState($PowerState, $true, $true)
69102
}
70103
104+
function touch {
105+
param(
106+
[Parameter(Mandatory,Position=1)][string]$Item,
107+
[DateTime]$t = (Get-Date),
108+
[ValidateSet('CreationTime','CreationTimeUtc','LastAccessTime','LastAccessTimeUtc','LastWriteTime','LastWriteTimeUtc')]
109+
[string]$Time = 'LastWriteTime'
110+
)
111+
if (-not (Test-Path -LiteralPath $Item)) {
112+
New-Item $Item >$null
113+
}
114+
Get-Item $Item | % {
115+
$_.$Time = $t
116+
}
117+
}
118+
119+
function unset-histfile {
120+
Set-PSReadLineOption -HistorySaveStyle SaveNothing
121+
}
122+
123+
function bell {
124+
echo "`a"
125+
}
126+
127+
function beep {
128+
param(
129+
[Parameter(Position=0)]
130+
[int]
131+
$Frequency = 1000,
132+
[Parameter(Position=1)]
133+
[int]
134+
$Milliseconds = 1000
135+
)
136+
[Console]::Beep($Frequency, $Milliseconds)
137+
}
138+
139+
function sha256sum {
140+
param([Parameter(Mandatory,Position=1)][string]$Path)
141+
(Get-FileHash -Path $Path).Hash.ToLower()
142+
}
143+
144+
Set-StrictMode -Off
71145
```

0 commit comments

Comments
 (0)