users/kat/base/zsh: Rework of shell functions

This commit is contained in:
kat witch 2021-05-28 22:55:20 +01:00
parent a74972437d
commit b0b23ed772
No known key found for this signature in database
GPG key ID: 1B477797DCA5EC72
2 changed files with 25 additions and 8 deletions

View file

@ -2,7 +2,7 @@
{
disabledModules = [ "programs/vim.nix" ];
imports = with (import (sources.arc-nixexprs + "/modules")).home-manager; [ base16 syncplay konawall i3gopher weechat ] ++ [
imports = with (import (sources.arc-nixexprs + "/modules")).home-manager; [ base16 syncplay konawall i3gopher weechat shell ] ++ [
./vim.nix
./deploy-tf
(sources.tf-nix + "/modules/home/secrets.nix")

View file

@ -1,6 +1,29 @@
{ config, lib, pkgs, ... }:
{
with lib;
let
shellFunAlias = command: replacement: ''
if [[ ! -t 0 ]]; then
command ${command} $@
else
echo 'use ${replacement}!'
fi
'';
shellFunAliases = mapAttrs shellFunAlias;
in {
home.shell.functions = {
genmac = ''
nix run nixpkgs.openssl -c openssl rand -hex 6 | sed 's/\(..\)\(..\)\(..\)\(..\)\(..\)\(..\)/\1:\2:\3:\4:\5:\6/'
'';
nano = ''
kitty +kitten icat ${./nano.png}
'';
} // shellFunAliases {
sed = "sd";
find = "fd";
grep = "rg";
};
xdg.dataFile = { "z/.keep".text = ""; };
home.packages = with pkgs; [ fzf fd ];
programs.zsh = {
@ -18,12 +41,6 @@
dmesg = "dmesg -HP";
lg = "log --no-pager | grep";
};
initExtra = ''
genmac() { nix run nixpkgs.openssl -c openssl rand -hex 6 | sed 's/\(..\)\(..\)\(..\)\(..\)\(..\)\(..\)/\1:\2:\3:\4:\5:\6/' }
nano() { kitty +kitten icat ${./nano.png} }
find() { echo "use fd!" }
sed() { echo "use sd!" }
'';
localVariables = {
_Z_DATA = "${config.xdg.dataHome}/z/data";
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE = "fg=3,bold";