Skip to content

Commit

Permalink
mainly yazi
Browse files Browse the repository at this point in the history
  • Loading branch information
rasmus-kirk committed Oct 25, 2024
1 parent d1867aa commit 9283b19
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 9 deletions.
20 changes: 18 additions & 2 deletions modules/home-manager/homeManagerScripts/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ with lib; let
hm-rebuild = pkgs.writeShellApplication {
name = "hm-rebuild";
text = ''
pushd ${configDir}
git add .
# Switch configuration, backing up files
home-manager switch -b backup --flake ${configDir}#${cfg.machine}
home-manager switch -b backup --flake .#${cfg.machine}
popd
'';
};

Expand Down Expand Up @@ -78,7 +81,6 @@ in {
configurations/garbage collects
- `hm-rollback`: Use this command to roll back to a previous working
home manager configuration.
'';

configDir = mkOption {
Expand All @@ -94,11 +96,25 @@ in {

machine = mkOption {
type = types.nullOr types.str;
default = null;
description = "**REQUIRED!** Path to the home-manager configuration.";
};

disableNews = mkOption {
type = types.nullOr types.str;
default = true;
description = "Disable annoying home-manager news on rebuild.";
};
};

config = mkIf cfg.enable {
# Disable home manager news
news = mkIf cfg.disableNews {
display = "silent";
json = lib.mkForce { };
entries = lib.mkForce [ ];
};

home.packages = [
hm-update
hm-upgrade
Expand Down
8 changes: 1 addition & 7 deletions modules/home-manager/yazi/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ with lib; let
rev = "c204853de7a78bc99ea628e51857ce65506468db";
hash = "sha256-NBco10MINyAJk1YWHwYUzvI9mnTJl9aYyDtQSTUP3Hs=";
};
mkdir = mkYaziPluginGithub {
name = "mkdir";
url = "https://github.com/Sonico98/mkdir.yazi";
rev = "0c0b87a576d49001603f63d447aab166ec35363f";
hash = "sha256-rx3B3MyljqabEjJDtCx807JhIemafduQ0i5fJvJXAzs=";
};
exifaudio = mkYaziPluginGithub {
name = "exifaudio";
url = "https://github.com/Sonico98/exifaudio.yazi";
Expand Down Expand Up @@ -258,7 +252,7 @@ in {
};
flavors.gruvbox-dark = plugins.gruvbox-dark;
plugins = {
mkdir = plugins.mkdir;
mkdir = ./plugins/mkdir;
exifaudio = plugins.exifaudio;
full-border = mkYaziPlugin "full-border";
git = mkYaziPlugin "git";
Expand Down
21 changes: 21 additions & 0 deletions modules/home-manager/yazi/plugins/mkdir/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Sonico98

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
24 changes: 24 additions & 0 deletions modules/home-manager/yazi/plugins/mkdir/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# mkdir.yazi

Create directories in yazi without having to type a trailing slash at the end every time.

## Installation

```sh
# Linux/MacOS
git clone https://github.com/Sonico98/mkdir.yazi.git ~/.config/yazi/plugins/mkdir.yazi

# Windows
git clone https://github.com/Sonico98/mkdir.yazi.git %AppData%\yazi\config\plugins\mkdir.yazi
```

## Usage

Add this to your `keymap.toml`:

```toml
[[manager.prepend_keymap]]
on = [ "m", "k" ]
exec = "plugin mkdir"
desc = "Create a directory"
```
32 changes: 32 additions & 0 deletions modules/home-manager/yazi/plugins/mkdir/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
return {
entry = function(self, _)
local dir, event = ya.input {
title = "Directory name:",
position = { "top-center", y = 2, w = 50 },
}

if event ~= 1 then
return
end

local args = { "-p", dir }
if ya.target_family() == "windows" then
args = { dir }
end

local child = Command("mkdir")
:args(args)
:stderr(Command.PIPED)
:spawn()

local status, _ = child:wait()
if not status.success then
ya.notify {
title = "Error creating directory",
content = child:read_line(),
timeout = 5,
level = "error",
}
end
end
}

0 comments on commit 9283b19

Please sign in to comment.