1. 36
    1. 2

      Anyone care to share the most useful bits of their config?

      My terminal is Wezterm because it’s fairly hugely configurable (albeit all via a config file)

      1. 12

        A snippet of bash that I have found useful in the construction of PATH variables:

        $ paths=(
        > ~/bin
        > /usr/bin
        > /sbin
        > )
        
        $ export PATH=$(IFS=':'; printf '%s' "${paths[*]}")
        
        $ echo $PATH
        /home/jclulow/bin:/usr/bin:/sbin
        

        You can add things conditionally with paths+=( /another/dir ), and most critically you don’t need to figure out where to put colons: it happens automatically.

        1. 1

          that’s a little nicer than my method.

          here’s my pathconfig file https://github.com/pmarreck/dotfiles/blob/master/.pathconfig

          and here’s the function(s) I wrote to “safely” manipulate it https://github.com/pmarreck/dotfiles/blob/master/bin/functions/prepend_path.bash

          Includes test coverage

          1. 2

            It was definitely the conclusion of many years of code golf on the specific topic haha

            1. 1

              I think I thought about doing it the array way but then wanted something that was POSIX-compatible in case I ever switched shells, or something

        2. 6

          Honestly, my most useful bits are very simple:

          • fish shell + prompt with git status
          • ctrl-r uses fzf for history recall
          • j project to jump to $PROJECTS/project. No tomfoolery/dependencies/learning involved.
          • git aliases: gs for short-form git status, gl for git log

          Not going to tell people how to work, but that’s all I need. It is very simple, keeps on working, and doesn’t need maintenance.

          1. 3

            Fzf is the best. I’m also a huge fan of alias g=git in the bash config, then managing l=log subcommands in git’s config. It just feels right to me to delegate the aliases to their own binaries’ config.

            1. 1

              Definitely a fan of KISS!

              I use McFly for my ctrl-R replacement https://github.com/cantino/mcfly because it has some useful intelligence built-in, but fzf is definitely simpler.

              I like the j function. Again, simple!

              I also have similar git aliases such as gs. also “push” and “pull” just do a git push/pull

              1. 2

                I love reading about other people’s configs, and sometimes pick up bits and pieces to add it to my own config.

                However, it is rare to actually integrate those into my daily workflow, mostly because it tends to be dev/leadership-focused rather than something where I’m using the shell extensively through the workday. Really, I need a shell for project management stuff. Dev workflows are in a decent spot now overall.

            2. 4
              alias rm='echo That command is not available'
              alias delete='/bin/rm'
              

              The extra four characters is just enough to keep me from making a drastic mistake.

              1. 3

                I only did this recently, but I kind of tried to replicate VS Code’s integrated terminal and git UI in wezterm using splits and gitui, so that when I’m editing a file in Helix and press Ctrl+` it’ll toggle a split horizontal terminal, and if I press Alt+g it opens a fullscreen split running gitui.

                https://kirarin.hootr.club/git/steinuil/flakes/src/commit/d64ccb507f6181c4009dbde31f801b9bfe2cfba5/modules/scripts/wezterm.lua#L105

                Another thing I use quite frequently is just a Nushell script I wrote to run nixos-rebuild or nix-darwin rebuild depending on the hostname of the current machine, and a wrapper to nix search that shows the results in a Nushell table. I have a half-baked wrapper for some docker commands as well but it’s far from being complete so I haven’t committed it yet.

                1. 2

                  In a ./link script in my dotfiles repo, it adds a symlink to all versioned dotfiles directly to the home directory:

                  list_versioned_dotfiles |
                  while read line ; do
                    ln -s ~/.dotfiles/$line ~/$line
                  done
                  

                  This lets me view/edit files I want to be version controlled directly in my home directory without managing the home directory as a repo. I honestly forgot which ones are versioned as I edit them directly from ~/, but every few months I can check in with a git diff in the .dotfiles directory and see what I have changed. It is usually multi-os config differences.

                  1. 2

                    I’ve got a lot of configs useful to me, but only one I’ve tried to document as a blog post: using broot with Zsh, especially as an argument completer for partially typed paths.

                    1. 2

                      I use _SHLVL=$(printf '\$%.0s' $(seq 1 $SHLVL)) to tell how many subshells deep I am.

                      1. 1

                        hmmm, this only prints \$ for me, times the levels of depth

                        also, doesn’t SHLVL already tell you how many subshells deep you are?

                        1. 3

                          I stick this in my PS1, so if I enter shells it stacks the $.

                          [user@host]$ bash
                          [user@host]$$ bash
                          [user@host]$$$
                          
                          1. 1

                            that’s pretty neat! will have to consider that

                    2. 2

                      invoking @okaleniuk so author could see the reaction to his piece of text