From da4e23a0d9cf515dd1989b0c97f4d348820aab37 Mon Sep 17 00:00:00 2001 From: Emmet Date: Sun, 26 Oct 2025 11:17:06 -0500 Subject: [PATCH] Cleanup --- .scratch/scratch.org-mode | 1 - hosts/TEMPLATE/configuration.nix | 4 +- hosts/TEMPLATE/default.nix | 6 +- hosts/TEMPLATE/hardware-configuration.nix | 2 +- hosts/TEMPLATE/home.nix | 2 +- hosts/duskfall/configuration.nix | 2 +- hosts/duskfall/default.nix | 6 +- hosts/ori/configuration.nix | 4 +- hosts/ori/default.nix | 6 +- hosts/ori/hardware-configuration.nix | 2 +- hosts/ori/home.nix | 2 +- hosts/snowfire/configuration.nix | 2 +- hosts/snowfire/default.nix | 6 +- hosts/snowfire/hardware-configuration.nix | 2 +- hosts/stardust/configuration.nix | 2 +- hosts/stardust/default.nix | 6 +- hosts/stardust/hardware-configuration.nix | 2 +- hosts/stardust/home.nix | 2 +- hosts/zenith/configuration.nix | 2 +- hosts/zenith/default.nix | 6 +- hosts/zenith/hardware-configuration.nix | 2 +- modules/system/brave-policy/default.nix | 2 +- modules/system/gaming/default.nix | 2 +- modules/system/gnome/default.nix | 2 +- modules/system/hyprland/default.nix | 4 +- modules/system/nix/default.nix | 2 +- modules/system/overlays/ranger.nix | 6 +- modules/system/users/default.nix | 2 +- modules/user/blender/default.nix | 2 +- modules/user/browser/default.nix | 2 +- modules/user/dmenu-scripts/default.nix | 2 +- modules/user/emacs/default.nix | 32 +- modules/user/gnome/default.nix | 2 +- modules/user/home.nix | 2 +- modules/user/media/default.nix | 2 +- modules/user/nix/default.nix | 2 +- modules/user/plasma/default.nix | 2 +- modules/user/ranger/README.org | 25 - modules/user/ranger/colorschemes/hail.py | 183 -- modules/user/ranger/commands.py | 62 - modules/user/ranger/commands_full.py | 1993 --------------------- modules/user/ranger/ranger.nix | 72 - modules/user/ranger/rc.conf | 764 -------- modules/user/ranger/rifle.conf | 233 --- modules/user/ranger/scope.sh | 493 ----- modules/user/terminal/default.nix | 2 +- modules/user/userInfo/default.nix | 2 +- modules/user/xdg/default.nix | 2 +- 48 files changed, 71 insertions(+), 3897 deletions(-) delete mode 100644 .scratch/scratch.org-mode delete mode 100644 modules/user/ranger/README.org delete mode 100644 modules/user/ranger/colorschemes/hail.py delete mode 100644 modules/user/ranger/commands.py delete mode 100644 modules/user/ranger/commands_full.py delete mode 100644 modules/user/ranger/ranger.nix delete mode 100644 modules/user/ranger/rc.conf delete mode 100644 modules/user/ranger/rifle.conf delete mode 100755 modules/user/ranger/scope.sh diff --git a/.scratch/scratch.org-mode b/.scratch/scratch.org-mode deleted file mode 100644 index 90fd3cd..0000000 --- a/.scratch/scratch.org-mode +++ /dev/null @@ -1 +0,0 @@ -# Scratchpad \ No newline at end of file diff --git a/hosts/TEMPLATE/configuration.nix b/hosts/TEMPLATE/configuration.nix index 6656a60..aabdf64 100644 --- a/hosts/TEMPLATE/configuration.nix +++ b/hosts/TEMPLATE/configuration.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ ... }: { config = { @@ -57,5 +57,5 @@ ## EXTRA CONFIG GOES HERE }; - + } diff --git a/hosts/TEMPLATE/default.nix b/hosts/TEMPLATE/default.nix index b29cc69..90ce64d 100644 --- a/hosts/TEMPLATE/default.nix +++ b/hosts/TEMPLATE/default.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, ... }: { imports = [ @@ -8,7 +8,7 @@ config = { home-manager.users = builtins.listToAttrs - (map (user: { name = user; value = - ({ imports = [ ./home.nix ../../modules/user ]; });}) config.systemSettings.users); + (map (user: { name = user; value = + { imports = [ ./home.nix ../../modules/user ]; };}) config.systemSettings.users); }; } diff --git a/hosts/TEMPLATE/hardware-configuration.nix b/hosts/TEMPLATE/hardware-configuration.nix index f878f7c..13f1474 100644 --- a/hosts/TEMPLATE/hardware-configuration.nix +++ b/hosts/TEMPLATE/hardware-configuration.nix @@ -1,7 +1,7 @@ ## THIS FILE MUST BE GENERATED ON A PER MACHINE BASIS ## RUN -{ config, lib, pkgs, modulesPath, inputs, ... }: +{ ... }: { diff --git a/hosts/TEMPLATE/home.nix b/hosts/TEMPLATE/home.nix index 02c76b1..eb882b1 100644 --- a/hosts/TEMPLATE/home.nix +++ b/hosts/TEMPLATE/home.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ ... }: { config = { diff --git a/hosts/duskfall/configuration.nix b/hosts/duskfall/configuration.nix index ca06d37..c102dd5 100644 --- a/hosts/duskfall/configuration.nix +++ b/hosts/duskfall/configuration.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ pkgs, ... }: { config = { diff --git a/hosts/duskfall/default.nix b/hosts/duskfall/default.nix index b29cc69..90ce64d 100644 --- a/hosts/duskfall/default.nix +++ b/hosts/duskfall/default.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, ... }: { imports = [ @@ -8,7 +8,7 @@ config = { home-manager.users = builtins.listToAttrs - (map (user: { name = user; value = - ({ imports = [ ./home.nix ../../modules/user ]; });}) config.systemSettings.users); + (map (user: { name = user; value = + { imports = [ ./home.nix ../../modules/user ]; };}) config.systemSettings.users); }; } diff --git a/hosts/ori/configuration.nix b/hosts/ori/configuration.nix index d868cfe..2c058ed 100644 --- a/hosts/ori/configuration.nix +++ b/hosts/ori/configuration.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ pkgs, ... }: { config = { @@ -218,5 +218,5 @@ ''; virtualisation.docker.extraOptions="--iptables=true"; }; - + } diff --git a/hosts/ori/default.nix b/hosts/ori/default.nix index b29cc69..90ce64d 100644 --- a/hosts/ori/default.nix +++ b/hosts/ori/default.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, ... }: { imports = [ @@ -8,7 +8,7 @@ config = { home-manager.users = builtins.listToAttrs - (map (user: { name = user; value = - ({ imports = [ ./home.nix ../../modules/user ]; });}) config.systemSettings.users); + (map (user: { name = user; value = + { imports = [ ./home.nix ../../modules/user ]; };}) config.systemSettings.users); }; } diff --git a/hosts/ori/hardware-configuration.nix b/hosts/ori/hardware-configuration.nix index c84667b..cce9b41 100644 --- a/hosts/ori/hardware-configuration.nix +++ b/hosts/ori/hardware-configuration.nix @@ -1,7 +1,7 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, inputs, ... }: +{ config, lib, modulesPath, ... }: { imports = diff --git a/hosts/ori/home.nix b/hosts/ori/home.nix index b191058..d5d547d 100644 --- a/hosts/ori/home.nix +++ b/hosts/ori/home.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ ... }: { config = { diff --git a/hosts/snowfire/configuration.nix b/hosts/snowfire/configuration.nix index 910cb46..bf7ddca 100644 --- a/hosts/snowfire/configuration.nix +++ b/hosts/snowfire/configuration.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ pkgs, ... }: { config = { diff --git a/hosts/snowfire/default.nix b/hosts/snowfire/default.nix index b29cc69..90ce64d 100644 --- a/hosts/snowfire/default.nix +++ b/hosts/snowfire/default.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, ... }: { imports = [ @@ -8,7 +8,7 @@ config = { home-manager.users = builtins.listToAttrs - (map (user: { name = user; value = - ({ imports = [ ./home.nix ../../modules/user ]; });}) config.systemSettings.users); + (map (user: { name = user; value = + { imports = [ ./home.nix ../../modules/user ]; };}) config.systemSettings.users); }; } diff --git a/hosts/snowfire/hardware-configuration.nix b/hosts/snowfire/hardware-configuration.nix index ea190b4..0c25d9b 100644 --- a/hosts/snowfire/hardware-configuration.nix +++ b/hosts/snowfire/hardware-configuration.nix @@ -22,7 +22,7 @@ # https://wiki.nixos.org/wiki/Mesa hardware = { graphics = - with pkgs; { + { enable = true; enable32Bit = true; }; diff --git a/hosts/stardust/configuration.nix b/hosts/stardust/configuration.nix index af560ea..f6ecc01 100644 --- a/hosts/stardust/configuration.nix +++ b/hosts/stardust/configuration.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ ... }: { config = { diff --git a/hosts/stardust/default.nix b/hosts/stardust/default.nix index b29cc69..90ce64d 100644 --- a/hosts/stardust/default.nix +++ b/hosts/stardust/default.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, ... }: { imports = [ @@ -8,7 +8,7 @@ config = { home-manager.users = builtins.listToAttrs - (map (user: { name = user; value = - ({ imports = [ ./home.nix ../../modules/user ]; });}) config.systemSettings.users); + (map (user: { name = user; value = + { imports = [ ./home.nix ../../modules/user ]; };}) config.systemSettings.users); }; } diff --git a/hosts/stardust/hardware-configuration.nix b/hosts/stardust/hardware-configuration.nix index 4293d5b..3f46122 100644 --- a/hosts/stardust/hardware-configuration.nix +++ b/hosts/stardust/hardware-configuration.nix @@ -1,7 +1,7 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: +{ config, lib, modulesPath, ... }: { imports = diff --git a/hosts/stardust/home.nix b/hosts/stardust/home.nix index 4c55d07..188b856 100644 --- a/hosts/stardust/home.nix +++ b/hosts/stardust/home.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ ... }: { config = { diff --git a/hosts/zenith/configuration.nix b/hosts/zenith/configuration.nix index 9cd8be3..a45cbf4 100644 --- a/hosts/zenith/configuration.nix +++ b/hosts/zenith/configuration.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ pkgs, ... }: { config = { diff --git a/hosts/zenith/default.nix b/hosts/zenith/default.nix index b29cc69..90ce64d 100644 --- a/hosts/zenith/default.nix +++ b/hosts/zenith/default.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, ... }: { imports = [ @@ -8,7 +8,7 @@ config = { home-manager.users = builtins.listToAttrs - (map (user: { name = user; value = - ({ imports = [ ./home.nix ../../modules/user ]; });}) config.systemSettings.users); + (map (user: { name = user; value = + { imports = [ ./home.nix ../../modules/user ]; };}) config.systemSettings.users); }; } diff --git a/hosts/zenith/hardware-configuration.nix b/hosts/zenith/hardware-configuration.nix index 5b2342a..b57b709 100644 --- a/hosts/zenith/hardware-configuration.nix +++ b/hosts/zenith/hardware-configuration.nix @@ -1,7 +1,7 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: +{ config, lib, modulesPath, ... }: { imports = diff --git a/modules/system/brave-policy/default.nix b/modules/system/brave-policy/default.nix index 0bf371f..aaeff62 100644 --- a/modules/system/brave-policy/default.nix +++ b/modules/system/brave-policy/default.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ...}: +{ config, lib, ...}: let cfg = config.systemSettings.brave; diff --git a/modules/system/gaming/default.nix b/modules/system/gaming/default.nix index 1c4336a..f88d955 100644 --- a/modules/system/gaming/default.nix +++ b/modules/system/gaming/default.nix @@ -1,4 +1,4 @@ -{ lib, config, pkgs, inputs, ... }: +{ lib, config, pkgs, ... }: let cfg = config.systemSettings.gaming; diff --git a/modules/system/gnome/default.nix b/modules/system/gnome/default.nix index 7b42e48..13aa210 100644 --- a/modules/system/gnome/default.nix +++ b/modules/system/gnome/default.nix @@ -1,4 +1,4 @@ -{ inputs, pkgs, config, lib, ... }: +{ pkgs, config, lib, ... }: let cfg = config.systemSettings.gnome; diff --git a/modules/system/hyprland/default.nix b/modules/system/hyprland/default.nix index bfe47ec..001d6a0 100644 --- a/modules/system/hyprland/default.nix +++ b/modules/system/hyprland/default.nix @@ -1,4 +1,4 @@ -{ inputs, pkgs, pkgs-stable, config, lib, ... }: +{ inputs, pkgs, config, lib, ... }: let cfg = config.systemSettings.hyprland; @@ -48,7 +48,7 @@ in enableHidpi = true; theme = "sddm-astronaut-theme"; package = pkgs.kdePackages.sddm; - extraPackages = with pkgs; [ + extraPackages = with pkgs; [ (sddm-astronaut.override { themeConfig = { background = config.stylix.image; diff --git a/modules/system/nix/default.nix b/modules/system/nix/default.nix index 543e1c0..420310e 100644 --- a/modules/system/nix/default.nix +++ b/modules/system/nix/default.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, inputs, ... }: +{ config, pkgs, ... }: { config = { diff --git a/modules/system/overlays/ranger.nix b/modules/system/overlays/ranger.nix index 57a8f84..3c338f8 100644 --- a/modules/system/overlays/ranger.nix +++ b/modules/system/overlays/ranger.nix @@ -1,15 +1,15 @@ -{ config, lib, pkgs, ... }: +{ lib, pkgs, ... }: { config = { nixpkgs.overlays = [ (self: super: { - ranger = super.ranger.overrideAttrs (oldAttrs: rec { + ranger = super.ranger.overrideAttrs (oldAttrs: { preConfigure = '' substituteInPlace ranger/__init__.py \ --replace "DEFAULT_PAGER = 'less'" "DEFAULT_PAGER = '${lib.getBin pkgs.bat}/bin/bat'" - + # give image previews out of the box when building with w3m substituteInPlace ranger/config/rc.conf \ --replace "set preview_images false" "set preview_images true" diff --git a/modules/system/users/default.nix b/modules/system/users/default.nix index 6cfdd6c..76edc1b 100644 --- a/modules/system/users/default.nix +++ b/modules/system/users/default.nix @@ -1,4 +1,4 @@ -{ config, lib, inputs, ... }: +{ config, lib, ... }: { options = { diff --git a/modules/user/blender/default.nix b/modules/user/blender/default.nix index e019494..cc2e1b2 100644 --- a/modules/user/blender/default.nix +++ b/modules/user/blender/default.nix @@ -9,7 +9,7 @@ in { }; }; - config = { + config = lib.mkIf cfg.enable { home.packages = [ pkgs.blender-hip (pkgs.writeScriptBin "declarative-blender-prefs" diff --git a/modules/user/browser/default.nix b/modules/user/browser/default.nix index d394ba5..3c89788 100644 --- a/modules/user/browser/default.nix +++ b/modules/user/browser/default.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, lib, ... }: let browser = config.userSettings.browser; diff --git a/modules/user/dmenu-scripts/default.nix b/modules/user/dmenu-scripts/default.nix index f7de2bb..b7e3284 100644 --- a/modules/user/dmenu-scripts/default.nix +++ b/modules/user/dmenu-scripts/default.nix @@ -1,4 +1,4 @@ -{ config, lib, ...}: +{ lib, ...}: { options = { diff --git a/modules/user/emacs/default.nix b/modules/user/emacs/default.nix index f763441..edab5b9 100644 --- a/modules/user/emacs/default.nix +++ b/modules/user/emacs/default.nix @@ -44,18 +44,18 @@ in { rainbow-mode default-text-scale (epkgs.callPackage ( - { lib, fetchurl, trivialBuild }: - + { lib, trivialBuild }: + trivialBuild { pname = "web-mode"; version = "17.3.20"; - + src = builtins.fetchGit { url = "https://github.com/fxbois/web-mode.git"; rev = "0c83581d1e93d1d802c730a1d5e90cd1c740e1b2"; ref = "main"; }; - + meta = with lib; { description = "web template editing mode for emacs"; homepage = "https://web-mode.org/"; @@ -70,18 +70,18 @@ in { lsp-mode flycheck lsp-ui lsp-treemacs # fix ultra-scroll (epkgs.callPackage ( - { lib, fetchurl, trivialBuild }: - + { lib, trivialBuild }: + trivialBuild { pname = "ultra-scroll"; version = "0.2.0"; - + src = builtins.fetchGit { url = "https://github.com/jdtsmith/ultra-scroll.git"; rev = "64ad7be02e11317576498dabb15c92cf31e2c04c"; ref = "main"; }; - + meta = with lib; { description = "scroll Emacs like lightning"; homepage = "https://github.com/jdtsmith/ultra-scroll"; @@ -91,12 +91,12 @@ in { } ) {}) (epkgs.callPackage ( - { lib, fetchurl, trivialBuild }: - + { lib, trivialBuild }: + trivialBuild { pname = "lsp-treemacs-nerd-icons"; version = "2efa09a-unstable"; - + src = builtins.fetchGit { url = "https://github.com/Velnbur/lsp-treemacs-nerd-icons.git"; rev = "2efa09a701b8b455bfb66529454f27c30f7462dc"; @@ -108,7 +108,7 @@ in { treemacs nerd-icons ]; - + meta = with lib; { description = "Use nerd icons for lsp-mode and lsp-treemacs"; homepage = "https://github.com/Velnbur/lsp-treemacs-nerd-icons"; @@ -118,18 +118,18 @@ in { } ) {}) (epkgs.callPackage ( - { lib, fetchurl, trivialBuild }: - + { lib, trivialBuild }: + trivialBuild { pname = "scratch-plus"; version = "2efa09a-unstable"; - + src = builtins.fetchGit { url = "https://git.sr.ht/~swflint/scratch-plus"; rev = "b794901f968000f6e338808307385b683b79ec8b"; ref = "main"; }; - + meta = with lib; { description = "Better scratch buffers"; homepage = "https://git.sr.ht/~swflint/scratch-plus"; diff --git a/modules/user/gnome/default.nix b/modules/user/gnome/default.nix index a6f9634..1cbe405 100644 --- a/modules/user/gnome/default.nix +++ b/modules/user/gnome/default.nix @@ -1,4 +1,4 @@ -{ inputs, pkgs, config, lib, ... }: +{ config, lib, ... }: let cfg = config.userSettings.gnome; diff --git a/modules/user/home.nix b/modules/user/home.nix index 80b2500..d8147ea 100644 --- a/modules/user/home.nix +++ b/modules/user/home.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, inputs, ... }: +{ ... }: { diff --git a/modules/user/media/default.nix b/modules/user/media/default.nix index cd843b7..2961291 100644 --- a/modules/user/media/default.nix +++ b/modules/user/media/default.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, inputs, ... }: +{ config, lib, pkgs, ... }: let cfg = config.userSettings.media; diff --git a/modules/user/nix/default.nix b/modules/user/nix/default.nix index a2c00e0..ae0e7a0 100644 --- a/modules/user/nix/default.nix +++ b/modules/user/nix/default.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, inputs, ... }: +{ ... }: { config = { diff --git a/modules/user/plasma/default.nix b/modules/user/plasma/default.nix index 601a8ba..c4210d7 100644 --- a/modules/user/plasma/default.nix +++ b/modules/user/plasma/default.nix @@ -1,4 +1,4 @@ -{config, lib, pkgs, inputs, ...}: +{config, lib, inputs, ...}: let cfg = config.userSettings.plasma; in { diff --git a/modules/user/ranger/README.org b/modules/user/ranger/README.org deleted file mode 100644 index 4d055ed..0000000 --- a/modules/user/ranger/README.org +++ /dev/null @@ -1,25 +0,0 @@ -#+title: Ranger File Manager -#+author: Emmet - -* What is Ranger? -[[https://ranger.github.io/][Ranger]] is a minimalistic TUI file manager controlled with vim keybindings (making it /extremely/ efficient). - -[[https://raw.githubusercontent.com/librephoenix/nixos-config-screenshots/main/app/ranger.png]] - -If you've never tried a terminal file manager, I suggest you try it out. Here's a quick overview of how to work with it: -- =j= and =k= - Move up and down -- =l= - Move into a directory or open file at point -- =h= - Move up a directory -- =g g= - Move to top -- =G= - Move to bottom -- =SPC= - Mark a file -- =y y= - Copy (yank) file(s) -- =d d= - Cut file(s) -- =p p= - Paste file(s) -- =d T= - Trash file(s) -- =d D= - /Delete/ a file (no undo!) -- =!= - Run a shell command in current directory -- =@= - Run a shell command on file(s) -- =Ctrl-r= - Refresh view - -Just like in vim, commands can be given by typing a colon =:= (semicolons =;= also work in ranger!) and typing the command, i.e =:rename newfilename=. diff --git a/modules/user/ranger/colorschemes/hail.py b/modules/user/ranger/colorschemes/hail.py deleted file mode 100644 index 9a04f53..0000000 --- a/modules/user/ranger/colorschemes/hail.py +++ /dev/null @@ -1,183 +0,0 @@ -#!/usr/bin/env python3 - -# This file is part of ranger, the console file manager. -# License: GNU GPL version 3, see the file "AUTHORS" for details. - -from __future__ import (absolute_import, division, print_function) - -from ranger.gui.colorscheme import ColorScheme -from ranger.gui.color import ( - black, blue, cyan, green, magenta, red, white, yellow, default, - normal, bold, reverse, dim, BRIGHT, - default_colors, -) - - -class Default(ColorScheme): - progress_bar_color = blue - - def use(self, context): # pylint: disable=too-many-branches,too-many-statements - fg, bg, attr = default_colors - - if context.reset: - return default_colors - - elif context.in_browser: - if context.selected: - attr = reverse - else: - attr = normal - if context.empty or context.error: - bg = red - if context.border: - fg = default - if context.media: - if context.image: - fg = yellow - else: - fg = magenta - if context.container: - fg = red - if context.directory: - attr |= bold - fg = red - fg += BRIGHT - elif context.executable: - attr |= bold - fg = red - fg += BRIGHT - if context.socket: - attr |= bold - fg = magenta - fg += BRIGHT - if context.fifo or context.device: - fg = yellow - if context.device: - attr |= bold - fg += BRIGHT - if context.link: - fg = cyan if context.good else magenta - if context.tag_marker and not context.selected: - attr |= bold - if fg in (red, magenta): - fg = white - else: - fg = red - fg += BRIGHT - if not context.selected and (context.cut or context.copied): - attr |= bold - fg = black - fg += BRIGHT - # If the terminal doesn't support bright colors, use dim white - # instead of black. - if BRIGHT == 0: - attr |= dim - fg = white - if context.main_column: - # Doubling up with BRIGHT here causes issues because it's - # additive not idempotent. - if context.selected: - attr |= bold - if context.marked: - attr |= bold - fg = yellow - if context.badinfo: - if attr & reverse: - bg = magenta - else: - fg = magenta - - if context.inactive_pane: - fg = cyan - - elif context.in_titlebar: - if context.hostname: - fg = red if context.bad else green - elif context.directory: - fg = red - elif context.tab: - if context.good: - bg = green - elif context.link: - fg = cyan - attr |= bold - - elif context.in_statusbar: - if context.permissions: - if context.good: - fg = cyan - elif context.bad: - fg = magenta - if context.marked: - attr |= bold | reverse - fg = yellow - fg += BRIGHT - if context.frozen: - attr |= bold | reverse - fg = cyan - fg += BRIGHT - if context.message: - if context.bad: - attr |= bold - fg = red - fg += BRIGHT - if context.loaded: - bg = self.progress_bar_color - if context.vcsinfo: - fg = blue - attr &= ~bold - if context.vcscommit: - fg = yellow - attr &= ~bold - if context.vcsdate: - fg = cyan - attr &= ~bold - - if context.text: - if context.highlight: - attr |= reverse - - if context.in_taskview: - if context.title: - fg = blue - - if context.selected: - attr |= reverse - - if context.loaded: - if context.selected: - fg = self.progress_bar_color - else: - bg = self.progress_bar_color - - if context.vcsfile and not context.selected: - attr &= ~bold - if context.vcsconflict: - fg = magenta - elif context.vcsuntracked: - fg = cyan - elif context.vcschanged: - fg = red - elif context.vcsunknown: - fg = red - elif context.vcsstaged: - fg = green - elif context.vcssync: - fg = green - elif context.vcsignored: - fg = default - - elif context.vcsremote and not context.selected: - attr &= ~bold - if context.vcssync or context.vcsnone: - fg = green - elif context.vcsbehind: - fg = red - elif context.vcsahead: - fg = blue - elif context.vcsdiverged: - fg = magenta - elif context.vcsunknown: - fg = red - - return fg, bg, attr diff --git a/modules/user/ranger/commands.py b/modules/user/ranger/commands.py deleted file mode 100644 index 97b7909..0000000 --- a/modules/user/ranger/commands.py +++ /dev/null @@ -1,62 +0,0 @@ -# This is a sample commands.py. You can add your own commands here. -# -# Please refer to commands_full.py for all the default commands and a complete -# documentation. Do NOT add them all here, or you may end up with defunct -# commands when upgrading ranger. - -# A simple command for demonstration purposes follows. -# ----------------------------------------------------------------------------- - -from __future__ import (absolute_import, division, print_function) - -# You can import any python module as needed. -import os - -# You always need to import ranger.api.commands here to get the Command class: -from ranger.api.commands import Command - - -# Any class that is a subclass of "Command" will be integrated into ranger as a -# command. Try typing ":my_edit" in ranger! -class my_edit(Command): - # The so-called doc-string of the class will be visible in the built-in - # help that is accessible by typing "?c" inside ranger. - """:my_edit - - A sample command for demonstration purposes that opens a file in an editor. - """ - - # The execute method is called when you run this command in ranger. - def execute(self): - # self.arg(1) is the first (space-separated) argument to the function. - # This way you can write ":my_edit somefilename". - if self.arg(1): - # self.rest(1) contains self.arg(1) and everything that follows - target_filename = self.rest(1) - else: - # self.fm is a ranger.core.filemanager.FileManager object and gives - # you access to internals of ranger. - # self.fm.thisfile is a ranger.container.file.File object and is a - # reference to the currently selected file. - target_filename = self.fm.thisfile.path - - # This is a generic function to print text in ranger. - self.fm.notify("Let's edit the file " + target_filename + "!") - - # Using bad=True in fm.notify allows you to print error messages: - if not os.path.exists(target_filename): - self.fm.notify("The given file does not exist!", bad=True) - return - - # This executes a function from ranger.core.acitons, a module with a - # variety of subroutines that can help you construct commands. - # Check out the source, or run "pydoc ranger.core.actions" for a list. - self.fm.edit_file(target_filename) - - # The tab method is called when you press tab, and should return a list of - # suggestions that the user will tab through. - # tabnum is 1 for and -1 for by default - def tab(self, tabnum): - # This is a generic tab-completion function that iterates through the - # content of the current directory. - return self._tab_directory_content() diff --git a/modules/user/ranger/commands_full.py b/modules/user/ranger/commands_full.py deleted file mode 100644 index 4650e75..0000000 --- a/modules/user/ranger/commands_full.py +++ /dev/null @@ -1,1993 +0,0 @@ -# -*- coding: utf-8 -*- -# This file is part of ranger, the console file manager. -# This configuration file is licensed under the same terms as ranger. -# =================================================================== -# -# NOTE: If you copied this file to /etc/ranger/commands_full.py or -# ~/.config/ranger/commands_full.py, then it will NOT be loaded by ranger, -# and only serve as a reference. -# -# =================================================================== -# This file contains ranger's commands. -# It's all in python; lines beginning with # are comments. -# -# Note that additional commands are automatically generated from the methods -# of the class ranger.core.actions.Actions. -# -# You can customize commands in the files /etc/ranger/commands.py (system-wide) -# and ~/.config/ranger/commands.py (per user). -# They have the same syntax as this file. In fact, you can just copy this -# file to ~/.config/ranger/commands_full.py with -# `ranger --copy-config=commands_full' and make your modifications, don't -# forget to rename it to commands.py. You can also use -# `ranger --copy-config=commands' to copy a short sample commands.py that -# has everything you need to get started. -# But make sure you update your configs when you update ranger. -# -# =================================================================== -# Every class defined here which is a subclass of `Command' will be used as a -# command in ranger. Several methods are defined to interface with ranger: -# execute(): called when the command is executed. -# cancel(): called when closing the console. -# tab(tabnum): called when is pressed. -# quick(): called after each keypress. -# -# tab() argument tabnum is 1 for and -1 for by default -# -# The return values for tab() can be either: -# None: There is no tab completion -# A string: Change the console to this string -# A list/tuple/generator: cycle through every item in it -# -# The return value for quick() can be: -# False: Nothing happens -# True: Execute the command afterwards -# -# The return value for execute() and cancel() doesn't matter. -# -# =================================================================== -# Commands have certain attributes and methods that facilitate parsing of -# the arguments: -# -# self.line: The whole line that was written in the console. -# self.args: A list of all (space-separated) arguments to the command. -# self.quantifier: If this command was mapped to the key "X" and -# the user pressed 6X, self.quantifier will be 6. -# self.arg(n): The n-th argument, or an empty string if it doesn't exist. -# self.rest(n): The n-th argument plus everything that followed. For example, -# if the command was "search foo bar a b c", rest(2) will be "bar a b c" -# self.start(n): Anything before the n-th argument. For example, if the -# command was "search foo bar a b c", start(2) will be "search foo" -# -# =================================================================== -# And this is a little reference for common ranger functions and objects: -# -# self.fm: A reference to the "fm" object which contains most information -# about ranger. -# self.fm.notify(string): Print the given string on the screen. -# self.fm.notify(string, bad=True): Print the given string in RED. -# self.fm.reload_cwd(): Reload the current working directory. -# self.fm.thisdir: The current working directory. (A File object.) -# self.fm.thisfile: The current file. (A File object too.) -# self.fm.thistab.get_selection(): A list of all selected files. -# self.fm.execute_console(string): Execute the string as a ranger command. -# self.fm.open_console(string): Open the console with the given string -# already typed in for you. -# self.fm.move(direction): Moves the cursor in the given direction, which -# can be something like down=3, up=5, right=1, left=1, to=6, ... -# -# File objects (for example self.fm.thisfile) have these useful attributes and -# methods: -# -# tfile.path: The path to the file. -# tfile.basename: The base name only. -# tfile.load_content(): Force a loading of the directories content (which -# obviously works with directories only) -# tfile.is_directory: True/False depending on whether it's a directory. -# -# For advanced commands it is unavoidable to dive a bit into the source code -# of ranger. -# =================================================================== - -from __future__ import (absolute_import, division, print_function) - -from collections import deque -import os -import re - -from ranger.api.commands import Command - - -class alias(Command): - """:alias - - Copies the oldcommand as newcommand. - """ - - context = 'browser' - resolve_macros = False - - def execute(self): - if not self.arg(1) or not self.arg(2): - self.fm.notify('Syntax: alias ', bad=True) - return - - self.fm.commands.alias(self.arg(1), self.rest(2)) - - -class echo(Command): - """:echo - - Display the text in the statusbar. - """ - - def execute(self): - self.fm.notify(self.rest(1)) - - -class cd(Command): - """:cd [-r] - - The cd command changes the directory. - If the path is a file, selects that file. - The command 'cd -' is equivalent to typing ``. - Using the option "-r" will get you to the real path. - """ - - def execute(self): - if self.arg(1) == '-r': - self.shift() - destination = os.path.realpath(self.rest(1)) - if os.path.isfile(destination): - self.fm.select_file(destination) - return - else: - destination = self.rest(1) - - if not destination: - destination = '~' - - if destination == '-': - self.fm.enter_bookmark('`') - else: - self.fm.cd(destination) - - def _tab_args(self): - # dest must be rest because path could contain spaces - if self.arg(1) == '-r': - start = self.start(2) - dest = self.rest(2) - else: - start = self.start(1) - dest = self.rest(1) - - if dest: - head, tail = os.path.split(os.path.expanduser(dest)) - if head: - dest_exp = os.path.join(os.path.normpath(head), tail) - else: - dest_exp = tail - else: - dest_exp = '' - return (start, dest_exp, os.path.join(self.fm.thisdir.path, dest_exp), - dest.endswith(os.path.sep)) - - @staticmethod - def _tab_paths(dest, dest_abs, ends_with_sep): - if not dest: - try: - return next(os.walk(dest_abs))[1], dest_abs - except (OSError, StopIteration): - return [], '' - - if ends_with_sep: - try: - return [os.path.join(dest, path) for path in next(os.walk(dest_abs))[1]], '' - except (OSError, StopIteration): - return [], '' - - return None, None - - def _tab_match(self, path_user, path_file): - if self.fm.settings.cd_tab_case == 'insensitive': - path_user = path_user.lower() - path_file = path_file.lower() - elif self.fm.settings.cd_tab_case == 'smart' and path_user.islower(): - path_file = path_file.lower() - return path_file.startswith(path_user) - - def _tab_normal(self, dest, dest_abs): - dest_dir = os.path.dirname(dest) - dest_base = os.path.basename(dest) - - try: - dirnames = next(os.walk(os.path.dirname(dest_abs)))[1] - except (OSError, StopIteration): - return [], '' - - return [os.path.join(dest_dir, d) for d in dirnames if self._tab_match(dest_base, d)], '' - - def _tab_fuzzy_match(self, basepath, tokens): - """ Find directories matching tokens recursively """ - if not tokens: - tokens = [''] - paths = [basepath] - while True: - token = tokens.pop() - matches = [] - for path in paths: - try: - directories = next(os.walk(path))[1] - except (OSError, StopIteration): - continue - matches += [os.path.join(path, d) for d in directories - if self._tab_match(token, d)] - if not tokens or not matches: - return matches - paths = matches - - return None - - def _tab_fuzzy(self, dest, dest_abs): - tokens = [] - basepath = dest_abs - while True: - basepath_old = basepath - basepath, token = os.path.split(basepath) - if basepath == basepath_old: - break - if os.path.isdir(basepath_old) and not token.startswith('.'): - basepath = basepath_old - break - tokens.append(token) - - paths = self._tab_fuzzy_match(basepath, tokens) - if not os.path.isabs(dest): - paths_rel = self.fm.thisdir.path - paths = [os.path.relpath(os.path.join(basepath, path), paths_rel) - for path in paths] - else: - paths_rel = '' - return paths, paths_rel - - def tab(self, tabnum): - from os.path import sep - - start, dest, dest_abs, ends_with_sep = self._tab_args() - - paths, paths_rel = self._tab_paths(dest, dest_abs, ends_with_sep) - if paths is None: - if self.fm.settings.cd_tab_fuzzy: - paths, paths_rel = self._tab_fuzzy(dest, dest_abs) - else: - paths, paths_rel = self._tab_normal(dest, dest_abs) - - paths.sort() - - if self.fm.settings.cd_bookmarks: - paths[0:0] = [ - os.path.relpath(v.path, paths_rel) if paths_rel else v.path - for v in self.fm.bookmarks.dct.values() for path in paths - if v.path.startswith(os.path.join(paths_rel, path) + sep) - ] - - if not paths: - return None - if len(paths) == 1: - return start + paths[0] + sep - return [start + dirname + sep for dirname in paths] - - -class chain(Command): - """:chain ; ; ... - - Calls multiple commands at once, separated by semicolons. - """ - resolve_macros = False - - def execute(self): - if not self.rest(1).strip(): - self.fm.notify('Syntax: chain ; ; ...', bad=True) - return - for command in [s.strip() for s in self.rest(1).split(";")]: - self.fm.execute_console(command) - - -class shell(Command): - escape_macros_for_shell = True - - def execute(self): - if self.arg(1) and self.arg(1)[0] == '-': - flags = self.arg(1)[1:] - command = self.rest(2) - else: - flags = '' - command = self.rest(1) - - if command: - self.fm.execute_command(command, flags=flags) - - def tab(self, tabnum): - from ranger.ext.get_executables import get_executables - if self.arg(1) and self.arg(1)[0] == '-': - command = self.rest(2) - else: - command = self.rest(1) - start = self.line[0:len(self.line) - len(command)] - - try: - position_of_last_space = command.rindex(" ") - except ValueError: - return (start + program + ' ' for program - in get_executables() if program.startswith(command)) - if position_of_last_space == len(command) - 1: - selection = self.fm.thistab.get_selection() - if len(selection) == 1: - return self.line + selection[0].shell_escaped_basename + ' ' - return self.line + '%s ' - - before_word, start_of_word = self.line.rsplit(' ', 1) - return (before_word + ' ' + file.shell_escaped_basename - for file in self.fm.thisdir.files or [] - if file.shell_escaped_basename.startswith(start_of_word)) - - -class open_with(Command): - - def execute(self): - app, flags, mode = self._get_app_flags_mode(self.rest(1)) - self.fm.execute_file( - files=[f for f in self.fm.thistab.get_selection()], - app=app, - flags=flags, - mode=mode) - - def tab(self, tabnum): - return self._tab_through_executables() - - def _get_app_flags_mode(self, string): # pylint: disable=too-many-branches,too-many-statements - """Extracts the application, flags and mode from a string. - - examples: - "mplayer f 1" => ("mplayer", "f", 1) - "atool 4" => ("atool", "", 4) - "p" => ("", "p", 0) - "" => None - """ - - app = '' - flags = '' - mode = 0 - split = string.split() - - if len(split) == 1: - part = split[0] - if self._is_app(part): - app = part - elif self._is_flags(part): - flags = part - elif self._is_mode(part): - mode = part - - elif len(split) == 2: - part0 = split[0] - part1 = split[1] - - if self._is_app(part0): - app = part0 - if self._is_flags(part1): - flags = part1 - elif self._is_mode(part1): - mode = part1 - elif self._is_flags(part0): - flags = part0 - if self._is_mode(part1): - mode = part1 - elif self._is_mode(part0): - mode = part0 - if self._is_flags(part1): - flags = part1 - - elif len(split) >= 3: - part0 = split[0] - part1 = split[1] - part2 = split[2] - - if self._is_app(part0): - app = part0 - if self._is_flags(part1): - flags = part1 - if self._is_mode(part2): - mode = part2 - elif self._is_mode(part1): - mode = part1 - if self._is_flags(part2): - flags = part2 - elif self._is_flags(part0): - flags = part0 - if self._is_mode(part1): - mode = part1 - elif self._is_mode(part0): - mode = part0 - if self._is_flags(part1): - flags = part1 - - return app, flags, int(mode) - - def _is_app(self, arg): - return not self._is_flags(arg) and not arg.isdigit() - - @staticmethod - def _is_flags(arg): - from ranger.core.runner import ALLOWED_FLAGS - return all(x in ALLOWED_FLAGS for x in arg) - - @staticmethod - def _is_mode(arg): - return all(x in '0123456789' for x in arg) - - -class set_(Command): - """:set