Skip to main content
Background Image
  1. Posts/

Custom welcome message script for Nushell

··336 words·2 mins· loading · loading ·
yuzjing
Author
yuzjing
Table of Contents

This is a custom welcome message script for Nushell, designed to replace the default startup banner and provide an information-rich dashboard about the system’s status each time the shell starts.

Features Overview
#

  • System Information: Displays the hostname, kernel version, and the current logged-in user.
  • Last Login: Shows the user information, source IP, and time of the last login to the system.
  • Resource Status:
    • CPU: Displays the CPU model and the real-time 1-minute, 5-minute, and 15-minute system load averages.
    • Memory: Shows used and total memory in GB, along with the usage percentage.
    • Disk: Shows used and total disk space in GB, along with the usage percentage.
  • Container Status:
    • Podman Containers: Summarizes the total number of discovered containers, as well as the number of running and exited containers.
    • Podman Pods: Summarizes the total number of discovered pods and the number of currently running pods.
  • Security Status:
    • Fail2ban: Presents four key metrics for Jails in a table: “Current failed,” “Total failed,” “Current banned,” and “Total banned.”

Dependencies
#

  • Core Utilities: uname, last, df (these are fundamental components of all modern Linux distributions).
  • Optional Utilities:
    • podman: If it is not installed or the service is not running, the relevant section will display a friendly warning message.
    • fail2ban-client: If it is not installed, the relevant section will display a warning.
    • sudo: To allow a non-root user to query the Fail2ban status, a sudo rule must be pre-configured.

Installation
#

  1. Back up your old configuration: Before making any changes, please back up your existing config.nu file.
    1cp ~/.config/nushell/config.nu ~/.config/nushell/config.nu.bak
    
  2. Replace the configuration: Copy the complete code below and entirely replace the contents of your ~/.config/nushell/config.nu file with it.
  3. (Optional, Not Recommended) Configure Sudo for Fail2ban: To allow a non-root user to see the Fail2ban status, use the sudo visudo command to add the following rule at the end of the file (please replace your_username with your actual username):
    1your_username ALL=(ALL) NOPASSWD: /usr/bin/fail2ban-client status
    
  4. Restart Nushell: Close and reopen your terminal to see the new custom welcome screen.

Source Code
#

https://github.com/yuzjing/devScripts/blob/main/nu_banner