andresgongora / synth-shell

Boost your terminal, script by script
GNU General Public License v3.0
945 stars 236 forks source link

Custom apt update upgrade autoremove alias will only update then stops. #231

Open ru55-t opened 1 year ago

ru55-t commented 1 year ago

I have a bash alias that as the title says updates upgrades cleans and autoremoves packages in apt that prior to installing synth-shell worked well but not after installing it. It gets through the first update step and goes no further.

To Reproduce From the terminal I type my alias (which you can view in the screenshot): sal then enter my passowrd and then apt starts the update process, finishtes that but then stops.

Expected behavior Is that the apt alias 'sal' goes through all the update upgrade autoremove and cleaning steps without any stops. I think my code is incompatible with synth-shell and I've tried a few different tacks in formatting, even aliasing a scirpt to complete the process to no avail.

Screenshots Scrot-shot_2022-08-17_at_12:05:57-AM

Additional context Changing apts update flash colour from ubuntu orange to a nicer green is the trick I'm trying to preserve and have only managed to get it working in this current format, with any deviations failing. Any suggestions as a work around are welcome. Cheers.

andresgongora commented 1 year ago

Hi. I'm looking into your issue right now. Let's get straight to it:

  1. Have you tried your alias with synth-shell-prompt disabled? Go to your bashrc file and simply comment the part where it is sourced. I'm 99% it's synth-shell-prompt and not any of the aliases that come packed along synth-shell.

  2. Assuming it's the colorized prompt. I guess it's interfering with your scripts own coloring. Just to know if this could be the problem; can you try running a modified version of your script with no colors or text formatting? Let me know, this could be an important lead. Maybe I forgot to unset a variable or something. Or maybe we have to insert a "$(tput sgr0)" somewhere to avoid collisions.

Cheers

ru55-t commented 1 year ago

Hi. Sorry for the late reply, life got a bit hectic but all is calm now. Your right about commenting out synth-shell-prompt script, all aliases work as expected. Re-enabled your script after removing all colour changes and any formatting like \n newline or any echoes from my .bash_aliases file then restarted tilda (also konsole & gnome-terminal) but no change. It can't get past the first line which is simply: sudo apt update then at the next line is: apt list -a -u

All colour changes removed completely, no fancy formatting and all aliases are simple one liners so could it be that the prompt script is simply stopping the alias at the end of the first line and going no further?

I've tried to emulate what your prompt script does with a PS1 line in the .bashrc file but that was disastrous lol so I reverted back. Everything else works in your synth-shell package except the prompt script with my update alias.

On a side note your greeter script alerted me to a few failing services which is great and I've since remedied. Cheers.

andresgongora commented 1 year ago

This is VERY odd. For instance, if you use the full synth-shell package, you get some aliases right out of the gate, such as history and ls among others and they usually work quite well. Could you send me a text version of your script? I don't use Debian but I could nonetheless try to run it. Do your other aliases work?

ru55-t commented 1 year ago

Sure, it's quite long as I've accumulated a few aliases over the years mostly for convenience. Yeah, all the other aliases are fine but I think this might be because their only 1 liners. Could it be that I'm using sudo with apt?

So I've completey removed all .bash* files from my home directory and started from scratch. Uninstalled synth-shell completely and reinstalled it leaving nothing out. I have only setup the source .bash_aliases in .bashrc while only using the update all alias 'sal' in the .bash_aliases file. Same results across all 3 terminals (konsole, gnome-terminal and tilda) then I disabled all but synteh-shell-prompt, restarted all terminals for the same results.

Then I put this back in .bash_aliases: alias sau="sudo apt update -o APT::Color::Yellow='$(printf '\e[32m')' echo -e '\n\033[32m* General update done.\033[0m\n'"

Restarted all 3 terminals and as predicted, it doesn't reach the second line.

bash_aliases.zip

andresgongora commented 1 year ago

I'm on the go right now, I'll have a better look at your response once I get back home. Meanwhile, have you tried converting your alias to a single line using && and || to concatenate commands. This is obviously not the "good" solution, I'd like to solve the root problem, not find a workaround. But if it still doesn't work when the command is a one liner, that could be a good hint of what's going on ;)

On Fri, Aug 26, 2022 at 10:38 AM ru55-t @.***> wrote:

Sure, it's quite long as I've accumulated a few aliases over the years mostly for convenience. Yeah, all the other aliases are fine but I think this might be because their only 1 liners. Could it be that I'm using sudo with apt?

So I've completey removed all .bash* files from my home directory and started from scratch. Uninstalled synth-shell completely and reinstalled it leaving nothing out. I have only setup the source .bash_aliases in .bashrc while only using the update all alias 'sal' in the .bash_aliases file. Same results across all 3 terminals (konsole, gnome-terminal and tilda) then I disabled all but synteh-shell-prompt, restarted all terminals for the same results.

Then I put this back in .bash_aliases: alias sau="sudo apt update -o APT::Color::Yellow='$(printf '\e[32m')' echo -e '\n\033[32m* General update done.\033[0m\n'"

Restarted all 3 terminals and as predicted, it doesn't reach the second line.

bash_aliases.zip https://github.com/andresgongora/synth-shell/files/9431232/bash_aliases.zip

— Reply to this email directly, view it on GitHub https://github.com/andresgongora/synth-shell/issues/231#issuecomment-1228222312, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC36INTJUIYDMRC3MMGG5Z3V3B7CFANCNFSM56VT7WVQ . You are receiving this because you commented.Message ID: @.***>

ru55-t commented 1 year ago

No I haven't tried that, will give it a go. Read up a little on both operators and did this: alias sal="sudo apt update -o APT::Color::Yellow='$(printf '\e[32m')' && echo -e '\n\033[1;32m General update finished, now upgrading any packages that need it...\033[0m\n' && apt list -a -u && # list upgradable && echo -e '\033[1;32m Upgrade finished, autoremoving and cleaning up...\033[0m\n' && sudo apt autoremove -y # remove any orphaned package(s) dependencies && sudo apt clean && # clear apt cache && echo -e '\n\033[1;32m All done.\033[0m\n' && soxbeep" Alos tried: alias sal="sudo apt update -o APT::Color::Yellow='$(printf '\e[32m')' \\ echo -e '\n\033[1;32m General update finished, now upgrading any packages that need it...\033[0m\n' \\ apt list -a -u \\ # list upgradable \ echo -e '\033[1;32m Upgrade finished, autoremoving and cleaning up...\033[0m\n' \\ sudo apt autoremove -y \\ # remove any orphaned package(s) dependencies \\ sudo apt clean \\ # clear apt cache \\ echo -e '\n\033[1;32m All done.\033[0m\n' \\ soxbeep"

With the 1st change I get the > bash next line prompt which I don't know how to use in conjunction with my alias, so I Ctrl+z to exit out of it. With the 2nd it errors at the first ( where it starts a print command. I don't really know what I'm doing here (I'm not a bash ninja...yet lol) so I'm must not be formatting it correctly or I don't have enougth knowledge on the use of operators yet.