Skip to content

Instantly share code, notes, and snippets.

@jaderebrasil
Last active August 22, 2022 17:02
Show Gist options
  • Save jaderebrasil/38f089bd27a356886165d2eed3c83b18 to your computer and use it in GitHub Desktop.
Save jaderebrasil/38f089bd27a356886165d2eed3c83b18 to your computer and use it in GitHub Desktop.
Powershell . $PROFILE
$THEME="atomic-custom"
# Autocomplete
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadLineOption -HistoryNoDuplicates
Set-PSReadLineKeyHandler -Key Tab -Function Complete
# Vi mode
Set-PSReadLineOption -EditMode Vi
$env:SHELL_VI_MODE = "I"
Set-PSReadlineOption -ViModeIndicator Script -ViModeChangeHandler {
param($mode)
if ($mode -eq "Command") {
$env:SHELL_VI_MODE = "N"
} else {
$env:SHELL_VI_MODE = "I"
}
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()
}
# Set-PSReadLineKeyHandler -Key 'alt+k' -Function HistorySearchBackward
# Set-PSReadLineKeyHandler -Key 'alt+j' -Function HistorySearchForward
Set-PSReadLineKeyHandler -Key 'ctrl+p' -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key 'ctrl+n' -Function HistorySearchForward
# useful bindings
Set-PSReadLineKeyHandler 'ctrl+o' -ScriptBlock {
[Microsoft.PowerShell.PSConsoleReadLine]::Insert('lfcd')
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
}
Set-PSReadLineKeyHandler 'ctrl+f' -ScriptBlock {
[Microsoft.PowerShell.PSConsoleReadLine]::Insert('fzf | Split-Path | cd')
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
}
Set-PSReadLineKeyHandler 'ctrl+e' -ScriptBlock {
[Microsoft.PowerShell.PSConsoleReadLine]::Insert('nvim "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\LocalState\settings.json"')
[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
}
function lfcd {
$tmp = New-TemporaryFile
lf -last-dir-path="$tmp" @args
if (Test-Path -Path "$tmp" -PathType Leaf) {
$dir = $(cat "$tmp")
Remove-Item -Path "$tmp" -Force
if (Test-Path -Path "$dir") {
if ("$dir" -ne "$(pwd)") {
cd "$dir"
}
}
}
}
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/$THEME.omp.json" | Invoke-Expression
##########################################
############# miniconda3 #################
##########################################
$Env:CONDA_EXE = "C:/Users/jader/miniconda3/Scripts/conda.exe"
$Env:_CE_M = ""
$Env:_CE_CONDA = ""
$Env:_CONDA_ROOT = "C:/Users/jader/miniconda3"
$Env:_CONDA_EXE = "C:/Users/jader/miniconda3\Scripts\conda.exe"
$CondaModuleArgs = @{ChangePs1 = $False}
Import-Module "$Env:_CONDA_ROOT\shell\condabin\Conda.psm1" -ArgumentList $CondaModuleArgs
Remove-Variable CondaModuleArgs
conda activate base
##########################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment