Настройка приглашения PowerShell — эквивалент CMD $ M $ P $ _ $ + $ G?

Я начал «играть» с PowerShell и пытаюсь заставить его «вести себя».

Одна из вещей, которые я хотел бы сделать, — настроить PROMPT так, чтобы он был «похож» на то, что делает «$ M $ P $ _ $ + $ G» в MS-Dos:

Краткое изложение того, что они делают:

Персонаж | Описание
$ m Удаленное имя, связанное с текущей буквой диска или пустой строкой, если текущий диск не является сетевым.
$ p Текущий диск и путь
$ _ ENTER-LINEFEED
$ + Ноль или более знаков плюса (+ ) символов в зависимости от глубины стека каталогов pushd, по одному символу для каждого выдвинутого уровня
$ g> (знак больше)

Итак, окончательный результат будет примерно таким:

\spma1fp1JARAVJ$ H:temp ++>

Я смог добавить функции $M и $_ (и отличную функцию истории) в свою подсказку следующим образом:

function prompt { ## Get the history. Since the history may be either empty, ## a single item or an array, the @() syntax ensures ## that PowerShell treats it as an array $history = @(get-history) ## If there are any items in the history, find out the ## Id of the final one. ## PowerShell defaults the $lastId variable to ‘0’ if this ## code doesn’t execute. if($history.Count -gt 0) { $lastItem = $history[$history.Count — 1] $lastId = $lastItem.Id } ## The command that we’re currently entering on the prompt ## will be next in the history. Because of that, we’ll ## take the last history Id and add one to it. $nextCommand = $lastId + 1 ## Get the current location $currentDirectory = get-location ## Set the Windows Title to the current location $host.ui.RawUI.WindowTitle = «PS: » + $currentDirectory ## And create a prompt that shows the command number, ## and current location «PS:$nextCommand $currentDirectory >» }

Но остальное мне еще не удалось скопировать ….

Большое спасибо за советы, которые обязательно придут!

Источник: ledsshop.ru

Стиль жизни - Здоровье!