lukesampson / pshazz

Give your powershell some pizazz.
The Unlicense
575 stars 40 forks source link

Full CWD path on window title #94

Open safakgur opened 5 years ago

safakgur commented 5 years ago

Since the default theme displays only the current folder's name, I find it helpful to display the full path of the working directory on the window title (instead of using a theme that displays it inline with every command). Adding $host.UI.RawUI.WindowTitle = gl to prompt achieves that.

If you don't find this useful enough to add to pshazz, I'd appreciate any pointers about how to add this to my PS profile without overwriting pshazz.

chawyehsu commented 5 years ago

This is a good idea, if you can make it being configurable for any pshazz themes, pull-request is welcome.

Deide commented 5 years ago

I achieved this with a user plugin named title, which I then added to my theme. Here's the code (let me know if you have any improvements):

function pshazz:title:init {
    $title = $global:pshazz.theme.title

    # default
    if(!$title) { $title = 'Console' }

    $global:pshazz.title = $title
}

function global:pshazz:title:prompt {
    $vars = $global:pshazz.prompt_vars
    $vars.keys | % { set-variable $_ $vars[$_] }
    $title = $executionContext.InvokeCommand.ExpandString($global:pshazz.title)
    $host.ui.rawui.WindowTitle = $title
}

Then in your theme, simply add the plugin to the list of plugins, and add a field for your title; something like "title": "$user@$hostname | $path",

It's especially nice with ConEmu, as this title can be shown in the "status" bar at the bottom of the window.

Note: You can place user plugins in your pshazz/plugins directory.

safakgur commented 4 years ago

At the time I created this issue, I was using ConEmu with "Quake mode" enabled and window title added to status bar exactly like @Deide described:

image

But I'm using Windows Terminal for some time now and it doesn't have a status bar yet. So I disabled this as the tab itself was not really suitable for long paths. I also noticed that I don't find myself wondering the current path so often and I kind of lost my interest in this feature.

I'm not closing the issue in case this is something you want to do at some point but feel free to close it if no one is interested anymore.

Thank you.