• 1 Post
  • 47 Comments
Joined 2 years ago
cake
Cake day: September 16th, 2023

help-circle
  • I made this one to find binaries in NixOs and other systems

    get_bin_path() {
            paths=${2:-$PATH}
            for dr in $(echo $paths | tr ':' '\n') ; do
                    if [ -f "$dr/$1" ] ; then
                            echo "$dr/$1"
                            return 0
                    fi
            done
            return 1
    }
    

    Then I made this one to, if I have a shell o opened inside neovim it will tell the neovim process running the shell to open a file on it, instead of starting a new process

    _nvim_con() {
            abs_path=$(readlink --canonicalize "$@" | sed s'| |\\ |'g)
            $(get_bin_path nvim) --server $NVIM --remote-send "<ESC>:edit $abs_path<CR>"
            exit
    }
    
    # start host and open file
    _nvim_srv() {
            $(get_bin_path nvim) --listen $HOME/.cache/nvim/$$-server.pipe $@
    }
    
    if [ -n "$NVIM" ] ; then
            export EDITOR="_nvim_con"
    else
            export EDITOR="_nvim_srv"
    fi
    

    Lastly this bit: which if it detects a file and a line number split by a : it will open the file and jump to the line

    _open() {
            path_parts=$(readlink --canonicalize "$@" | sed s'| |\\ |'g | sed 's/:/\t/' )
            file=$(echo "$path_parts" | awk ' { print $1 }' )
            line=$(echo "$path_parts" | awk ' { print $2 }' )
    
            if [ -n "$line" ] ; then
                    # has line number
                    if [ -n "$NVIM" ] ; then
                            $(get_bin_path nvim) --server $NVIM --remote-send "<ESC>:edit $file<CR>:+$line<CR>"
                            exit
                    else
                            $(get_bin_path nvim) --listen $HOME/.cache/nvim/$$-server.pipe $file "+:$line"
                    fi
            else
                    $EDITOR $file
            fi
    }
    
    alias nvim="_open"
    

    all of my bash config is here



  • owsei@programming.devtoMemes@lemmy.mlFirst time?
    link
    fedilink
    arrow-up
    5
    ·
    17 days ago

    Which country?

    In Brazil there have been several pretty important meddlings, but at most the schools say that there where “several parties involved”

    Like our dictatorship, where I’d only learnt “other countries incentivized the coup”









  • owsei@programming.devtoScience Memes@mander.xyzHalf as Hot
    link
    fedilink
    English
    arrow-up
    3
    ·
    edit-2
    8 months ago

    Every decision is arbitrary in some way. We, as humans, defined it would be better to arrange the periodic table a certain way, based on characteristics of the elements, but the characteristics chosen are arbitrary. We could’ve just chosen a different set for ordering, like alphabetical.

    Tho, that’s a correct (IIRC) yet weird usage of “arbitrary”, and since language exists to talk, not to be correct, we might as well not use this definition of arbitrary and stick to what conveys information better.

    Edit: I’m wrong! perhaps “correct” was the word I meant to say, not sure tho.