From 16bea5ecd006526b23e909865e13f793b10ca09b Mon Sep 17 00:00:00 2001
From: notohh <github@notohh.dev>
Date: Mon, 17 Mar 2025 05:33:35 -0400
Subject: [PATCH] terminal: add television && update yazi, atuin, starship

---
 home/programs/terminal/atuin.nix              |   7 +-
 home/programs/terminal/starship.nix           |   1 +
 home/programs/terminal/television/config.json |   5 +
 home/programs/terminal/television/config.toml | 212 ++++++++++++++++++
 home/programs/terminal/television/default.nix |   9 +
 home/programs/terminal/yazi/default.nix       |   5 +-
 6 files changed, 236 insertions(+), 3 deletions(-)
 create mode 100644 home/programs/terminal/television/config.json
 create mode 100644 home/programs/terminal/television/config.toml
 create mode 100644 home/programs/terminal/television/default.nix

diff --git a/home/programs/terminal/atuin.nix b/home/programs/terminal/atuin.nix
index de4444a..c14dad6 100644
--- a/home/programs/terminal/atuin.nix
+++ b/home/programs/terminal/atuin.nix
@@ -1,6 +1,11 @@
-_: {
+{
+  inputs,
+  pkgs,
+  ...
+}: {
   programs.atuin = {
     enable = true;
+    package = inputs.atuin.packages.${pkgs.system}.default;
     enableNushellIntegration = true;
     settings = {
       auto_sync = true;
diff --git a/home/programs/terminal/starship.nix b/home/programs/terminal/starship.nix
index 0c19c4a..b548aff 100644
--- a/home/programs/terminal/starship.nix
+++ b/home/programs/terminal/starship.nix
@@ -9,6 +9,7 @@
     enable = true;
     enableNushellIntegration = true;
     settings = {
+      command_timeout = 2000;
       add_newline = false;
       format = lib.concatStrings [
         "$character"
diff --git a/home/programs/terminal/television/config.json b/home/programs/terminal/television/config.json
new file mode 100644
index 0000000..6bce8cd
--- /dev/null
+++ b/home/programs/terminal/television/config.json
@@ -0,0 +1,5 @@
+{
+  "indexes": ["nixpkgs", "home-manager", "nur"],
+  "update_interval": "12h",
+  "enable_waiting_message": true
+}
diff --git a/home/programs/terminal/television/config.toml b/home/programs/terminal/television/config.toml
new file mode 100644
index 0000000..4504490
--- /dev/null
+++ b/home/programs/terminal/television/config.toml
@@ -0,0 +1,212 @@
+# CONFIGURATION FILE LOCATION ON YOUR SYSTEM:
+# -------------------------------------------
+# Defaults:
+# ---------
+#  Linux:   `$HOME/.config/television/config.toml`
+#  macOS:   `$HOME/.config/television/config.toml`
+#  Windows: `%APPDATA%\television\config.toml`
+#
+# XDG dirs:
+# ---------
+# You may use XDG_CONFIG_HOME if set on your system.
+# In that case, television will expect the configuration file to be in:
+# `$XDG_CONFIG_HOME/television/config.toml`
+#
+
+# General settings
+# ----------------------------------------------------------------------------
+frame_rate = 60 # DEPRECATED: this option is no longer used
+tick_rate = 50
+
+[ui]
+# Whether to use nerd font icons in the UI
+# This option requires a font patched with Nerd Font in order to properly
+# display glyphs (see https://www.nerdfonts.com/ for more information)
+use_nerd_font_icons = false
+# How much space to allocate for the UI (in percentage of the screen)
+# ┌───────────────────────────────────────┐
+# │                                       │
+# │            Terminal screen            │
+# │    ┌─────────────────────────────┐    │
+# │    │                             │    │
+# │    │                             │    │
+# │    │                             │    │
+# │    │       Television UI         │    │
+# │    │                             │    │
+# │    │                             │    │
+# │    │                             │    │
+# │    │                             │    │
+# │    └─────────────────────────────┘    │
+# │                                       │
+# │                                       │
+# └───────────────────────────────────────┘
+ui_scale = 100
+# Whether to show the top help bar in the UI by default
+# This option can be toggled with the (default) `ctrl-g` keybinding
+show_help_bar = false
+# Whether to show the preview panel in the UI by default
+# This option can be toggled with the (default) `ctrl-o` keybinding
+show_preview_panel = true
+# Where to place the input bar in the UI (top or bottom)
+input_bar_position = "top"
+# DEPRECATED: title is now always displayed at the top as part of the border
+# Where to place the preview title in the UI (top or bottom)
+# preview_title_position = "top"
+# The theme to use for the UI
+# A list of builtin themes can be found in the `themes` directory of the television
+# repository. You may also create your own theme by creating a new file in a `themes`
+# directory in your configuration directory (see the `config.toml` location above).
+theme = "catppuccin"
+
+# Previewers settings
+# ----------------------------------------------------------------------------
+[previewers.file]
+# The theme to use for syntax highlighting.
+# Bulitin syntax highlighting uses the same syntax highlighting engine as bat.
+# To get a list of your currently available themes, run `bat --list-themes`
+# Note that setting the BAT_THEME environment variable will override this setting.
+theme = "TwoDark"
+
+# Keybindings
+# ----------------------------------------------------------------------------
+#
+# Channel mode
+# ------------------------
+[keybindings.Channel]
+# Quit the application
+quit = ["esc", "ctrl-c"]
+# Scrolling through entries
+select_next_entry = ["down", "ctrl-n", "ctrl-j"]
+select_prev_entry = ["up", "ctrl-p", "ctrl-k"]
+select_next_page = "pagedown"
+select_prev_page = "pageup"
+# Scrolling the preview pane
+scroll_preview_half_page_down = "ctrl-d"
+scroll_preview_half_page_up = "ctrl-u"
+# Add entry to selection and move to the next entry
+toggle_selection_down = "tab"
+# Add entry to selection and move to the previous entry
+toggle_selection_up = "backtab"
+# Confirm selection
+confirm_selection = "enter"
+# Copy the selected entry to the clipboard
+copy_entry_to_clipboard = "ctrl-y"
+# Toggle the remote control mode
+toggle_remote_control = "ctrl-r"
+# Toggle the send to channel mode
+toggle_send_to_channel = "ctrl-s"
+# Toggle the help bar
+toggle_help = "ctrl-g"
+# Toggle the preview panel
+toggle_preview = "ctrl-o"
+
+
+# Remote control mode
+# -------------------------------
+[keybindings.RemoteControl]
+# Quit the application
+quit = "esc"
+# Scrolling through entries
+select_next_entry = ["down", "ctrl-n", "ctrl-j"]
+select_prev_entry = ["up", "ctrl-p", "ctrl-k"]
+select_next_page = "pagedown"
+select_prev_page = "pageup"
+# Select an entry
+select_entry = "enter"
+# Toggle the remote control mode
+toggle_remote_control = "ctrl-r"
+# Toggle the help bar
+toggle_help = "ctrl-g"
+# Toggle the preview panel
+toggle_preview = "ctrl-o"
+
+
+# Send to channel mode
+# --------------------------------
+[keybindings.SendToChannel]
+# Quit the application
+quit = "esc"
+# Scrolling through entries
+select_next_entry = ["down", "ctrl-n", "ctrl-j"]
+select_prev_entry = ["up", "ctrl-p", "ctrl-k"]
+select_next_page = "pagedown"
+select_prev_page = "pageup"
+# Select an entry
+select_entry = "enter"
+# Toggle the send to channel mode
+toggle_send_to_channel = "ctrl-s"
+# Toggle the help bar
+toggle_help = "ctrl-g"
+# Toggle the preview panel
+toggle_preview = "ctrl-o"
+
+
+# Shell integration
+# ----------------------------------------------------------------------------
+#
+# The shell integration feature allows you to use television as a picker for
+# your shell commands (as well as your shell history with <CTRL-R>).
+# E.g. typing `git checkout <CTRL-T>` will open television with a list of
+# branches to choose from.
+
+[shell_integration.channel_triggers]
+# Add your channel triggers here. Each key is a channel that will be triggered
+# by the corresponding commands.
+# Example: say you want the following commands to trigger the following channels
+# when pressing <CTRL-T>:
+#          `git checkout`  should trigger the `git-branches` channel
+#          `ls`            should trigger the `dirs` channel
+#          `cat` and `cp`  should trigger the `files` channel
+#
+# You would add the following to your configuration file:
+# ```
+# [shell_integration.channel_triggers]
+# "git-branches" = ["git checkout"]
+# "dirs" = ["ls"]
+# "files" = ["cat", "cp"]
+# ```
+"alias" = ["alias", "unalias"]
+"env" = ["export", "unset"]
+"dirs" = ["cd", "ls", "rmdir"]
+"files" = [
+  "cat",
+  "less",
+  "head",
+  "tail",
+  "vim",
+  "nano",
+  "bat",
+  "cp",
+  "mv",
+  "rm",
+  "touch",
+  "chmod",
+  "chown",
+  "ln",
+  "tar",
+  "zip",
+  "unzip",
+  "gzip",
+  "gunzip",
+  "xz",
+]
+"git-diff" = ["git add", "git restore"]
+"git-branch" = [
+  "git checkout",
+  "git branch",
+  "git merge",
+  "git rebase",
+  "git pull",
+  "git push",
+]
+"docker-images" = ["docker run"]
+"git-repos" = ["nvim", "code", "hx", "git clone"]
+
+
+[shell_integration.keybindings]
+# controls which key binding should trigger tv
+# for shell autocomplete
+"smart_autocomplete" = "ctrl-t"
+# controls which keybinding should trigger tv
+# for command history
+"command_history" = "ctrl-r"
diff --git a/home/programs/terminal/television/default.nix b/home/programs/terminal/television/default.nix
new file mode 100644
index 0000000..86067f3
--- /dev/null
+++ b/home/programs/terminal/television/default.nix
@@ -0,0 +1,9 @@
+{pkgs, ...}: {
+  home.packages = with pkgs; [
+    television
+    nix-search-tv
+  ];
+  xdg.configFile."television/config.toml".source = ./config.toml;
+  # xdg.configFile."television/default_channels.toml".source = ./config.toml;
+  xdg.configFile."nix-search-tv/config.json".source = ./config.json;
+}
diff --git a/home/programs/terminal/yazi/default.nix b/home/programs/terminal/yazi/default.nix
index 425f9e4..e7cfa7d 100644
--- a/home/programs/terminal/yazi/default.nix
+++ b/home/programs/terminal/yazi/default.nix
@@ -1,6 +1,7 @@
 {
-  config,
+  inputs,
   pkgs,
+  config,
   ...
 }: {
   # xdg.configFile."yazi/init.lua".source = ./init.lua;
@@ -8,7 +9,7 @@
 
   programs.yazi = {
     enable = true;
-    package = pkgs.yazi;
+    package = inputs.yazi.packages.${pkgs.system}.default;
     enableNushellIntegration = true;
     settings = {
       manager = {