Having been accustomed to zsh on Linux, I recently discovered that PowerShell 7 also supports persistent settings for command-line prediction views. I tried it out and found it quite useful.
Not sure what action was taken, but this feature is enabled – it just appeared
In today’s diverse operating system environment, system administrators and developers are seeking a cross-platform, efficient, and powerful tool to meet their needs for system management and automation. PowerShell 7 is such a highly anticipated tool, offering robust scripting capabilities and enabling operation across Windows, Linux, and macOS, bringing unprecedented convenience to users.
PowerShell 7: A Powerful Cross-Platform Tool
Cross-platform features
PowerShell 7 removes platform limitations, allowing users to utilize a single tool for enterprise-level server management on Windows, system administration in Linux environments, or everyday development tasks on macOS. This significantly improves work efficiency and reduces learning costs and operational complexity caused by platform differences.
Powerful features
It features robust scripting capabilities, supporting object-oriented programming, functions, and modules. With PowerShell 7, users can easily manage the file system (creating, deleting, copying, moving files and folders), access and modify the registry for in-depth system configuration, and manage processes and services for effective monitoring and control. Furthermore, PowerShell 7 integrates with various Windows and non-Windows technologies, such as user and permission management in Active Directory and resource provisioning and management on Azure cloud platforms.
Open-source ecosystem
PowerShell 7 is open-source, enabling global developers and enthusiasts to actively participate in its development and improvement. A wealth of open-source modules and tools are constantly emerging, enriching PowerShell 7’s functionality and applications. Users can find suitable modules within the open-source community to extend PowerShell 7’s capabilities or contribute their own code to advance the entire community.
Compatibility and Stability
PowerShell 7 introduces numerous new features and improvements while maintaining compatibility with older PowerShell versions. These enhancements boost performance, increase stability, and allow users to complete tasks more smoothly, reducing interruptions due to software issues.
Open command-line prediction view
Among PowerShell 7’s many useful features, the INLINE_CODE_0 command is a practical tool that enhances the user’s command-line experience
Without enabling the command, inline auto-completion is available. Enabling it provides predictive suggestions in a list format, allowing users to select options with arrow keys, improving accuracy and efficiency of command input.
How to make commands persistent
To ensure a command takes effect each time PowerShell starts, you can add it to the PowerShell profile. The PowerShell profile is a special script that automatically executes its commands when PowerShell launches.
Confirm configuration file path
In PowerShell, we can use the $_
variable to view the configuration file path. If the file does not exist at that path, the user can create it manually.
echo $PROFILE
Open configuration file
Open the file corresponding to the configuration file path obtained through the __INLINE_CODE_0
variable using a text editor, such as the powerful Notepad++ or the lightweight Visual Studio Code
Add command
Add the INLINE_CODE_0 command to the open configuration file. Ensure the command is written accurately to guarantee it takes effect when the configuration file is executed.
Save configuration file
After adding the command, save the configuration file and close the text editor. The configuration file now includes the commands we want to execute each time PowerShell starts.
Verification Settings
Close the current PowerShell window and restart it. In the newly launched PowerShell, when entering commands, the command-line input prediction view should display in a list format, indicating that our settings have taken effect successfully.
Through these steps, we not only gained a deeper understanding of PowerShell 7’s powerful features and capabilities but also learned how to enhance the user experience by setting command-line input prediction views and ensuring these settings persist. We hope this knowledge helps you use PowerShell 7 more confidently and efficiently to complete various system management and automation tasks.