terminal todo list

interpretive language scripts


Moderator: Forum moderators

williwaw
Posts: 1957
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 172 times
Been thanked: 370 times

terminal todo list

Post by williwaw »

a simple terminal todo list that could be improved

mkdir -p ~/todo/do ~/todo/done
paste the code into your .bashrc

tasks are stored as file names ex. # todo taxes , # todo mow grass
but multi word tasks need to be enclosed in quotes to be removed from the todo list
ex. # todo 'mow grass'
hmm ?

Code: Select all

# mkdir -p ~/todo/do ~/todo/done
# paste this code to your .bashrc
# https://sambrin.medium.com/fin-command-line-todo-list-made-with-30a2346de068
#STANDARD="\e[0m"
   TODO_LIST_LABEL="\n----------Todo List-----------\n"
   TODO_LIST_END="\n------------------------------\n"
TASKS_DIR=~/todo/do/
COMPLETED_DIR=~/todo/done/
function todo {
 if [ -z "$1" ]
 then
   printf "${TODO_LIST_LABEL}"
   find ${TASKS_DIR} -not -path '*/\.*' -type f -execdir echo '{}' ';' | nl -s ' ' -b n
   printf "${TODO_LIST_END}"
 else
   touch ${TASKS_DIR}"${*}"
   todo
 fi
}
_fin () {
   IFS=$'\n' tmp=( $(compgen -W "$(ls "${TASKS_DIR}")" -- "${COMP_WORDS[$COMP_CWORD]}" ))
   COMPREPLY=( "${tmp[@]// /\ }" )
   IFS=$' '
}
function fin {
 if ! [[ -z "$1" ]] && [ -e ${TASKS_DIR}"${*}" ]
 then
   mv ${TASKS_DIR}"$1" ${COMPLETED_DIR}
   todo
   printf " $1 removed from list \n\n"
 else
   echo -e "\nusage: fin [existing task to complete]\n"
 fi
}
complete -o default -F _fin fin
Last edited by williwaw on Sat Apr 13, 2024 9:26 pm, edited 3 times in total.
User avatar
MochiMoppel
Posts: 1239
Joined: Mon Jun 15, 2020 6:25 am
Location: Japan
Has thanked: 21 times
Been thanked: 439 times

Re: terminal todo

Post by MochiMoppel »

williwaw wrote: Thu Apr 11, 2024 10:42 pm

a simple terminal todo list that could be improved
mkdir -P ~/todo/do ~/todo/done
paste the code into your .bashrc

Did you test? Should be mkdir -p ~/todo/do ~/todo/done
Small letter p !

williwaw
Posts: 1957
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 172 times
Been thanked: 370 times

Re: terminal todo

Post by williwaw »

MochiMoppel wrote: Fri Apr 12, 2024 1:48 am
williwaw wrote: Thu Apr 11, 2024 10:42 pm

a simple terminal todo list that could be improved
mkdir -P ~/todo/do ~/todo/done
paste the code into your .bashrc

Did you test? Should be mkdir -p ~/todo/do ~/todo/done
Small letter p !

yes, I have been using it. you are correct small -p

todo get dogfood works
fin get dogfood fails
error reports get is removed from list , but neither get or get dogfood is removed

some1
Posts: 86
Joined: Wed Aug 19, 2020 4:32 am
Has thanked: 18 times
Been thanked: 15 times

Re: terminal todo list

Post by some1 »

terminal todo list
hmm - yeah someday
----
----

The classic linux commandline todo-list app is/was called todo.txt
and at least goes back to 2010.

Its still maintained.
Website,info,downloads:
http://todotxt.org/

----
Anyway - a todo-list-app is a rather personal thingie -
so good initiative.

tosim
Posts: 481
Joined: Thu Jul 23, 2020 1:13 pm
Has thanked: 929 times
Been thanked: 59 times

Re: terminal todo list

Post by tosim »

Why not just open a terminal, type in "devto"? Then, go to "man devto" and see all the options. Nice and easy!

williwaw
Posts: 1957
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 172 times
Been thanked: 370 times

Re: terminal todo list

Post by williwaw »

some1 wrote: Fri Apr 12, 2024 9:09 am

Its still maintained.
Website,info,downloads:
http://todotxt.org/

nice app with cool features.

this terminal todo list focus is like a stickynote
minimalist
nothing much to remember how.. just "todo" and "fin"

@tosim
command not found

dev.to?
in the browser?

Burunduk
Posts: 255
Joined: Thu Jun 16, 2022 6:16 pm
Has thanked: 7 times
Been thanked: 127 times

Re: terminal todo

Post by Burunduk »

williwaw wrote: Fri Apr 12, 2024 2:06 am

todo get dogfood works
fin get dogfood fails
error reports get is removed from list , but neither get or get dogfood is removed

Inconsistency:

touch ${TASKS_DIR}"${*}" in the function todo

but

