Closed zuixalias closed 1 year ago
Can you share the script?
#!/usr/bin/env bash
REL_PATH=path/to/editor/editor_name
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
$SCRIPT_DIR/$REL_PATH $@
Probably running the sript as an arg to some terminal would keep it open (idk)
Without specifics on the editor in question, I have no idea why this wouldn't work. Does it work if you set EDITOR
to something like vim, nano, etc.?
I am curious: what is the purpose of this script?
Yes, the behaviour on the editor is same as any other editor (ex: vi
)
The issue i think is that it's a script, as putting this in the script leads to the same behaviour:
vi
Whereas specifying the editor directly in $EDITOR
(i.e., no script) it's works good...including the editor that i am using.
Did you make sure the script is executable? I just did a quick test with this script:
#!/bin/sh -e
exec nvim "$@"
If the script is not executable, it immediately exits. If it is executable, it works just how I'd expect it to.
It also causes really broken behavior when I try to reproduce #34.
I see, i am not sure what else is broken but for me cfm crashes and keeps running in bg with 99% cpu usage.
That sounds like an issue with your script. Without knowing what's actually in it or what the point of it is, I am not sure I can help you very much, unfortunately.
Yes, i jus tried it.
chmod +x scriptname
#!/bin/sh -e
exec /home/user/path/to/editor/editor_binary_name "$@"
It's still the same...
Do you get any sort of error when you try to rename a file, for example?
No, it creates the file with the default name. Then if i try to recreate a file/ folder...it tell me that File/ Directory already exists
Could it be related to the shell? Like you using a different shell so it works for you but on bash it doesn't.
(I am a linux newbie so don't know much)
Renaming the file gives: Target file already exists
cfm does not use your shell. What editor are you using?
I am using hx
(Helix)
Does EDITOR=hx cfm
work properly?
Hmm, there is the issue i think.
EDITOR=vi cfm
works but
EDITOR=path/to/editor/editor_binary_name cfm
does not...(the editor_binary
is marked as executable btw)
No no no, i am sorry, it works...just needed to specify path from root (/home/user/...
) or with ~/...
...
When cfm prompts you for input, the working directory is set to /tmp
as it is editing a file located there. If you are trying to do anything with a relative path, unless it's relative to /tmp
it will not work.
I see, ok...but the script that i first posted is meant for such use cases, i.e., it will always use the correct path, irrespective of the current working directory/ directory from which it is called. So that is most probably not the issue (i just checked the paths to confirm this)
STEPS TO REPRODUCE MY SETUP IN THIS ISSUE (Leaving here just in case) :
Download the helix editor zip file and extract it to ~/ware/files/helix
. Make the hx
binary executable.
Direct download or Github releases
In .bashrc
export the path:
export PATH="$PATH:~/ware"
Paste this script in ~/ware
with the name hx
(make executable if needed):
#!/usr/bin/env bash
REL_PATH=files/helix/hx SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd) $SCRIPT_DIR/$REL_PATH $@
Now you can run helix form anywhere by typing `hx`.
---------------------------------------------------------------------------
Now, to reproduce the issue:
- Run `cfm` and create a dir/ file.
But if you run `cfm` by specifying the path directly, it works:
```bash
EDITOR=~/ware/files/helix/hx cfm
Try using $HOME
instead of ~
in your PATH.
What sorcery is this xD. It is solved now, thanks a lot!
Programs do not expand tildes in path usually. Your shell is expanding the one when you manually set EDITOR like that, but the exec family of syscalls will not expand tildes.
I have a shell script that i use to run my editor which i have used in
$EDITOR
. When a file/ folder is created using cfm, the editor opens and exits quickly i believe, so i am unable to name/ rename them.