Skip to content

Commit

Permalink
{hosts/nixos/home,modules/hm/terminals/{default,ghosty}}: add ghostty
Browse files Browse the repository at this point in the history
Finally, a GOOD terminal, and it's still only on version 1.0.1. It is
already pretty much good to go; there are still some features that are
missing or need some polishing, and the zero-configuration philosophy is
still not fully there yet. *BUT* nevertheless, even in the current
state, the terminal is phenomenal
  • Loading branch information
DontEatOreo committed Jan 2, 2025
1 parent 9b37f5f commit fa9a11d
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 41 deletions.
2 changes: 0 additions & 2 deletions hosts/nixos/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ in
defaultSopsFile = ../../secrets/secrets.yaml;
};
}

inputs.xremap-flake.nixosModules.default
];
};
}
48 changes: 48 additions & 0 deletions hosts/nixos/home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
../../modules/home-manager/config/starship.nix
inputs.sops-nix.homeManagerModules.sops
inputs.catppuccin.homeManagerModules.catppuccin
inputs.xremap-flake.homeManagerModules.default
{
catppuccin = {
enable = true;
Expand All @@ -45,6 +46,10 @@
fastfetch.enable = true;
firefox.enable = true;
fzf.enable = true;
ghostty = {
enable = true;
theme.flavor = config.catppuccin.flavor;
};
git.enable = true;
mpv.enable = true;
nixcord = {
Expand Down Expand Up @@ -75,6 +80,49 @@

home.stateVersion = "24.11";
}
{
xremap.withGnome = true;
xremap.config.keymap = [
{
name = "Swap CapsLock and Escape Keys";
remap = {
"CapsLock" = "Esc";
"Esc" = "CapsLock";
};
}
{
name = "Ctrl+Arrows for Start/End of Line";
remap = {
"Ctrl-Left" = "Home";
"Ctrl-Right" = "End";
};
}
{
name = "Alt+Arrows for Jumping Between Words";
remap = {
"Alt-Left" = "Ctrl-Left";
"Alt-Right" = "Ctrl-Right";
};
}
{
name = "Ctrl+Up/Down for Start/End of Page";
remap = {
"Ctrl-Up" = "Ctrl-Home";
"Ctrl-Down" = "Ctrl-End";
};
}
{
name = "Restore original key behavior in Ghostty";
application.only = [ "ghostty" ];
remap = {
"Alt-Left" = "Alt-Left";
"Alt-Right" = "Alt-Right";
"Ctrl-Left" = "Ctrl-Left";
"Ctrl-Right" = "Ctrl-Right";
};
}
];
}
];
};
extraSpecialArgs = {
Expand Down
40 changes: 1 addition & 39 deletions hosts/nixos/services.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{ username, ... }:
{
_: {
services = {
libinput = {
enable = true;
Expand All @@ -14,42 +13,5 @@
openssh = {
enable = true;
};
xremap = {
withGnome = true;
serviceMode = "user";
userName = username;
config = {
keymap = [
{
name = "Swap CapsLock and Escape Keys";
remap = {
"CapsLock" = "Esc";
"Esc" = "CapsLock";
};
}
{
name = "Ctrl+Arrows for Start/End of Line";
remap = {
"Ctrl-Left" = "Home";
"Ctrl-Right" = "End";
};
}
{
name = "Alt+Arrows for Jumping Between Words";
remap = {
"Alt-Left" = "Ctrl-Left";
"Alt-Right" = "Ctrl-Right";
};
}
{
name = "Ctrl+Up/Down for Start/End of Page";
remap = {
"Ctrl-Up" = "Ctrl-Home";
"Ctrl-Down" = "Ctrl-End";
};
}
];
};
};
};
}
1 change: 1 addition & 0 deletions modules/home-manager/terminals/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
_: {
imports = [
./bash.nix
./ghostty.nix
./zsh.nix
];
}
131 changes: 131 additions & 0 deletions modules/home-manager/terminals/ghostty.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
{
pkgs,
lib,
config,
...
}:
let
inherit (pkgs.stdenvNoCC.hostPlatform) isDarwin;
in
{

options.hm.ghostty = {
enable = lib.mkEnableOption "Ghostty";
theme = {
flavor = lib.mkOption {
type = lib.types.str;
default = config.catppuccin.flavor;
description = "Catppuccin flavor for dark mode";
};
};
};

config = lib.mkIf config.hm.ghostty.enable {
programs.ghostty = {
enable = true;
enableBashIntegration = true;
enableZshIntegration = true;
clearDefaultKeybinds = true;
settings =
let
superKey = if isDarwin then "super" else "ctrl";
in
{
# General
## Font
font-family = "MonaspiceKr Nerd Font";
font-size = 18;

## Theme
theme = "catppuccin-${config.hm.ghostty.theme.flavor}";

## Scroll
scrollback-limit =
let
mkMillion = m: m * 1000000;
in
mkMillion 100;

## Mouse & Cursor
cursor-style-blink = false;
mouse-scroll-multiplier = 3;

# Line height
adjust-underline-position = 4;

## Keybinds
keybind =
let
mkSuper = k: c: "${superKey}+${k}=${c}";
mkSuperShift = k: c: "${superKey}+shift+${k}=${c}";
mkSuperShiftNested =
p: k: c:
"${superKey}+shift+${p}>${k}=${c}";
in
[
# Cursor Movement
(mkSuper "left" "text:\\x01") # Move cursor start of line
(mkSuper "right" "text:\\x05") # Move cursor end of line
("alt+left=csi:1;5D") # Move cursor one word left
("alt+righ=csi:1;5C") # Move cursor one word right

# Split Management
## Creation
(mkSuper "t" "new_tab")
(mkSuperShiftNested "s" "up" "new_split:up")
(mkSuperShiftNested "s" "down" "new_split:down")
(mkSuperShiftNested "s" "left" "new_split:left")
(mkSuperShiftNested "s" "right" "new_split:right")

## Navigation
(mkSuperShift "up" "goto_split:top")
(mkSuperShift "down" "goto_split:bottom")
(mkSuperShift "left" "goto_split:left")
(mkSuperShift "right" "goto_split:right")

## Resizing
(mkSuperShiftNested "r" "up" "resize_split:up,30")
(mkSuperShiftNested "r" "down" "resize_split:down,30")
(mkSuperShiftNested "r" "left" "resize_split:left,30")
(mkSuperShiftNested "r" "right" "resize_split:right,30")
(mkSuperShift "e" "equalize_splits")

# Screen Management
(mkSuperShift "g" "write_screen_file:open")
(mkSuper "k" "clear_screen")
(mkSuper "home" "scroll_page_up")
(mkSuper "end" "scroll_page_down")

# Font Size Control
(mkSuper "plus" "increase_font_size:1")
(mkSuper "equal" "increase_font_size:1")
(mkSuper "minus" "decrease_font_size:1")
(mkSuper "_" "decrease_font_size:1")
(mkSuper "0" "reset_font_size")

## Clipboard
(mkSuperShift "c" "copy_to_clipboard")
(mkSuperShift "v" "paste_from_clipboard")

# Misc
(mkSuper "a" "select_all")
(mkSuperShift "," "reload_config")
]
++
# Tab Navigation (1-9)
(map (n: mkSuper (toString n) ("goto_tab:" + toString n)) (lib.range 1 9));

# Misc
confirm-close-surface = false;
quit-after-last-window-closed = true;
clipboard-paste-protection = false;
}
// lib.optionalAttrs isDarwin {
macos-icon = "custom-style";
macos-icon-ghost-color = "#81C8BE";
macos-icon-screen-color = "#33364A";
macos-option-as-alt = true;
};
};
};
}

0 comments on commit fa9a11d

Please sign in to comment.