CmdFav is a PowerShell module designed to help you manage and organize your favorite commands efficiently. It provides cmdlets for adding, editing, exporting, and importing favorite commands, allowing you to streamline your command-line experience. By this it provides kind of bookmarking system for everyday snippets in the commandline.
-
Add-CmdFav: Add your frequently used commands to a cache with custom names, tags, and descriptions.
-
Edit-CmdFav: Modify properties of existing favorite commands, such as command line, tags, descriptions, and even rename them.
-
Export-CmdFav: Export your favorite commands to a JSON file for backup or sharing.
-
Import-CmdFav: Import favorite commands from a JSON file and integrate them into your cache.
# Install the CmdFav module from the PowerShell Gallery
Install-Module -Name CmdFav -Scope CurrentUser
Important first words! Even this should be obvious: NEVER use the module to save something secret! Everyone who gets access to the cache file can read everything in it! So instead of saving an API access token or a password save a multiline command which retrieves the secret from something like a SecretManagement Vault.
# Directly add the command
Add-CmdFav -Name "MyFavorite" -CommandLine "Get-Process" -Tag "Monitoring"
# Take the last used command from the history
(Get-ADForest).domains|% {Get-ADUser -server $_ -filter {mail -like '*company.com'} -Properties mail}|select UserPrincipalName,name,mail
Add-CmdFav -Name Example.AllADMailAddresses -LastCommand -Description "Get all users with their mail addresses from all forest domains"
# Build a multiline command from the last 4 commands in the history
Get-History -Count 4|Add-CmdFav -Name Example.MultiLine
Get-CmdFav -Name Example.AllADMailAddresses
#Shorter
gcf Example.AllADMailAddresses
#Opens a GridView for selecting the command
Get-CmdFav
Edit-CmdFav -Name "MyFavorite" -CommandLine "Get-Service -Status Running" -Tag "Service" -Description "List running services"
Export-CmdFav -Path "C:\Path\To\Favorites.json"
Import-CmdFav -Path "C:\Path\To\Favorites.json"
Set-PSFConfig -FullName CmdFav.HistorySave.Path -Value "C:\Users\MyUser\OneDrive\PowerShell" -PassThru|Register-PSFConfig -Scope UserDefault
Attention! If you have already got commands saved you have to modify something in the cache to get the existing data automatically transferred! Or copy the cmdfav.json
file from $($env:AppData)\PowerShell\PSFramework\Config
manually to the new location.
New features will be added if any of my scripts need it ;-)
I cannot guarantee that no breaking change will occur as the development follows my internal DevOps need completely. Likewise I will not insert full documentation of all parameters as I don't have time for this copy&paste. Sorry. But major changes which classify as breaking changes will result in an increment of the major version. See Changelog for information regarding breaking changes.
See the open issues for a list of proposed features (and known issues).
If you need a special function feel free to contribute to the project.
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated. For more details please take a look at the CONTRIBUTE document
Short stop:
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
- The module works on the ADOM level as this is the only permission set I've been granted
- Maybe there are some inconsistencies in the docs, which may result in a mere copy/paste marathon from my other projects
Distributed under the GNU GENERAL PUBLIC LICENSE version 3. See LICENSE.md
for more information.
Project Link: https://github.com/Callidus2000/CmdFav
- Friedrich Weinmann for his marvelous PSModuleDevelopment and psframework
- Joel Bennett for his quick help regarding How to inject text into the NEXT command prompt