如何在 Ubuntu 上配置 PowerShell 提示符?

如何在 Ubuntu 上配置 PowerShell 提示符?

我如何配置配置PowerShell文件以便改变提示?

nicholas@mordor:~/.config$ 
nicholas@mordor:~/.config$ ls -alh
total 108K
drwxr-xr-x 23 nicholas nicholas 4.0K Feb  4 19:50 .
drwxr-xr-x 66 nicholas nicholas 4.0K Feb 21 15:46 ..
drwx------  6 nicholas nicholas 4.0K Nov 11 13:51 calibre
drwx------  2 nicholas nicholas 4.0K Feb 21 00:15 dconf
drwx------  2 nicholas nicholas 4.0K Sep 28 10:19 enchant
drwx------  2 nicholas nicholas 4.0K Oct  2 12:11 eog
drwx------  3 nicholas nicholas 4.0K Sep 27 17:00 evolution
drwxr-xr-x  2 nicholas nicholas 4.0K Nov 11 02:04 gedit
-rw-rw-r--  1 nicholas nicholas    3 Sep 27 17:21 gnome-initial-setup-done
drwx------  3 nicholas nicholas 4.0K Oct  1 13:39 gnome-session
drwxr-xr-x  2 nicholas nicholas 4.0K Sep 27 17:09 goa-1.0
drwxr-xr-x  2 nicholas nicholas 4.0K Dec  6 03:28 gthumb
drwx------  2 nicholas nicholas 4.0K Feb 19 23:58 gtk-3.0
drwx------  3 nicholas nicholas 4.0K Sep 27 17:00 ibus
drwx------  2 nicholas nicholas 4.0K Jan 26 10:24 liferea
drwxrwxr-x  4 nicholas nicholas 4.0K Nov 18 03:11 menus
-rw-rw-r--  1 nicholas nicholas  366 Feb  4 19:50 mimeapps.list
drwxr-xr-x  2 nicholas nicholas 4.0K Dec 28 06:36 nautilus
drwxrwxr-x  2 nicholas nicholas 4.0K Nov 15 14:17 NuGet
drwx------  2 nicholas nicholas 4.0K Sep 27 21:28 procps
drwx------  2 nicholas nicholas 4.0K Sep 27 17:00 pulse
drwxr-xr-x  5 nicholas nicholas 4.0K Feb 19 01:01 transmission
drwx------  2 nicholas nicholas 4.0K Sep 27 17:01 update-notifier
-rw-------  1 nicholas nicholas  633 Sep 27 17:00 user-dirs.dirs
-rw-rw-r--  1 nicholas nicholas    5 Sep 27 17:00 user-dirs.locale
drwx------ 18 nicholas nicholas 4.0K Jan 30 00:56 VSCodium
drwx------  2 nicholas nicholas 4.0K Jan 30 13:16 yelp
nicholas@mordor:~/.config$ 
nicholas@mordor:~/.config$ pwd
/home/nicholas/.config
nicholas@mordor:~/.config$ 
nicholas@mordor:~/.config$ pwsh
PowerShell 7.1.2
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

PS /home/nicholas/.config> 

而不是显示当前工作目录,只需简单地“ps”即可?但是,我没有看到任何这样的文件建议

答案1

我认为只需创建文件即可:

nicholas@mordor:~$ 
nicholas@mordor:~$ pwsh
PowerShell 7.1.2
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

posh> 
posh> cat /home/nicholas/.config/powershell/Microsoft.PowerShell_profile.ps1


function prompt {
  $p = "posh"
  "$p> "
}


posh> 
posh> exit
nicholas@mordor:~$ 

不确定如何做更多的事情..但是有效。

相关内容