mirror of
https://github.com/oddlama/nix-config.git
synced 2025-10-11 07:10:39 +02:00
feat: reactivate zsh and add plugins from my previous config
This commit is contained in:
parent
7307d0aa43
commit
15210f06b4
11 changed files with 115 additions and 156 deletions
|
@ -32,10 +32,6 @@ in {
|
|||
[
|
||||
".local/share/nix" # Repl history
|
||||
]
|
||||
# TODO away once atuin is gone
|
||||
++ optionals config.programs.atuin.enable [
|
||||
".local/share/atuin"
|
||||
]
|
||||
++ optionals nixosConfig.programs.steam.enable [
|
||||
".local/share/Steam"
|
||||
".steam"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{...}: {
|
||||
imports = [
|
||||
./nushell.nix
|
||||
./starship.nix
|
||||
./nushell
|
||||
./zsh
|
||||
];
|
||||
|
||||
|
@ -23,9 +23,4 @@
|
|||
tmux = "tmux -2";
|
||||
rg = "rg -S";
|
||||
};
|
||||
|
||||
programs.atuin = {
|
||||
enable = true;
|
||||
settings.auto_sync = false;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
# FIXME: ctrl-del not working
|
||||
# FIXME: DEL also deletes to the left :(
|
||||
# FIXME: ignore certain history entries (" .*", ...)
|
||||
programs.fish = {
|
||||
enable = true;
|
||||
interactiveShellInit = lib.mkMerge [
|
||||
(lib.mkBefore ''
|
||||
set -g ATUIN_NOBIND true
|
||||
set -g fish_greeting
|
||||
'')
|
||||
(lib.mkAfter ''
|
||||
bind \cr _atuin_search
|
||||
atuin gen-completions --shell fish | source
|
||||
|
||||
bind \e\[A history-prefix-search-backward
|
||||
bind \e\[B history-prefix-search-forward
|
||||
'')
|
||||
];
|
||||
plugins = [
|
||||
{
|
||||
name = "fzf";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "oddlama";
|
||||
repo = "fzf.fish";
|
||||
rev = "63c8f8e65761295da51029c5b6c9e601571837a1";
|
||||
sha256 = "036n50zr9kyg6ad408zn7wq2vpfwhmnfwab465km4dk60ywmrlcb";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
|
@ -8,8 +8,4 @@
|
|||
home.persistence."/persist".directories = [
|
||||
".config/nushell"
|
||||
];
|
||||
|
||||
# XXX: remove once removed. DEBOALOGR
|
||||
programs.starship.enableNushellIntegration = false;
|
||||
programs.atuin.enableNushellIntegration = false;
|
||||
}
|
|
@ -29,9 +29,9 @@
|
|||
show_always = true;
|
||||
};
|
||||
hostname = {
|
||||
format = "[$ssh_symbol$hostname]($style)";
|
||||
format = "[$hostname]($style)[$ssh_symbol](green)";
|
||||
ssh_only = false;
|
||||
ssh_symbol = "->";
|
||||
ssh_symbol = "";
|
||||
style = "cyan";
|
||||
};
|
||||
directory = {
|
||||
|
|
|
@ -10,57 +10,47 @@
|
|||
'';
|
||||
dotDir = ".config/zsh";
|
||||
history = {
|
||||
path = "/dev/null";
|
||||
save = 0;
|
||||
size = 0;
|
||||
path = "\${XDG_DATA_HOME-$HOME/.local/share}/zsh/history";
|
||||
save = 1000500;
|
||||
size = 1000000;
|
||||
};
|
||||
initExtra = lib.mkMerge [
|
||||
(lib.mkBefore ''
|
||||
unset HISTFILE
|
||||
'')
|
||||
(lib.mkAfter (''
|
||||
function atuin-prefix-search() {
|
||||
local out
|
||||
if out=$(${pkgs.sqlite}/bin/sqlite3 -readonly ~/.local/share/atuin/history.db \
|
||||
'SELECT command FROM history WHERE command LIKE cast('"x'$(str_to_hex "$_atuin_search_prefix")'"' as text) || "%" ORDER BY timestamp DESC LIMIT 1 OFFSET '"$_atuin_search_offset"); then
|
||||
[[ -z "$out" ]] && return 1
|
||||
BUFFER=$out
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}; zle -N atuin-prefix-search
|
||||
''
|
||||
+ lib.readFile ./zshrc))
|
||||
];
|
||||
initExtra = lib.readFile ./zshrc;
|
||||
plugins = [
|
||||
{
|
||||
# Must be before plugins that wrap widgets, such as zsh-autosuggestions or fast-syntax-highlighting
|
||||
name = "fzf-tab";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "Aloxaf";
|
||||
repo = "fzf-tab";
|
||||
rev = "69024c27738138d6767ea7246841fdfc6ce0d0eb";
|
||||
sha256 = "07wwcplyb2mw10ia9y510iwfhaijnsdcb8yv2y3ladhnxjd6mpf8";
|
||||
};
|
||||
src = pkgs.zsh-fzf-tab;
|
||||
}
|
||||
{
|
||||
name = "fast-syntax-highlighting";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "zdharma-continuum";
|
||||
repo = "fast-syntax-highlighting";
|
||||
rev = "7c390ee3bfa8069b8519582399e0a67444e6ea61";
|
||||
sha256 = "0gh4is2yzwiky79bs8b5zhjq9khksrmwlaf13hk3mhvpgs8n1fn0";
|
||||
};
|
||||
src = pkgs.zsh-fast-syntax-highlighting;
|
||||
}
|
||||
{
|
||||
name = "zsh-autosuggestions";
|
||||
src = pkgs.zsh-autosuggestions;
|
||||
}
|
||||
{
|
||||
name = "zsh-histdb";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "zsh-users";
|
||||
repo = "zsh-autosuggestions";
|
||||
rev = "a411ef3e0992d4839f0732ebeb9823024afaaaa8";
|
||||
sha256 = "1g3pij5qn2j7v7jjac2a63lxd97mcsgw6xq6k5p7835q9fjiid98";
|
||||
owner = "larkery";
|
||||
repo = "zsh-histdb";
|
||||
rev = "30797f0c50c31c8d8de32386970c5d480e5ab35d";
|
||||
hash = "sha256-PQIFF8kz+baqmZWiSr+wc4EleZ/KD8Y+lxW2NT35/bg=";
|
||||
};
|
||||
}
|
||||
{
|
||||
name = "zsh-histdb-skim";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "m42e";
|
||||
repo = "zsh-histdb-skim";
|
||||
rev = "3af19b6ec38b93c85bb82a80a69bec8b0e050cc5";
|
||||
hash = "sha256-lJ2kpIXPHE8qP0EBnLuyvatWMtepBobNAC09e7itGas=";
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
home.persistence."/persist".directories = [
|
||||
".local/share/zsh" # History
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,65 +1,86 @@
|
|||
autoload -U add-zle-hook-widget
|
||||
|
||||
# --------------------------------------------------------------------------------
|
||||
# FZF widgets
|
||||
|
||||
function __fzf() {
|
||||
if [[ -n "$TMUX_PANE" && ( "${FZF_TMUX:-0}" != 0 || -n "$FZF_TMUX_OPTS" ) ]]; then
|
||||
fzf-tmux -d"${FZF_TMUX_HEIGHT:-40%}" -- "$@"
|
||||
else
|
||||
fzf "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
function __fzf_select() {
|
||||
setopt localoptions pipefail no_aliases 2>/dev/null
|
||||
local item
|
||||
FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore,tab:down,btab:up,change:top,ctrl-space:toggle $FZF_DEFAULT_OPTS" __fzf "$@" | while read item; do
|
||||
echo -n "${(q)item} "
|
||||
done
|
||||
local ret=$?
|
||||
echo
|
||||
return $ret
|
||||
}
|
||||
|
||||
function __fzf_find_files() {
|
||||
local include_hidden=${1:-0}
|
||||
local types=${2:-fdl}
|
||||
shift 2
|
||||
local type_selectors=()
|
||||
local i
|
||||
for (( i=0; i<${#types}; i++ )); do
|
||||
[[ "$i" -gt 0 ]] && type_selectors+=('-o')
|
||||
type_selectors+=('-type' "${types:$i:1}")
|
||||
done
|
||||
local hide_hidden_files=()
|
||||
if [[ $include_hidden == "0" ]]; then
|
||||
hide_hidden_files=('-path' '*/\.*' '-o')
|
||||
fi
|
||||
setopt localoptions pipefail no_aliases 2>/dev/null
|
||||
command find -L . -mindepth 1 \
|
||||
\( "${hide_hidden_files[@]}" -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \) -prune \
|
||||
-o \( "${type_selectors[@]}" \) -print \
|
||||
| __fzf_select "$@"
|
||||
}
|
||||
|
||||
function __fzf_find_files_widget_helper() {
|
||||
LBUFFER="${LBUFFER}$(__fzf_find_files "$@")"
|
||||
local ret=$?
|
||||
zle reset-prompt
|
||||
return $ret
|
||||
}
|
||||
|
||||
function fzf-select-file-or-dir() { __fzf_find_files_widget_helper 0 fdl -m; }; zle -N fzf-select-file-or-dir
|
||||
function fzf-select-file-or-dir-hidden() { __fzf_find_files_widget_helper 1 fdl -m; }; zle -N fzf-select-file-or-dir-hidden
|
||||
function fzf-select-dir() { __fzf_find_files_widget_helper 0 d -m; }; zle -N fzf-select-dir
|
||||
function fzf-select-dir-hidden() { __fzf_find_files_widget_helper 1 d -m; }; zle -N fzf-select-dir-hidden
|
||||
function fzf-cd() {
|
||||
local dir="$(__fzf_find_files 0 d +m)"
|
||||
if [[ -z "$dir" ]]; then
|
||||
zle redisplay
|
||||
return 0
|
||||
fi
|
||||
zle push-line # Clear buffer. Auto-restored on next prompt.
|
||||
BUFFER="cd -- $dir"
|
||||
zle accept-line
|
||||
local ret=$?
|
||||
unset dir # ensure this doesn't end up appearing in prompt expansion
|
||||
zle reset-prompt
|
||||
return $ret
|
||||
}
|
||||
zle -N fzf-cd
|
||||
|
||||
# --------------------------------------------------------------------------------
|
||||
# Keybinds
|
||||
|
||||
# Reset all keybinds and use "emacs" keybinds
|
||||
bindkey
|
||||
bindkey -d
|
||||
bindkey -e
|
||||
|
||||
function str_to_hex() {
|
||||
local str="$1"
|
||||
for (( i=0; i<${#str}; i++ )); do
|
||||
printf "%02x" "'${str:$i:1}"
|
||||
done
|
||||
}
|
||||
function atuin-beginning-search-any-end() {
|
||||
local reset_offset_to=$_atuin_search_offset
|
||||
if [[ -v _atuin_search_last_buffer ]] && [[ "$_atuin_search_last_buffer" == "$BUFFER" ]]; then
|
||||
_atuin_search_offset=$((_atuin_search_offset + $direction))
|
||||
else
|
||||
# You cannot start searching "forward", so instead we wan't to do nothing.
|
||||
[[ "$direction" == "-1" ]] && return 1
|
||||
|
||||
reset_offset_to=0
|
||||
_atuin_search_offset=0
|
||||
_atuin_search_prefix=$LBUFFER
|
||||
_atuin_search_original_cursor=$CURSOR
|
||||
_atuin_search_original_buffer=$BUFFER
|
||||
fi
|
||||
|
||||
# If the offset would become than zero we want to stop searching and reset the buffer,
|
||||
# since we essentiall pressed "down" past the first search
|
||||
if [[ "$_atuin_search_offset" -ge 0 ]] && zle atuin-prefix-search; then
|
||||
zle .end-of-line
|
||||
_atuin_search_last_buffer=$BUFFER
|
||||
else
|
||||
_atuin_search_offset=$reset_offset_to
|
||||
# Reset to original input line if the history lookup fails
|
||||
# while completing in "forward" direction (ArrowDown) i.e. the offset is 0
|
||||
if [[ $_atuin_search_offset == 0 ]]; then
|
||||
BUFFER=$_atuin_search_original_buffer
|
||||
CURSOR=$_atuin_search_original_cursor
|
||||
fi
|
||||
return 1
|
||||
fi
|
||||
}; zle -N atuin-beginning-search-any-end
|
||||
|
||||
function atuin-reset-search() {
|
||||
unset _atuin_search_last_buffer
|
||||
}; zle -N atuin-beginning-search-any-end
|
||||
add-zle-hook-widget line-init atuin-reset-search
|
||||
|
||||
function atuin-beginning-search-backward-end() {
|
||||
direction="1" atuin-beginning-search-any-end
|
||||
}; zle -N atuin-beginning-search-backward-end
|
||||
_zsh_autosuggest_bind_widget atuin-beginning-search-backward-end clear
|
||||
|
||||
function atuin-beginning-search-forward-end() {
|
||||
direction="-1" atuin-beginning-search-any-end
|
||||
}; zle -N atuin-beginning-search-forward-end
|
||||
_zsh_autosuggest_bind_widget atuin-beginning-search-forward-end clear
|
||||
if autoload history-search-end; then
|
||||
zle -N history-beginning-search-backward-end history-search-end
|
||||
zle -N history-beginning-search-forward-end history-search-end
|
||||
fi
|
||||
|
||||
function nop() {
|
||||
true
|
||||
|
@ -133,12 +154,12 @@ function setup_keybinds() {
|
|||
bindkeys keys_CtrlDelete kill-line
|
||||
bindkeys keys_AltDelete delete-word
|
||||
|
||||
bindkeys keys_Up atuin-beginning-search-backward-end
|
||||
bindkeys keys_Up history-beginning-search-backward-end
|
||||
bindkeys keys_ShiftUp up-line
|
||||
bindkeys keys_CtrlUp nop
|
||||
bindkeys keys_AltUp nop
|
||||
|
||||
bindkeys keys_Down atuin-beginning-search-forward-end
|
||||
bindkeys keys_Down history-beginning-search-forward-end
|
||||
bindkeys keys_ShiftDown down-line
|
||||
bindkeys keys_CtrlDown nop
|
||||
bindkeys keys_AltDown nop
|
||||
|
@ -159,9 +180,6 @@ function setup_keybinds() {
|
|||
bindkeys keys_PageDown nop
|
||||
bindkeys keys_ShiftPageDown nop
|
||||
|
||||
# atuin
|
||||
bindkey '^R' _atuin_search_widget
|
||||
|
||||
# fzf file and directory related expansions and functions
|
||||
bindkey '\ef' fzf-select-file-or-dir
|
||||
bindkey '\eF' fzf-select-file-or-dir-hidden
|
||||
|
@ -253,6 +271,13 @@ zstyle ':completion:*' special-dirs ..
|
|||
# --------------------------------------------------------------------------------
|
||||
# ZSH Options
|
||||
|
||||
# Ignore certain commands in history
|
||||
HISTORY_IGNORE_REGEX='^(.|. |..|.. |rm .*|rmd .*|git fixup.*|git unstash|git stash.*|git checkout -f.*)$'
|
||||
function zshaddhistory() {
|
||||
emulate -L zsh
|
||||
[[ ! $1 =~ "$HISTORY_IGNORE_REGEX" ]]
|
||||
}
|
||||
|
||||
# Emit an error when a glob has no match
|
||||
setopt nomatch
|
||||
# Don't use extended globbing
|
||||
|
@ -292,10 +317,3 @@ setopt auto_list
|
|||
setopt auto_menu
|
||||
# Move cursor to end of word if there was only one match
|
||||
setopt always_to_end
|
||||
|
||||
# Ignore certain commands in history
|
||||
HISTORY_IGNORE_REGEX='^(.|. |..|.. |rm .*|rmd .*|git fixup.*|git unstash|git stash.*|git checkout -f.*)$'
|
||||
function zshaddhistory() {
|
||||
emulate -L zsh
|
||||
[[ ! $1 =~ "$HISTORY_IGNORE_REGEX" ]]
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
programs = {
|
||||
bat = {
|
||||
enable = true;
|
||||
config.theme = "base16";
|
||||
config.theme = "TwoDark";
|
||||
};
|
||||
fzf.enable = true;
|
||||
gpg.enable = true;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
./config/htop.nix
|
||||
./config/impermanence.nix
|
||||
./config/neovim.nix
|
||||
./config/nushell
|
||||
./config/shell
|
||||
./config/utils.nix
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue