hwatch
hwatch copied to clipboard
[Bug] does not load dotfiles
I have an alias, l
alias l='ls -lhF --color'
set in a file sourced by ~/.profile
It's unclear why I can see the alias running
hwatch --shell 'bash -l -c' alias l
but I can't use the alias using
hwatch --shell 'bash -l -c' l
Am I using the wrong options? Is this a bug for anyone else?
viddy is looking like a great watch
alternative too
Probably the alias expansion is happening on the shell side you are running.
Are you using zsh as a shell? In my environment with zsh, the execution command is expanded and passed to hwatch.
If the shell invoking hwatch was bash, the alias could be executed without being expanded on the shell side.
I'm using bash.
These didn't work
hwatch --shell 'bash -l -c' 'source ~/.aliases && l'
hwatch --shell 'bash -l -c' 'shopt -s expand_aliases && l'
I believe this is a bash specification.
Due to bash specifications, aliases are not expanded when not in interactive mode. This seems to be the same even when the -l
option is added.
https://linux.die.net/man/1/bash
Aliases are not expanded when the shell is not interactive, unless the expand_aliases shell option is set using shopt (see the description of shopt under SHELL BUILTIN COMMANDS below).
Even if you run it without going through hwatch, the alias will not run.
$ bash -l -c 'shopt -s expand_aliases && l'
bash: line 1: l: command not found
$ bash -l -c 'source ~/.profile && l'
bash: line 1: l: command not found
In other words, if you can find a way to run aliases without going through hwatch, you might be able to run aliases on hwatch as well. So I did some research and found that it doesn't work if aliases are specified on the same line in the first place. https://unix.stackexchange.com/a/502261
$ bash -l -c 'shopt -s expand_aliases && l /hoge'
bash: line 1: l: command not found
$ bash -l -c 'shopt -s expand_aliases'$'\n''l /hoge'
ls: cannot access '/hoge': No such file or directory
So, if you run the command as shown below, I think alias will work with hwatch as well.
hwatch -n 2 --shell 'bash -O expand_aliases -l -c "'$'\n''{COMMAND}"' 'l'
I think it's resolved, so I'll close the issue.