ft: home-manager terminal
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
};
|
||||
hardware.tuxedo-drivers.enable = true;
|
||||
|
||||
# FIXME: this patch does not work
|
||||
# adds a `stretch_aspect` scaler (Valve/gamescope#927) and lets `--rt` use the
|
||||
# rtprio limit from modules/gaming.nix instead of CAP_SYS_NICE.
|
||||
# nixpkgs.overlays = [
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
yad
|
||||
brightnessctl
|
||||
grim
|
||||
file
|
||||
tree
|
||||
];
|
||||
|
||||
|
||||
@@ -53,22 +53,35 @@
|
||||
vim
|
||||
];
|
||||
|
||||
# TODO: switch to home manager
|
||||
# home-manager = {
|
||||
# useGlobalPkgs = true;
|
||||
# useUserPackages = true;
|
||||
# extraSpecialArgs = { inherit inputs; };
|
||||
# # Move a file home-manager would overwrite aside instead of failing.
|
||||
# backupFileExtension = "backup";
|
||||
#
|
||||
# users.djai = {
|
||||
# home.stateVersion = "26.05";
|
||||
# programs.home-manager.enable = true;
|
||||
#
|
||||
# # TODO: unified ssh-config secret
|
||||
# home.file.".ssh/config".text = ''
|
||||
# Include ${config.sops.secrets."ssh-config".path}
|
||||
# '';
|
||||
# };
|
||||
# };
|
||||
home-manager = {
|
||||
useGlobalPkgs = true;
|
||||
useUserPackages = true;
|
||||
extraSpecialArgs = { inherit inputs; };
|
||||
backupFileExtension = "bck";
|
||||
|
||||
users."djai" = {
|
||||
programs.home-manager.enable = true;
|
||||
|
||||
home.file.".ssh/config".text = ''
|
||||
Include ${config.sops.secrets."ssh-config".path}
|
||||
'';
|
||||
|
||||
home = {
|
||||
stateVersion = "26.05";
|
||||
sessionPath = [
|
||||
"$HOME/bin"
|
||||
"$HOME/.local/bin"
|
||||
"$HOME/.cargo/bin"
|
||||
"$HOME/Scripts"
|
||||
];
|
||||
|
||||
sessionVariables = {
|
||||
NEWT_COLORS_FILE = "$HOME/.newtColours";
|
||||
BROWSER = "librewolf";
|
||||
EDITOR = "nvim";
|
||||
STARSHIP_LOG = "error";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
hyprpicker
|
||||
hyprsunset
|
||||
wf-recorder
|
||||
grimblast
|
||||
wmctrl
|
||||
hyprprop
|
||||
hyprlandPlugins.hypr-darkwindow
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
imports = [
|
||||
./fish.nix
|
||||
./kitty.nix
|
||||
];
|
||||
|
||||
environment.defaultPackages = with pkgs; [
|
||||
fbterm
|
||||
kitty
|
||||
starship
|
||||
];
|
||||
|
||||
# TODO: switch to home manager
|
||||
# keeping these here so root also benefits
|
||||
programs.fish.enable = true;
|
||||
programs.tmux = {
|
||||
enable = true;
|
||||
@@ -18,19 +23,4 @@
|
||||
resurrect
|
||||
];
|
||||
};
|
||||
|
||||
# home-manager.users.djai = {
|
||||
# programs.fish.enable = true;
|
||||
# programs.tmux.enable = true;
|
||||
#
|
||||
# programs.kitty = {
|
||||
# enable = true;
|
||||
# settings = {
|
||||
# shell = "${pkgs.tmux}/bin/tmux";
|
||||
# font_family = "Iosevka Nerd Font";
|
||||
# };
|
||||
# extraConfig = ""; # TODO theming
|
||||
# };
|
||||
#
|
||||
# };
|
||||
}
|
||||
|
||||
8
modules/terminal/fish-config/bulkpaste.fish
Normal file
8
modules/terminal/fish-config/bulkpaste.fish
Normal file
@@ -0,0 +1,8 @@
|
||||
case Hyprland
|
||||
hyprctl dispatch 'hl.dsp.focus({ direction = "left" })'
|
||||
for i in (ls | grep "$argv[1]")
|
||||
sleep 0.05
|
||||
copy "$i"
|
||||
sleep 0.05
|
||||
hyprctl dispatch 'hl.dsp.send_shortcut({ mods = "CTRL", key = "v" })'
|
||||
end
|
||||
6
modules/terminal/fish-config/copy.fish
Normal file
6
modules/terminal/fish-config/copy.fish
Normal file
@@ -0,0 +1,6 @@
|
||||
switch "$XDG_SESSION_TYPE"
|
||||
case wayland
|
||||
echo "file://$(realpath -- "$argv")" | wl-copy -t text/uri-list
|
||||
case x11
|
||||
echo "file://$(realpath -- "$argv")" | xclip -i -selection clipboard -t text/uri-list
|
||||
end
|
||||
9
modules/terminal/fish-config/files.fish
Normal file
9
modules/terminal/fish-config/files.fish
Normal file
@@ -0,0 +1,9 @@
|
||||
if test -z "$argv[1]"
|
||||
set dir '.'
|
||||
else
|
||||
set dir "$argv[1]"
|
||||
end
|
||||
for i in (find "$dir" -maxdepth 1 -type d )
|
||||
set b (find "$i" -type f| wc -l)
|
||||
printf "%d/%s\n" $b (basename "$i")
|
||||
end | sort -nr | column -ts/
|
||||
4
modules/terminal/fish-config/fmf.fish
Normal file
4
modules/terminal/fish-config/fmf.fish
Normal file
@@ -0,0 +1,4 @@
|
||||
set dest "$(fzf)"
|
||||
if test $status -eq 0
|
||||
cd "$(realpath (dirname "$dest"))"
|
||||
end
|
||||
3
modules/terminal/fish-config/histdelete.fish
Normal file
3
modules/terminal/fish-config/histdelete.fish
Normal file
@@ -0,0 +1,3 @@
|
||||
string match -qr '^(exit|ls$|clear)' -- $argv
|
||||
and history delete --exact --case-sensitive -- (string trim -r $argv)
|
||||
|
||||
1
modules/terminal/fish-config/move.fish
Normal file
1
modules/terminal/fish-config/move.fish
Normal file
@@ -0,0 +1 @@
|
||||
rename.sh "$argv"
|
||||
5
modules/terminal/fish-config/nshell.fish
Normal file
5
modules/terminal/fish-config/nshell.fish
Normal file
@@ -0,0 +1,5 @@
|
||||
if test -n "$argv"
|
||||
eval "nix-shell --run fish -p" (string join -- " -p " $argv)
|
||||
else
|
||||
nix-shell --run fish
|
||||
end
|
||||
12
modules/terminal/fish-config/ranger.fish
Normal file
12
modules/terminal/fish-config/ranger.fish
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
set tempfile '/tmp/chosendir'
|
||||
command ranger --choosedir=$tempfile (pwd) $argv
|
||||
|
||||
if test -f $tempfile
|
||||
if [ (cat $tempfile) != (pwd) ]
|
||||
cd (cat $tempfile)
|
||||
end
|
||||
end
|
||||
|
||||
rm -f $tempfile
|
||||
|
||||
2
modules/terminal/fish-config/run.fish
Normal file
2
modules/terminal/fish-config/run.fish
Normal file
@@ -0,0 +1,2 @@
|
||||
echo (cat -- "$argv")
|
||||
fish -c (cat -- "$argv")
|
||||
6
modules/terminal/fish-config/runl.fish
Normal file
6
modules/terminal/fish-config/runl.fish
Normal file
@@ -0,0 +1,6 @@
|
||||
if test -n "$argv[2]"
|
||||
echo (cat -- "$argv[1]" | sed -n $argv[2]p)
|
||||
fish -c (cat -- "$argv[1]" | sed -n $argv[2]p)
|
||||
else
|
||||
cat -n -- "$argv[1]"
|
||||
end
|
||||
2
modules/terminal/fish-config/secret.fish
Normal file
2
modules/terminal/fish-config/secret.fish
Normal file
@@ -0,0 +1,2 @@
|
||||
tr -dc A-Za-z0-9 </dev/urandom | head -c 32
|
||||
echo
|
||||
1
modules/terminal/fish-config/show_colour.fish
Normal file
1
modules/terminal/fish-config/show_colour.fish
Normal file
@@ -0,0 +1 @@
|
||||
perl -e 'foreach $a(@ARGV){print "\e[48:2::".join(":",unpack("C*",pack("H*",$a)))."m \e[49m "};print "\n"' "$argv"
|
||||
6
modules/terminal/fish-config/sudo.fish
Normal file
6
modules/terminal/fish-config/sudo.fish
Normal file
@@ -0,0 +1,6 @@
|
||||
if test "$argv" = !!
|
||||
echo sudo $history[1]
|
||||
eval command sudo $history[1]
|
||||
else
|
||||
command sudo $argv
|
||||
end
|
||||
7
modules/terminal/fish-config/tmux-updater.fish
Normal file
7
modules/terminal/fish-config/tmux-updater.fish
Normal file
@@ -0,0 +1,7 @@
|
||||
if set -q TMUX
|
||||
set -l name (tmux display -p '#{session_name}')
|
||||
if test -n "$name"; and string match -qr '^[0-9]+' -- $name
|
||||
set num (string match -rim 1 "[0-9]*" -- $name)
|
||||
tmux rename-session "$num: cmd: $argv[1]" 2>/dev/null
|
||||
end
|
||||
end
|
||||
10
modules/terminal/fish-config/yazi.fish
Normal file
10
modules/terminal/fish-config/yazi.fish
Normal file
@@ -0,0 +1,10 @@
|
||||
set tempfile /tmp/chosendir
|
||||
command yazi cwd-file=$tempfile (pwd) $argv
|
||||
|
||||
if test -f $tempfile
|
||||
if [ (cat $tempfile) != (pwd) ]
|
||||
cd (cat $tempfile)
|
||||
end
|
||||
end
|
||||
|
||||
rm -f $tempfile
|
||||
87
modules/terminal/fish.nix
Normal file
87
modules/terminal/fish.nix
Normal file
@@ -0,0 +1,87 @@
|
||||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
# automatically discover functions in the relative fish functions directory
|
||||
fishFuncDir = ./fish-config/functions;
|
||||
fishFuncs = lib.attrsets.mapAttrs'
|
||||
(name: _: lib.nameValuePair (lib.strings.removeSuffix ".fish" "${name}") ({
|
||||
body = builtins.readFile (fishFuncDir + "/${name}");
|
||||
}))
|
||||
(lib.attrsets.filterAttrs
|
||||
(name: type: type == "regular")
|
||||
(builtins.readDir fishFuncDir)
|
||||
);
|
||||
in
|
||||
{
|
||||
home-manager.users.djai.programs.fish = {
|
||||
enable = true;
|
||||
binds = {
|
||||
"\cf" = {
|
||||
command = "forward-char";
|
||||
mode = "insert";
|
||||
};
|
||||
"\ef" = {
|
||||
command = "forward-word";
|
||||
mode = "insert";
|
||||
};
|
||||
};
|
||||
shellInit = ''
|
||||
# start fbterm if in raw tty
|
||||
if string match -qr "/dev/tty[2-9]" (tty)
|
||||
fbterm -- env TERM=fbterm tmux new
|
||||
end
|
||||
|
||||
[ -d "$HOME/.cargo/env.fish" ] && source "$HOME/.cargo/env.fish"
|
||||
'';
|
||||
|
||||
interactiveShellInit = ''
|
||||
fish_vi_key_bindings
|
||||
starship init fish | source
|
||||
fish_config theme choose "Catppuccin Macchiato"
|
||||
|
||||
if test -n "$TMUX"
|
||||
ascii.sh
|
||||
else
|
||||
if test "$TERM" != "linux"
|
||||
tmux new
|
||||
end
|
||||
end
|
||||
|
||||
# make clear also remove scrollback on kitty
|
||||
[ "(set -q TERM)" -a "$TERM" = "xterm-kitty" ] && alias clear "printf '\033[2J\033[3J\033[1;1H'"
|
||||
'';
|
||||
|
||||
loginShellInit = ''
|
||||
~/Scripts/diaryEntry.sh > /dev/null # TODO: move to somewhere
|
||||
'';
|
||||
|
||||
shellAbbrs = {
|
||||
"webcam" = "mpv av://v4l2:/dev/video0 --profile=low-latency --untimed";
|
||||
"venv" = ". .venv/bin/activate.fish";
|
||||
"rug" = "sudo openconnect --protocol=gp safenet.vpn.rug.nl";
|
||||
"dia" = "nvim (date +%F)";
|
||||
|
||||
"rm" = "rm -I";
|
||||
"mv" = "mv -vn";
|
||||
"make" = "make -j8";
|
||||
|
||||
"ll" = "ls -hlav --ignore=..";
|
||||
"l" = "ls -lav --ignore=.\?\*";
|
||||
"la" = "ls -A";
|
||||
|
||||
"lg" = "lazygit";
|
||||
"fih" = "fish";
|
||||
"twi" = "twitch";
|
||||
"keh" = "kitten icat";
|
||||
};
|
||||
|
||||
# discovered functions + overrides
|
||||
functions = fishFuncs // {
|
||||
tmux-updater = fishFuncs.tmux-updater // {onEvent = "fish_preexec";};
|
||||
histdelete = fishFuncs.histdelete // {onEvent = "fish_postexec";};
|
||||
};
|
||||
};
|
||||
home-manager.users."djai".home.shell.enableFishIntegration = true;
|
||||
|
||||
home.file.".config/fish/themes".source = config.lib.file.mkOutOfStoreSymLink ./fish-config/themes/;
|
||||
}
|
||||
46
modules/terminal/kitty.nix
Normal file
46
modules/terminal/kitty.nix
Normal file
@@ -0,0 +1,46 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
home-manager.users."djai".programs.kitty = {
|
||||
enable = true;
|
||||
keybindings = {
|
||||
"ctrl+shift+t" = "new_tab_with_cwd";
|
||||
"ctrl+shift+enter" = "new_window_with_cwd";
|
||||
"ctrl+shift+b" = "detach_window";
|
||||
|
||||
"ctrl+j" = "neighboring_window down";
|
||||
"ctrl+k" = "neighboring_window up";
|
||||
"ctrl+h" = "neighboring_window left";
|
||||
"ctrl+l" = "neighboring_window right";
|
||||
|
||||
"ctrl+shift+n" = "new_os_window_with_cwd";
|
||||
};
|
||||
themeFile = "Catppuccin-Macchiato";
|
||||
|
||||
settings = {
|
||||
shell = "${pkgs.fish}/bin/fish";
|
||||
font_family = "CaskaydiaCove Nerd Font Mono";
|
||||
close_on_child_death = true;
|
||||
enable_audio_bell = false;
|
||||
|
||||
window_padding_width = 6;
|
||||
tab_bar_min_tabs = 1;
|
||||
tab_bar_edge = "bottom";
|
||||
tab_bar_style = "powerline";
|
||||
tab_powerline_style = "slanted";
|
||||
tab_title_template = "{title}{' - {}'.format(num_windows) if num_windows > 1 else ''}";
|
||||
|
||||
allow_remote_control = "password";
|
||||
listen_on = "unix:@kitty";
|
||||
remote_control_password = " \"\" allow_safe.py"; # FIXME: seems to be borked on nixos
|
||||
};
|
||||
};
|
||||
|
||||
home-manager.users."djai".home.file.".config/kitty/allow_safe.py".text = ''
|
||||
#!/usr/bin/env python3
|
||||
def is_cmd_allowed(pcmd, window, from_socket, extra_data):
|
||||
if pcmd['cmd'] == "launch":
|
||||
return 'args' not in pcmd['payload']
|
||||
return False
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user