So, I just found out about a programme called SynthShell which kind of does the work for you and gives you a nice looking shell, the thing is that this also creates some config files and other stuff in my system, instead of just one .bashrc file to edit. What would be the best way to learn to have a nice looking bash where I can just have a backup of it that I can use throughout systems?

  • chtk@feddit.nl
    link
    fedilink
    arrow-up
    20
    arrow-down
    1
    ·
    11 months ago

    You’ll want to look into a category of programs called dotfiles managers. There’s a bunch of them. Most of them are based on some kind of version control system, usually git.

    I personally use yadm

    • 𝘋𝘪𝘳𝘬
      link
      fedilink
      arrow-up
      10
      ·
      edit-2
      11 months ago

      I personally use yadm

      I just use some code and Git.

      if [ ! -z "$PS1" ]; then
          repo="${XDG_CONFIG_HOME}/dotfiles/"
          br='origin/main'
      
          title="\e[1m\e[31m\n ░▒▓\e[7m    %s    \e[27m▓▒░\e[0m\n\n%s\n\n"
          status="$(git --git-dir="$repo" --work-tree="$HOME" status -s)"
          diff=$(git --git-dir="$repo" --work-tree="$HOME" diff --stat --cached $br)
      
          [ -n "$status" ] && printf "$title" "Uncommited changes!" "$status"
          [ -n "$diff" ] && printf "$title" "Not yet pushed commits!" "$diff"
      
          unset title status diff br
          alias dotfiles="/usr/bin/git --git-dir=$repo --work-tree=$HOME"
      fi
      

      The code runs when it’s an interactive shell with a PS1 prompt and just checks if any of the tracked files have changed or if there are commits that are not pushed. By configuration I ignore all untracked files. If something has changed or wasn’t pushed it always prints an annoying message.

      Whenever I want to do something I use dotfiles ..... instead of git ....., everything else works the same.

      • Beej Jorgensen@lemmy.sdf.org
        link
        fedilink
        arrow-up
        3
        arrow-down
        1
        ·
        11 months ago

        This is the fun way. I have a ton of configuration files in git and I symlink to them from various places with an install script. And zshrc has enough brains to determine the OS it’s running under and the hostname. Between those two, I can have it do all the Right Things no matter what system it’s on. So far, it deploys to my personal Mac, my work Mac, my personal Linux box, my SDF account, and my Android phone with tmux.

        Basically I clone the repo into .local/share/beejsys and then run the install script and everything just works. And I don’t typically have to rerun the install script after a pull.

    • ghost_laptopOP
      link
      fedilink
      arrow-up
      2
      ·
      11 months ago

      I think I maybe phrased it horribly, my question was more like, what do I need to learn in order to modify myself the .bashrc by myself instead of using a programme. Does it make sense?

      • OpenStars@discuss.online
        link
        fedilink
        English
        arrow-up
        9
        ·
        11 months ago

        Bash syntax - I recommend Unix Power Tools by O’Reilly, but it is more advanced so maybe start with a basic version. People look at me funny whenever I say this, but I started myself with something like Unix for Dummies. Why not!?

        Keep in mind that this is no trivial task: bash is basically a programming language unto itself - it even has conditionals, loops, variables, etc. Yet SO worth it if you use Unix and want to know more what it is doing.

        You also should have a basic familiarity with Unix foundationals as well, to know why something such as this is very dangerous:

        export PATH=“~/bin/:$PATH”

        So, the easy way would be to just take the nice file, copy it wherever you want, and leave it at that. The hard way of actually understanding it may require a deeper dive into Unix. Unix Power Tools, with the picture of a drill on the cover, or maybe someone will recommend a better option but that’s what comes to my mind.

        Have fun!:-)

      • dream_weasel@sh.itjust.works
        link
        fedilink
        arrow-up
        3
        ·
        11 months ago

        So you can do what you like, but if you are going down the road of shell customization, I recommend you first consider if bash is the shell you want to keep by googling around and reading some articles.

        I personally use ZSH (and I cannibalized ohmyzsh for the few configs I wanted instead of taking the whole giant bastard of a thing) but fsh is a fine choice if you don’t care about posix (a different discussion). There are some other options to consider as well, but if you’re gonna configure, don’t do it then do it again in a month with different syntax lol.

        • ghost_laptopOP
          link
          fedilink
          arrow-up
          1
          ·
          11 months ago

          Yeah, recently after posting this I went down a rabbit hole and found out about zsh and fish and I kind of like fish so I’m thinking about going straight to that, what a hard choice.

    • Elw@lemmy.sdf.org
      link
      fedilink
      arrow-up
      2
      arrow-down
      1
      ·
      11 months ago

      This sounds really similar to how I do things but I use Ansible. What are the advantages to something like yadm, that is specifically designed for dot file management, and a generic config management utility like Ansible?

      • d3Xt3r@lemmy.nzM
        link
        fedilink
        arrow-up
        2
        ·
        edit-2
        11 months ago

        I’ve only started using yadm recently so I may not be able to elaborate in detail, but for me the main draw for using yadm (as opposed to Ansible, which I use at work) is the simplicity. It’s basically just a bash script that uses git, so there’s no dependencies besides git and tools installed on most Unix systems. Ansible felt like overkill for what I needed, ie just something to manage and sync my dotfiles.

        Also, maybe it’s personal bias, but I really hate installing/using Python-based programs - they often tend to go wild with their dependencies and eventually break. I recall trying to install Ansible on a Raspberry Pi at some point (via pip) and it failed because one of the dependencies couldn’t be compiled for whatever reason. I gave up after trying to fix it for a while, and dropped the idea. I’ve had similar experiences with other large Python projects, there’s always some drama. Why is why I prefer compiled binaries or simple shell scripts like yadm.

        I’ve no issues using Ansible at work though. We use it on RHEL so it’s quite stable and doesn’t have the dependency issues you’d get on a bleeding-edge, ever-changing, end-user system. Plus it really shines at the Infrastructure as Code stuff so we use it to automate everything from networking gear to VMs. But I feel it’s overkill for something as simple as syncing a bunch of text files.

        • Elw@lemmy.sdf.org
          link
          fedilink
          arrow-up
          1
          ·
          9 months ago

          I recently started uses dotbot for managing dot files across my systems. It sounds very similar, in terms of the simplicity of the implementation, to yadm. You define a config file in yaml or json and run the “install” script which calls the dotbot utility, passing in your config file. With a simple change to the install script, I’ve been able to create multiple config files, one per environment (work, home, linux, mac, etc.) and I’ve been thinking about how I could automatically sync changes to git whenever I edit a config file. Leaning towards setting up an autocmd in neovim to automatically commit and push changes on save when I have one of the config files open. Just not yet sure how to do this in a way that would only run the sync for the configs and not every json or yaml file on my system. I’ve only ever set up autocmds for specific file extensions but the syntax leads me to believe it’s flexible enough that any arbitrarily specific file name or path could work the same.

  • tiny@midwest.social
    link
    fedilink
    English
    arrow-up
    5
    arrow-down
    1
    ·
    11 months ago

    If you are using nixos try home manager. Otherwise Ansible is nice for plopping templates and files into your own home directory

  • bionade24@kbin.social
    link
    fedilink
    arrow-up
    3
    ·
    11 months ago

    chezmoi.io is one of the best dotfile managers available. Great template language if you need different, many ways to distribute secrets safely, merging works well even with templates, not limited to homedir.

  • DigitalDilemma
    link
    fedilink
    arrow-up
    4
    arrow-down
    1
    ·
    11 months ago

    I uses Uyuni to push config files out to the machines I’m working on, including .bashrc files, .vimrc and all kinds of little QOL improvements.

    Probably overkill just to use Uyuni for that, though.

  • ipsirc
    link
    fedilink
    English
    arrow-up
    3
    ·
    11 months ago

    https://github.com/sineemore/backpack

    "backpack is a small wrapper around ssh.

    It transfers contents of a local file ~/.backpack and itself to remote host, sources it and continues with normal ssh session.

    works best as alias ssh=backpack won’t create any files on remote hosts (even temporary) tries to fallback to normal ssh when remote shell is not bash self-replication allows you to use backpack again directly from remote host, in this case backpack will keep original local file as you go deaper from host to host."

  • driveway@lemmy.zip
    link
    fedilink
    arrow-up
    1
    ·
    11 months ago

    You can use syncthing. Set it up and forget about it, you’ll have the same dotfiles anywhere. I have it on my phone so that changes are always synced to it if all other computers are offline.

  • callyral [he/they]@pawb.social
    link
    fedilink
    English
    arrow-up
    1
    arrow-down
    1
    ·
    11 months ago

    if you want a shell that needs less configuration and has more features, i recommend fish shell.

    for bash, you could search for someone else’s bashrc, copy that, and modify until it works how you want it to.

  • thejml@lemm.ee
    link
    fedilink
    English
    arrow-up
    1
    arrow-down
    1
    ·
    11 months ago

    As long as you’re not going to store sensitive data in there, I’ve just been using GitHub. I’ve got a Private Repository setup with my configs (.bashrc as well as WM configs and other dot files) and I just commit/push it up and heave an update script pull it down elsewhere. Then it’s also version controlled.

    • ghost_laptopOP
      link
      fedilink
      arrow-up
      1
      ·
      11 months ago

      I think I maybe phrased it horribly, my question was more like, what do I need to learn in order to modify myself the .bashrc by myself instead of using a programme. Does it make sense?

      • ShaunaTheDead@kbin.social
        link
        fedilink
        arrow-up
        4
        arrow-down
        1
        ·
        edit-2
        11 months ago

        You need to learn bash scripting. Also, there are a few default files that the .bashrc uses which can be helpful to compartmentalize the custom things you do to it so that it’s easier to undo if you screw something up. To do that, just add this to the bottom of your .bashrc

        if [ -f ~/.bash_custom ]; then
            . ~/.bash_custom
        fi
        
        

        What that will do is check if the .bash_custom file exists and then run the .bash_custom file in your home directory and apply anything in there. Also, you can call the file whatever you like, but bash does have some defaults that it will check for and run them without editing the .bashrc at all. It’s kind of hard to find a list of the the files that it automatically checks for, but I know that .bash_aliases is one of them, and I think it checks .bash_commands as well, but I’m not entirely sure. Either way, you can force it to check your custom one by using the code above.

        Then you can create the file and add any custom things in there that you like. For example, I like to frequently update through the terminal but running sudo apt update && sudo apt upgrade && sudo apt autoremove && flatpak upgrade was a bit tedious and I wanted a bit less feedback so I made a custom alias for my personal use.

        alias update='echo "Updating packages..."; sudo apt update -y &> /dev/null; echo "Packages updated."; echo "Upgrading packages..."; sudo apt upgrade -y &> /dev/null; echo "Packages upgraded."; echo "Cleaning up packges..."; sudo apt autoremove -y &> /dev/null; echo "Packages cleaned up."; echo "Updating flatpaks..."; flatpak update -y &> /dev/null; echo "Flatpaks updated."'

        Which hides most of the text from updating and just gives me feedback on what it’s currently doing if I don’t really care to know all of the details. So now I just run update in the terminal and plug in my password and it updates and upgrades everything in a human readable way.

        There’s a lot that can be done with bash scripting, like editing files, iterating over files and directories, setting environment variables. It’s basically a full programming language so the limits are mostly your imagination.

      • deanso@linux.community
        link
        fedilink
        English
        arrow-up
        2
        arrow-down
        1
        ·
        11 months ago

        Use chatgpt. Take the first line of your bashrc file and ask it to explain it. Than the second line etc. Won’t be always perfect but for bashrc it shouldn’t be a problem and you can learn a lot from it.