mv ${TASKS_DIR}"$1" ${COMPLETED_DIR} in the function fin

Replace $1 with ${*} in the mv and printf for fin get dogfood to work.

geo_c
Posts: 2881
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 2205 times
Been thanked: 878 times

Re: terminal todo

Post by geo_c »

Burunduk wrote: Sun Apr 14, 2024 12:30 am

Replace $1 with ${*} in the mv and printf for fin get dogfood to work.

Yes this works! I like it, quick and easy.

And using the echo command you can make entries into the created text files and read them with the cat command like this:

Code: Select all

bash-5.2# todo local-taxes

----------Todo List-----------
       ./local-taxes

------------------------------
bash-5.2# echo mailed by Monday >> ~/todo/do/local-taxes
bash-5.2# echo or filed online >> ~/todo/do/local-taxes
bash-5.2# cat  ~/todo/do/local-taxes
mailed by Monday
or filed online
bash-5.2#

Now I will symlink the /todo/do and /todo/done directories to a location outside my install so that all my OS's will be saving and reading from the same location.

geo_c
Old School Hipster, and Such

williwaw
Posts: 1957
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 172 times
Been thanked: 370 times

Re: terminal todo

Post by williwaw »

Burunduk wrote: Sun Apr 14, 2024 12:30 am

Replace $1 with ${*} in the mv and printf for fin get dogfood to work.

thanks, works fine.

geo_c
Posts: 2881
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 2205 times
Been thanked: 878 times

Re: terminal todo list

Post by geo_c »

Here are three scripts to view, replace, or add to the text contained in the ~/todo/do files

EDIT: These scripts do not work if there are spaces in the filenames. But they do work with wildcards. (See bottom image) Backslash spaces don't seem to work when prompted for the filename however. Without spaces in the filenames scripts work very smoothly.

They aren't bash functions, so the scripts prompt for the filename and look for it in ~/root/todo/do

todop Prints the contents of the given file
todoa Adds text to the contents of the given file
todor Replaces all the text of the given file

I located the scripts in /usr/bin, here's an example usage:
Image

todop

Code: Select all

#!/bin/bash 
read -p 'Enter todo filename: ' TASKNAME
echo ""
echo ""$TASKNAME":"
cat ~/todo/do/$TASKNAME
echo "" 

todor

Code: Select all

#!/bin/bash
read -p 'Enter todo filename: ' TASKNAME
echo ""
echo ""$TASKNAME":"
cat ~/todo/do/$TASKNAME
echo "" 
read -p 'Enter replacement text: ' NEWTEXT
echo ""
echo $NEWTEXT > ~/todo/do/$TASKNAME
printf ""$TASKNAME":"
echo ""
cat ~/todo/do/$TASKNAME
echo ""

todoa

Code: Select all

#!/bin/bash
read -p 'Enter todo filename: ' TASKNAME
echo ""
echo ""$TASKNAME":"
cat ~/todo/do/$TASKNAME
echo ""
read -p 'Enter additional text: ' ADDTEXT
echo ""
echo $ADDTEXT >> ~/todo/do/$TASKNAME
printf ""$TASKNAME":"
echo ""
cat ~/todo/do/$TASKNAME
echo ""

So by linking the ~/todo/do and ~/todo/done directories to a folder outside the installed system, and copying the three scripts to /usr/bin, I now have a very handy terminal to-do utility which is synced across multiple OS's. And of course if I want very long detailed todo text files, those can be edited in a text editor, then printed in the terminal with the todop command and comments added to the end of the file with the todoa command.

As noted in the edit above using an asterisk* can take care of spaces when prompted for the filename. Here's an example:
Image

Of course this method could overwrite other files in the /todo/do directory that have similar names. But kind of works well once you get the hang of it. (see post below)

Last edited by geo_c on Sun Apr 14, 2024 2:20 pm, edited 1 time in total.

geo_c
Old School Hipster, and Such

geo_c
Posts: 2881
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 2205 times
Been thanked: 878 times

Re: terminal todo list

Post by geo_c »

Further testing shows that using asterisks around filename words adjacent to spaces works fine, and if for some reason there are two files that fit the conditions, then the script gives an "ambiguous redirect" error and does not write to any files. So it's a safe approach in that regard.

I actually like this todo routine better than the one built in calcurse.

geo_c
Old School Hipster, and Such

tosim
Posts: 481
Joined: Thu Jul 23, 2020 1:13 pm
Has thanked: 929 times
Been thanked: 59 times

Re: terminal todo list

Post by tosim »

williwaw: You should find the cmd "devtodo" in Synaptic.

williwaw
Posts: 1957
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 172 times
Been thanked: 370 times

Re: terminal todo list

Post by williwaw »

@geo_c nice additions.

the original code, not being supplied as a standalone script, but rather added to .bashrc had a simple simplicity of not needing any options like for instance, todo -a for adding a task and todo-r for removing a task.

