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') ; doif [ -f "$dr/$1" ] ; thenecho"$dr/$1"return 0
fidonereturn 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" ] ; thenexport EDITOR="_nvim_con"elseexport 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 numberif [ -n "$NVIM" ] ; then
$(get_bin_path nvim) --server $NVIM --remote-send "<ESC>:edit $file<CR>:+$line<CR>"exitelse
$(get_bin_path nvim) --listen $HOME/.cache/nvim/$$-server.pipe $file"+:$line"fielse$EDITOR$filefi
}
alias nvim="_open"
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