Last active
October 25, 2019 10:04
-
-
Save technic/0ae0ff830b1decf74a2d74e147b7b0b0 to your computer and use it in GitHub Desktop.
Powershell profile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ssh-agent | |
check-ssh-agent() { | |
test -S "$SSH_AUTH_SOCK" && { | |
ssh-add -l >& /dev/null | |
if [ $? -ne 2 ]; then | |
echo "ssh-agent is already running ($SSH_AUTH_SOCK)" | |
true | |
else | |
false | |
fi | |
} | |
} | |
# read stored agent data | |
if test -z "$SSH_AUTH_SOCK"; then | |
export SSH_AUTH_SOCK="$(< /tmp/.ssh/SSH_AUTH_SOCK.env)" | |
fi | |
# if env data is invalid start new instance | |
check-ssh-agent || { | |
eval "$(ssh-agent -s)" > /dev/null | |
# path compatible with posh-git | |
echo "$SSH_AUTH_SOCK" > /tmp/.ssh/SSH_AUTH_SOCK.env | |
echo "$SSH_AGENT_PID" > /tmp/.ssh/SSH_AGENT_PID.env | |
ssh-add | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# UTF-8 | |
chcp 65001 | |
$env:PYTHONIOENCODING="UTF-8" | |
Import-Module posh-docker | |
# Import-Module '$HOME\PycharmProjects\vcpkg\scripts\posh-vcpkg' | |
Import-Module posh-git | |
Start-SshAgent -Quiet | |
Set-PSReadlineKeyHandler -Key Ctrl+D -Function ViExit | |
Set-PSReadlineKeyHandler -Key Ctrl+L -ScriptBlock { | |
[Microsoft.PowerShell.PSConsoleReadLine]::BackwardKillLine(); | |
[Microsoft.PowerShell.PSConsoleReadLine]::ClearScreen(); | |
# Because prompt has two lines | |
[Microsoft.PowerShell.PSConsoleReadLine]::ScrollDisplayUpLine(); | |
} | |
# Bash like | |
# Set-PSReadlineKeyHandler -Key Tab -Function Complete | |
# Zsh like | |
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete | |
$GitPromptSettings.DefaultPromptSuffix = '`n$(''>'' * ($nestedPromptLevel + 1)) ' | |
$GitPromptSettings.DefaultPromptAbbreviateHomeDirectory = $true | |
$gitBase = (Get-Command git -CommandType Application |Get-Item).Directory.Parent.FullName | |
Set-Alias ssh (Join-Path $gitBase "/usr/bin/ssh") | |
Set-Alias scp (Join-Path $gitBase "/usr/bin/scp") | |
Remove-Variable gitBase | |
# (& "$HOME\Anaconda3\Scripts\conda.exe" "shell.powershell" "hook") | Out-String | Invoke-Expression | |
$Env:CONDA_EXE = "$HOME\Anaconda3\Scripts\conda.exe" | |
$Env:_CE_M = "" | |
$Env:_CE_CONDA = "" | |
$Env:_CONDA_ROOT = "$HOME\Anaconda3" | |
$Env:_CONDA_EXE = "$HOME\Anaconda3\Scripts\conda.exe" | |
Import-Module "$Env:_CONDA_ROOT\shell\condabin\Conda.psm1" | |
Add-CondaEnvironmentToPrompt | |
conda activate base | |
function Get-VirtualEnvName { | |
if ($env:VIRTUAL_ENV) { | |
# $virtualEnvName = ($env:VIRTUAL_ENV -split '\\')[-1] | |
# return "$virtualEnvName " | |
} elseif ($env:CONDA_DEFAULT_ENV) { | |
return "($env:CONDA_DEFAULT_ENV) " | |
} | |
} | |
$GitPromptSettings.DefaultPromptPrefix = '$(Get-VirtualEnvName)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment