Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Aliases too simple

Status
Not open for further replies.

kriva

IS-IT--Management
Nov 5, 2007
3
US
I'm still getting used to PowerShell, trying to use it as much as possible.

One snag I'm hitting is that my unix background leads me to expect and want some things that I'm having difficulty finding.

For example, I'd like to fix it so that

- 'ls' would mean 'get-childitem -force -name'
- 'dir' would mean 'get-childitem -force'

What is the best way to do this?

I wasted a little time trying to define these as aliases, since I didn't realize that PS aliases are one-word items.
 
more to the question:

I can define functions that do what I want, for example:

function l ([string] $a) { get-childitem -force -name }

but how can I put this in place of the built-in "ls"?

When I do

remove-item alias:ls

it seems to alter, but not remove the "ls" alias. The output format changes, and it's still listed in the "alias" command.

----
Kevin Kelleher
 
Oh, never mind... I got it now.

After I removed the "ls" alias, I did a "which ls" and found that it's finding an ls.exe in a unix emulation package I installed.

So now in my profile I do:

remove-item alias:ls
function ls ([string] $a) { get-childitem -force -name $a }



----
Kevin Kelleher
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top