But just how much code do you want in .bashrc?

If todo is to become a standalone script, then I guess all functions could be contained in one script and even made interactive etc.
hmmm lets see # todo -tree

your original post got me going in a different direction of using no code at all, well, just a few aliases and a mkdir ~/tododir

alias todo="cd ~/tododir"
alias do="touch $1" (wrap multiword tasks with quotes)
alias ls="ls -1" (that's ls -one)
let's not alias rm for done

@tosim I could not find devto command, but there is a dev.to
ah. devtodo
ok will look for that

williwaw
Posts: 1957
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 172 times
Been thanked: 370 times

Re: terminal todo list

Post by williwaw »

this version removes the error returned when fin is given without an arguement.
when fin is now given without an arguement, it returns the list of finished tasks.

Code: Select all

# mkdir -p ~/todo/do ~/todo/done
# add this code to your .bashrc
# type 'todo taskname' at the prompt to add a task
# type 'fin taskname' at the prompt to remove a task
# https://sambrin.medium.com/fin-command-line-todo-list-made-with-30a2346de068
#STANDARD="\e[0m"
   TODO_LIST_LABEL="\n----------Todo List-----------\n"
   TODO_LIST_END="\n------------------------------\n"
   COMP_LIST_LABEL="\n----------Done List-----------\n"
   COMP_LIST_END="\n------------------------------\n"
TASKS_DIR=~/todo/do/
COMPLETED_DIR=~/todo/done/
function todo {
 if [ -z "$1" ]
 then
   printf "${TODO_LIST_LABEL}"
   find ${TASKS_DIR} -not -path '*/\.*' -type f -execdir echo '{}' ';' | nl -s ' ' -b n
   printf "${TODO_LIST_END}"
 else
   touch ${TASKS_DIR}"${*}"
   todo
 fi
}
_fin () {
   IFS=$'\n' tmp=( $(compgen -W "$(ls "${TASKS_DIR}")" -- "${COMP_WORDS[$COMP_CWORD]}" ))
   COMPREPLY=( "${tmp[@]// /\ }" )
   IFS=$' '
}
function fin {
 if ! [[ -z "$1" ]] && [ -e ${TASKS_DIR}"${*}" ]
 then
   mv ${TASKS_DIR}"${*}" ${COMPLETED_DIR}
   todo
   printf " ${*} removed from list \n\n"
 else
#  echo -e "\nusage: fin [existing task to complete]\n"
   printf "${COMP_LIST_LABEL}"
   find ${COMPLETED_DIR} -not -path '*/\.*' -type f -execdir echo '{}' ';' | nl -s ' ' -b n
   printf "${COMP_LIST_END}" 
 fi
}
complete -o default -F _fin fin
geo_c
Posts: 2881
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 2205 times
Been thanked: 878 times

Re: terminal todo list

Post by geo_c »

I added the updated todo.sh to my bashrc, and wrote three more scripts to print, add text, and replace the text of the files in the /roo/todot/done directory.

The added scripts I've included in the attached gzip are:

todop: prompts for a filename in the /root/todo/do directory and prints the text contained in that file
todoa: prompts for a filename in the /root/todo/do directory and prompts to add text to the end of the text contained in that file
todor: prompts for a filename in the /root/todo/do directory and prompts to replace the text contained in that file
finp: prompts for a filename in the /root/todo/done directory and prints the text contained in that file
fina: prompts for a filename in the /root/todo/done directory and prompts to add text to the end of the text contained in that file
finr: prompts for a filename in the /root/todo/done directory and prompts to replace the text contained in that file

just place these scripts in your executable path, mine are in /usr/bin and they are handy commands to use in conjunction with the todo command.

todo.tar.gz
(1.01 KiB) Downloaded 37 times

geo_c
Old School Hipster, and Such

geo_c
Posts: 2881
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 2205 times
Been thanked: 878 times

Re: terminal todo list

Post by geo_c »

I added one of the above scripts as a bash function in bashrc

I will do it with all 6 scripts posted above.
The first one is todoadd and runs like this:

Code: Select all

root# todoadd todoScript

Current text:
check for empty spaces
test
consider look
check appearance
add more functions
todoreplace todoprint finadd finreplace finprint

Enter additional text: post to forum

Updated text:
check for empty spaces
test
consider look
check appearance
add more functions
todoreplace todoprint finadd finreplace finprint
post to forum

root# 

The code for it is added to bashrc. I added a separate file in /etc/bash/bashrc.d called todoadd.sh:

Code: Select all

function todoadd {
 if ! [[ -z "$1" ]] && [ -e ${TASKS_DIR}"${*}" ]
 then
   echo ""
   printf "Current text:"
   echo ""
   cat ${TASKS_DIR}"${*}"
   echo ""
   read -p 'Enter additional text: ' ADDTEXT
   echo ""
   printf "Updated text:"
   echo ""
   echo $ADDTEXT >> ${TASKS_DIR}"$1"
   cat ${TASKS_DIR}"${*}"
   echo ""
 else
#  echo -e "\nusage: fin [existing task to complete]\n"
   printf "${TODO_LIST_LABEL}"
   find ${TASKS_DIR} -not -path '*/\.*' -type f -execdir echo '{}' ';' | nl -s ' ' -b n
   printf "${TODO_LIST_END}" 
 fi
}
complete -o default -F _todoadd todoadd

geo_c
Old School Hipster, and Such

geo_c
Posts: 2881
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 2205 times
Been thanked: 878 times

Re: terminal todo list

Post by geo_c »

These work GREAT!

Real gz file:

todo_bashrc_files.tar.gz
(1.22 KiB) Downloaded 30 times

On KLV-airedale or similar bash setups place these 7 shell scripts in /etc/bash/bashrc.d
Or they can all be pasted into one master .bashrc.

todo.sh (as found in the original post, containing the todo and fin commands)
todoadd.sh (adds text to the end of a task file found in ~/todo/do)
todoreplace.sh (replaces all text in a task file found in ~/todo/do)
todoprint.sh (displays all text found in a task file found in ~/todo/do)
finadd.sh (adds text to the end of a completed task file found in ~/todo/done)
finreplace.sh (replaces all text in a completed task file found in ~/todo/done)
finprint.sh (displays all text in a completed task file found in ~/todo/done)

Usage looks like this:

Code: Select all

root# todo

----------Todo List-----------
       ./inventory
       ./inventory-a
       ./gig
       ./cancelCard
       ./todoScript
       ./room
       ./score

------------------------------
root# todoprint cancelCard

Current text:
close account

root# todoadd cancelCard

Current text:
close account

Enter additional text: open new account

Updated text:
close account
open new account

root# todoreplace cancelCard

Current text:
close account
open new account

Enter replacement text: close account without opening a new one

Updated text:
close account without opening a new one

root# fin cancelCard

----------Todo List-----------
       ./inventory
       ./inventory-a
       ./gig
       ./todoScript
       ./room
       ./score

------------------------------
 cancelCard removed from list 

root# fin

----------Done List-----------
       ./cameraCard
       ./evaluations
       ./changePhoneCard
       ./cancelCard
       ./BarbPayments

------------------------------
root# finprint cancelCard

Current text:
close account without opening a new one

root# finadd cancelCard

Current text:
close account without opening a new one

Enter additional text: maybe open a new account

Updated text:
close account without opening a new one
maybe open a new account

root# finreplace cancelCard

Current text:
close account without opening a new one
maybe open a new account

Enter replacement text: just close account and be done

Updated text:
just close account and be done

root#

The function names could be replaced with shorter ones, but I decided to make them obvious and deliberate when typing.

Also I tried using the less command instead of he cat command to print the text of a file, for longer files that need to be paged, but the script seemed to end on the pager and didn't complete. So I'm not sure of the syntax for that kind of functionality.

One other note about the scripts is that the /do and done directories are defined in every script, and those can probably be commented out or deleted. But I left them in and they are identical, which doesn't appear to cause any error.

geo_c
Old School Hipster, and Such

williwaw
Posts: 1957
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 172 times
Been thanked: 370 times

Re: terminal todo list

Post by williwaw »

https://waxzce.medium.com/use-bashrc-d- ... 204d5389ff

First, create a directory

mkdir ~/.bashrc.d
chmod 700 ~/.bashrc.d

Then add this to your actual .bashrc or .bash_profile (on top)

for file in ~/.bashrc.d/*.bashrc;
do
source “$file”
done

Then just split the file inside the ~/.bashrc.d directory with precise MYFILE.bashrc file. You’ll need to give them execution rights too

chmod +x ~/.bashrc.d/*.bashrc

I think with only the highlighted code in your .bashrc, one could extract your gz into a newly created ~/.bashrc.d
(not tested)

Also I tried using the less command instead of he cat command to print the text of a file, for longer files that need to be paged, but the script seemed to end on the pager and didn't complete. So I'm not sure of the syntax for that kind of functionality.

without actually seeing your usage of less in a script, just guessing you might try something like cat filename | less

geo_c
Posts: 2881
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 2205 times
Been thanked: 878 times

Re: terminal todo list

Post by geo_c »

williwaw wrote: Fri Apr 26, 2024 4:37 pm

https://waxzce.medium.com/use-bashrc-d- ... 204d5389ff

First, create a directory
Then just split the file inside the ~/.bashrc.d directory with precise MYFILE.bashrc file. You’ll need to give them execution rights too
chmod +x ~/.bashrc.d/*.bashrc

I don't think I'll try that with the Void based KLs, because they seem to work well with the bashrc.d configuration in etc/bash.

I may try that approach on F96_CE4 when I add them there.

williwaw wrote: Fri Apr 26, 2024 4:37 pm

I think with only the highlighted code in your .bashrc, one could extract your gz into a newly created ~/.bashrc.d
(not tested)

This is basically how it's setup now in KLV-airedale and Spectr. Well not really, the scripts are separate in a directory called /etc/bash/bashrc.d

williwaw wrote: Fri Apr 26, 2024 4:37 pm

without actually seeing your usage of less in a script, just guessing you might try something like cat filename | less

I have a cat command that prints the contents of todo task file or completed task file, and I simply tried putting less in place of cat:
As line 19 of this todoprints.sh script. But I'll try it by using the cat filename pipe to less approach and see what happens.

Code: Select all

# mkdir -p ~/todo/do ~/todo/done
# add todo.sh to you .bashrc
# add this code to your .bashrc
# type 'todoprint taskname' at the prompt to display text in a task file located in ../todo
# https://sambrin.medium.com/fin-command-line-todo-list-made-with-30a2346de068
#STANDARD="\e[0m"
   TODO_LIST_LABEL="\n----------Todo List-----------\n"
   TODO_LIST_END="\n------------------------------\n"
   COMP_LIST_LABEL="\n----------Done List-----------\n"
   COMP_LIST_END="\n------------------------------\n"
TASKS_DIR=~/todo/do/
COMPLETED_DIR=~/todo/done/
function todoprint {
 if ! [[ -z "$1" ]] && [ -e ${TASKS_DIR}"${*}" ]
 then
   echo ""
   printf "Current text:"
   echo ""
   cat ${TASKS_DIR}"${*}"
   echo ""
 else
#  echo -e "\nusage: fin [existing task to complete]\n"
   printf "${TODO_LIST_LABEL}"
   find ${TASKS_DIR} -not -path '*/\.*' -type f -execdir echo '{}' ';' | nl -s ' ' -b n
   printf "${TODO_LIST_END}" 
 fi
}
complete -o default -F _todoprint todoprint

