#!/bin/bash # put this in your .bashrc # This function updates the xterm title # whenever we complete a foo command, ie # # % foo some-args # # This invokes fooF() and prints "some-args" # in the xterm title bar. # # Designed to be used together with readline, # where we redefine the behaviour of RETURN # Don't forget to turn off the bell too! function fooF() { echo -ne "\033]0;bash: ${COMP_LINE:4}\007" unset -v COMPREPLY } # now bind this function to foo complete -F fooF foo # and reprogram the enter key #(uses emacs keybindings) bind 'RETURN: "\C-afoo \t\b\b\b\b\C-e\n"' bind 'set bell-style none'