LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   Gedit Problem (https://www.linuxquestions.org/questions/linux-desktop-74/gedit-problem-4175673817/)

TBotNik 04-23-2020 12:33 PM

Gedit Problem
 
All,

Created this script, to open a list of last files edited:
Code:

#! /bin/bash
#  Script to edit a list of files with GEDIT!
#  Should be in the APP Launcher
#
#  Run with cmd: bash /Scripts/FileMgmt/gedit-last.sh

srcfil=/Scripts/FileMgmt/gedit-list.txt
fillin=''
while IFS= read -r line; do
  fillin="$fillin$line "
done <$srcfil
gedit $fillin

Using this input file:
Code:

# Gedit multifile input file gedit-list.txt
/home/files/Dropbox/Books_Authoring/Blogs_&_Domains/Spiritual/kng/How_to_Pray.html
/home/files/Dropbox/Books_Authoring/Blogs_&_Domains/Spiritual/kng/Who_is_God.html
/home/files/Dropbox/Corporate/Comps_&_Holds/Dads_HC/Blog_Posts/HealthCare&You2.html
/home/files/Dropbox/Books_Authoring/Blogs_&_Domains/Truth-Party/TP_Ref01.html
/home/files/Dropbox/Books_Authoring/Blogs_&_Domains/Truth-Party/TP_Ref02.html
/home/files/Dropbox/Books_Authoring/Blogs_&_Domains/Truth-Party/TP_Ref03.html
/home/files/Dropbox/Books_Authoring/Blogs_&_Domains/Truth-Party/TP_Ref04.html
/home/files/Dropbox/Books_Authoring/Blogs_&_Domains/Truth-Party/TP_Ref05.html
/home/files/Dropbox/Books_Authoring/Blogs_&_Domains/Truth-Party/TP_Ref06.html
/home/files/Dropbox/Books_Authoring/Blogs_&_Domains/Truth-Party/TP_Ref07.html
/home/files/Dropbox/Books_Authoring/Blogs_&_Domains/Truth-Party/TP_Ref08.html

I works except for two problems:
  1. It open a new GEDIT window without the profile settings, not in the current open GEDIT session. This is not usable as it is all white, with no contrast, so I can not see the text,
  2. It reads the comment line, which it must ignore.
I'm sure ignoring the comment line is simple if I just look the the '#' 1st character.

I did not find anything about determining if GEDIT exist and opening the file list in new tabs.

Cheers!

TBNK

pan64 04-23-2020 01:04 PM

probably: https://askubuntu.com/questions/7567...les-from-nauti

TBotNik 04-23-2020 09:19 PM

Comment line fixed
 
All,

Added the test on "fstchr" so now skipping the comment line.

Code:

#! /bin/bash
#  Script to edit a list of files with GEDIT!
#  Should be in the APP Launcher
#
#  Run with cmd: bash /Scripts/FileMgmt/gedit-last.sh

srcfil=/Scripts/FileMgmt/gedit-list.txt
fillin=''
while IFS= read -r line; do
        fstchr=${line:0:1}
        if [[ "$fstchr" == "#" ]]; then
                continue
        fi
  fillin="$fillin$line "
done <$srcfil
# echo $fillin
gedit $fillin


TBotNik 04-23-2020 09:22 PM

Quote:

Originally Posted by pan64 (Post 6115026)

pan64,

Don't understand anything at/in the link you sent. I'm on KDE not Nautulis!

Cheers!

TBNK

PS:

Running cmd:
Code:

ps -A | grep gedit
Shows:
Quote:

3106 ? 00:04:14 gedit
Which is my currently open gedit session.

I assume my script should run this cmd and then change/add some option to assign the new tabs/sessions to this window, instead of a new one! Running cmd: "man gedit" did not show me any options that seemed like it/they would work.

Cheers!

tofino_surfer 04-24-2020 02:25 PM

Quote:

pan64,

Don't understand anything at/in the link you sent. I'm on KDE not Nautulis!
If you are on KDE then why are you using gedit ? You can use Kate which is a multi-file editor instead. Kate is superior to gedit. If you are having problems with gedit profile settings and you are using KDE you should try Kate instead.

Quote:

It open a new GEDIT window without the profile settings, not in the current open GEDIT session.
With KDE's Kate it adds new files specified at the command line such as $ kate new_file to the current open Kate window if there is one. I just tried this as I am on KDE also.

Quote:

I assume my script should run this cmd and then change/add some option to assign the new tabs/sessions to this window, instead of a new one! Running cmd: "man gedit" did not show me any options that seemed like it/they would work.
Kate does what you want automatically by default so there would be no need for scripts running ps commands or the like.


Also very importantly you never mentioned in your first post that you were using KDE. How would pan64 or anyone else know this ?

Nautilus is the file browser for Gnome. You wouldn't be "on Nautilus". You would be using a desktop environment such as Gnome which uses Nautilus as its file browser. Since you only mentioned gedit many would assume you were using Gnome or something related. There is no need for the exclamation marks.

TBotNik 04-24-2020 05:46 PM

Quote:

Originally Posted by tofino_surfer (Post 6115429)
If you are on KDE then why are you using gedit ? You can use Kate which is a multi-file editor instead. Kate is superior to gedit. If you are having problems with gedit profile settings and you are using KDE you should try Kate instead.



With KDE's Kate it adds new files specified at the command line such as $ kate new_file to the current open Kate window if there is one. I just tried this as I am on KDE also.



Kate does what you want automatically by default so there would be no need for scripts running ps commands or the like.


Also very importantly you never mentioned in your first post that you were using KDE. How would pan64 or anyone else know this ?

Nautilus is the file browser for Gnome. You wouldn't be "on Nautilus". You would be using a desktop environment such as Gnome which uses Nautilus as its file browser. Since you only mentioned gedit many would assume you were using Gnome or something related. There is no need for the exclamation marks.

tofino_surfer,

I always appreciate any inputs, but sometimes people respond with an opinion, not actual help, thus it is with your response.

Yes Kate is available but has no options I need and totally unveiwable as no "CONTRAST" and therefore I hate it. GEDIT has been my trusted and totally usable for all apps I engage, so sticking to it. Besides would run into the same problem with KATE, as I already have. Yes I had to customize GEDIT to my liking, but I did that over 15 years, adding plugins, configuring fonts/sizes, colors, background, etc. etc.

As for KATE doing what I want, total BS. What happens is I have 5-50 files open editing them and the edit session crashes. I'm building a separate "SAVE" bash script that records all GEDIT open/editing files, into the source file being used in this current script, so when I crash I have this as a restore. KATE as GEDIT does not keep a list of the last files edited, so has the same problem.

Your opinion is KATE is better, I disagree and so did not help with my problem.

Nautilus is a browser for losers as any every Linux user knows the only "SECURE" browser is FireFox, since 1998 and the IISC declared that use of any other browser the user is responsible for all losses and only FireFox shifts that legal blame back to the writer/programmer of any data breaching or phishing scripts. Firefox is now totally self secure, but use to need addons of: NoScript, AD_Block Plus and Ghostery to be secure.

You have to be a half wit to be using anything but Firefox as you have 0 protection using any other browser. That goes for Chrome also as Google is the #! promoter and violator of data breaches and phishing and has all their illegal viruses built right into Chrome.

Yes cmdline on Kubuntu is the same as Ubuntu, except for a list of addons and extras that come with KDE and the users separately install as apps/scripts he/she normally uses.

Cheers!

TBNK

scasey 04-24-2020 05:57 PM

Can’t help with either gedit or Kedit ... here’s an opinion....

I use SciTE on both Windows and Linux. Very customizable, excellent documentation. I’ve never had a need to open 50 files at once, but I have been as high as 20-25.

sevendogsbsd 04-24-2020 06:50 PM

OP: Nautilus isn’t a browser, it’s the file manager in the Gnome DE. Before you lash out, do your homework.

tofino_surfer 04-24-2020 11:04 PM

Quote:

Nautilus is a browser for losers as any every Linux user knows the only "SECURE" browser is FireFox,
You apparently don't understand what a file manager or file browser is and think it is a "web browser". Nautilus which is now called the very boring "Gnome files" is the equivalent of the Dolphin file manager in KDE.

File managers which may be called file browsers are very different from web browsers.

https://en.wikipedia.org/wiki/GNOME_Files

From the page above the "browser" interface of this file manager is described. The "browser" interface is often the default which is why file manager applications are sometimes called "file browsers"

Code:

In the version included with GNOME 2.6, Nautilus switched to a spatial interface.[7] Several Linux distributions have made "browser" mode the default. The "classic" interface is still available:

    By a filing cabinet shaped icon.
    By an option in the "Edit -> Preferences -> Behavior" menu in Nautilus.
    In a folder's context menu.
    By using the "--browser" switch when started by a command via a launcher or shell.

Quote:

You have to be a half wit to be using anything but Firefox as you have 0 protection using any other browser. That goes for Chrome also as Google is the #! promoter and violator of data breaches and phishing and has all their illegal viruses built right into Chrome.
How is this not an opinion and much more of a rant. All because you don't understand the difference between the file manager application of a desktop environment and a web browser.

Quote:

Your opinion is KATE is better, I disagree and so did not help with my problem.
The main problem you mentioned was that you could not open a list of files into an existing editor window with gedit. Such functionality is built into Kate. If you have an open Kate window and inside a script you open multiple files with a command they will all appear in the existing window. So on the basis of built-in functionality Kate is more powerful. gedit may have more plugins and be more configurable however it doesn't do what you want or you would not have made this post.

Nowhere in your first post did you mention that you found Kate unsuitable for other reasons or that you had ever tried Kate. No one replying to your post could have known this. I therefore did help with the problem you asked.

Quote:

As for KATE doing what I want, total BS.
It solves the main problem in your post so you could be less rude.

Quote:

What happens is I have 5-50 files open editing them and the edit session crashes.
From https://unix.stackexchange.com/quest...r-kate-crashes

Code:


Being one of the Kate Developers, I can explain the workflow like this:

When Kate or the system crashes, you lose all text buffers that were never saved. However, if you are working on a text file (that exists as file on disk), a swap file is created next to the file, called .filename.kate-swp. Now, if Kate starts again, Kate searches for these swap files. If found it replicates all edit actions that were recorded in this swap file, and your data is fully restored.

Rule of thumb: Always (and I repeat: always) work with files, not unsaved text buffers. That is good practice with everything you do on a Computer.


ondoho 04-25-2020 04:33 AM

Well, it's definitely not the first time this user lashed out like that.
Asking questions, getting angry at being pointed to a flaw in the original premise, not listening to answers.
Emotion getting in the way.
I wish it wasn't such a common scenario on the interwebz.

Quote:

Originally Posted by TBotNik (Post 6115014)
Created this script, to open a list of last files edited:

I know of several code/plaintext editors that do this ootb, regardless of DE.
I'm not going to tell you which though because you'll just lash out again, saying editor XYZ is "not what you want".

TBotNik 04-27-2020 10:00 PM

All,

When I added the script to the launcher menu it ran perfectly. I even closed out all GEDIT sessions, hit the launcher and comes up in the default GEDIT with my custom profile and adds all files to the tabs.

So marked this solved!

Cheers!

TBNK


All times are GMT -5. The time now is 03:35 PM.