geo_c
Old School Hipster, and Such

williwaw
Posts: 1957
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 172 times
Been thanked: 370 times

Re: terminal todo list

Post by williwaw »

geo_c wrote: Sun Apr 14, 2024 12:07 pm

Here are three scripts to view, replace, or add to the text contained in the ~/todo/do files

EDIT: These scripts do not work if there are spaces in the filenames. But they do work with wildcards. (See bottom image) Backslash spaces don't seem to work when prompted for the filename however. Without spaces in the filenames scripts work very smoothly.

They aren't bash functions, so the scripts prompt for the filename and look for it in ~/root/todo/do

todop Prints the contents of the given file
todoa Adds text to the contents of the given file
todor Replaces all the text of the given file

I located the scripts in /usr/bin, here's an example usage:
Image

todop

Code: Select all

#!/bin/bash 
read -p 'Enter todo filename: ' TASKNAME
echo ""
echo ""$TASKNAME":"
cat ~/todo/do/$TASKNAME
echo "" 

todor

Code: Select all

#!/bin/bash
read -p 'Enter todo filename: ' TASKNAME
echo ""
echo ""$TASKNAME":"
cat ~/todo/do/$TASKNAME
echo "" 
read -p 'Enter replacement text: ' NEWTEXT
echo ""
echo $NEWTEXT > ~/todo/do/$TASKNAME
printf ""$TASKNAME":"
echo ""
cat ~/todo/do/$TASKNAME
echo ""

todoa

Code: Select all

#!/bin/bash
read -p 'Enter todo filename: ' TASKNAME
echo ""
echo ""$TASKNAME":"
cat ~/todo/do/$TASKNAME
echo ""
read -p 'Enter additional text: ' ADDTEXT
echo ""
echo $ADDTEXT >> ~/todo/do/$TASKNAME
printf ""$TASKNAME":"
echo ""
cat ~/todo/do/$TASKNAME
echo ""

So by linking the ~/todo/do and ~/todo/done directories to a folder outside the installed system, and copying the three scripts to /usr/bin, I now have a very handy terminal to-do utility which is synced across multiple OS's. And of course if I want very long detailed todo text files, those can be edited in a text editor, then printed in the terminal with the todop command and comments added to the end of the file with the todoa command.

As noted in the edit above using an asterisk* can take care of spaces when prompted for the filename. Here's an example:
Image

Of course this method could overwrite other files in the /todo/do directory that have similar names. But kind of works well once you get the hang of it. (see post below)

I have your additional scripts added to my path and have tried them two ways. the first with my version of todo incorporated into .bashrc, and the second with your version of todo.sh, (renamed to todo and made executable) placed in the path alongside the other scripts.
for some reason. todo for me has never prepended the output with ./ as I see it does for you, but no matter,
the usage as shown below seems to not find the file

0 ~ $ todo groceries

----------Todo List-----------
groceries
pay the taxes before the 15TH

