Fedora-OSTree-Setup-dev / Fedora-OSTree-Setup

Glorified scipt that automates the setup of Fedora Silverblue/Kinoite based on given config file.
GNU General Public License v3.0
7 stars 3 forks source link

change default shell to fish #14

Open iaacornus opened 1 year ago

iaacornus commented 1 year ago
boredsquirrel commented 1 year ago

This should be optional. What are the advantages for you?

iaacornus commented 1 year ago

This should be optional. What are the advantages for you?

yes, it's optional, users can agree with the prompt and change it or not

boredsquirrel commented 1 year ago
  1. add fish to rpm-ostree command

  2. add this to reboot command

mkdir -p ~/.config/fish
touch ~/.config/fish/config.fish
echo 'set fish_greeting ""' >> ~/.config/fish/config.fish
cat ~/.bashrc >> ~/.config/fish/config.fish

# correct bash commands
sed -i 's/PATH=/set PATH /g' ~/.config/fish/config.fish

# removed, breaks SDDM !
# sudo lchsh $USER /usr/bin/fish

# Konsole profile

printf """[General]
Command=/usr/bin/fish
Icon=bluefish
Name=Fish
Parent=FALLBACK/""" > ~/.local/share/konsole/Fish.profile

# Gnome terminal profile

xdg-open https://fishshell.com/docs/current/fish_for_bash_users.html#fish-for-bash-users

The Konsole profile uses the Bluefish icon, which I find is the only nice icon available, if it is not existent there is none, which is also no problem. You have to configure the fish profile as the default somewhere

How to do this in Gnome terminal? Also there is a new one, right? I would include both.

Also found out Fedora uses a different command for changing the shell, possibly to avoid security flaws, so it needs sudo.

Problems

Replacing Fish as default shell is not recommended, some reported it breaks login!

Also if a shell script lacks the #!/bin/sh or #!/bin/bash it may not run!

I dont know currently how to load another script containing aliases, this is really useful using the bash alias project

The PATH command is different in fish, but this can be replaced easily.

Some other preconfigured bash commands may give problems, copying the complete config should be a choice.

boredsquirrel commented 1 year ago

maybe create a seperate fish appstarter

printf """[Desktop Entry]
Name=Fish Shell
Exec=fish
Icon=utilities-terminal
Terminal=true
Type=Application""" > ~/.local/share/applications/fish.desktop
boredsquirrel commented 1 year ago

another question is how to remove this huge shell "username" (?):

user@fedora /v/h/u/.c/fish> 
boredsquirrel commented 1 year ago

fish shell now needs another way to add the paths to $PATH

Some dude made some commands to make this easy

# addpaths
function addpaths
    contains -- $argv $fish_user_paths
       or set -U fish_user_paths $fish_user_paths $argv
    echo "Updated PATH: $PATH"
end

# removepaths
function removepath
    if set -l index (contains -i $argv[1] $PATH)
        set --erase --universal fish_user_paths[$index]
        echo "Updated PATH: $PATH"
    else
        echo "$argv[1] not found in PATH: $PATH"
    end
end

# make functions autoloading
funcsave addpaths; funcsave removepath

# use
addpaths ~/.cargo/bin ~/.local/bin ~/.bin
boredsquirrel commented 1 year ago

EDIT: No you should not! automatically exiting bash may cause lots of programs to misbehave, while you really only want fish for its usability.

you could also just change to fish via

echo "fish" >> ~/.bashrc

a more extreme way would be changing the shell permanently

sudo usermod -s /usr/bin/fish $USER
boredsquirrel commented 1 year ago

unsure. Some people said it doesnt do anything unexpected, some others say it breaks the system. I would just keep fish as the shell for the Terminal app, and use good old bash for everything else. Fish is pretty nice!

boredsquirrel commented 1 year ago

PROBLEM:

Distrobox using Fedora doesnt work if fish is not installed. Some script detecting if a distrobox using fedora exists and installing fish there is needed.

distrobox list | grep registry.fedoraproject.org && distrobox-enter -- sudo dnf install -y fish

Problems here:

my boxes look like this:

077f55158c2e | fedora               | Up 8 minutes                   | registry.fedoraproject.org/fedora-toolbox:37
ec27f1092d84 | fedora-blank         | Exited (143) 7 days ago        | registry.fedoraproject.org/fedora-toolbox:37

SOLUTION: ask for user input of the boxes name, if empty the default F36 one will be chosen.

in bash:

read -p "You need to install fish in your Fedora distrobox. How is it called? (leave blank if no name) " bname
distrobox list | grep registry.fedoraproject.org && distrobox-enter $bname -- sudo dnf install -y fish
boredsquirrel commented 1 year ago

So I did some tests. Fish is really nice, and having is as default shell doesnt break SDDM or Wayland.

Interstingly, changing the usershell to /usr/bin/bash breaks Wayland, X11 stays intact for most parts. Tried to revert it back and it broke.

So to be secure I would not replace the user shell, especially not the root shell. But it seems to be possible.

john-ghatas commented 1 year ago

The root shell should not be modified, this should be optional anyway since shells are a user preference kinda thing.

boredsquirrel commented 1 year ago

Yes agreed. Do you know if there are Gnome terminal profiles? On KDE I dont have to change any shell, just create a new profile using fish and set that as default.

The alternative would be to have an Appstarter opening fish and set that to Ctrl+Alt+T

john-ghatas commented 1 year ago

Yes gnome supports profiles

image

boredsquirrel commented 1 year ago

nice! Would you like to create a config file we can automatically print somewhere, so that users just have to select the profile? Maybe even set the profile as default?

john-ghatas commented 1 year ago

Sure that would only be a custom command to invoke fish then right?

john-ghatas commented 1 year ago

I found the following link to dump and save Gnome terminal profiles

john-ghatas commented 1 year ago

Created the following config file

> dconf dump /org/gnome/terminal/legacy/profiles:/
[/]
list=['b1dcc9dd-5262-4d8d-a863-c897e6d979b9']

[:b1dcc9dd-5262-4d8d-a863-c897e6d979b9]
use-custom-command=false

[legacy/profiles:]
list=['8844b46f-4827-4106-9afb-77fcf76521fa']

[legacy/profiles:/:8844b46f-4827-4106-9afb-77fcf76521fa]
custom-command='fish'
use-custom-command=true
visible-name='fish'

Then load that config

[...]

Used https://gist.github.com/fdaciuk/9ec4d8afc32063a6f74a21f8308e3807

john-ghatas commented 1 year ago

Managed to export the configuration but I can't find any working example on how to import it