nickcox / pure-pwsh Goto Github PK
View Code? Open in Web Editor NEWPowerShell implementation of the pure prompt
License: MIT License
PowerShell implementation of the pure prompt
License: MIT License
e.g.
`
$pure.PromptChar = "$"
then type e.g.
$ + (changes to default char ??)
I copy-pasted this straight from the README
Import-Module pure-pwsh
Import-Module posh-git
$pure.PrePrompt = {
param ($user, $cwd, $git, $slow)
"`n$user{1}{0}$cwd $git $slow `n" -f
($user ? ' ' : ''),
(($ve = $env:virtual_env) ? "$($pure._branchcolor)($(Split-Path -Leaf $ve)) " : "" )
}
And here's my prompt:
(venv)
(venv) ~\programming\python\some_project_with_venv main*
❯
I tried to figure this out myself but the PowerShell syntax is really difficult for me to parse and I couldn't tell what needed changing.
I'd like to do something like this
$PrePrompt = {if ($Env:CONDA_DEFAULT_ENV -ne "base") {
"($Env:CONDA_DEFAULT_ENV) "
} else { }}
$pure.PrePrompt = {param ($cwd, $git, $slow) "$($myColors.DeepSkyBlue3)$([Environment]::UserName) $cwd $git`n$PrePrompt"}
It would be nice to support Vi mode indicator especially since PowerShell has a native readline Vi mode.
Remove dependency on posh-git and replace with libgit2sharp
.
I'm not sure if this is at all related to #8 . But pressing Ctrl + L leaves an additional line, which might be related to some miscalculation of the console prompt height.
$pure.PrePrompt= {param ($cwd, $git, $slow) "$([Environment]::UserName) $cwd $git $slow"}
How would I go about colors my username with the same color used for cwd ?
Additionally how would I go about customizing other default colors
When starting powershell or pwsh with this prompt it ends up adding a new line at initialization.
I.e.
$ pwsh -NoLogo
<pure prompt> # additional new line is inserted above
$ pwsh -NoLogo
<normal prompt> # no new line above
I think it would make sense for this port to use the same settings as stock Pure for consistency. This way, users switching between zsh and PowerShell can benefit from the same appearance out of the box (I use PowerShell Core on Linux occasionally).
For the record, I use those settings to make pure-pwsh look closer to stock Pure:
$esc = [char]27
$pure.PwdColor = "$esc[34m"
$pure.BranchColor = "$esc[90m"
$pure.RemoteColor = "$esc[36m"
$pure.PromptColor = "$esc[35m"
I'm hosting an OpenSSH server using the official Microsoft-supplied port on Windows 10 build 17134. When I connect to it from my Linux PC and start PowerShell, the prompt is garbled (but the rest is fine); I tried both kitty and Konsole to rule out a terminal-specific issue.
This does not occur in cmd.exe or PowerShell with the default prompt. See below for an example (look how the prompt is moved to the right):
Say I want to shorten very long paths with a function
function ShortenPath([string] $path) {
$loc = $path.Replace($HOME, '~')
# remove prefix for UNC paths
$loc = $loc -replace '^[^:]+::', ''
# make path shorter like tabs in Vim,
# handle paths starting with \\ and . correctly
return ($loc -replace '\\(\.?)([^\\])[^\\]*(?=\\)', '\$1$2')
}
how would I go about adding this in this prompt?
If each of these took a configurable function of, say, string -> string
then users could bring their own preferred path shortening.
Hi! thanks for the great work! I love pure and glad to see a version for powershell.
I have an issue at the moment, when I run a git checkout <branch>
or git pull
that works I get a prompt with a ?
instead of the ❯
.
It also replicates the last command there, then immediately draws a new prompt. Then my next command fails because it tries to combine it with the reprinted command.
Here is example output:
E:\repos\virtuoso develop ⇣
❯ git pull
Updating 76e0a5f..f18bf0e
Fast-forward
app/pods/application/template.hbs | 9 +-
.../application-current-user/template.hbs | 10 +-
app/pods/components/application-nav/template.hbs | 34 +++--
.../components/application-search/template.hbs | 18 +--
.../components/display-flash-messages/template.hbs | 4 +-
app/templates/head.hbs | 2 +-
package.json | 3 +-
E:\repos\virtuoso develop
? git pull
E:\repos\virtuoso develop (3.05s)
❯ git pull
fatal: Cannot rebase onto multiple branches.
E:\repos\virtuoso develop (2.51s)
❯ git status
On branch develop
Your branch is up to date with 'origin/develop'.
nothing to commit, working tree clean
E:\repos\virtuoso develop
❯ git pull
Already up to date.
Current branch develop is up to date.
My profile is this:
if ($host.Name -eq 'ConsoleHost')
{
Import-Module PSReadLine
}
Remove-PSReadlineKeyHandler 'CTRL+R'
Import-Module PSFzf
Import-Module -Name E:\repos\pure-pwsh\pure-pwsh\pure-pwsh.psd1
Import-Module posh-git
#Import-Module oh-my-posh
#Set-Theme agnoster
new-item -path Env:. -name FZF_DEFAULT_COMMAND -value "rg --files . 2> nul"
new-item -path Env:. -name EDITOR -value "atom"
New-Alias vim nvim
New-Alias which get-command
Import-Module "C:\ProgramData\chocolatey\lib\ripgrep\tools\_rg.ps1"
#function Get-GitStatus { & git status $args }
#New-Alias -Name gst -Value Get-GitStatus -Force -Option AllScope
#function Get-GitCommit { & git commit -ev $args }
#New-Alias -Name gc -Value Get-GitCommit -Force -Option AllScope
function Get-GitAdd { & git add --all $args }
New-Alias -Name ga -Value Get-GitAdd -Force -Option AllScope
function Get-GitTree { & git lg }
New-Alias -Name lg -Value Get-GitTree -Force -Option AllScope
function Get-GitCheckout { & git checkout $args }
New-Alias -Name gco -Value Get-GitCheckout -Force -Option AllScope
function Get-GitBranch { & git branch $args }
New-Alias -Name gb -Value Get-GitBranch -Force -Option AllScope
function Get-GitDiff { & git diff $args }
New-Alias -Name gd -Value Get-GitDiff -Force -Option AllScope
# Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
}
$DefaultUser = 'invad'
# Host Foreground
$Host.PrivateData.ErrorForegroundColor = 'Red'
$Host.PrivateData.WarningForegroundColor = 'Yellow'
$Host.PrivateData.DebugForegroundColor = 'Green'
$Host.PrivateData.VerboseForegroundColor = 'Blue'
$Host.PrivateData.ProgressForegroundColor = 'Gray'
# Host Background
$Host.PrivateData.ErrorBackgroundColor = 'DarkGray'
$Host.PrivateData.WarningBackgroundColor = 'DarkGray'
$Host.PrivateData.DebugBackgroundColor = 'DarkGray'
$Host.PrivateData.VerboseBackgroundColor = 'DarkGray'
Anyway we could performance optimize the module so it starts up faster?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.