Skip to content

Instantly share code, notes, and snippets.

@zouhir
Created May 2, 2025 00:49
Show Gist options
  • Save zouhir/c937fb5e318352bed6b8334146e74095 to your computer and use it in GitHub Desktop.
Save zouhir/c937fb5e318352bed6b8334146e74095 to your computer and use it in GitHub Desktop.
I'd be happy to help you create a simple fish shell configuration. Let's break this down into manageable pieces to address your requirements.
## 1. Simple Two-Line Prompt with SSH Awareness
For a two-line prompt that indicates when you're SSH'd into your dev server, we can create a simple config file. Here's what we'll do:
1. First, let's create or edit your fish configuration file
2. Add a simple two-line prompt configuration
3. Make sure it shows when you're SSH'd into a server
## 2. Aliases File
We'll create a separate file for your aliases to keep things organized.
## 3. Sensible Defaults
I'll provide some basic sensible defaults that don't overcomplicate things.
Let me create these files for you:
### 1. Main Fish Configuration File
Let's create a `config.fish` file:
```fish
# Main fish configuration file: ~/.config/fish/config.fish
# Load aliases from separate file
source ~/.config/fish/aliases.fish
# Simple two-line prompt configuration
function fish_prompt
# First line
set_color blue
echo -n (prompt_pwd)
# Show SSH status if connected
if set -q SSH_CONNECTION
set_color red
echo -n " [SSH: "(hostname)"]"
end
# Git status (if in git directory)
if command -sq git && git rev-parse --is-inside-work-tree >/dev/null 2>&1
set_color yellow
echo -n " ("(git branch --show-current)")"
end
# Second line
echo
set_color green
echo -n '➜ '
set_color normal
end
# Sensible defaults
set -g fish_greeting "" # Disable greeting
set -g fish_color_command blue # Command color
set -g fish_color_error red # Error color
set -g fish_color_param cyan # Parameter color
# Enable command history
set -g fish_history save
```
### 2. Aliases File
Now let's create your aliases file:
```fish
# Fish aliases file: ~/.config/fish/aliases.fish
# Navigation shortcuts
alias .. 'cd ..'
alias ... 'cd ../..'
alias ll 'ls -lah'
alias la 'ls -A'
alias l 'ls -CF'
# System shortcuts
alias update 'sudo apt update && sudo apt upgrade'
alias cls 'clear'
# Git shortcuts
alias gs 'git status'
alias ga 'git add'
alias gc 'git commit'
alias gl 'git log --oneline'
alias gp 'git push'
# Server shortcut - modify with your server details
alias sshdev 'ssh username@your-dev-server'
```
### Installation Instructions
1. Create the fish configuration directory if it doesn't exist:
```
mkdir -p ~/.config/fish/
```
2. Save the first code block as `~/.config/fish/config.fish`
3. Save the second code block as `~/.config/fish/aliases.fish`
4. Make both files executable:
```
chmod +x ~/.config/fish/config.fish ~/.config/fish/aliases.fish
```
5. Restart your fish shell or run `source ~/.config/fish/config.fish`
This setup gives you:
- A simple two-line prompt showing your current directory on the first line
- Clear indication when you're SSH'd into a server (in red)
- Git branch information if you're in a git repository
- A clean second line with just a prompt indicator
- A separate aliases file that's easy to edit
- Some sensible defaults without overcomplicating things
Feel free to customize the colors, prompt symbols, or aliases based on your preferences!​​​​​​​​​​​​​​​​
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment