Skip to main content

I slightly modified your@Marcel's script. It did not workedwork for me, I could not tell why.

This is what I did :

#!/bin/bash
    
extension=$(echo $1 | rev | cut -d'.' -f1 | rev)
fName=$(basename $1 .$extension)
tmp=$(mktemp /var/tmp/$fName.XXXXXXXXXXXX.$extension)"
                                                                                                                                                                                           
sudo cat "$1" > "$tmp"
( while true;do
    changeControl=$(inotifywait -e modify "$tmp" 2>/dev/null)
    sudo cp $tmp $1
done ) &
    
pid=$!

nvim $tmp
kill $pid
rm "$tmp"

The script extractextracts the extension of the source file and useuses it the for the temp file. This way, plugins like phpactor or intelephense still works.

Then it runruns the while in parallel and waitwaits for any change.

Anyway thanks Marcel for your primary proposition that leadled me to a solution.

I slightly modified your script. It did not worked for me, I could not tell why.

This is what I did :

#!/bin/bash
    
extension=$(echo $1 | rev | cut -d'.' -f1 | rev)
fName=$(basename $1 .$extension)
tmp=$(mktemp /var/tmp/$fName.XXXXXXXXXXXX.$extension)"
                                                                                                                                                                                           
sudo cat "$1" > "$tmp"
( while true;do
    changeControl=$(inotifywait -e modify "$tmp" 2>/dev/null)
    sudo cp $tmp $1
done ) &
    
pid=$!

nvim $tmp
kill $pid
rm "$tmp"

The script extract the extension of the source file and use it the for temp file. This way, plugins like phpactor or intelephense still works.

Then it run the while in parallel and wait for any change.

Anyway thanks for your primary proposition that lead me to a solution.

I slightly modified @Marcel's script. It did not work for me, I could not tell why.

This is what I did :

#!/bin/bash
    
extension=$(echo $1 | rev | cut -d'.' -f1 | rev)
fName=$(basename $1 .$extension)
tmp=$(mktemp /var/tmp/$fName.XXXXXXXXXXXX.$extension)"
                                                                                                                                                                                           
sudo cat "$1" > "$tmp"
( while true;do
    changeControl=$(inotifywait -e modify "$tmp" 2>/dev/null)
    sudo cp $tmp $1
done ) &
    
pid=$!

nvim $tmp
kill $pid
rm "$tmp"

The script extracts the extension of the source file and uses it for the temp file. This way, plugins like phpactor or intelephense still works.

Then it runs the while in parallel and waits for any change.

Anyway thanks Marcel for your primary proposition that led me to a solution.

added 10 characters in body
Source Link

I slightly modified your script. It did not worked for me, I could not tell why.

This is what I did :

    #!/bin/bash
    
    extension=$(echo $1 | rev | cut -d'.' -f1 | rev)
    fName=$(basename $1 .$extension)
    tmp=$(mktemp /var/tmp/$fName.XXXXXXXXXXXX.$extension)"
                                                                                                                                                                                           
    sudo cat "$1" > "$tmp"
    ( while true;do
        changeControl=$(inotifywait -e modify "$tmp" 2>/dev/null)
        sudo cp $tmp $1
    done ) &
    
    pid=$!

    nvim $tmp
    kill $pid
    rm "$tmp"

The script extract the extension of the source file and use it the for temp file. This way, plugins like phpactor or intelephense still works.

Then it run the while in parallel and wait for any change.

Anyway thanks for your primary proposition that lead me to a solution.

I slightly modified your script. It did not worked for me, I could not tell why.

This is what I did :

    #!/bin/bash
    
    extension=$(echo $1 | rev | cut -d'.' -f1 | rev)
    fName=$(basename $1 .$extension)
    tmp=$(mktemp /var/tmp/$fName.XXXXXXXXXXXX.$extension)"
                                                                                                                                                                                           
    sudo cat "$1" > "$tmp"
    ( while true;do
        changeControl=$(inotifywait -e modify "$tmp" 2>/dev/null)
        sudo cp $tmp $1
    done ) &
    
    pid=$!

    nvim $tmp
    kill $pid
    rm "$tmp"

The script extract the extension of the source file and use it the for temp file. This way, plugins like phpactor or intelephense still works.

Then it run the while in parallel and wait for any change.

Anyway thanks for your primary proposition that lead me to a solution.

I slightly modified your script. It did not worked for me, I could not tell why.

This is what I did :

#!/bin/bash
    
extension=$(echo $1 | rev | cut -d'.' -f1 | rev)
fName=$(basename $1 .$extension)
tmp=$(mktemp /var/tmp/$fName.XXXXXXXXXXXX.$extension)"
                                                                                                                                                                                           
sudo cat "$1" > "$tmp"
( while true;do
    changeControl=$(inotifywait -e modify "$tmp" 2>/dev/null)
    sudo cp $tmp $1
done ) &
    
pid=$!

nvim $tmp
kill $pid
rm "$tmp"

The script extract the extension of the source file and use it the for temp file. This way, plugins like phpactor or intelephense still works.

Then it run the while in parallel and wait for any change.

Anyway thanks for your primary proposition that lead me to a solution.

added 18 characters in body
Source Link

I slightly modified your script. It did not worked for me, I could not tell why.

This is what I did :

    #!/bin/bash
    
    extension=$(echo $1 | rev | cut -d'.' -f1 | rev)
    fName=$(basename $1 .$extension)
    tmp=$(mktemp /var/tmp/$fName.XXXXXXXXXXXX.$extension)"
                                                                                                                                                                                           
    sudo cat "$1" > "$tmp"
    ( while true;do
        changeControl=$(inotifywait -e modify "$tmp" 2>/dev/null)
        sudo cp $tmp $1
    done ) &
    
    pid=$!

[your editor(ex :  nvim, vi$tmp
 or whatever)] $tmp
 kill $pid
    rm "$tmp"

The script extract the extension of the source file and use it the for temp file. This way, plugins like phpactor or intelephense still works.

Then it run the while in parallel and wait for any change.

Anyway thanks for your primary proposition that lead me to a solution.

I slightly modified your script. It did not worked for me, I could not tell why.

This is what I did :

#!/bin/bash
    
extension=$(echo $1 | rev | cut -d'.' -f1 | rev)
fName=$(basename $1 .$extension)
tmp=$(mktemp /var/tmp/$fName.XXXXXXXXXXXX.$extension)"
                                                                                                                                                                                           
sudo cat "$1" > "$tmp"
( while true;do
   changeControl=$(inotifywait -e modify "$tmp" 2>/dev/null)
   sudo cp $tmp $1
done ) &
    
pid=$!

[your editor(ex : nvim, vi or whatever)] $tmp
kill $pid
rm "$tmp"

The script extract the extension of the source file and use it the for temp file. This way, plugins like phpactor or intelephense still works.

Then it run the while in parallel and wait for any change.

Anyway thanks for your primary proposition that lead me to a solution.

I slightly modified your script. It did not worked for me, I could not tell why.

This is what I did :

    #!/bin/bash
    
    extension=$(echo $1 | rev | cut -d'.' -f1 | rev)
    fName=$(basename $1 .$extension)
    tmp=$(mktemp /var/tmp/$fName.XXXXXXXXXXXX.$extension)"
                                                                                                                                                                                           
    sudo cat "$1" > "$tmp"
    ( while true;do
        changeControl=$(inotifywait -e modify "$tmp" 2>/dev/null)
        sudo cp $tmp $1
    done ) &
    
    pid=$!

    nvim $tmp
    kill $pid
    rm "$tmp"

The script extract the extension of the source file and use it the for temp file. This way, plugins like phpactor or intelephense still works.

Then it run the while in parallel and wait for any change.

Anyway thanks for your primary proposition that lead me to a solution.

added 38 characters in body
Source Link
Loading
added 38 characters in body
Source Link
Loading
deleted 42 characters in body
Source Link
Loading
added 66 characters in body
Source Link
Loading
Source Link
Loading