I need to pass lisp to emacs from the terminal with an alias, but the alias is not populating the way I would like it to in the shell configuration.
I am trying to set a shell alias in home-manager like this:
{ pkgs, lib, config, ... }:
let
emacsCommand = headline: ''
emacsclient -t --eval='(progn (find-file "~/nixfiles/README.org") (goto-char (org-find-exact-headline-in-buffer \\"${headline}\\")))'
'';
in
{
home.shellAliases = {
# ...
cfb = emacsCommand "Browsers";
cfw = "nvim ~/nixfiles/modules/home-manager/default.nix";
# ...
}
But when I check the ~/.config/config.fish
, the alias is set to this:
alias cfb 'emacsclient -t --eval='\''(progn (find-file "~/nixfiles/README.org") (goto-char (org-find-exact-headline-in-buffer "Browsers")))'\'''
I want the result to be this:
alias cfb 'emacsclient -t --eval=\'(progn (find-file "~/nixfiles/README.org") (goto-char (org-find-exact-headline-in-buffer "Browsers")))\''
I have been playing in the repl for an hour and I cannot make it happen. What am I doing wrong?
Other things tried
nix-repl> let
emacsCommand = headline: ''
emacsclient -t --eval='(progn (find-file "~/nixfiles/README.org") (goto-char (org-find-exact-headline-in-buffer "${headline}")))';
'';
in emacsCommand "Browsers"
results in "emacsclient -t --eval='(progn (find-file \"~/nixfiles/README.org\") (goto-char (org-find-exact-headline-in-buffer \"Browsers\")))';\n"
When I put that in the config, the config.fish
:
alias cfb 'emacsclient -t --eval='\''(progn (find-file "~/nixfiles/README.org") (goto-char (org-find-exact-headline-in-buffer "Browsers")))'\'';
I have read this bit about string interpolation from the manual, but it looks like home-manager is automatically adding in more escapes than I am telling it to do, so I canât figure out how to get it to do what I want.