I am setting up my PowerShell profile and would like to define the alias I use for my text editor as a variable, so that if I port my profile to others, they would be free to define the alias as they wish.
Here are some of the first few lines of my profile:
$textEditorAlias = 'np'
$textEditorExecutable = 'notepad++.exe'
set-alias -name $textEditorAlias -value (get-command $textEditorExecutable).path -scope Global -Option AllScope
# Shortcuts to commonly used files.
function frequentFile { $textEditorAlias 'C:\<pathToFile>\fileName' }
My problem is the function above returns "unexpected token in expression or statement".
If I replace the function with
function frequentFile { np 'C:\<pathToFile>\fileName' }
then it works.
Is there a way to have the variable $textEditorAlias expand within the function's expression cleanly?
Thank you.