{"id":7893,"date":"2014-10-22T06:00:00","date_gmt":"2014-10-22T13:00:00","guid":{"rendered":"http:\/\/www.sapien.com\/blog\/?p=7893"},"modified":"2014-10-22T08:28:10","modified_gmt":"2014-10-22T15:28:10","slug":"expand-all-aliases-ctrlshiftalta","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2014\/10\/22\/expand-all-aliases-ctrlshiftalta\/","title":{"rendered":"Expand All Aliases: Ctrl+Shift+A"},"content":{"rendered":"<p>Windows PowerShell aliases are very handy. They typically have fewer characters than the commands and parameters that they represent, so they\u2019re quicker to type and great for tweeting. However, it has long been an established best practice that aliases should not be used in blogs, in help, in examples, or in any shared scripts and commands. They create an extra layer of confusion for beginners and they\u2019re an obstacle for anyone who needs to maintain the script.<\/p>\n<p>Still, we use them. I know that, despite my best efforts, I type \u201cdir\u201d and \u201cwhere\u201d and \u201cgcm\u201d and \u201cipmo\u201d and \u201csls\u201d\u00a0 and, worst of all, \u201cforeach\u201d when I mean the ForEach-Object cmdlet, not the ForEach statement.<\/p>\n<p>Fortunately, some nifty features in PowerShell Studio 2014 make it easy to conform to the best practice, despite our habits.<\/p>\n<ul>\n<li>When you type an alias, PrimalSense shows that it\u2019s a alias.<\/li>\n<\/ul>\n<blockquote><p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/10\/image.png\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; border-width: 0px;\" title=\"image\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2014\/10\/image_thumb.png\" alt=\"image\" width=\"442\" height=\"217\" border=\"0\" \/><\/a><\/p><\/blockquote>\n<ul>\n<li>When you type a cmdlet alias or parameter alias and then press <strong>TAB<\/strong>, PowerShell Studio expands it. (You can disable this feature in Options\\Editor\\<strong>Enable alias tab expansion<\/strong>.)<\/li>\n<li>When you type a partial parameter name (such as \u2013m or \u2013mod for \u2013Module) and a space, PowerShell Studio expands it.<\/li>\n<li>To expand an alias, right-click and click <strong>Expand to Cmdlet<\/strong> or <strong>Expand Parameter<\/strong>.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>But, when I\u2019m scripting, I\u2019m a bit too focused to think about aliases. Instead, when I\u2019m done with my script, just before I sign it, I type:<\/p>\n<blockquote><p><strong>CTRL + SHIFT + A<\/strong><\/p><\/blockquote>\n<p>Ctrl+Shift+A converts all cmdlet and parameter aliases, and parameter partial names*, to their full names with correct capitalization. What an easy way to support a best practice.<\/p>\n<p>Oh, and in case you\u2019re wondering, PowerShell Studio 2014 is happy to undo all of your good deeds. You can right-click and click <strong>Convert to Alias<\/strong> or type Ctrl+Shift+Alt+A to convert all cmdlet and parameter names to aliases.<\/p>\n<p>&nbsp;<\/p>\n<p>A few notes * :<\/p>\n<ul>\n<li>Beginning in PowerShell Studio 2014 version 4.1.72, Ctrl+Shift+A expands aliases and Ctrl+Shift+Alt+A contracts names to their aliases. In earlier versions, Ctrl+Shift+Alt+A expands aliases and Ctrl+Shift+A contracts them.<\/li>\n<li>Also, beginning in version 4.1.72,\u00a0 Ctrl+Shift+A expands cmdlet aliases, parameter aliases and partial parameter names. In earlier versions, Ctrl+Shift+Alt+A expands only cmdlet aliases.<\/li>\n<li>The alias expansion features don\u2019t expand aliases that you have defined in your profile. In best practice fashion, just like your users, the PowerShell Studio Editor window does not have access to your profile.<\/li>\n<li>The alias expansion features don\u2019t recognize aliases that you have defined in your script. (You really shouldn\u2019t define aliases in a script anyway.)<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><i>June Blender is a technology evangelist at SAPIEN Technologies, Inc. You can reach her at <a href=\"mailto:juneb@sapien.com\">juneb@sapien.com<\/a> or follow her on Twitter at <a href=\"https:\/\/twitter.com\/juneb_get_help\">@juneb_get_help<\/a>.<\/i><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Windows PowerShell aliases are very handy. They typically have fewer characters than the commands and parameters that they represent, so they\u2019re quicker to type and great for tweeting. However, it has long been an established best practice that aliases should not be used in blogs, in help, in examples, or in any shared scripts and [&hellip;]<\/p>\n","protected":false},"author":31,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[703,25],"tags":[934,874,930],"class_list":["post-7893","post","type-post","status-publish","format-standard","hentry","category-powershell-studio","category-windows-powershell","tag-juneb","tag-powershell-studio-2014","tag-ui"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/7893","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/31"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=7893"}],"version-history":[{"count":9,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/7893\/revisions"}],"predecessor-version":[{"id":8058,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/7893\/revisions\/8058"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=7893"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=7893"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=7893"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}