Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run shell commands for command segment directly in shell #47

Closed
AjayKMehta opened this issue Oct 9, 2020 · 2 comments · Fixed by #49
Closed

Run shell commands for command segment directly in shell #47

AjayKMehta opened this issue Oct 9, 2020 · 2 comments · Fixed by #49
Assignees
Labels
🤩 enhancement Improvement of a feature

Comments

@AjayKMehta
Copy link
Contributor

AjayKMehta commented Oct 9, 2020

In comments for #26, I mentioned wanting to create a segment that displays an icon only if (Get-PSReadLineOption).HistorySaveStyle -ne 'SaveNothing'. This does not work correctly because each time, the command gets run in a new instance of pwsh.

Theme used to test this: https://gist.github.com/AjayKMehta/1b5324a485a9db6e7d326276ab5786cf

@JanDeDobbeleer said he would look into seeing if he can modify the code so that a command can be run directly in your shell fixing this problem.

@AjayKMehta AjayKMehta changed the title Run shell commands for command segment directly in shell Run shell commands for command segment directly in shell Oct 9, 2020
@JanDeDobbeleer
Copy link
Owner

@AjayKMehta unfortunately running direct commands isn't possible given the compiled nature of the beast. Although I think there might be another way to offer this functionality without generating a performance hit.

I'll try to draft a solution later today/tomorrow.

@JanDeDobbeleer JanDeDobbeleer self-assigned this Oct 9, 2020
@JanDeDobbeleer JanDeDobbeleer added the 🤩 enhancement Improvement of a feature label Oct 9, 2020
@JanDeDobbeleer JanDeDobbeleer mentioned this issue Oct 9, 2020
4 tasks
@JanDeDobbeleer
Copy link
Owner

JanDeDobbeleer commented Oct 9, 2020

@AjayKMehta I found a reasonable fix by thinking out of the box.
Will be available once I merge #49

Import-Module oh-my-posh
Set-PoshPrompt jandedobbeleer

function Set-EnvVar {
    $env:POSH=$(if ((Get-PSReadLineOption).HistorySaveStyle -ne 'SaveNothing'){'💾'} else {''})
}
New-Alias -Name 'Set-PoshContext' -Value 'Set-EnvVar' -Scope Global

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤩 enhancement Improvement of a feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants