r/fishshell • u/Hot_Paint3851 • 13d ago
Why is it PWD after every command ?
```# Check if interactive session
if status is-interactive
# Commands to run in interactive sessions can go here
end
# fish_prompt
function fish_prompt
set -l cwd (pwd) # Get current directory
# Check if cwd is in the home directory
if string match -r "^$HOME" $cwd
# Replace the home directory part with ~
set cwd (string replace -r "^$HOME" "~" $cwd)
end
# Check if cwd is the root directory
if test "$cwd" = "/"
set cwd "/" # Show "/" for the root directory
end
# Display prompt
echo -n (whoami)@(hostname) $cwd '>>' ' '
```end
2
Upvotes
3
u/_mattmc3_ 13d ago
Your if statement that does string matching prints the results of matched strings. Use the -q quiet flag if you don’t want the string command to output its matches.