Posts for Tag:
shell

If you upgraded to the [Fish Shell](http://fishshell.com) 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](http://fishshell.com/release_notes.html)) [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.

- What this does is pipe the result of the echoTask (which will run **echo "\"**) as input (standard) to the mdTask, which will run **multimarkdown --snippet**;
- The outPipe will simply take the output of the mdTask so we can return what multimarkdown created;
- The commands need the full path in order for the tasks to run;
- In case you are curious, i'm creating a markdown editor for OSX with realtime preview inline;
- If you want to test this particular piece of code as-is, make sure you [install multimarkdown for OSX first](http://fletcherpenney.net/multimarkdown/download/).

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 config.fish 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

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).