------------------------------
0 ~ $ todo buy groceries

----------Todo List-----------
buy groceries
groceries
pay the taxes before the 15TH

------------------------------
0 ~ $ todoa
bash: /home/88/bin/todoa: cannot execute: required file not found
1 ~ $ todoa groceries
bash: /home/88/bin/todoa: cannot execute: required file not found
1 ~ $ todoa buy groceries
bash: /home/88/bin/todoa: cannot execute: required file not found
1 ~ $ todoa buy*
bash: /home/88/bin/todoa: cannot execute: required file not found
1 ~ $ todoa *groceries
bash: /home/88/bin/todoa: cannot execute: required file not found
1 ~ $

Code: Select all

 $ read --help
read: read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]
    Read a line from the standard input and split it into fields.
    
    Reads a single line from the standard input, or from file descriptor FD
    if the -u option is supplied.  The line is split into fields as with word
    splitting, and the first word is assigned to the first NAME, the second
    word to the second NAME, and so on, with any leftover words assigned to
    the last NAME.  Only the characters found in $IFS are recognized as word
    delimiters. By default, the backslash character escapes delimiter characters
    and newline.
    
    If no NAMEs are supplied, the line read is stored in the REPLY variable.
    
    Options:
      -a array	assign the words read to sequential indices of the array
    		variable ARRAY, starting at zero
      -d delim	continue until the first character of DELIM is read, rather
    		than newline
      -e	use Readline to obtain the line
      -i text	use TEXT as the initial text for Readline
      -n nchars	return after reading NCHARS characters rather than waiting
    		for a newline, but honor a delimiter if fewer than
    		NCHARS characters are read before the delimiter
      -N nchars	return only after reading exactly NCHARS characters, unless
    		EOF is encountered or read times out, ignoring any
    		delimiter
      -p prompt	output the string PROMPT without a trailing newline before
    		attempting to read
      -r	do not allow backslashes to escape any characters
      -s	do not echo input coming from a terminal
      -t timeout	time out and return failure if a complete line of
    		input is not read within TIMEOUT seconds.  The value of the
    		TMOUT variable is the default timeout.  TIMEOUT may be a
    		fractional number.  If TIMEOUT is 0, read returns
    		immediately, without trying to read any data, returning
    		success only if input is available on the specified
    		file descriptor.  The exit status is greater than 128
    		if the timeout is exceeded
      -u fd	read from file descriptor FD instead of the standard input
    
    Exit Status:
    The return code is zero, unless end-of-file is encountered, read times out
    (in which case it's greater than 128), a variable assignment error occurs,
    or an invalid file descriptor is supplied as the argument to -u.
1 ~ $ 
Burunduk
Posts: 255
Joined: Thu Jun 16, 2022 6:16 pm
Has thanked: 7 times
Been thanked: 127 times

Re: terminal todo list

Post by Burunduk »

williwaw wrote: Mon Apr 29, 2024 7:26 pm

0 ~ $ todoa
bash: /home/88/bin/todoa: cannot execute: required file not found

It could be this problem -- an error in the shebang.

On my Fossapup-9.5:

Code: Select all

root# echo $'#!/bin/bash\r' >test.sh
root# chmod 755 test.sh
root# bat test.sh
───────┬────────────────────────────────────────────────────────────────
       │ File: test.sh
───────┼────────────────────────────────────────────────────────────────
   1   │ #!/bin/bash
───────┴────────────────────────────────────────────────────────────────
root# ./test.sh
bash-5.2: ./test.sh: cannot execute: required file not found

The message used to be more informative in the old bash:

Code: Select all

root# ./test.sh
bash: ./test.sh: /bin/bash^M: bad interpreter: No such file or directory
geo_c
Posts: 2881
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 2205 times
Been thanked: 878 times

Re: terminal todo list

Post by geo_c »

williwaw wrote: Mon Apr 29, 2024 7:26 pm

I have your additional scripts added to my path and have tried them two ways. the first with my version of todo incorporated into .bashrc, and the second with your version of todo.sh, (renamed to todo and made executable) placed in the path alongside the other scripts.
for some reason. todo for me has never prepended the output with ./ as I see it does for you, but no matter,
the usage as shown below seems to not find the file

My todo.sh might not be a good one, as there were a modifications mentioned here in this topic thread, and I might not be using the proper corrections.

0 ~ $ todo groceries

----------Todo List-----------
groceries
pay the taxes before the 15TH

------------------------------
0 ~ $ todo buy groceries

----------Todo List-----------
buy groceries
groceries
pay the taxes before the 15TH

------------------------------
0 ~ $ todoa
bash: /home/88/bin/todoa: cannot execute: required file not found
1 ~ $ todoa groceries
bash: /home/88/bin/todoa: cannot execute: required file not found
1 ~ $ todoa buy groceries
bash: /home/88/bin/todoa: cannot execute: required file not found
1 ~ $ todoa buy*
bash: /home/88/bin/todoa: cannot execute: required file not found
1 ~ $ todoa *groceries
bash: /home/88/bin/todoa: cannot execute: required file not found
1 ~ $

If the script toda is in your path, as an executable binary, it's looking for /root/todo/do so it can display the contents and prompt you for which file to edit. I'm not sure why it doesn't find /root/todo/do though. That command doesn't work with the filename as an argument, as it's not a bash function. It's a script with a prompt. Somehow the "~/" is not understood as your /root or maybe something you did in bash. I'd have to know more.

Code: Select all

 $ read --help
read: read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]
    Read a line from the standard input and split it into fields.
    
    Reads a single line from the standard input, or from file descriptor FD
    if the -u option is supplied.  The line is split into fields as with word
    splitting, and the first word is assigned to the first NAME, the second
    word to the second NAME, and so on, with any leftover words assigned to
    the last NAME.  Only the characters found in $IFS are recognized as word
    delimiters. By default, the backslash character escapes delimiter characters
    and newline.
    
    If no NAMEs are supplied, the line read is stored in the REPLY variable.
    
    Options:
      -a array	assign the words read to sequential indices of the array
    		variable ARRAY, starting at zero
      -d delim	continue until the first character of DELIM is read, rather
    		than newline
      -e	use Readline to obtain the line
      -i text	use TEXT as the initial text for Readline
      -n nchars	return after reading NCHARS characters rather than waiting
    		for a newline, but honor a delimiter if fewer than
    		NCHARS characters are read before the delimiter
      -N nchars	return only after reading exactly NCHARS characters, unless
    		EOF is encountered or read times out, ignoring any
    		delimiter
      -p prompt	output the string PROMPT without a trailing newline before
    		attempting to read
      -r	do not allow backslashes to escape any characters
      -s	do not echo input coming from a terminal
      -t timeout	time out and return failure if a complete line of
    		input is not read within TIMEOUT seconds.  The value of the
    		TMOUT variable is the default timeout.  TIMEOUT may be a
    		fractional number.  If TIMEOUT is 0, read returns
    		immediately, without trying to read any data, returning
    		success only if input is available on the specified
    		file descriptor.  The exit status is greater than 128
    		if the timeout is exceeded
      -u fd	read from file descriptor FD instead of the standard input
    
    Exit Status:
    The return code is zero, unless end-of-file is encountered, read times out
    (in which case it's greater than 128), a variable assignment error occurs,
    or an invalid file descriptor is supplied as the argument to -u.
1 ~ $ 

geo_c
Old School Hipster, and Such

williwaw
Posts: 1957
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 172 times
Been thanked: 370 times

Re: terminal todo list

Post by williwaw »

@Burunduk thanks

0 ~ $ whereis bash
bash: /usr/local/bin/bash /usr/local/man/man1/bash.1.gz
0 ~ $

yes. I guess if I am going to use someone elses script, I should check if the specified interpeter is in my path :oops: (its a long story why bash is in /usr/local/bin)

geo_c wrote: Mon Apr 29, 2024 8:55 pm

That command doesn't work with the filename as an argument, as it's not a bash function. It's a script with a prompt.

but that would be so nice!
perhaps I will look for a way, or at least a psuedocode suggestion.

edited out mistaken observations

Last edited by williwaw on Tue Apr 30, 2024 6:50 am, edited 1 time in total.
geo_c
Posts: 2881
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 2205 times
Been thanked: 878 times

Re: terminal todo list

Post by geo_c »

williwaw wrote: Mon Apr 29, 2024 10:22 pm
geo_c wrote: Mon Apr 29, 2024 8:55 pm

That command doesn't work with the filename as an argument, as it's not a bash function. It's a script with a prompt.

but that would be so nice!
perhaps I will look for a way, or at least a psuedocode suggestion.

Well the todoadd.sh, todoreplace.sh, and todoprint.sh, along with the corresponding finadd.sh, finreplace.sh, and finprint.sh are indeed bash functions.

I have placed them in my /etc/bash/bashrc.d folder and that's all that is necessary to run them like found here: viewtopic.php?p=117992#p117992

They work great on KLV-airedale. I'm not an expert in all the ways to configure bashrc though. I think you could either take the approach of keeping the shell scripts in a bashrc.d directory, or copy the code into your universal bashrc. Whatever fits your setup best.

So to sum up, the original scripts I posted todoa, todor, and todop, are no longer necessary. Though I still have both on the system because they take up very little room.

so I'm going to admit, @Burunduk , that's some valuable information about the shebang. Now I get it, it points to where the actual bash binary is?
duh....

I've never let a lack of proper information stop me from experimenting.

geo_c
Old School Hipster, and Such

williwaw
Posts: 1957
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 172 times
Been thanked: 370 times

Re: terminal todo list

Post by williwaw »

geo_c wrote: Tue Apr 30, 2024 1:08 am

Well the todoadd.sh, todoreplace.sh, and todoprint.sh, along with the corresponding finadd.sh, finreplace.sh, and finprint.sh are indeed bash functions.

I have placed them in my /etc/bash/bashrc.d folder and that's all that is necessary to run them

sorry , I missed that change in functionality.
so I guess what I am looking to do is something like todoa groceries and have the script offer to add something to the grocery list, but all written as a standalone script.

geo_c
Posts: 2881
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 2205 times
Been thanked: 878 times

Re: terminal todo list

Post by geo_c »

williwaw wrote: Tue Apr 30, 2024 2:25 am
geo_c wrote: Tue Apr 30, 2024 1:08 am

Well the todoadd.sh, todoreplace.sh, and todoprint.sh, along with the corresponding finadd.sh, finreplace.sh, and finprint.sh are indeed bash functions.

I have placed them in my /etc/bash/bashrc.d folder and that's all that is necessary to run them

sorry , I missed that change in functionality.
so I guess what I am looking to do is something like todoa groceries and have the script offer to add something to the grocery list, but all written as a standalone script.

You might be able to start with the todoadd.sh and build it out from there. Above my paygrade at the moment. I'll play with in a system where I don't have it added to bashrc yet, like F96.

EDIT: I definitely don't know how to get that to work as a standalone script. But in F96 the 7 scripts placed in /etc/bash_completion.d work great. They give you all the functionality you're looking for. I mean it would probably be nice to insert text on a certain line, but that would get a lot more complicated, would need some kind of sed command worked in.

geo_c
Old School Hipster, and Such

williwaw
Posts: 1957
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 172 times
Been thanked: 370 times

Re: terminal todo list

Post by williwaw »

geo_c wrote: Tue Apr 30, 2024 3:19 am

EDIT: I definitely don't know how to get that to work as a standalone script.

not a standalone script, but I can add functions to a file and then source the file.

for instance if put all your *add, *replace, and *print functions into todo.sh, then run
source todo.sh at the prompt, it lets me run all the functions in that terminal instance. (useful for testing)

I can also add . todo.sh to .bashrc to make bash source todo.sh every time a teminal is opened.

geo_c
Posts: 2881
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 2205 times
Been thanked: 878 times

Re: terminal todo list

Post by geo_c »

williwaw wrote: Tue Apr 30, 2024 5:38 pm
geo_c wrote: Tue Apr 30, 2024 3:19 am

EDIT: I definitely don't know how to get that to work as a standalone script.

not a standalone script, but I can add functions to a file and then source the file.

for instance if put all your *add, *replace, and *print functions into todo.sh, then run
source todo.sh at the prompt, it lets me run all the functions in that terminal instance. (useful for testing)

I can also add . todo.sh to .bashrc to make bash source todo.sh every time a teminal is opened.

Yes, so using source adds the function temporarily in that bash instance. The scripts are fully working and should be able to be combined into one. At the moment I'm working on a sed or awk script to insert text lines in the todo/do task files between the lines that are there. It almost works, but NOT. I'll keep experimenting with it. I can post what I have if you're inclined to trouble shoot it. I'm basically grabbing ideas from forums, and not good enough to know what different approaches I should take to get it working.

Getting a good todoinsert and todoremove command to add and delete text from the specific lines in the files will make the todo script very handy in the terminal, as not only a todo list but a basic file creator and editor, allowing to organize information on the fly.

I've been using these todo functions as a daily planner now since first trying the script you posted. Fits my workflow.

geo_c
Old School Hipster, and Such

williwaw
Posts: 1957
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 172 times
Been thanked: 370 times

Re: terminal todo list

Post by williwaw »

temporialy and permanent if you dont want to maintain a ~/bashrc.d dir or configs in /etc

I have thought of the possibility of numbering. Not only the tasks (filenames) but also the file content lists.
so something like fin4
or
todoreplace7 for inside the file

reading up a bit when I have a chance.

geo_c
Posts: 2881
Joined: Fri Jul 31, 2020 3:37 am
Has thanked: 2205 times
Been thanked: 878 times

Re: terminal todo list

Post by geo_c »

williwaw wrote: Tue Apr 30, 2024 11:57 pm

tI have thought of the possibility of numbering. Not only the tasks (filenames) but also the file content lists.
so something like fin4
or
todoreplace7 for inside the file

reading up a bit when I have a chance.

Well me too, because I was reading on sed and grep, and if we grep the lines with a grep -n then we'll get the lines numbered, and then a specific number can be chosen to act on with sed. But getting that to work with one command with a double argument (variable?) in other words: todoreplace laundry 7 would be something I have no idea how to do.

edit: just playing with that grep, and first of all I should change the todoprint function to a grep line instead of cat, and then it will display the line numbers.

geo_c
Old School Hipster, and Such

Post Reply

Return to “Scripts”