Configuring Jenkins: Change PowerShell Core Default Terminal Size on Linux Host
Introduction
Jenkins is a powerful open-source automation server that enables developers to build, test, and deploy their software. PowerShell Core is a cross-platform version of PowerShell, which is a task automation and configuration management framework from Microsoft. In this article, we will discuss how to change the default terminal size of PowerShell Core when using Jenkins on a Linux host.
Why Change the Default Terminal Size?
By default, the PowerShell Core terminal window on a Linux host has a small size, which can make it difficult to read the output of commands, especially when running long scripts. Therefore, changing the default terminal size can improve the readability and usability of the PowerShell Core terminal window.
Resolving the Issue on Windows
Before we dive into the solution for Linux hosts, it is worth noting that the issue of truncating output in PowerShell Core on Windows hosts has been resolved. According to this Stack Overflow post (https://stackoverflow.com/questions/37969686/powershell-core-on-linux-truncating-output-to-80-columns), the issue was caused by a bug in PowerShell Core that has since been fixed. Therefore, if you are using PowerShell Core on a Windows host, you can simply update to the latest version to resolve the issue.
Changing the Default Terminal Size on Linux Hosts
To change the default terminal size of PowerShell Core on a Linux host, you can follow these steps:
- Open the terminal window and run the following command to open the PowerShell Core profile file:
nano ~/.config/powershell/Microsoft.PowerShell_profile.ps1
- Add the following code to the profile file:
# Set the terminal window size
function Resize-Host {
param()
$host.UI.RawUI.BufferSize = New-Object System.Management.Automation.Host.Size(120, 3000)
$host.UI.RawUI.WindowSize = New-Object System.Management.Automation.Host.Size(120, 50)
}
# Call the function to set the terminal window size
Resize-Host
This code defines a function called Resize-Host that sets the buffer size and window size of the terminal window. The buffer size is set to 120 characters wide and 3000 lines high, while the window size is set to 120 characters wide and 50 lines high. You can adjust these values to suit your needs.
- Save the profile file and exit the text editor.
- Restart the PowerShell Core terminal window for the changes to take effect.
Conclusion
In this article, we have discussed how to change the default terminal size of PowerShell Core when using Jenkins on a Linux host. By following the steps outlined in this article, you can improve the readability and usability of the PowerShell Core terminal window.
References
- PowerShell Core on Linux truncating output to 80 columns: https://stackoverflow.com/questions/37969686/powershell-core-on-linux-truncating-output-to-80-columns
- PowerShell Core profile file: https://docs.microsoft.com/en-us/powershell/core/customizing/profile?view=powershell-7.1#powershell-core-profile-locations
- PowerShell Core host UI: https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.host.pshostuserinterface?view=powershell-7.1
Summary
- The default terminal size of PowerShell Core on Linux hosts can be changed to improve readability and usability.
- The issue of truncating output in PowerShell Core on Windows hosts has been resolved.
- To change the default terminal size on Linux hosts, you can define a function called
Resize-Hostin the PowerShell Core profile file and call the function to set the terminal window size. - The buffer size and window size can be adjusted to suit your needs.
- The changes take effect after restarting the PowerShell Core terminal window.
Types of References
- Stack Overflow post
- Microsoft documentation
HTML Unordered List
- https://stackoverflow.com/questions/37969686/powershell-core-on-linux-truncating-output-to-80-columns
- https://docs.microsoft.com/en-us/powershell/core/customizing/profile?view=powershell-7.1#powershell-core-profile-locations
- https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.host.pshostuserinterface?view=powershell-7.1