Skip to content

Callidus2000/CmdFav

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues GPLv3 License

CmdFav PowerShell Module

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.

movingExample

Features

  • 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.

Installation from the PowerShell Gallery

# Install the CmdFav module from the PowerShell Gallery
Install-Module -Name CmdFav -Scope CurrentUser

Usage

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.

Add a Favorite Command to the favorite System:

# 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

Recall stored commands

Get-CmdFav -Name Example.AllADMailAddresses

#Shorter
gcf Example.AllADMailAddresses

#Opens a GridView for selecting the command
Get-CmdFav

Edit an Existing Favorite Command

Edit-CmdFav -Name "MyFavorite" -CommandLine "Get-Service -Status Running" -Tag "Service" -Description "List running services"

Export Favorite Commands

Export-CmdFav -Path "C:\Path\To\Favorites.json"

Import Favorite Commands

Import-CmdFav -Path "C:\Path\To\Favorites.json"

Change the save location for the settings cache

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.

Roadmap

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.

Contributing

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:

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Limitations

  • 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

License

Distributed under the GNU GENERAL PUBLIC LICENSE version 3. See LICENSE.md for more information.

Contact

Project Link: https://github.com/Callidus2000/CmdFav

Acknowledgements

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published