Hi, thanks for help.
ou don't add it to `.bashrc`. Instead, you need to configure your*terminal emulator*. It is the graphical application that you use to access the command line. Since you mentioned you're using Mate desktop, I suspect the terminal emulator you are using is "mate-terminal" and I'll give you instructions for that. If you happen to be using a different one (like xfce4-terminal, konsole, sakura, xterm, etc.), the steps are going to be slightly different. So, right-click somewhene in your mate-terminal window and choose "Profiles->Profile Preferences" as in the attached screenshot. Then, in the "Editing Profile" windows that shows, switch to the "Title and Command" tab and tick the "Run command as a login shell" option (as shown in the second attached screenshot). Finally, close the "Editing Profile" window.
1. I already had this option enabled in the MATE terminal 2.
shopt -q login_shell; echo $?If the bash instance you're interacting with is a login shell, it shall print "0". Otherwise, it'll print "1".
gfp@Tuxedo ~$ shopt -q login_shell; echo $? 0 3. How do you create this screenshot with the red arrow? I know how to create a screenshot, but I don’t know how to add something remarks with red colour. Which package do you use for this? 4.
your profiles get enabled when you "log in" in a terminal.And here we're just causing the execution of mate-terminal application to be treated as such login.
So how can I now enable all e.g. 10 profiles at once in the terminal? which commands do I have to use? I enabled always one profile by one: guix shell -p ~/Projekte/Libreoffice/guix-profil to open libreoffice guix shell -p ~/Projekte/Musik/guix-profil to open the music profil with several packages and so on... 5.is there also a possibility to enable all my profiles when I log in to my MATE desktop? so that I can save time and don’t need to open one profile after another in the terminal?
(Except the case, if there is a possibility, question 4, to open all profiles at once by one command in the MATE terminal, so that I have all packages in all profiles enabled at once)
Kind regards Gottfried Am 17.04.23 um 13:56 schrieb Wojtek Kosior:
Hi, thanks for helping me. ------------------------------------------------------------------ 1. I added: "GUIX_EXTRA_PROFILES=/home/gfp/Projekte" to my /.bash_profile 2. I changed the sentence "profile=$i/$(basename "$i")" to: "profile=$i" 3. my /.bash_profile looks now, after changing like this: [...]Looks good :)Where do I have to add "-l" in /.bashrc?You don't add it to `.bashrc`. Instead, you need to configure your *terminal emulator*. It is the graphical application that you use to access the command line. Since you mentioned you're using Mate desktop, I suspect the terminal emulator you are using is "mate-terminal" and I'll give you instructions for that. If you happen to be using a different one (like xfce4-terminal, konsole, sakura, xterm, etc.), the steps are going to be slightly different. So, right-click somewhene in your mate-terminal window and choose "Profiles->Profile Preferences" as in the attached screenshot. Then, in the "Editing Profile" windows that shows, switch to the "Title and Command" tab and tick the "Run command as a login shell" option (as shown in the second attached screenshot). Finally, close the "Editing Profile" window. Once you restart mate-terminal, it should run bash as a login shell. You can verify this by running the following command (well, 2 commands) shopt -q login_shell; echo $? If the bash instance you're interacting with is a login shell, it shall print "0". Otherwise, it'll print "1". Now, it might be good to clarify some things. What we're doing here does *not* enable your profiles when you start the Mate desktop. It instead enables them when you start mate-terminal with bash in it. In other words, your profiles get enabled when you "log in" in a terminal. And here we're just causing the execution of mate-terminal application to be treated as such login. But don't worry about these details — this is what you want. The lines you now have in your `.bash_profile` will also enable your Guix profiles when you log in through a TTY or through SSH. This is the correct behavior :) Best luck ;) Wojtek -- (sig_start) website: https://koszko.org/koszko.html PGP: https://koszko.org/key.gpg fingerprint: E972 7060 E3C5 637C 8A4F 4B42 4BC5 221C 5A79 FD1A ♥ R29kIGlzIHRoZXJlIGFuZCBsb3ZlcyBtZQ== | ÷ c2luIHNlcGFyYXRlZCBtZSBmcm9tIEhpbQ== ✝ YnV0IEplc3VzIGRpZWQgdG8gc2F2ZSBtZQ== | ? U2hhbGwgSSBiZWNvbWUgSGlzIGZyaWVuZD8= -- (sig_end) On Mon, 17 Apr 2023 07:37:40 +0000 Gottfried <[email protected]> wrote:Hi, thanks for helping me. ------------------------------------------------------------------ 1. I added: "GUIX_EXTRA_PROFILES=/home/gfp/Projekte" to my /.bash_profile 2. I changed the sentence "profile=$i/$(basename "$i")" to: "profile=$i" 3. my /.bash_profile looks now, after changing like this: # Honor per-interactive-shell startup file if [ -f ~/.bashrc ]; then . ~/.bashrc; fi GUIX_EXTRA_PROFILES=/home/gfp/Projekte for i in $GUIX_EXTRA_PROFILES/*; do profile=$i if [ -f "$profile"/etc/profile ]; then GUIX_PROFILE="$profile" . "$GUIX_PROFILE"/etc/profile fi unset profile done ---------------------------------------------------------------------- 4. my /.bashrc looks like this # Bash initialization for interactive non-login shells and # for remote shells (info "(bash) Bash Startup Files"). # Export 'SHELL' to child processes. Programs such as 'screen' # honor it and otherwise use /bin/sh. export SHELL if [[ $- != *i* ]] then # We are being invoked from a non-interactive shell. If this # is an SSH session (as in "ssh host command"), source # /etc/profile so we get PATH and other essential variables. [[ -n "$SSH_CLIENT" ]] && source /etc/profile # Don't do anything else. return fi # Source the system-wide file. source /etc/bashrc # Adjust the prompt depending on whether we're in 'guix environment'. if [ -n "$GUIX_ENVIRONMENT" ] then PS1='\u@\h \w [env]\$ ' else PS1='\u@\h \w\$ ' fi alias ls='ls -p --color=auto' alias ll='ls -l' alias grep='grep --color=auto' ---------------------------------------------------------------------change the configuration of one's terminal emulator to start bashwith `-l`5. Where do I have to add "-l" in /.bashrc? Kind regards Gottfried Am 16.04.23 um 22:18 schrieb Wojtek Kosior:Hi Gottfried, I see 3 potential problems. 1. The snippet you addet to .bashrc refers to a variable named "GUIX_EXTRA_PROFILES". Is this variable defined somewhere? Is seems it isn't. It should be assigned the path to the directory holding your profiles so you could for example add a GUIX_EXTRA_PROFILES=/path/to/directory/with/my/guix/profiles line before the `for` loop. Of course, replacing the "/path/to/directory/with/my/guix/profiles" with the appropriate path for your system. 2. Why is `basename` being used here? Consider the following example: - "GUIX_EXTRA_PROFILES" is set to /home/user/my-extra-guix-stuff - you have 1 extra Guix profile under "/home/user/my-extra-guix-stuff/music" - the profile mentioned above has its `profile` script under "/home/user/my-extra-guix-stuff/music/etc/profile" Now, let's look at what the profile=$i/$(basename "$i") line does. This line is inside a `for` loop, in each iteration the variable "i" holds the path to one of the profiles under "/home/user/my-extra-guix-stuff". In one iteration "i" is going to hold the string "/home/user/my-extra-guix-stuff/music". The `basename "$i"` command therefore outputs just "music". So the line we're analyzing assigns the string "/home/user/my-extra-guix-stuff/music/music" to variable called "profile". Is this what we wanted? The next line is going to check for the existence of file "/home/user/my-extra-guix-stuff/music/music/etc/profile" but it should instead check for the existence of "/home/user/my-extra-guix-stuff/music/etc/profile". So you might want to e.g. replace the line profile=$i/$(basename "$i") with just profile=$i 3. You edited "~/.bash_profile" which is indeed known to be read by bash. However, this is not that simple. Bash has 3 possible modes of running: non-interactive shell, interactive shell and (interactive) login shell. The "login shell" mode is meant to be used when, well, bash is spawned in a terminal upon user login. "~/.bash_profile" is *only* read by bash in this mode and not in the other 2. In interactive shell mode, bash reads "~/.bashrc" *instead*. When you, for example, execute a `bash` command inside an already-running shell, the child bash shell that spawns is not going to consider itself a login shell but rather a mere interactive shell. To make bash think is is a login shell, you can e.g. start it with a `-l` flag, like `bash -l`. The problem is, most terminal emulators by default don't start bash this way. The 2 solutions I've been using are to either - change the configuration of one's terminal emulator to start bash with `-l` - or make the ".bashrc" script check if current interactive shell was spawned by a teminal emulator process and if yes, have it activate the Guix profiles. The 1st solution is the proper one, the 2nd one is just a workaround for terminal emulators that are not configurable enough :) Wojtek -- (sig_start) website: https://koszko.org/koszko.html PGP: https://koszko.org/key.gpg fingerprint: E972 7060 E3C5 637C 8A4F 4B42 4BC5 221C 5A79 FD1A ♥ R29kIGlzIHRoZXJlIGFuZCBsb3ZlcyBtZQ== | ÷ c2luIHNlcGFyYXRlZCBtZSBmcm9tIEhpbQ== ✝ YnV0IEplc3VzIGRpZWQgdG8gc2F2ZSBtZQ== | ? U2hhbGwgSSBiZWNvbWUgSGlzIGZyaWVuZD8= -- (sig_end) On Sun, 16 Apr 2023 13:09:00 +0000 Gottfried <[email protected]> wrote:Hi, according to the cookbook I added -------------------------------------------- for i in $GUIX_EXTRA_PROFILES/*; do profile=$i/$(basename "$i") if [ -f "$profile"/etc/profile ]; then GUIX_PROFILE="$profile" . "$GUIX_PROFILE"/etc/profile fi unset profile done ----------------------------------------------- into my .bash_profile file in order to enable all profiles at login time: ------------------------------------------------ My .bash_profile file looks now like that: # Honor per-interactive-shell startup file if [ -f ~/.bashrc ]; then . ~/.bashrc; fi for i in $GUIX_EXTRA_PROFILES/*; do profile=$i/$(basename "$i") if [ -f "$profile"/etc/profile ]; then GUIX_PROFILE="$profile" . "$GUIX_PROFILE"/etc/profile fi unset profile done ----------------------------------------------- but when starting MATE Desktop all my profiles are not enabled. Could somebody help because probably the two entries in my .bash_profile got a mistake.
--
OpenPGP_0x61FAF349C9FB7F94.asc
Description: OpenPGP public key
OpenPGP_signature
Description: OpenPGP digital signature
