-
Notifications
You must be signed in to change notification settings - Fork 9
/
Profile.ps1
106 lines (88 loc) · 2.96 KB
/
Profile.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# ---------------------------------------------------------------------------
# Settings
# ---------------------------------------------------------------------------
$MaximumHistoryCount = 512
$FormatEnumerationLimit = 100
# ---------------------------------------------------------------------------
# Modules
# ---------------------------------------------------------------------------
# PSReadline provides Bash like keyboard cursor handling
if ($host.Name -eq 'ConsoleHost')
{
Import-Module PSReadline
Set-PSReadLineOption -MaximumHistoryCount 4000
Set-PSReadlineOption -ShowToolTips:$true
# With these bindings, up arrow/down arrow will work like
# PowerShell/cmd if the current command line is blank. If you've
# entered some text though, it will search the history for commands
# that start with the currently entered text.
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
Set-PSReadlineKeyHandler -Key "Tab" -Function "MenuComplete"
Set-PSReadlineKeyHandler -Chord 'Shift+Tab' -Function "Complete"
}
# fzf is a fuzzy file finder, and will provide fuzzy location searching
# when using Ctrl+T, and will provide better reverse command searching via
# Ctrl-R.
Import-Module PSFzf -ArgumentList 'Ctrl+T','Ctrl+R'
Import-Module oh-my-posh
Set-PoshPrompt -Theme "$(Split-Path -Path $MyInvocation.MyCommand.Definition -Parent)\.MyPoshTheme.omp.json"
# Colorize directory output
if ($host.Name -eq 'ConsoleHost')
{
Import-Module Terminal-Icons
}
# Utils
Import-Module StreamUtils
Import-Module StringUtils
Import-Module Profile
# ---------------------------------------------------------------------------
# Custom Aliases
# ---------------------------------------------------------------------------
set-alias unset remove-variable
set-alias mo measure-object
set-alias eval invoke-expression
set-alias n vim.exe
set-alias vi vim.exe
# ---------------------------------------------------------------------------
# Helper functions
# ---------------------------------------------------------------------------
# starts a new execution scope
function Start-NewScope
{
param($Prompt = $null) Write-Host "Starting New Scope"
if ($Prompt -ne $null)
{
if ($Prompt -is [ScriptBlock])
{
$null = New-Item function:Prompt -Value $Prompt -force
}
else
{
function Prompt {"$Prompt"}
}
}
$host.EnterNestedPrompt()
}
# 'cause shutdown commands are too long and hard to type...
function Restart
{
shutdown /r /t 1
}
# --------------------------------------------------------------------------
# EXO Helpers
# --------------------------------------------------------------------------
function dev($project)
{
cd "$(get-content Env:INETROOT)\sources\dev\$project"
}
function test($project)
{
cd "$(get-content Env:INETROOT)\sources\test\$project"
}
function bcc
{
build -Cc
}
# Workaround oh-my-posh rendering bug when Powershell is launched with -NoLogo
cls