Fish Shell Port and File Utilities
A set of Fish shell functions to list listening ports, interactively kill processes by port, and create timestamped file backups.
Fish Shell Port and File Utilities
A set of Fish shell functions to list listening ports, interactively kill processes by port, and create timestamped file backups.
This script adds three convenient utilities to your Fish shell: ports
to see what's running, pkillport
to stop a process, and backup
for quick file snapshots.
The ports
function requires either lsof
or ss
to be installed on your system. The pkillport
function requires fzf
(a command-line fuzzy finder) for its interactive menu.
Installation
Save the script's content to a file in your Fish functions directory, for example, ~/.config/fish/functions/utils.fish
. Fish will automatically load the functions in new shell sessions. You do not need to source it manually.
Usage
ports
- List Listening Ports
Run this command to get a colorized list of all processes currently listening on TCP ports. It shows the PID, process name, port number, and the full command.
Example Command:
Example Output:
pkillport
- Interactively Kill a Process by Port
This command displays an interactive fzf
menu of listening ports. You can fuzzy-find a process, see a preview of what will be killed, and press Enter to select. It will then ask for confirmation before killing the process.
Example Command:
This will open a screen where you can type to filter and use arrow keys to select a process to terminate.
backup
- Create a Timestamped Backup
Creates a quick backup of any file. A timestamp in YYYYMMDD-HHMMSS
format is appended to the original filename.
Example Command:
Example Output: