It annoys me when I am working with PowerShell try to pipe the results of a cmdlet into a exe which doesn’t understand pipelined data. To solve this problem I began aliasing some of the common programs I would like … Continue reading →
Since switching to Mercurial I often use the “hg summary” command. hg summary [–remote] aliases: sum summarize working directory state This generates a brief summary of the working directory state, including … Continue reading →
ls * -recurse -include *.aspx, *.ascx, *.cs, *.ps1 | Get-Content | Measure-Object -Line
Just replace the file extensions with the ones you use in your project.
I often browse through directories using the command line interface. It is sometimes times faster and provides more information than using the GUI. However, many times there are operations that are easier in the GUI. This is why I always loved CMD.exe’s START command.
The START COMMAND Starts a separate window to run a specified program or command. START ["title"] [/D path] [/I] [/MIN] [/MAX] [/SEPARATE | /SHARED] [/LOW | /NORMAL | /HIGH | /REALTIME | /ABOVENORMAL | /BELOWNORMAL] [/AFFINITY ] [/WAIT] [/B] [command/program] [parameters] "title" Title to display in window title bar. path Starting directory B Start application without creating a new window. The application has ^C handling ignored. Unless the application enables ^C processing, ^Break is the only way to interrupt the application I The new environment will be the original environment passed to the cmd.exe and not the current environment. MIN Start window minimized MAX Start window maximized SEPARATE Start 16-bit Windows program in separate memory space SHARED Start 16-bit Windows program in shared memory space LOW Start application in the IDLE priority class NORMAL Start application in the NORMAL priority class HIGH Start application in the HIGH priority class REALTIME Start application in the REALTIME priority class
The START command is built into the command processor and lets you launch (“start”) programs. Where this command comes in handy is that if you pass it a directory path it will open that directory in a GUI window. So, when I am traversing directories in the command window and I want to open the directory in a GUI I just type “start .” and presto it opens.
The Move To Powershell
When I started using Powershell the START command no longer worked since its not part of Powershell. After a little searching I found the Invoke-Item command-let.
The Invoke-Item Command NAME Invoke-Item SYNOPSIS Invokes the provider-specific default action on the specified item. SYNTAX Invoke-Item [-path] <string> [-include <string>] [-exclude <string>] [-filter <string>] [-credential <PSCrede ntial>] [-whatIf] [-confirm] [<CommonParameters>] Invoke-Item [-literalPath] <string> [-include <string>] [-exclude <string>] [-filter <string>] [-credential < PSCredential>] [-whatIf] [-confirm] [<CommonParameters>] DETAILED DESCRIPTION Invokes the provider-specific default action on the specified item. When applied to a file system item, for example , it will either run the file or open it with the application associated with that file type.
This command-let doesn’t behave exactly the same as START command. For example calling the command START without any parameters will spawn a new command shell however to do that with Invoke-Item you must write “Invoke-Item [path to Powershell directory]\Powershell.exe”. But since the way I mainly use it still works since “Invoke-Item .” does the same thing as “START .”.
After figuring this out there was one more thing I had to do. I am so used to writing “start .” that is became second nature to me therefore I needed to be able to do that in Powershell as well. So I added this line into my Powershell profile:
set-alias start Invoke-Item
Now I can write “start .” in both Powershell and cmd.exe and have it behave the way I want.