website icon indicating copy to clipboard operation
website copied to clipboard

pretty-powershell/

Open utterances-bot opened this issue 2 years ago • 74 comments

Pretty Powershell

Having Fun with Technology

https://christitus.com/pretty-powershell/

utterances-bot avatar Oct 31 '22 13:10 utterances-bot

the one link command is not using a raw link btw

REVENGE977 avatar Oct 31 '22 13:10 REVENGE977

As @REVENGE977 stated earlier

Fixed: irm "https://raw.githubusercontent.com/ChrisTitusTech/powershell-profile/main/setup.ps1" | iex

jtjh avatar Oct 31 '22 13:10 jtjh

Need to add Xargs (I forget where I got this from but it works great!)

function Xargs { param( $Cmd ) process { $args += ,$_ } end { & $Cmd @args } }

TheyCallMeZ avatar Oct 31 '22 14:10 TheyCallMeZ

After installing this, I now receive a ParserError

Line | 125 | if (( $+commands[nvim] )); then | ~ | Missing statement block after if ( condition ).

Nothing changes after installing this. I've installed the font, but it all looks the same. Thanks.

silverskymedia avatar Oct 31 '22 15:10 silverskymedia

Test-CommandExists doesnt exist in my installation of Powershell v7.2.7

Velosofy avatar Oct 31 '22 16:10 Velosofy

The one -click install gives me this antivirus response..

irm "https://github.com/ChrisTitusTech/powershell-profile/blob/main/setup.ps1" | iex

Suspicious activity blocked 2 minutes ago

Feature: Antivirus

PowerShell tried to load a malicious resource detected as Heur.BZC.ZFV.Boxter.341.1359F945 and was blocked. Your device is safe.

hiddengerbil avatar Oct 31 '22 19:10 hiddengerbil

I turned off my antivirus to get this script to run. After it completed, I now get this PowerShell error

. : File C:\Users\virtualtom\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:3

  • . 'C:\Users\virtualtom\Documents\WindowsPowerShell\Microsoft.PowerShe ...
  • + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
    

hiddengerbil avatar Oct 31 '22 19:10 hiddengerbil

I get the following error when trying to install the program. Any suggestions?

iex : At line:198 char:17

  •         Sign up
    
  •             ~
    

The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string. At line:203 char:209

  • ... k Button--medium Button d-lg-none color-fg-inherit p-1"> <span cla ...
  •                                                             ~
    

The '<' operator is reserved for future use. At line:412 char:13

  •   CI/CD &amp; Automation
    
  •         ~
    

The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string. At line:1684 char:126

  • ... js-jump-to-line-field" type="text" placeholder="Jump to line…" ...
  •                                                             ~
    

The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string. At line:1684 char:148

  • ... pe="text" placeholder="Jump to line…" aria-label="Jump to line ...
  •                                                          ~~~~
    

