One of my favorite commands on *NIX is ls -alF, or "list Alf" as I usually remember it. It gives you not just a list of file names in a directory, but what they are, what permissions they have, and shows hidden files and folders to boot.

But when I come back to Windows, PowerShell's ls alias doesn't work as well. It's just a wrapper/alias for Get-ChildItem (iirc), and you have to add the -Force param to it to see everything. So ls -Force shows hidden items, but ls and ls -alF doesn't.

I made a quick alias for PowerShell so that I could type ls-alf instead -- or actually ls-[tab]. The problem is that you can't set up an alias that includes attributes, so I have to make not an alias but a function...

function ls-alf { Get-ChildItem -Force }

(fwiw, you can use ls or gci or another alias for Get-ChildItem in your function.)

That works for the window you're in, but to make it permanent, you need to put it into your profile file, which luckily is kept in the $profile variable. For instance...

vim $profile

For me to do that, though, I had to make this directory first ($profile linked to a path that didn't exist):

mkdir C:\Users\MyFreakinName\Documents\WindowsPowerShell

Now you slap in the function, and you're done. Unless you haven't set your execution policy on your current box yet. Then you run a PowerShell console as admin, and run...

set-executionpolicy remotesigned

Finally. Success-ish.

Labels: , ,