Nukesor / pueue

:stars: Manage your shell commands.
MIT License
4.69k stars 128 forks source link

add: make shell command configurable #458

Closed Nukesor closed 9 months ago

Nukesor commented 10 months ago

Fixes #454 Fixes #363

This is waiting for some people to actually test this.

I would like to see some tests for:

However, the more the merrier.

How to test:

cd /tmp
git clone git@github.com:nukesor/pueue
cd pueue
git switch configurable-shell
cargo install --path pueue

For bash, add this to your daemon settings section:

  shell_command: [
    "bash",
    "-c",
    "shopt -s expand_aliases && {{ pueue_command_string }}",
  ]
  env_vars:
    BASH_ENV: "/path/to/aliases_file"

For zsh, add this:

  shell_command: [
    "zsh",
    "-c",
    ". /path/to/aliases_file; setopt aliases; eval {{ pueue_command_string }}",
  ]

Make sure to restart your daemon!

github-actions[bot] commented 10 months ago

Test Results

    3 files  ±0    22 suites  ±0   3m 46s :stopwatch: +51s 143 tests ±0  143 :heavy_check_mark: ±0  0 :zzz: ±0  0 :x: ±0  306 runs  ±0  306 :heavy_check_mark: ±0  0 :zzz: ±0  0 :x: ±0 

Results for commit d3927561. ± Comparison against base commit 1552761b.

:recycle: This comment has been updated with latest results.

codecov-commenter commented 10 months ago

Codecov Report

Merging #458 (d392756) into development (1552761) will increase coverage by 0.35%. The diff coverage is 94.48%.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

@@               Coverage Diff               @@
##           development     #458      +/-   ##
===============================================
+ Coverage        79.44%   79.80%   +0.35%     
===============================================
  Files               77       77              
  Lines             5444     5511      +67     
===============================================
+ Hits              4325     4398      +73     
+ Misses            1119     1113       -6     
Files Coverage Δ
pueue/src/bin/pueue.rs 66.66% <ø> (+5.37%) :arrow_up:
pueue/src/client/client.rs 60.10% <100.00%> (+0.96%) :arrow_up:
pueue/src/client/commands/edit.rs 97.34% <100.00%> (+0.07%) :arrow_up:
pueue/src/client/commands/restart.rs 75.92% <100.00%> (+0.45%) :arrow_up:
pueue/src/daemon/mod.rs 69.69% <ø> (+2.07%) :arrow_up:
pueue/src/daemon/task_handler/spawn_task.rs 90.29% <100.00%> (+1.49%) :arrow_up:
pueue_lib/src/settings.rs 72.94% <100.00%> (+2.73%) :arrow_up:
pueue/src/daemon/task_handler/callback.rs 11.49% <0.00%> (ø)
pueue_lib/src/process_helper/unix.rs 94.08% <96.00%> (-0.26%) :arrow_down:
pueue_lib/src/process_helper/mod.rs 73.07% <86.84%> (+37.36%) :arrow_up:
isti115 commented 10 months ago

Thanks for taking the effort to support multiple shells!

I have managed to get my Nushell (nu) definitions working with this configuration:

  shell_command: [
    "nu",
    "--env-config ~/.config/nushell/env.nu",
    "--config ~/.config/nushell/config.nu",
    "-c",
    "{{ pueue_command_string }}"
  ]

I also tested PowerShell Core (pwsh), which works without any extra flags, seemingly the profile gets loaded into non-interactive sessions by default:

  shell_command: [
    "pwsh",
    "-c",
    "{{ pueue_command_string }}"
  ]
WindSoilder commented 9 months ago

Sorry for late reply, I've tried in nushell recently, and verified it works too

Nukesor commented 9 months ago

I think I'm going to merge this, It has been open for long enough and from what I can see it works quite well with various shells :)

We'll squash any upcoming bugs once the feature is released.

I'll explicitly mark this feature as experimental, since there's a lot of stuff that can go wrong with shells :D

Thanks @ everyone for helping out with testing the shells :)

jarrodu commented 7 months ago

Is this feature documented? I did not see it in the the Wiki. I found the config option in the config file and searched for "shell_command" here.

Nukesor commented 6 months ago

It's not yet documented, we should add a section to the wiki :sweat_smile: eventually.

The feature was only announced in the recent changelog of https://github.com/Nukesor/pueue/releases/tag/v3.3.0 Most info about this can be found in this issue: https://github.com/Nukesor/pueue/issues/454

Feel free to add some docs to the wiki :) Everyone can contribute!