Closed alexander-seidl closed 4 years ago
Maybe, i can access an envionment variable in a platform independent way. @CONFIG, that was indroduced with expanding images does not work here.
Hey, I opened another issue for the same purpose without noticing! To keep only one of them I'll close this issue and move the discussion to #265 .
I tried to reimplement the following example [1] so that i can use on my Windows and MacOS Machine. The crucial point ist the second arg: "/path/to/your/script.py". What can i do to make it run on both machines? Python is properly installed on both machines. I need some dynamic replacement here that replaces "root" accordingly for Mac and Windows. How can i do this?
macos root: /root/ windows root: C:\root\
path = root + script.py
[1] script.py:
print("Hello from python")
- trigger: ":pyscript" replace: "{{output}}" vars: - name: output type: script params: args: - python - /path/to/your/script.py
I was trying to do the same in order to point to the relative locations of my dotfiles given the OS, for running some scripts.
While many use-cases might be left out, this one works - sort of:
- trigger: ":test"
replace: "{{myshell}}"
vars:
- name: WHOME
type: shell
params:
cmd: 'if [[ "$OSTYPE" == "darwin"* ]]; then echo $HOME; elif [[ "$OSTYPE" == "linux-gnu"* ]]; then if [[ `uname -a | grep -i linux | grep -i microsoft` != "" ]]; then echo /path/to/your/custom/home; fi; fi'
- name: myshell
type: shell
params:
cmd: "whatever/your/command/is/using/ $ESPANSO_WHOME"
I tried sourcing the .env file in $HOME - since it will have the basic variables defined - but that didn't work. So, this is the current work around to point to the same custom scripts in both WSL and OSX.
If anyone has a better/cleaner solution - do share!
I tried to reimplement the following example [1] so that i can use on my Windows and MacOS Machine. The crucial point ist the second arg: "/path/to/your/script.py". What can i do to make it run on both machines? Python is properly installed on both machines. I need some dynamic replacement here that replaces "root" accordingly for Mac and Windows. How can i do this?
macos root: /root/ windows root: C:\root\
path = root + script.py
[1] script.py:
print("Hello from python")