-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMicrosoft.PowerShell_profile.ps1
More file actions
52 lines (46 loc) · 1.64 KB
/
Microsoft.PowerShell_profile.ps1
File metadata and controls
52 lines (46 loc) · 1.64 KB
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
# python virtual enviroment
# 1. activate an existing virtual environment
function vrun {
$venvBinDirectory = "$(Get-Location)\venv\bin"
# $venvBinDirectory = "$(Get-Location)\venv\Scrpits"
if (Test-Path -Path $venvBinDirectory){
.\venv\bin\activate
} else {
.\venv\Scripts\activate
}
}
# 2. create a new virtual environment
function mkv{
python -m venv venv
}
# command prompt configuration
function prompt {
# show only directory name in the prompt.
# if it is home directory show only symbol "~"
$currentDirectory = $(Get-Location)
if ($currentDirectory.Path -eq "C:\Users\$env:UserName"){
$directoryName = "~"
}
else{
$directoryName = Split-Path $currentDirectory -leaf
}
# if current directory is a git repository, display active branch name in the prompt
$isRepository = git rev-parse --is-inside-work-tree
if ($isRepository){
$branchName = git rev-parse --abbrev-ref HEAD
$anythinToCommit = git status --porcelain
if ($anythinToCommit){
$opts = @{ForegroundColor="red";}
} else {
$opts = @{ForegroundColor="darkgreen";}
}
$gitEmojiCode= [System.Convert]::toInt32("2387", 16)
$gitEmoji = [System.Char]::ConvertFromUtf32($gitEmojiCode)
write-host -NoNewLine @opts -object "$branchName"
write-host -NoNewLine -object "$gitEmoji" -ForegroundColor Blue
}
# write all the information
write-host "$directoryName" -NoNewline -ForegroundColor DarkYellow
write-host "$" -NoNewline -ForegroundColor Green
return " "
}