Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>Function funcOpenPowerShellProfile { Notepad $PROFILE } Set-Alias fop funcOpenPowerShellProfile </code></pre> <p>Only a <a href="http://undefined.com/ia/2006/10/24/the-fourteen-types-of-programmers-type-4-lazy-ones/" rel="nofollow">sagaciously-lazy individual</a> would tell you that <code>fop</code> is so much easier to type than <code>Notepad $PROFILE</code> at the prompt, unless, of course, you associate "fop" with a <a href="http://en.wikipedia.org/wiki/Fop" rel="nofollow">17th century English ninny</a>.</p> <hr /> <p>If you wanted, you could take it a step further and make it somewhat useful:</p> <pre><code>Function funcOpenPowerShellProfile { $fileProfileBackup = $PROFILE + '.bak' cp $PROFILE $fileProfileBackup PowerShell_ISE $PROFILE # Replace with Desired IDE/ISE for Syntax Highlighting } Set-Alias fop funcOpenPowerShellProfile </code></pre> <hr /> <p>For satisfying survivalist-paranoia:</p> <pre><code>Function funcOpenPowerShellProfile { $fileProfilePathParts = @($PROFILE.Split('\')) $fileProfileName = $fileProfilePathParts[-1] $fileProfilePathPartNum = 0 $fileProfileHostPath = $fileProfilePathParts[$fileProfilePathPartNum] + '\' $fileProfileHostPathPartsCount = $fileProfilePathParts.Count - 2 # Arrays start at 0, but the Count starts at 1; if both started at 0 or 1, # then a -1 would be fine, but the realized discrepancy is 2 Do { $fileProfilePathPartNum++ $fileProfileHostPath = $fileProfileHostPath + ` $fileProfilePathParts[$fileProfilePathPartNum] + '\' } While ( $fileProfilePathPartNum -LT $fileProfileHostPathPartsCount ) $fileProfileBackupTime = [string](date -format u) -replace ":", "" $fileProfileBackup = $fileProfileHostPath + ` $fileProfileBackupTime + ' - ' + $fileProfileName + '.bak' cp $PROFILE $fileProfileBackup cd $fileProfileHostPath $fileProfileBackupNamePattern = $fileProfileName + '.bak' $fileProfileBackups = @(ls | Where {$_.Name -Match $fileProfileBackupNamePattern} | ` Sort Name) $fileProfileBackupsCount = $fileProfileBackups.Count $fileProfileBackupThreshold = 5 # Change as Desired If ( $fileProfileBackupsCount -GT $fileProfileBackupThreshold ) { $fileProfileBackupsDeleteNum = $fileProfileBackupsCount - ` $fileProfileBackupThreshold $fileProfileBackupsIndexNum = 0 Do { rm $fileProfileBackups[$fileProfileBackupsIndexNum] $fileProfileBackupsIndexNum++; $fileProfileBackupsDeleteNum-- } While ( $fileProfileBackupsDeleteNum -NE 0 ) } PowerShell_ISE $PROFILE # Replace 'PowerShell_ISE' with Desired IDE (IDE's path may be needed in # '$Env:PATH' for this to work; if you can start it from the "Run" window, # you should be fine) } Set-Alias fop funcOpenPowerShellProfile </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload