Script directory for a PowerShell profile. https://blog.lksz.me/keeping-track-of-everything/#-mypsscriptroot
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
550 B

  1. [CmdletBinding(SupportsShouldProcess)]param(
  2. [switch]$sudo,
  3. [Parameter(Position = 0, ValueFromRemainingArguments = $true)]
  4. [string[]]$Path
  5. )
  6. $local:editor = '/bin/nvim'
  7. if( (Test-Path env:EDITOR) -and (Test-Path $env:EDITOR) ) {
  8. $editor = $env:EDITOR;
  9. }
  10. if( $editor -match 'vim?$' ) {
  11. $editor += ' -p'
  12. }
  13. if( $sudo ) {
  14. $editor = "sudo $editor"
  15. }
  16. $local:arguments = $Path -join "' '"
  17. if( $Path ) { $arguments = "'$arguments'" }
  18. if( $PSCmdlet.ShouldProcess( "Edit ($editor): $arguments" ) ) {
  19. Invoke-Expression "$editor $arguments"
  20. }