# pwsh cheatsheet

# support Crtl+D
echo 'Set-PSReadlineOption -EditMode Emacs' >> $PROFILE

# grep
ls -r | sls "find me" |% { code -g "$($_.Path):$($_.LineNumber):$($_.Matches[0].Index)" }

# ssh
Enter-PSSession -Credential (Get-Credential -Message '?' -UserName $login) $host

# Out-File with utf-8
@"
Hello
World
"@ | Out-File 1.txt -Encoding (&{if($PSVersionTable.PSVersion.Major -gt 5){"UTF8NoBOM"}else{"Default"}})


:: cmd cheatsheet

set script_path=%~dp0
set script_path_without_trailing_dir_sep=%script_path:~0,-1%
set script_path_with_unix_dir_sep=%script_path:\=/%
set first_param=%~1
set /p user_input=Your choice: 

rd /q /s "dir-to-remove"
xcopy /y "dir-to-copy-files-from" "dir-to-copy-files-to"
xcopy /y "dir-to-copy-files-from\*.html" "dir-to-copy-files-to\"
xcopy /y /s "dir-to-copy-files-from-recursively\*" "dir-to-copy-files-to\"

call npm install


--- Windows Environment Variables ---

~ == %USERPROFILE% == %HOMEDRIVE%%HOMEPATH%
%ProgramFiles%, %ProgramFiles(x86)% ---> %LOCALAPPDATA%\Programs


--- Windows Shortcuts ---

Win+Shift+S       take screenshot
Win+Ctrl+Shift+B  restart video driver

Win+E           explorer
  Ctrl+Shift+N  new folder

Win                 Start Menu (you can type what you need right after opening)
  Ctrl+Shift+Enter  run selected program as Administrator