Skip to content

Commit 06fe671

Browse files
Adrien FolieAdrien Folie
authored andcommitted
feat: replace fish by bash
1 parent da5b65d commit 06fe671

File tree

6 files changed

+64
-120
lines changed

6 files changed

+64
-120
lines changed

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
.PHONY: all re clean test fish git vim vifm tmux vscode
1+
.PHONY: all re clean test bash git vim vifm tmux vscode
22

3-
all: git vim tmux fish vifm vscode
3+
all: git vim tmux bash vifm vscode
44

55
re: clean all
66

@@ -10,8 +10,8 @@ clean:
1010
test:
1111
scripts/test.exp
1212

13-
fish:
14-
fish/install.sh
13+
bash:
14+
bash/install.sh
1515

1616
git:
1717
git/install.sh

bash/bashrc

Lines changed: 9 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -8,96 +8,13 @@ export TERM=xterm-256color
88
export LC_ALL=en_US.UTF-8
99
export PAGER=most
1010

11-
# Prompt configuration
12-
# Colors
13-
RESET="\[\033[0m\]"
14-
RED="\[\033[0;31m\]"
15-
YELLOW="\[\033[0;33m\]"
16-
BLUE="\[\033[0;34m\]"
17-
WHITE="\[\033[0;37m\]"
18-
GREEN="\[\033[0;32m\]"
19-
PURPLE="\[\033[0;35m\]"
20-
21-
# Git prompt symbols
22-
GIT_PROMPT_PREFIX="["
23-
GIT_PROMPT_SUFFIX="]"
24-
GIT_PROMPT_SEPARATOR="|"
25-
GIT_PROMPT_STAGED="$RED"
26-
GIT_PROMPT_CONFLICTS="$RED"
27-
GIT_PROMPT_CHANGED="$BLUE"
28-
GIT_PROMPT_UNTRACKED=""
29-
GIT_PROMPT_STASHED=""
30-
GIT_PROMPT_CLEAN="$GREEN"
31-
32-
# Git status function
33-
git_status() {
34-
local branch staged conflicts changed untracked stashed clean
35-
36-
# Get current branch
37-
branch=$(git symbolic-ref HEAD 2>/dev/null)
38-
if [[ -n "$branch" ]]; then
39-
branch=${branch##*/}
40-
41-
# Count staged files
42-
staged=$(git diff --staged --numstat | wc -l)
43-
# Count conflicts
44-
conflicts=$(git diff --name-only --diff-filter=U | wc -l)
45-
# Count changed files
46-
changed=$(git diff --numstat | wc -l)
47-
# Count untracked files
48-
untracked=$(git ls-files --others --exclude-standard | wc -l)
49-
# Check if stash exists
50-
if [[ -n $(git stash list) ]]; then
51-
stashed=1
52-
else
53-
stashed=0
54-
fi
55-
# Check if clean
56-
if [[ $staged -eq 0 && $conflicts -eq 0 && $changed -eq 0 && $untracked -eq 0 ]]; then
57-
clean=1
58-
else
59-
clean=0
60-
fi
61-
62-
# Build status string
63-
local status="$GIT_PROMPT_PREFIX$PURPLE$branch$RESET$GIT_PROMPT_SEPARATOR"
64-
65-
[[ $staged -gt 0 ]] && status+="$GIT_PROMPT_STAGED"
66-
[[ $conflicts -gt 0 ]] && status+="$GIT_PROMPT_CONFLICTS"
67-
[[ $changed -gt 0 ]] && status+="$GIT_PROMPT_CHANGED"
68-
[[ $untracked -gt 0 ]] && status+="$GIT_PROMPT_UNTRACKED"
69-
[[ $stashed -gt 0 ]] && status+="$GIT_PROMPT_STASHED"
70-
[[ $clean -eq 1 ]] && status+="$GIT_PROMPT_CLEAN"
71-
72-
echo -n "$status$RESET$GIT_PROMPT_SUFFIX"
73-
fi
74-
}
75-
76-
# Set prompt command
77-
PROMPT_COMMAND=__prompt_command
78-
79-
__prompt_command() {
80-
local EXIT="$?"
81-
local PATH_SHORT="${PWD/#$HOME/\~}"
82-
local TIME="\$(date +%R)"
83-
84-
PS1="$YELLOW$PATH_SHORT$RESET"
85-
86-
# Add git status if in a git repository
87-
if git rev-parse --git-dir > /dev/null 2>&1; then
88-
PS1+=" \$(git_status)"
89-
fi
90-
91-
PS1+="\n$WHITE$TIME$RESET \$ "
92-
}
93-
94-
# rbenv setup
11+
# Ruby
9512
if command -v rbenv >/dev/null 2>&1; then
9613
export PATH="$HOME/.rbenv/bin:$PATH"
9714
eval "$(rbenv init -)"
9815
fi
9916

100-
# nvm setup
17+
# Node
10118
export NVM_DIR="$HOME/.nvm"
10219
export NVM_DEFAULT_VERSION=20
10320

@@ -107,36 +24,32 @@ if [ -d "$NVM_DIR" ]; then
10724
command -v nvm >/dev/null 2>&1 && nvm use "$NVM_DEFAULT_VERSION" >/dev/null 2>&1
10825
fi
10926

110-
# golang configuration
27+
# Golang
11128
if command -v go >/dev/null 2>&1; then
11229
export GOPATH="$HOME/dev/go"
11330
fi
11431

115-
# brew configuration
32+
# Brew
11633
if command -v brew >/dev/null 2>&1; then
11734
alias python=/opt/homebrew/bin/python3
11835
fi
11936

120-
# PATH modifications
37+
# Rust
12138
if [ -d "$HOME/.cargo/bin" ]; then
12239
export PATH="$HOME/.cargo/bin:$PATH"
12340
fi
12441

125-
# Vi mode
12642
set -o vi
12743

12844
# Aliases
12945
alias ll='ls -lF'
13046
alias la='ls -lA'
13147
alias git='hub'
13248

133-
# Load all configurations from conf.d
134-
if [ -d "$HOME/.config/bash/conf.d" ]; then
135-
for file in "$HOME/.config/bash/conf.d"/*.sh; do
136-
[ -r "$file" ] && source "$file"
137-
done
49+
# Prompt setup
50+
if [ -f "$HOME/.config/bash/prompt.bash" ]; then
51+
source "$HOME/.config/bash/prompt.bash"
13852
fi
13953

14054
# Load local customizations if they exist
141-
[ -f "$HOME/.bashrc.local" ] && source "$HOME/.bashrc.local"
142-
55+
[ -f "$HOME/.bashrc.local" ] && source "$HOME/.bashrc.local"

bash/conf.d/tools.sh

Whitespace-only changes.

bash/install.sh

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,8 @@
1-
#!/bin/bash
2-
1+
#!/bin/sh
32
set -e
43

5-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6-
CONFIG_DIR="$HOME/.config/bash"
7-
8-
# Create necessary directories
9-
mkdir -p "$CONFIG_DIR/conf.d"
10-
11-
# Create symlinks
12-
ln -sf "$SCRIPT_DIR/bashrc" "$HOME/.bashrc"
13-
ln -sf "$SCRIPT_DIR/bash_profile" "$HOME/.bash_profile"
14-
ln -sf "$SCRIPT_DIR/conf.d" "$CONFIG_DIR/"
15-
16-
# Install dependencies if they don't exist
17-
command -v hub >/dev/null 2>&1 || echo "Warning: 'hub' is not installed. Install it for git alias functionality."
18-
command -v rbenv >/dev/null 2>&1 || echo "Warning: 'rbenv' is not installed. Install it for Ruby version management."
19-
20-
echo "Bash configuration installed successfully!"
21-
echo "Please restart your shell or run 'source ~/.bashrc' to apply changes."
4+
mkdir -p "$HOME/.config/bash"
225

6+
ln -sf "$PWD/bash/bashrc" "$HOME/.bashrc"
7+
ln -sf "$PWD/bash/bash_profile" "$HOME/.bash_profile"
8+
ln -sf "$PWD/bash/prompt.bash" "$HOME/.config/bash/prompt.bash"

bash/prompt.bash

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Color codes
2+
YELLOW='\[\e[0;33m\]'
3+
BLUE='\[\e[0;34m\]'
4+
MAGENTA='\[\e[1;35m\]'
5+
RED='\[\e[0;31m\]'
6+
GREEN='\[\e[1;32m\]'
7+
WHITE='\[\e[1;37m\]'
8+
RESET='\[\e[0m\]'
9+
10+
# Git status function (simplified for Bash)
11+
bash_git_prompt() {
12+
git rev-parse --is-inside-work-tree &>/dev/null || return
13+
14+
local branch
15+
branch=$(git symbolic-ref --quiet --short HEAD 2>/dev/null || git rev-parse --short HEAD 2>/dev/null)
16+
[ -z "$branch" ] && return
17+
18+
local staged conflicts changed untracked stashed clean
19+
staged=$(git diff --cached --numstat 2>/dev/null | wc -l)
20+
conflicts=$(git diff --name-only --diff-filter=U 2>/dev/null | wc -l)
21+
changed=$(git diff --numstat 2>/dev/null | wc -l)
22+
untracked=$(git ls-files --others --exclude-standard 2>/dev/null | wc -l)
23+
stashed=$(git stash list 2>/dev/null | wc -l)
24+
clean=0
25+
if [[ $staged -eq 0 && $conflicts -eq 0 && $changed -eq 0 && $untracked -eq 0 ]]; then
26+
clean=1
27+
fi
28+
29+
# Use raw ANSI codes, not Bash variables, for color in the status string
30+
local status
31+
status="[\033[1;35m${branch}\033[0m"
32+
33+
[[ $staged -ne 0 ]] && status+="|\033[0;31m● $staged\033[0m"
34+
[[ $conflicts -ne 0 ]] && status+="|\033[0;31m✖ $conflicts\033[0m"
35+
[[ $changed -ne 0 ]] && status+="|\033[0;34m✚ $changed\033[0m"
36+
[[ $untracked -ne 0 ]] && status+="|\033[0;33m…$untracked\033[0m"
37+
[[ $stashed -ne 0 ]] && status+="|\033[0;33m⚑ $stashed\033[0m"
38+
[[ $clean -eq 1 ]] && status+="|\033[1;32m✔\033[0m"
39+
40+
status+="]"
41+
echo -ne " $status"
42+
}
43+
44+
# Set PS1 to mimic your Fish prompt (use double quotes for variable expansion)
45+
PS1="${YELLOW}\w${RESET}\$(bash_git_prompt) \n${WHITE}\A${RESET} \$ "

fish/config.fish

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ end
1010

1111
# rbenv
1212
if type rbenv >/dev/null 2>&1
13-
source (rbenv init - | psub)
13+
status --is-interactive; and source (rbenv init -|psub)
1414
end
1515

1616
# golang

0 commit comments

Comments
 (0)