2024-01-12 20:59:08 +00:00
|
|
|
{pkgs, ...}: let
|
|
|
|
inputrc = pkgs.writeText "inputrc" ''
|
|
|
|
set completion-ignore-case on
|
|
|
|
'';
|
|
|
|
in {
|
|
|
|
home-manager.users.buffet = {
|
|
|
|
home.sessionVariables = {
|
|
|
|
INPUTRC = inputrc;
|
|
|
|
};
|
|
|
|
|
2024-05-09 15:07:49 +00:00
|
|
|
programs = {
|
|
|
|
direnv.enableBashIntegration = true;
|
|
|
|
fzf.enableBashIntegration = true;
|
2024-01-19 14:36:08 +00:00
|
|
|
|
2024-05-09 15:07:49 +00:00
|
|
|
bash = {
|
|
|
|
enable = true;
|
|
|
|
historyControl = ["erasedups" "ignorespace"];
|
2024-01-12 20:59:08 +00:00
|
|
|
|
2024-05-09 15:07:49 +00:00
|
|
|
shellAliases = {
|
|
|
|
e = "\"$EDITOR\"";
|
|
|
|
mkdir = "mkdir -p";
|
|
|
|
rg = "rg -S";
|
|
|
|
};
|
2024-01-12 20:59:08 +00:00
|
|
|
|
2024-05-09 15:07:49 +00:00
|
|
|
shellOptions = [
|
|
|
|
"cdspell"
|
|
|
|
"checkjobs"
|
|
|
|
"extglob"
|
|
|
|
"globstar"
|
|
|
|
"histappend"
|
|
|
|
"nocaseglob"
|
|
|
|
];
|
2024-01-12 20:59:08 +00:00
|
|
|
|
2024-05-09 15:07:49 +00:00
|
|
|
bashrcExtra = ''
|
|
|
|
[[ -f ~/.profile ]] && . ~/.profile
|
|
|
|
'';
|
2024-01-29 13:30:45 +00:00
|
|
|
|
2024-05-09 15:07:49 +00:00
|
|
|
initExtra = ''
|
2024-05-18 13:52:38 +00:00
|
|
|
gwa() {
|
|
|
|
[[ "$1" ]] || {
|
|
|
|
echo "required branch name argument" >&2
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
local repo="''${PWD##*/}"
|
|
|
|
local uuid="$(< /proc/sys/kernel/random/uuid)"
|
|
|
|
local basepath="$HOME/worktrees"
|
|
|
|
local path="$basepath/$repo-$uuid"
|
|
|
|
|
|
|
|
mkdir -p "$basepath"
|
|
|
|
git worktree add "$path" -b "$1" && cd "$path"
|
|
|
|
}
|
|
|
|
|
|
|
|
gwd() {
|
|
|
|
local res="$(
|
|
|
|
set -o pipefail
|
|
|
|
git worktree list | \
|
|
|
|
${pkgs.fzf}/bin/fzf --preview 'git log --color --decorate --oneline' \
|
|
|
|
--preview-window=up \
|
|
|
|
--cycle \
|
|
|
|
--query "$1" |\
|
|
|
|
cut -d' ' -f1
|
|
|
|
)"
|
|
|
|
|
|
|
|
[[ $? -eq 0 ]] && echo "$res" && git worktree remove "$res"
|
|
|
|
}
|
|
|
|
|
|
|
|
gwg() {
|
|
|
|
local res="$(
|
|
|
|
set -o pipefail
|
|
|
|
|
|
|
|
local trees="$(git worktree list | ${pkgs.fzf}/bin/fzf --filter "$1" --no-sort)"
|
|
|
|
if [[ "$(wc -l <<<"$trees")" -eq 1 ]]; then
|
|
|
|
printf '%s\n' "$trees"
|
|
|
|
else
|
|
|
|
printf '%s\n' "$trees" | \
|
|
|
|
${pkgs.fzf}/bin/fzf --preview='git log --color --decorate --oneline' \
|
|
|
|
--preview-window=up \
|
|
|
|
--cycle \
|
|
|
|
--query "$1"
|
|
|
|
fi | cut -d' ' -f1
|
|
|
|
)"
|
|
|
|
|
|
|
|
[[ $? -eq 0 ]] && echo "$res" && cd "$res"
|
|
|
|
}
|
|
|
|
|
2024-05-09 15:07:49 +00:00
|
|
|
__prompt() {
|
|
|
|
local status="$?"
|
|
|
|
local row
|
|
|
|
local col
|
2024-01-19 14:36:08 +00:00
|
|
|
|
2024-05-09 15:07:49 +00:00
|
|
|
IFS=';' read -rs -dR -p $'\e[6n' row col >/dev/tty
|
|
|
|
if [[ $col != 1 ]]; then
|
|
|
|
printf '%s' $'\e[0;7m%\n\e[0m'
|
|
|
|
fi
|
2024-01-19 14:36:08 +00:00
|
|
|
|
2024-05-09 15:07:49 +00:00
|
|
|
PS1='\[\e[0;1m\]['
|
2024-01-19 14:36:08 +00:00
|
|
|
|
2024-05-09 15:07:49 +00:00
|
|
|
case $status in
|
|
|
|
0) PS1+='\[\e[32m\]' ;;
|
|
|
|
*) PS1+='\[\e[31m\]' ;;
|
|
|
|
esac
|
2024-01-19 14:36:08 +00:00
|
|
|
|
2024-05-09 15:07:49 +00:00
|
|
|
if [[ "$PWD" == "$HOME" ]]; then
|
|
|
|
PS1+="~"
|
|
|
|
elif [[ "$PWD" == / ]]; then
|
|
|
|
PS1+=/
|
|
|
|
else
|
|
|
|
PS1+="''${PWD##*/}"
|
|
|
|
fi
|
2024-01-19 14:36:08 +00:00
|
|
|
|
2024-05-09 15:07:49 +00:00
|
|
|
PS1+='\[\e[0;1m\]]\[\e[0m\]'
|
2024-01-19 14:36:08 +00:00
|
|
|
|
2024-05-09 15:07:49 +00:00
|
|
|
[[ $CONTAINER_ID ]] && PS1+="'"
|
2024-01-19 14:36:08 +00:00
|
|
|
|
2024-05-09 15:07:49 +00:00
|
|
|
PS1+=' '
|
|
|
|
}
|
|
|
|
PROMPT_COMMAND=__prompt
|
2024-01-12 20:59:08 +00:00
|
|
|
|
2024-05-09 15:07:49 +00:00
|
|
|
bind '"\C-o": "\C-a\C-k fg; if [[ $? == 1 ]]; then nvim; fi\n"'
|
|
|
|
bind '"\e\C-m": "\C-e | nvim\C-m"'
|
|
|
|
'';
|
|
|
|
};
|
2024-01-12 20:59:08 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|