Posts for Tag: fish

'Fish Shell 2.1 messed up prompt'

If you upgraded to the [Fish Shell]( version 2.1 you might have noticed your prompt now containing a bunch of new lines (blank). I believe it's due to the fact that the **echo** command now produces a new line by default (even though that's not explicitly stated in the [release notes]( [1](#note).

To solve it, replace all ocurrences of echo in your Fish prompt function with **echo -n \**. This will tell echo to not end with a new line.

Happy Fish'ing ;)

1. Fish developers, correct me if i'm wrong please :)

FISH Shell - How to set tmux window/pane title based on current command and directory

Here's a neat trick: Setting the current tmux window/pane title to the current running command. In case there is no command running, show the current working directory. But trim it a little, so we don't end up with huge window titles :)

In your file add the following functions:

# Set the tmux window title, depending on whether we are running something, or just prompting function fish_title if [ "fish" != $_ ] tmux rename-window "$_ $argv" else tmux_directory_title end end

function tmux_directory_title if [ "$PWD" != "$LPWD" ] set LPWD "$PWD" set INPUT $PWD set SUBSTRING (eval echo $INPUT| awk '{ print substr( $0, length($0) - 19, length($0) ) }') tmux rename-window "..$SUBSTRING" end end

The first one is a special function called by fish on every command execution. I'm using it to see what is being ran ($_ gives you the command in execution). If it's fish itself, then call tmux\_directory\_title to set PWD as the title.

The second function - as explained - sets the title as grabbed from the current working directory (PWD). Except it performs a little AWKing to trim it down to 20 chars max (the last ones).