Unexpected token 'Jump' in expression or statement. At line:1726 char:153

  • ... thub-terms-of-service" data-analytics-event="{"category":&q ...
  •                                                             ~
    

The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string. At line:1726 char:160

  • ... rms-of-service" data-analytics-event="{"category":"Foo ...
  •                                                             ~
    

The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string. At line:1726 char:172

  • ... ce" data-analytics-event="{"category":"Footer",&q ...
  •                                                             ~
    

The ampersand (&) character is not allowed. The & operator is reserved for future use; wrap an ampersand in double quotation marks ("&") to pass it as part of a string. At line:1726 char:179

  • ... ta-analytics-event="{"category":"Footer","ac ...
  •                                                              ~
    

Missing expression after unary operator ','. At line:1726 char:179

  • ... a-analytics-event="{"category":"Footer","act ...
  •                                                             ~
    

Unexpected token '&' in expression or statement. Not all parse errors were reported. Correct the reported errors and try again. At line:1 char:82

  • ... thub.com/ChrisTitusTech/powershell-profile/blob/main/setup.ps1" | iex
  •                                                                   ~~~
    
    • CategoryInfo : ParserError: (:) [Invoke-Expression], ParseException
    • FullyQualifiedErrorId : AmpersandNotAllowed,Microsoft.PowerShell.Commands.InvokeExpressionCommand

johnmac78 avatar Oct 31 '22 19:10 johnmac78

having same issue as hiddengerbil it is showing me . : File C:\Users\Rishab\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:3

  • . 'C:\Users\Rishab\Documents\WindowsPowerShell\Microsoft.PowerShell_p ...
  • + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
    

Rishab6358 avatar Oct 31 '22 20:10 Rishab6358

Having this issue after install:

Set-Alias : Cannot bind the argument to the 'Value' parameter because it is null.
In F:__Documents_WindowsPowerShell__Microsoft.PowerShell_profile.ps1: 142 Character: 28
+ Set-Alias -Name vim -Value $EDITOR
+ ~~~~~~~
    + CategoryInfo : InvalidData: (:) [Set-Alias], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.SetAliasCom
   mand

TheKeiki avatar Nov 01 '22 01:11 TheKeiki

Having the same error.. as above.

Set-Alias : Cannot bind argument to parameter 'Value' because it is null.
At C:\Users\grant\OneDrive\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:142 char:28
+ Set-Alias -Name vim -Value $EDITOR
+                            ~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Set-Alias], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.SetAliasCom
   mand

PapaHawk14 avatar Nov 01 '22 03:11 PapaHawk14

How Do I backup my current profile?

mendelsphotography avatar Nov 01 '22 04:11 mendelsphotography

How Do I backup my current profile?

the script auto-backup current profile as oldprofile.ps1

Velosofy avatar Nov 01 '22 05:11 Velosofy

@PapaHawk14 and @TheKeiki

That is because you don't have nvim/vim/pvim/vi installed If you don't intend to use any of those, just remove that part out from the profile

Velosofy avatar Nov 01 '22 05:11 Velosofy

Done - awesome….

On Tue, 1 Nov 2022 at 3:40 pm, Velosofy @.***> wrote:

@PapaHawk14 https://github.com/PapaHawk14 and @TheKeiki https://github.com/TheKeiki

That is because you don't have nvim/vim/pvim/vi installed If you don't intend to use any of those, just remove that part out from the profile

— Reply to this email directly, view it on GitHub https://github.com/ChrisTitusTech/website/issues/72#issuecomment-1298036856, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVHPCV7GAVENLEONQGA3L3DWGCQ2ZANCNFSM6AAAAAARTCTNQE . You are receiving this because you were mentioned.Message ID: @.***>

--

Grant Hawksworth Adelaide Sth Australia email: @.***

PapaHawk14 avatar Nov 01 '22 07:11 PapaHawk14

I also had some issues with the script execution which I resolved by doing this before executing the script above:

Set-ExecutionPolicy Bypass Process

OR

Set-ExecutionPolicy RemoteSigned

The script is working good and shows up perfectly on powershell but in Windows terminal some icons are missing. icons missing in the prompt

OS: Windows 10 Pro.

khurram-hassan avatar Nov 01 '22 12:11 khurram-hassan

I also had some issues with the script execution which I resolved by doing this before executing the script above:

Set-ExecutionPolicy Bypass Process

OR

Set-ExecutionPolicy RemoteSigned

The script is working good and shows up perfectly on powershell but in Windows terminal some icons are missing. icons missing in the prompt

OS: Windows 10 Pro.

The template does indeed require a Set-ExecutionPolicy RemoteSigned

Are you sure you're using the right font?

Velosofy avatar Nov 01 '22 12:11 Velosofy

Are you sure you're using the right font?

Yes, I am sure. As suggested in the article:

  1. I unzipped the cove.zip
  2. Installed all the 4 fonts present there
  3. and then made the default font for Windows Terminal as "Caskaydia Cove Nerd Font"

Windows Terminal settings

In powershell it is looking fine. prompt for powershell

khurram-hassan avatar Nov 01 '22 12:11 khurram-hassan

Yes, I am sure.

Possible of the "Windows PowerShell" terminal profile overriding the "default" profile font?

Velosofy avatar Nov 01 '22 13:11 Velosofy

Possible of the "Windows PowerShell" terminal profile overriding the "default" profile font?

You were right. I changed it as well and it worked.

Thanks

khurram-hassan avatar Nov 01 '22 13:11 khurram-hassan

I have the same issue as Khurram-hassan it seems. How do i override the default profile font?

MoebiusTesla avatar Nov 01 '22 14:11 MoebiusTesla

I have the same issue as Khurram-hassan it seems. How do i override the default profile font?

Assuming we're talking Windows Terminal - By simply changing the font for the default profile, but seems like you need to change the font for powershell profile aswell

Velosofy avatar Nov 01 '22 14:11 Velosofy

The following error can be removed from the profile.ps1 files. You should be able to find it in your My Documents\WindowsPowerShell folder called "Microsoft.PowerShell_profile.ps1" and "Microsoft.PowerShellISE_profile.ps1"

Edit the file and remove the following lines:

if (Test-CommandExists nvim) { $EDITOR='nvim' } elseif (Test-CommandExists pvim) { $EDITOR='pvim' } elseif (Test-CommandExists vim) { $EDITOR='vim' } elseif (Test-CommandExists vi) { $EDITOR='vi' } Set-Alias -Name vim -Value $EDITOR"

Save the file and now you can open Powershell and ISE without the error.

It does not seem to be assigning the correct value at the moment. I will look more into this later.

Error:

Set-Alias : Cannot bind argument to parameter 'Value' because it is null. At F:\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:142 char:28

  • Set-Alias -Name vim -Value $EDITOR
  •                        ~~~~~~~
    
    • CategoryInfo : InvalidData: (:) [Set-Alias], ParameterBindingValidationException
  • FullyQualifiedErrorId : >ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.SetAliasCom mand

b3y0ndd34th avatar Nov 01 '22 17:11 b3y0ndd34th

I'm getting this error: Could not find a part of the path 'C:\Users\lukav\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'. At line:8 char:10

  •      throw $_.Exception.Message
    
  •      ~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : OperationStopped: (Could not find ...l_profile.ps1'.:String) [], RuntimeException
    • FullyQualifiedErrorId : Could not find a part of the path 'C:\Users\lukav\Documents\WindowsPowerShell\Microsoft.PowerSh ell_profile.ps1'.

CattopyTheWeb avatar Nov 01 '22 17:11 CattopyTheWeb

The following error can be removed from the profile.ps1 files. You should be able to find it in your My Documents\WindowsPowerShell folder called "Microsoft.PowerShell_profile.ps1" and "Microsoft.PowerShellISE_profile.ps1"

Edit the file and remove the following lines:

if (Test-CommandExists nvim) { $EDITOR='nvim' } elseif (Test-CommandExists pvim) { $EDITOR='pvim' } elseif (Test-CommandExists vim) { $EDITOR='vim' } elseif (Test-CommandExists vi) { $EDITOR='vi' } Set-Alias -Name vim -Value $EDITOR"

Save the file and now you can open Powershell and ISE without the error.

It does not seem to be assigning the correct value at the moment. I will look more into this later.

Error:

Set-Alias : Cannot bind argument to parameter 'Value' because it is null. At F:\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:142 char:28

  • Set-Alias -Name vim -Value $EDITOR

  •                        ~~~~~~~
    
    • CategoryInfo : InvalidData: (:) [Set-Alias], ParameterBindingValidationException
  • FullyQualifiedErrorId : >ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.SetAliasCom mand

The problem is none of these editors are installed on the machine or if they are installed they are not in the system's PATH variable.

You can absolutely remove this chunk of code and be fine, but if you wanted a "vim" alias for a quick file editor you can add elseif statements for things you do have installed and are in the path

Case in point

if (Test-CommandExists nvim) {
$EDITOR='nvim'
} elseif (Test-CommandExists pvim) {
$EDITOR='pvim'
} elseif (Test-CommandExists vim) {
$EDITOR='vim'
} elseif (Test-CommandExists vi) {
$EDITOR='vi'
} elseif (Test-CommandExists code) {
$EDITOR='code'
} elseif (Test-CommandExists notepad++) {
$EDITOR='notepad++'
} elseif (Test-CommandExists notepad) {
$EDITOR='notepad'
}
Set-Alias -Name vim -Value $EDITOR

doing notepad last as every machine has notepad.

TheyCallMeZ avatar Nov 01 '22 17:11 TheyCallMeZ

I added the function gotodir. Simply go to the directory even if the parameter is a file.

gd $PROFILE

just add this to youre profile file.

go to a directory even in path is a file.

added 02-nov-2022

function gotodir($dir) { if ((get-item $dir -erroraction silentlycontinue ) -is [system.io.directoryinfo]) { cd $dir } else { cd (split-path -path $dir) } } set-alias -name gd -value gotodir <.sub>

bertman80 avatar Nov 02 '22 09:11 bertman80

Sorry for my previous post, I accidentally posted it too soon. I hoop you will delete it.

I added the function gotodir. Simply go to the directory even if the parameter is a file.

gd $PROFILE

just add this to youre profile file.

#go to a directory even in path is a file.
#added 02-nov-2022
function gotodir($dir) {
if ((get-item $dir -erroraction silentlycontinue ) -is [system.io.directoryinfo]) {
cd $dir
} else {
cd (split-path -path $dir)
}
}
set-alias -name gd -value gotodir

bertman80 avatar Nov 02 '22 10:11 bertman80

For all the EDITOR messages, just put this on line 133 just before the 'if (Test-CommandExists nvim) {' So the editor will be notepad if none of the other commands exist.

$EDITOR="notepad.exe"

bertman80 avatar Nov 02 '22 11:11 bertman80

I just fixed my error. Also can you do something with cmd too?

CattopyTheWeb avatar Nov 02 '22 23:11 CattopyTheWeb

I get the following error:

Copyright (c) Microsoft Corporation.

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

PS C:\Users\lexus> irm "https://github.com/ChrisTitusTech/powershell-profile/blob/main/setup.ps1" | iex
Invoke-Expression:
Line |
   1 |  … thub.com/ChrisTitusTech/powershell-profile/blob/main/setup.ps1" | iex
     |                                                                      ~~~
     | The '<' operator is reserved for future use.

PS C:\Users\lexus>

Any thoughts what I am doing wrong?

Helix70 avatar Nov 03 '22 06:11 Helix70