forthebadge forthebadge Gem Version

This gem was last updated on the 17.04.2024 (dd.mm.yyyy notation), at 20:42:27 o'clock.

Introducing the Roebe project

(This image was partially autogenerated using cfdg rules. See the project here: https://www.contextfreeart.org/gallery/ )

This project here, the roebe gem, is a fairly chaotic project that bundles together code that I may use on a daily basis, when working on a computer.

It is, thus, primarily a toolset-project in the sense that it contains code that I can use for everyday tasks. I used to have these .rb files spread out separately, in different directories, until I realized that I may need these files on other computer systems as well - for example, in an office/work situation, or in a university campus, on site. One day I thus decided to bundle these different .rb files together into a new project, with the toplevel namespace being simply Roebe, primarily to give these different classses a unified "namespace" (a module in ruby). The name is just a "placeholder" really; any other toplevel name could have been chosen too. (For anyone curious: the pronounciation of "roebe" is actually "rö", that is, the german umlaut "ö", which in english is a bit like Smörrebröd from the Muppet show - they also use the ö; and the trailing "be" part in "roebe" is not the english "be", but more a short "behhh", such as the "e" the english casual expression "meh". So the name is "rö-behh" - not hugely important, is it?).

Do not expect that the project will have some profound, additional meta-goals other than these mentioned; it really is just a somewhat random collection of different scripts, some of them being more useful than others and more commonly used. Most of these ruby files are probably totally useless to other people, too. Some were written solely to solve one specific problem, then move on and never again use the code. So it is a bit of a data graveyard too.

Some classes that are part of the roebe gem deal with opening local files via an editor, or opening local URLs via the browser; or deleting empty files or directories; symlinking content to other directories, and so forth. Since some years this is complemented by a separate project, called open, via the Open namespace, so that I can do:

Open.in_browser(remote_URL_here)
Open.in_editor('/tmp/foobar.md')

Additionally, the Roebe project may serve as an entry point to other gems, thus tapping into the larger ruby gem ecosystem as a whole. This is an important side-goal for this project, as it is, to word this differently, my main "jumping point" for ruby these days. If I need specialized functionality, I tend to write some ruby code, put it into the roebe project, and then move on from there.

Policy in effect in regards to the roebe project

The roebe-project is adjusted to my own use cases. This also means that other users of this gem may not find the project all that terribly useful, which is understandable.

Yet, at the same time, this gem is also my most popular gem. I am not sure why that is the case, but perhaps other users found some of the code or content in this gem useful.

Either way, no matter as to the underlying reason for this, I thought about how to make the roebe-gem more useful to other people. So, in April 2024 I decided to add a policy-directive to this gem, so that other users of this gem may understand how they could benefit from the project, as well as - even more importantly - how to adjust the project to their own use cases.

I will try to adjust the code so that people can overrule behaviour that they may want to have via the commandline. Furthermore, hardcoded paths should be avoided, if possible; at the least some flexibility should be kept in mind with regard to the roebe-gem, where methods should be usable by other users, aiming to adjust the behaviour of the classes to their use cases.

Let me try to explain the above rationale with a specific example - this may make it easier to understand the changed approach I will use past April 2024.

In the past I had a GUI application called contacts. This file, unsurprisingly, contained contacts-information I would use. This information I kept in a spearate .yml file which I did not publish - after all that information is not useful to anyone else, but simply refers to my own use case here, and my own contacts file.

But, for other people, they may want to use their own .yml file. So I needed to change the code to allow custom loading of .yml files in general. I also decided to add support for a special ENV variable, so that people can simply use that variable to override any other value in the contacts.rb file.

The file contacts.rb also comes with GUI code - the old ruby-gtk3 code, libui-code as well as jruby-SWING bindings.

Starting the gtk3 bindings, for instance, can be done via:

contacts --gtk3

The long-term goal is to extend this to many more .rb files in the roebe project, when it makes sense to offer a GUI.

General remarks about the Layout and Structure of the roebe project

The roebe-project is fairly large. Most code can be found within the classes/ subdirectory of the roebe gem, as well as the toplevel_methods/ subdirectory of the roebe gem - so, roebe/classes/ and roebe/toplevel_methods/ are the two primary subdirectories of this gem.

Following that, a few classes will be described below this section in this document (README.md) - but keep in mind that this is not a "complete" documentation of all the available classes that are distributed in this gem. Only some of these classes will be described in this file here (README.md).

Before running any of the code, I recommend to you to have a look at the source code of the corresponding .rb file - that way you may be able to judge whether the functionality is desired by you or whether it may need any modifications.

Keep in mind that the functionality defaults to my own use case, which may easily differ from your use case. Some of these classes have not been updated in years, so again: have a look at the source code before running any of these classes, in particular for larger classes or classes that remove files or directories (you can grep for delete and remove to find these).

Presently the roebe-project has only a very few external dependencies - but in theory, all external dependencies could be removed altogether. I like to make use of some external code, though, which is why most .rb files within this project require external .rb files via a begin/rescue LoadError clause. If you find a .rb file not doing so, consider this to be a bug - you can report this and I will fix it then.

The most important external dependency is on the colours gem, since I make use of colours a LOT on the commandline.

Licence of the project

The main licence of the roebe project used to be GPLv2.0 (no later option; exactly GPLv2.0) up until April 2021.

The roebe project also allowed the user to use BSD/MIT licence at their own discretion, so it was essentially a "choose whichever licence you prefer", at the least in regards to these two licences.

See this list on Wikipedia for the BSD/MIT licences:

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

In April 2021 the licence for the roebe project was switched to the MIT licence.

I do not have any issue with the GPL as such; it is a fine licence in and by itself.

However had, the roebe project is really just a collection of different scripts. It is not necessary to have it GPL-licenced - people can just take it and re-use how they want to. It's no problem. For core libraries I may choose the GPL, but for the roebe project it really is not necessary.

The primary point of this project is to allow people to use the code in any way, shape or form, as far as the project itself is concerned. The whole project is really just me randomly putting stuff together, lots of which I use on a daily basis, so the licence should not get into the way in this regard.

Other projects that I use tend to default to GPLv2, and a very few the LGPL variant, in particular when C/C++ code is used. But for trivial code, IMO, a less restrictive licence is better suited.

class Roebe::Upcaser

class Roebe::Upcaser will upcase all files in a given directory (the first argument to this class).

The default input to this class comes from the working directory (aka Dir.pwd in ruby parlance), so the simplest way to invoke this class by navigating to the desired directory at hand, and then invoke this class. Only do so when you are sure to want to upcase all files in the given directory, though.

You can also invoke this from the commandline via:

roebe --upcase_all_files

This will default to the current working directory, so make sure that you cd into the correct directory prior to invoking this class.

Since as of September 2018, a .yml file will be stored at /Depot/Temp/Roebe/ denoting a hash of the old files to the new files (a mapping). That way you can use ruby to "restore" the original files again - just load that Hash, .invert it and iterate over it. We will only store if we are on roebe, though - meaning if a certain environment variable is set to 1 (called IS_ROEBE).

There are also complementary classes that do similar operations. For example, another class downcases all extension names - so if you have .MP3 files, that other class can change the extension to .mp3 instead.

class Roebe::ConvertEncodingOfThisFile

class Roebe::ConvertEncodingOfThisFile can be used to convert the magic comment of the Encoding in a .rb file.

By default it will convert ISO encoding into UTF encoding.

class Roebe::InteractiveFileCreator

This class can be used to create a file "interactively", that is, by just asking a user about the parameters with which to create the corresponding files.

This can also be invoked from the commandline, via:

roebe --interactive
roebe --interactive-file-creator

class Roebe::IsoToUsb

This class can be used to "burn" (more accurately, copy) an .iso file to a USB device.

Warning:

The class currently makes a hardcoded assumption. At a later time, I may add a --help option and more options, but for now, the hardcoded approach is to be used, which means that in many situations it will not work for you.

I do not recommend anyone to use this before actually looking at the code either.

Batch-install my gems

To batch-install all my gems, this can be done from the commandline:

Roebe.install_my_gems

It will use setup.rb for now, but this may change in the future.

setup.rb

Since as of March 2018, the roebe project includes a slightly modified version of setup.rb - I needed this oldschool ruby file available in the event that an installation via gems would fail.

Not many modifications were made; I only needed to make the code available within the roebe gem, in the event I need to install a project without gems (such as when gem is not working, which was the primary reason for integrating setup.rb into the roebe gem; I also use code that allows me to extract .gem files without depending on bin/gem, by the way).

Tales from the crypt

I have a local file with my favourite tales-from-the-crypt episode.

I can then download the episodes via:

tales_from_the_crypt --download
tales_from_the_crypt --batch-download

where tales_from_the_crypt is an alias to the respective class at hand (roebe/classes/tales_from_the_crypt.rb).

You can also use your own yaml file for this or your own Array.

The yaml file should be simple - I use this schema:

S06E14:
 url: https://www.youtube.com/watch?v=O_PtahKvdx0
 name: 99 & 44/100 Pure Horror

If you want to see where the video-files will be downloaded into, invoke the class with the --directory? switch:

tales --directory?

For more options, use the commandline switch --help.

The primary use case, though, was to actually generate a playlist. See the MultimediaParadise project for how I would then go on to use this (https://rubygems.org/gems/multimedia_paradise).

SetAlias

class SetAlias allows you - and me - to set certain aliases in bash, sort of.

This can also be used to set "exam-aliases", to the numbers 1, 2, 3, 4 and so forth. The reason I used numbers here is because they are so simple to use - I just hit 1 on the keyboard, then hit enter, and that alias is run. Often I used this for exam questions, e. g. to ask a specific question, wait a bit, then reveal the answer to that question. But the use cases are more general, e. g. whatever "1" is being aliased to at that moment in time.

If you pass the argument exam_topics.md to class SetAlias then it will try to read a file called that way, and if found, assigns each line in that file towards the numbers 1, 2, 3 and so forth. This allows me to quickly change the main aliases in use per given (upcoming) exam - but it can also be used for non-exam related aliases of course. I just needed this functionality so that I can store exam-themes in such a file, across many different exams.

class Roebe::AvailableClasses

This class can count how many classes are registered in any given project. It does not work that reliably but it does its basic job somewhat ok.

class Roebe::UmlautConverter

If you ever need to quickly replace all german umlauts in a file with non-umlauts, such as ä becoming ae, then you could use this class.

Usage example:

Roebe::UmlautConverter.new('existing_path_to_the_target_file_goes_in_here')

Opening files

The subdirectory roebe/open/ contains code that helps with open-related activities - in other words, opening files.

For example, say that you wish to open some .pdf files. You may invoke open, which then uses the application that opens .pdf files. It will also keep track of all .pdf files that were opened this way into a small .yml file, if is_on_roebe? is set to true.

Generating a .gemspec file

class Roebe::GenerateGemspec can generate a .gemspec file, a template that you can fill in.

I use it usually when I create a new gem. It resides with the subdirectory roebe/classes/generate_gemspec/.

Random PS1 variable

class Roebe::TerminalPS1 can generate a random PS1 prompt, that is, the colour. This is tailored mostly to my own use case.

The prompt I use right now is:

export PS1=$CHOCOLATE'$(pwd)/'$CLOSING_TAG$WHIT

where $CHOCOLATE is the HTML colour chocolate. The '$(pwd)/' part refers to the current working directory.

class Roebe::IPaste

class Roebe::IPaste can be used to paste the content of the xorg-buffer onto the commandline, display it and execute it.

This has been necessary due to another class on the commandline called sco. This class obtained configure options from a .yml file and I needed to paste/invoke it on the commandline, so I created that class eventually. Now I just type "ipaste" on the commandline, hit enter and the content of the xorg buffer is executed onto the terminal. Very convenient!

class Roebe::FragmentMaker

class Roebe::FragmentMaker can be used to create a "fragment" that can be used in case/when menu structures.

Give it an input such as:

--foo-bar

and this class will generate a String that includes this:

when /^-?-?foo(-|_| )?bar/i

This can then be used to be "inserted" into a case/when menu, hence the term fragment for this.

I needed this for building commandline-applications, since I want to be flexible when it comes to user input.

Roebe.downcase_all_entries_in_the_current_directory

Roebe.downcase_all_entries_in_the_current_directory can be used to downcase all entries (files, directories, symlinks etc...) that are given to that method.

By default the content of Dir.pwd, aka the current working directory, will be used for input.

Be sure to invoke this only when you really, really want that functionality!

You can also invoke this from the commandline via a switch, like so:

roebe --downcase-all-entries

Roebe.generate_locales

If you wish to generate some locales on Linux, you can invoke the method Roebe.generate_locales().

Roebe.generate_protocols

The method Roebe.generate_protocols() will generate a file called /etc/protocols. This file is useful on *nix systems, in order to determine some of the core IP addresses.

You should backup the old file there, before invoking the above method, though.

Prepending and Appending Strings to files

I sometimes have to prepend or append a string to all files in a certain directory - normally the working directory.

For example, I may prepend the string DONE_ to .pdf files that I have finished reading; or the string _2018W to denote the current year (or another year) in said .pdf file.

Since I wanted to be able to do this on the commandline I added two classes to the Roebe namespace in November 2018:

(1) AppendThis (2) PrependThis

The main recommended API is the following one:

Roebe::PrependThis.to('DONE_',  files: :in_the_current_directory)
Roebe::AppendThis.to('_2018WS', files: :in_the_current_directory)

(You can first do "include Roebe"; then you do not have to preface the class via Roebe:: anymore.)

The first argument is the String that is to be prepended or appended to the files. The second argument is a Symbol, essentially - a shortcut to tell these two classes that we will default to the current working directory.

You can also feed in your own array of files, via the setter-method set_modify_these_files().

Of course, batch-renaming can easily be done in plain ruby through FileUtils.mv(), but I wanted a simple commandline variant as well that is at the least a little bit documented, rather than use "throwaway" code for this.

Updating the pciids file

On linux the pciids lists some hardware manufacturers that, for example, build certain wlan devices. Sometimes the wlan device may not be recognized by the linux kernel, so the program "update-pciids" can be called to download a remote dataset with the various IDs listed. That file is a shell script.

Roebe has support for a somewhat similar but reduced functionality of the update-pciids functionality. Simply issue the following command for this:

roebe --update-pciids

Radio stations

If you want to get the URL to some radio stations, do:

roebe --radio-stations

If you only want to know where that .yml file resides, do:

roebe --radio?

Note that this functionality depends on the MultimediaParadise project, so it will only work if you have that project (gem install multimedia_paradise) installed.

I needed this so that I can feed some URLs to rhythmbox, in order to easily listen to some radio stations.

Roebe::CreateDesktopFile

class Roebe::CreateDesktopFile can be used to create .desktop files. These files can be used for auto-starting programs on desktop systems such as the mate-desktop or xfce.

You can also use this toplevel method if you would like to:

Roebe.create_desktop_file_for()
Roebe.create_desktop_file()

Disable colour support

If you do not want or need to use the colours-related code, then you can disable this at any time via:

Roebe.disable_colours

You can also require the roebe-project without colours support, via:

require 'roebe/no_colours'

Comparing two files for differences via Roebe::CompareTheseTwoFiles

class Roebe::CompareTheseTwoFiles can be used to compare two different files quickly. It is a fairly trivial class and will only report the first difference found, then exit. (This behaviour may change at a later time, but for now this is how it is - January 2019).

Usage example:

Roebe::CompareTheseTwoFiles.new('foobar1.md', 'foobar2.md')
Roebe::CompareTheseTwoFiles.new(:default)

Some menus, such as a fluxbox start menu or a file for tabble can be generated - but this presently works only on my home setup. I may have to distribute these menu files too, but this requires of me to clean them up; I will probably do this at some distant time in the future, though.

To try to use it anyway (won't work for the time being):

require 'roebe/requires/require_menu_generator.rb'

Roebe::Menu::Generator('fluxbox')

Downloading OpenSSL certificates (certdata.txt)

To simply download the OpenSSL certificates used by the LFS project, aka certdata.txt, into the current working directory, issue the following command from the commandline:

roebe --download-certificates
roebe --certification # ← or this simpler variant

I needed this because I did not want to have to manually look up the URL to this file, and then wget download it.

Installing the rcfiles to a target directory

Usage example:

roebe --populate-this-directory-with-rcfiles=$CHROOT_TARGET/AUTOGENERATED

Entering chroot

Since as of November 2019, the roebe project supports some chroot commands.

Right now the use case is limited to LFS builds; in the future this may be expanded.

To invoke this, try:

roebe --chroot
roebe --enter-chroot

But keep in mind that this assumes a LFS chroot right now, so it is quite useless for most people.

The hack font and the cascadia font

If you wish to quickly install the font called Hack then this might work for you:

roebe --install-the-hack-font
roebe --install-hack-font
roebe --install-hack

This depends on the namespace Extracter, which is made available through the extracter gem ( gem install extracter ).

The use case for this was that I wanted to quickly install the hack font on different computer systems.

In December 2019, support for the cascadia font has been added as well.

To install it, do:

roebe --install-the-cascadia-font
roebe --install-cascadia-font
roebe --install-cascadia
roebe --cascadia

Download the usb.ids file

Via:

roebe --usb.ids
roebe --install-usb-ids # or use this variant here

you can quickly download the file usb.ids. This is important for usbutils. I was too lazy to look up the URL, so it was simply added to the Roebe project instead.

Comparing two directories

I sometimes need to compare the content of two directories.

It is possible to compare these via normal *nix tools, but I wanted colour support output as well, so I quickly wrote a class that does so, on 02.01.2020. A bin/ executable interface exists as well, called bin/compare_these_two_directories.

Invocation example:

compare_these_two_directories /directory_for_audio1/ /directory_for_audio2/
compare_these_two_directories /dir1/ /dir2/

Do note that the order matters, as only the different files will be reported based on the first input argument. If you need the reverse, you'd have to swap the two positions, like so:

compare_these_two_directories /directory_for_audio2/ /directory_for_audio1/
compare_these_two_directories /dir2/ /dir1/

Showing the available users on linux

Do the following:

require 'roebe/classes/show_available_users.rb'

Roebe.show_available_users

# or

Roebe::ShowAvailableUsers.new

class SimpleExtractor

This class can be used to quickly extract an archive, such as foobar-1.0.tar.xz.

Commandline invocation goes via the bin/ file like this:

simple_extractor foobar-1.0.tar.xz

It can also be used to extract a (local) .gem file.

Either use this:

gem unpack *.gem
gem unpack foobar-1.0.gem

Or, if gem itself does not work (such as if you lack support for openssl, which exactly happened to me in a restricted environment, aka on another computer system), try this:

require 'roebe/classes/extract_gem_file.rb'
Roebe::ExtractGemFile.new(i)

or just:

simple_extractor *.gem
simple_extractor foobar-1.0.gem

Note that this depends on bin/simple_extractor, which is part of the roebe project, but if you would like to just extract any .zip file via bin/roebe instead, you can do so via this way:

roebe --extract Variablen.zip

class Roebe::Run

class Roebe::Run can be used to "run" a file, that is, execute it after doing some "pre-processing".

The main use case is to compile a .c file or a .cpp file, but also a .java file.

For example, say that you have a file called foobar.c.

You may wish to compile it via gcc, including flags, but you are too lazy to specify them as-is.

So, you insert a special "macro" into that very .c file.

Example:

// run foobar.c SAVE_AS_IS

SAVE_AS_IS is a macro to use "-o foobar" automatically, thus specifying the name of the created file. It will automatically be named whatever the real name of the .c file at hand is; foobar.c is just an example in this case of course.

You can then "run" this file via:

run foobar.c

(This requires that you have aliased "run" to the ruby file run.rb, of course. This is the case on my home setup.)

The compilation will then be equivalent to the following variant with gcc:

gcc foobar.c -o foobar

Additionally, the compiled program at ./foobar will also be executed aka run - hence the name. I just wanted to combine "compile and then run" via one command, rather than use two separate commands. I am that lazy!

There may be more flags/macros that can be used, but for now, only the above is documented. This functionality may be expanded at a later time - see the menu-interface for all known macros.

For .java files, this class will first run "javac NameOfTheFile.java" before running "java NameOfTheFile".

Since as of March 2020, the project will automatically add -lm if the .c source code contains the math-library.

GoogleUrlCleaner

In April 2020 a new class was added to the Roebe project, called Roebe::GoogleUrlCleaner.

This class will "clean up" URLs from Google.

For example:

require 'roebe/classes/google_url_cleaner.rb'
Roebe.google_url_cleaner('https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=2ahUKEwjcnLmkleHoAhUL7KYKHYg0DwcQFjAAegQIAhAB&url=https%3A%2F%2Fwww.wko.at%2Fservice%2Ffactsheet-corona-kurzarbeit.pdf&usg=AOvVaw3549osY6ZGT_DwFViHgLtB') # =>'https://www.wko.at/service/factsheet-corona-kurzarbeit.pdf'

Roebe.google_url_cleaner('https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=2ahUKEwjZte3EleHoAhU-wcQBHa6eAY8QFjABegQIAhAB&url=https%3A%2F%2Fwww.virologie.meduniwien.ac.at%2Ffileadmin%2Fvirologie%2Ffiles%2FEpidemiologie%2F2012%2F1212s.pdf&usg=AOvVaw1DfKV-mPD0uDNlijYHfkvX'') # => 'https://www.virologie.meduniwien.ac.at/fileadmin/virologie/files/Epidemiologie/2012/1212s.pdf'

Roebe.google_url_cleaner('https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&ved=0CDIQFjAA&url=http%3A%2F%2Fwww.fda.gov%2Fohrms%2Fdockets%2Fac%2F05%2Fslides%2F2005-4144s1_05_Mendelson-HF-NHD%2520Pane.ppt&ei=NOFBUYKHBM-64APKnYGQAw&usg=AFQjCNGka328-0Jym7wOYtJ8pdgGJjLv6Q&sig2=Iq2vS_O3AfCioprk-j_q2w') # => 'http://www.fda.gov/ohrms/dockets/ac/05/slides/2005-4144s1_05_Mendelson-HF-NHD%20Pane.ppt'

This class will sanitize a Google URL and return the real URL.

I needed this functionality because I need to have the direct URL sometimes, e. g. when using wget. And I do not want to depend on google if I do not have to.

Do note that the class may not be complete; some cases may not be properly escaped yet. If found, new entries will be added to the file called test/testing_google_url_cleaner.rb.

Regexes in Ruby

This section is just a short summary of what I consider useful.

/[[:alnum:]]/  - Alphabetic and numeric character
/[[:alpha:]]/  - Alphabetic character
/[[:blank:]]/  - Space or tab
/[[:cntrl:]]/  - Control character
/[[:digit:]]/  - Digit
/[[:graph:]]/  - Non-blank character (excludes spaces, control
                 characters, and similar)
/[[:lower:]]/  - Lowercase alphabetical character
/[[:print:]]/  - Like [:graph:], but includes the space character
/[[:punct:]]/  - Punctuation character
/[[:space:]]/  - Whitespace character
/[[:upper:]]/  - Uppercase alphabetical
/[[:xdigit:]]/ - Digit allowed in a hexadecimal number 

How can these be used?

Consider the following example, a String stored in the variable called x:

x = "123"
x =~ /([[:digit:]]{1,2})/
puts $1 # => "12"

As you can see this would be similar to this:

x =~ /(\d{1,2})/

Obviously the second variant is much shorter. So why use the longer variant? That is a good question.

class Roebe::GenerateNanoConfig and the editor nano

class Roebe::GenerateNanoConfig can be used to generate a configuration file for the editor nano.

You can also display the content that is to be generated on the commandline, via:

generate_nano_config --show-nano-config

This requires that generate_nano_config is aliased to the .rb file that holds class Roebe::GenerateNanoConfig.

See also:

roebe --help

Since as of July 26th 2019 (26.07.2019) the roebe gem also comes with my custom nano-rc files included by default. Nano is not related to ruby per se, but I use nano a lot to quickly modify local files, so I found it more useful to bundle the nano-rc files into the roebe project as well by default.

VimParadise

In the past there was a separate gem, called vim_paradise.

That gem was able to create a .vimrc file, from scratch.

The idea for VimParadise was quite simple: I wanted some ruby-code to auto-generate my vimrc settings.

I kept on tweaking my vimrc over the years, and kept on making things worse and worse in doing so.

One day I decided it is time to have ruby help me generate a vimrc file, hence the VimParadise project was created.

In May 2020 the project was removed as a standalone gem, and instead integrated into the roebe gem here.

A bin executable exists, called:

vim_paradise

For useful VIM resources, have a look at the following webpages:

http://vim.wikia.com/wiki/Vim_Tips_Wiki http://hans.fugal.net/vim/vimrc_hans http://vimdoc.sourceforge.net/htmldoc/

Roebe.browser

This toplevel method is supposedly able to "handle" different browsers. Internally it delegates towards class Roebe::Browser.

In the past, I used to use firefox but lateron switched to palemoon in 2018, due to Mozilla's general arrogance and refusal to listen to users - which makes it quite pointless to keep on using firefox.

I used to open tabs by default in firefox only, but after I switched to palemoon, I needed a general way to open tabs via any browser - thus the toplevel method Roebe.browser was added.

Which browser is the default is now handled by a .yml file, since as of June 2020.

You can define which browser is used on your system via:

browser.rb --browser=/usr/bin/firefox

(Where browser.rb is an alias to the actual browser.rb file that can be found at roebe/browser/browser.rb.)

The path to the .yml file on your system can be determined via:

browser.rb file?

Determining which files are empty via class Roebe::Empty

class Roebe::Empty will return empty files. I needed this functionality for pipes such as:

ls | empty?

As well as the trailing question mark, for bash on the commandline.

The roebe project has a few classes that are related to the KDE project - in particular KDE konsole, since that is the main terminal I am using most of the time.

The KDE konsole is able to display text through various means or enhancements if you so will, be it bold, underline, italic or colours (in RGB format).

For example, say that you wish to display some text in a bold manner, in the middle of a sentence, then you could use escape sequences such as in the following example:

echo -e "Normal text \e[1mBold text\e[0m Normal text again"

The roebe project comes with a commandline-script called bin/konsole_title, which can be used to rename the title of a KDE konsole tab. I have aliased this to rti, for simplicity, on my computer systems.

Thus, when I wish to rename a tab in the konsole, I can simply do the following:

rti Hello world!

I use this in particular to automatically rename a KDE konsole tab through different scripts - which is very convenient.

konsole understands a lot of special commands. For example, if you wish to delete the icon that is on the left hand side of a typical konsole tab, you can use this code (e. g. in bash):

echo -ne "\033]32;\007"

Since that can be quite useful, this is also doable through the konsole_title script, by issuing any of the following instructions:

rti --clear-icons
rti --no-icon

You can also show icons that are stored in a "standard" search path.

These icons for use in the KDE konsole tab may typically be found in the 16x16 directory, such as the following one for oxygen:

/usr/share/icons/oxygen/16x16/status/dialog-warning.png

/usr/share/icons/oxygen/16x16/actions/
/usr/share/icons/oxygen/16x16/animations/
/usr/share/icons/oxygen/16x16/apps/
/usr/share/icons/oxygen/16x16/categories/
/usr/share/icons/oxygen/16x16/devices/
/usr/share/icons/oxygen/16x16/emblems/
/usr/share/icons/oxygen/16x16/emotes/
/usr/share/icons/oxygen/16x16/mimetypes/
/usr/share/icons/oxygen/16x16/places/
/usr/share/icons/oxygen/16x16/special/
/usr/share/icons/oxygen/16x16/status/

Have a look there to find out which names will available. Keep in mind that these icons will reside in different subdirectories, e. g. status/ or emotes/. Support for these icons depend on, for example, the oxygen theme, which could be found upstream at https://download.kde.org/stable/plasma/5.15.1/oxygen-5.15.1.tar.xz or a similar URL.

The following examples show how to use these dialog warnings from bash or zsh directly, without depending on ruby:

echo -e "\033]32;dialog-warning\007"
echo -e "\033]32;emblem-favorite\007"
echo -e "\033]32;emblem-mounted\007"
echo -e "\033]32;emblem-important\007"
echo -e "\033]32;waiting\007"

Note that you can combine this with regular text, such as in the following Hello world! example prefaced with the waiting-icon:

echo -e "\033]32;waiting\007\e]30;Hello world!\007"

The roebe gem supports this too, through konsole_title; at the least in some shortcut manner for some of these entries:

rti --dialog-warning
rti --warning
rti --emblem-warning
rti --emblem-mounted
rti --emblem-important
rti --waiting
rti --face-angel
rti --face-embarassed
rti --face-kiss
rti --face-laugh
rti --face-plain
rti --face-raspberry
rti --face-sad
rti --face-smile-big
rti --face-smile
rti --face-surprise
rti --face-uncertain
rti --face-wink

There are a LOT more options supported by konsole_title - the README here only lists a few of these options.

For a full listing, have a look at the file called menu.rb of the respective class.

Take note that you can also use custom icons that you have on your harddisc:

echo -e "\033]32;/home/x/DATA/IMG/foobar.png\007"

And keep in mind that these icons are only small, e. g. 16x16, so it is not trivial to see what this icon is made up of.

You can also set an image to be used via the commandline:

rti --image=/path/to/the/image.png
rti --use-this-image=/path/to/the/image.png

You can also omit the -- part, aka just use the file path directly:

rti /path/to/the/image.png

You can also use a random icon (but this requires a prior registration of that icon in a CONSTANT Array of that class):

rti --random-icon

You can also display the default icon, which is the KDE Konsole icon (terminal).

rti --terminal

It may typically be found within the oxygen theme, at a location such as:

/usr/share/icons/oxygen/16x16/apps/utilities-terminal.png

class Roebe::DownloadFromThisUrl

class Roebe::DownloadFromThisUrl can be used to download content from remote websites. Simply pass in the URL to the website from where you wish to download data from.

In pure ruby code this would look like this:

require 'roebe/classes/download_from_this_url.rb'
Roebe::DownloadFromThisUrl.new(URL_GOES_IN_HERE)
Roebe::DownloadFromThisUrl.new('https://archive.xfce.org/xfce/4.16pre1/src/')

I aliased this file towards download_from_this_url, so I can then do this on the commandline:

download_from_this_url https://archive.xfce.org/xfce/4.16pre1/src/

A filter may be used to denote which files are to be downloaded. As of July 2018, the filter I use is mostly to download only .pdf and .txt files. In September 2020, support for .tar.gz, .tar.bz2 and .tar.xz was added as well. For now this is a hardcoded array - in the future I may add options to specify omitting a filter from the commandline and so forth; but for the time being, it will remain as it is since I mostly wrote it only in a day to be able to batch-download some remote files that I needed to finish a given task.

In September 2020, the code was slightly adapted.

To disable the use of a filter, use --no-filter, like so:

download_from_this_url https://archive.xfce.org/xfce/4.16pre1/src/ --no-filter

Note that in the long run, the class may have to be rewritten, in order to support different behaviour. But again, I wrote it mostly quickly to finish a job, and then move on.

class Roebe::BurnISO

This class can be used to burn an .iso file onto a DVD, if growisofs is available.

Usage example:

require 'roebe/classes/burn_iso/burn_iso.rb'

Roebe::BurnISO.new('foobar.iso')

class Roebe::GrubConfigGenerator

Since as of November 2020, class Roebe::GrubConfigGenerator can be used to generate a new grub configuration file, typically called grub.cfg.

I needed this because I got tired of manually having to specify stuff for grub2 to work.

Usage example from ruby:

require 'roebe/classes/grub/grub_config_generator.rb'

Roebe::GrubConfigGenerator.new(ARGV)

class Roebe::Identical

If you want to compare two strings to one another, how identical they are to one another, then class Roebe::Identical may be of help here.

A usage example follows:

require 'roebe/classes/identical.rb'

Roebe::Identical.new("string1", "string2")

This would return a number such as 86, which is the percentage of the identity at hand. In this example, only one character was different (the "1" versus "2", respectively).

Alternatively, you can just use the module-level method Roebe.identical():

Roebe.identical("string1", "string2")

Since as of November 2020, you can use this on the commandline as well. Example:

roebe --compare-strings=string1,string2

The .Xresources file

This is not about ruby, but simply because I need some useful shells when I work on linux, before I can write ruby scripts.

To enable tabs in rxvt-unicode use:

URxvt.perl-ext-common: tabbed

Don't forget to have compiled perl support via --enable-perl prior to that. I forgot that in 2021 and could not figure out why the guides on the www did not work. :)

To start a new tab:

Shift+Down

To close the active tab:

Ctrl+d 

Specify the colours of tabs via:

URxvt.tabbed.tabbar-fg: 2
URxvt.tabbed.tabbar-bg: 0
URxvt.tabbed.tab-fg:    3
URxvt.tabbed.tab-bg:    0

This would make the tab colour green.

urxvt-tabbedex can be used to rename tabs.

To be able to resize the fonts on the fly, add:

URxvt.perl-ext-common: resize-font

Pretty looking font:

URxvt.font:     xft:bitstream vera sans mono:size=18:antialias=true
URxvt.boldFont: xft:bitstream vera sans mono:bold:size=18:antialias=true

URxvt*color0:  #000000 // black
URxvt*color1:  #B40000 // red
URxvt*color2:  #00AA00 // green
URxvt*color3:  #AAAA00 // yellow
URxvt*color4:  #5555AA // blue
URxvt*color5:  #AA00AA // magenta
URxvt*color6:  #00AAAA // cyan
URxvt*color7:  #AAAAAA // white
URxvt*color8:  #555555 // black (now and below: bright)
URxvt*color9:  #FF0000 // red
URxvt*color10: #00FF00 // green
URxvt*color11: #FFFF00 // yellow
URxvt*color12: #6464FF // blue
URxvt*color13: #FF00FF // magenta
URxvt*color14: #00FFFF // cyan
URxvt*color15: #FFFFFF // white

Ruby awesome bits, oddities and ugly bits - including the safe navigation operator (and a bit of Crystal code)

This subsection may collect a few ruby snippets that may be odd - or awesome; and also some that may be ugly.

Consider the following code in the ruby 2.5.1 days:

#!/usr/bin/ruby -w
# Encoding: UTF-8
# frozen_string_literal: true
# =========================================================================== #
def foobar(
    i = ' hello world'
  )"15.10.2018"
  puts i
end

foobar

Notice the weird "15.10.2018" part? That is actually ignored. But only in a line that has a ')' and ends a method, obviously. If you put that same string right next to the end keyword then a syntax error will be the outcome.

I found that strange because the ruby parser treats strings differently depending on the context at hand.

On second thought, I think this is actually valid behaviour, since it is just a string literal that is not used.

Another example that I have found interesting is RSpec.

Take code such as the following one:

expect(Dir.exist?('doc')).to be true

That surprised me. I am not entirely sure what the above entails to, but I think this is actually:

expect(Dir.exist?('doc')).to(be(true))

That means that ruby's flexibility sort of allows you to just omit the (), with the end result that an interesting DSL is created. It is not my own personal preference, but I think it is still interesting nonetheless. You can not do this in python because () are required rather than optional.

This subsection is just a bit documentation about the safe navigation operator in Ruby.

Code will typically look like this:

object&.method

I personally do not like the & there and actively avoid the safe navigation operator. A reason is that I find it to be very ugly.

Having said that, though, I have, in 2018, found an interesting example here:

https://github.com/ruby/ruby/commit/91fc0a91037c08d56a43e852318982c9035e1c99

The old code was:

f.close if f && !f.closed?

The new code is:

f&.close

This was interesting to me because the safe navigation code is much shorter than the old code. Not that I find the "if f" and "&&" and "!f.closed?" parts to be very elegant, either - but I think this may actually be a case where the safe navigation code, while really ugly, led to a better code layout. Still won't convince me to use it, but if we compare situations then we ought to compare all advantages and disadvantages rather than just a few select examples. We should keep both situations in mind.

Interestingly enough, Crystal appears to have copied the &. operator:

class Object
  def has_instance_var?(name) : Bool
    {{ @type.instance_vars.map &.name.stringify }}.includes? name
  end
end

It looks very strange to my eyes, the &.name.stringify part. Can't say that I think this is awesome, either in ruby or crystal, really.

However had, on second thought, the above code in crystal may perhaps be similar to &: in ruby instead.

For example:

%w( 1 2 3 ).map(&:to_s) # => ["1", "2", "3"]

I have no idea why crystal uses a '.' after the & in this case, though. And what the hell is .stringify, anyway? Does this mean to want to turn something into a String? Why is it named "stringify"? Who came up with this?

In September 2018 I have found another example for &, a very ugly one:

https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L191

The code is as follows:

t1&.kill&.join

It's quite disgusting combining the use of & twice really. It is not just twice as bad as a single &; it actually is about three times as bad.

In October 2019, ruby added the ... as an experimental feature.

Code may look like this:

def foo(...)
  bar(...)
end

Now I should say that I think the functionality itself is fine. But seriously? ... ? That's like someone having a mental lapse here.

I don't like the syntax at all - and, to be brutally honest, in the last 3-5 years, ruby has added too much horrible syntax. I can't see how adding new syntax for the sake of it OR adding it when the feature in itself will be of limited used, is a good thing.

In some ways this is irrelevant because I'll defend my code base against these insanities - but it's getting increasingly annoying to see how ruby is morphed about willy-nilly randomly. I have no idea what is going on there.

Unfortunately switching from ruby is not an option either, because the other languages suck even more. That is a strange dilemma here ... :P

The only good thing is that I can avoid crap syntax. I do not think I would use ruby if there would be a force to change how I have used it for +15 years into a crap syntax though. One has to be attentive of what crap syntax the future may bring here.

Note that this is really about the syntax, NOT the feature. The feature is ok, IMO; it is similar to "alias" or "alias_method", just with a bit more fine-tuned control.

Ruby allows you to make use of keyword arguments. The syntax can be a bit confusing, though.

For example:

def movie(title:, lang: lang = 'English')

This makes use of keyword arguments as well as specify default arguments. When I first saw this this was a bit confusing since lang is repeated, thus appearing twice.

Remember that this means that :title is mandatory.

If you invoke it like this:

movie lang: 'german'

Then a missing keyword: :title (ArgumentError) error will be shown.

class Roebe::UnicodeSnowman

This class will show a unicode-snowman on the commandline.

Keep in mind that you can colourize unicode-output on the commandline as well, via the RGB functionality of e. g. the colours gem. This allows you to colourize the snowman - or any Unicode token, anyway.

If you want to display the snowman on the commandline, you can do so via:

roebe --snowman

Regex cheat sheet

This subsection just mentions the regex rules in use, as a reminder.

^ and $ match the beginning and end of a line.
\A matches the beginning of a string, \z and \Z match the end of a string.
\b and \B match word boundaries and nonword boundaries.
| vertical bar matches either the regular expression that precedes it or the regular expression that follows it.

Useful knowledge bits about ruby:

  • class_eval and instance_eval both set self for the duration of the block.

Deprecations within the roebe gem

Over the years a lot of code was re-written or deleted. The more important changes may be noticed in this subsection.

On 30.08.2021 the old class called Roebe::FstabAppender was removed, and subsequently replaced with class Roebe::GenerateFstabFile. The latter uses better code and makes use of a yaml file for my default fstab-content. This should also make it easier for other people to auto-generate a fstab file. Simply change the entries in the yaml file, then run the class, and a new fstab file will be generated.

The UUID entry currently is hardoded, though, so replace that as well. Eventually I may auto-generate the UUID entry as well, but for now I only wanted to remove the old code from Roebe::FstabAppender really.

class Roebe::SymlinkFilesFromThatDirectoryToTheCurrentDirectory.new

First, before explaining what this class do, let's see how to use it:

require 'roebe/classes/symlink_files_from_that_directory_to_the_current_directory/symlink_files_from_that_directory_to_the_current_directory.rb'
Roebe::SymlinkFilesFromThatDirectoryToTheCurrentDirectory.new(ARGV)
Roebe::SymlinkFilesFromThatDirectoryToTheCurrentDirectory.new('/home/Programs/Pcre2/Current/lib/pkgconfig/')

The last example is how I use it most of the time. Or, to be more specific, I use the bin/ representative of it, with an alias called sfiles to that class.

So, what does this class do? It will symlink all files from the specified target directory into the current working directory. I needed this behaviour because the project called RBT (ruby build tools) has a few bugs right now (in October 2021). I do not know when I manage to fix these bugs, so I needed a quick work around - hence this class was created.

The class was already written many years ago, but the code was annoying to read and deal with and I had no idea what was going on, so I rewrote it in October 2021 finally.

Building a modified LFS/BLFS

Over the past 10 years or so, I have become increasingly displeased with the corporatification of Linux. Systemd is a good example, but it is not the only one. It's not solely confined to corporate-hackers taking over, but a concomittant rise in complexity. Things that used to be super-easy are now a LOT more complex. I will give an example.

Back in the oldschool days, you compiled the fat mono-repo for xfree (whatever the name for the old xorg-server was), then you compiled qt3 and kde3. That was fairly trivial. Nowadays, though, you need a LOT more additional stuff: xorg became modular so like 100-200 packages are necessary. You need mesa, which in turn needs python3 and LLVM - all of which increasingly become larger and larger. Then you need qt5, which is HUGE. And then you have to compile the KDE5 stack which has about 200-400 packages (depending on what applications you need, but even the minimal variant is soooooo much bigger than KDE3). And these are just a few examples - the same happened to the whole "Linux stack".

I would not be so upset if these things were to work properly, but you keep on having more and more problems, or you suddenly somehow end up with a dependency on systemd. So this is all viral: it leaks in garbage and complexity into your system.

As I am getting tired of this, and I don't want to adjust to systemd and the other crapware, I decided to transition into a modified LFS/BLFS variant. This subsection here shall keep track of useful information pertaining to this, and possibly code (in ruby) that may be of help here. Of course the RBT project may handle most of these things, but the roebe-gem contains a few useful classes in this regard, so I wanted to document any findings here, rather than keep this for RBT only.

So, what should be kept in mind for a modern computer system?

Normally there should be a first partition, say, 256 MB for an EFI system such as this variant:

/dev/sda1       2048     526335     524288  256M EFI System

(To be continued at a later time ...)

custom_methods.rb

The file custom_methods.rb was actually the reason why the roebe gem was eventually created. I stored tons of ruby code in that file, many years ago.

Things slowly changed as time passed by, yet custom_methods.rb still serves as "the main hub" - aka the main entry point to all my other ruby code and gems. Thus, a lot of ad-hoc methods are stored in that file.

This subsection here may include a few details about this file, but not everything will be documented here; only the more relevant entries may be documented.

The method .json_to_hash() can be used to load a local file, which is assumed to be a json file, and return a Hash in ruby.

API usage goes as follows:

hash = json_to_hash('/home/Temp/magic_the_gathering/card_collection.json')
pp hash; ''  

Imgur

This subsection just shows a bit of information in the event we wish to upload images to imgur.

The client-id is Client-ID 70ff50b8dfc3a53.

To upload an image to Imgur you could adapt this method:

ENDPOINTS = {
  image:   '/3/image/',
  gallery: '/3/gallery/'
}
API_PUBLIC_KEY = 'Client-ID 70ff50b8dfc3a53'
API_URI = URI.parse('https://api.imgur.com')
request = Net::HTTP::Post.new(API_URI.request_uri + ENDPOINTS[:image])
request.set_form_data(params)
request.add_field('Authorization', API_PUBLIC_KEY)

See also the class called UploadToImgur that is distributed via the roebe gem since as of October 2021. It contains a slightly better implementation to the above "raw points".

Since as of October 2022 class UploadToImgur can also download a remote image, which is first downloaded, and then uploaded to imgur automatically.

class Roebe::LeftHyphenInThisFile

class Roebe::LeftHyphenInThisFile can be used to put - hyphens on the left hand side of a file. It will generate a new file by default rather than overwrite the existing file.

You may ask "But why add a class for something that is as simple as using .map {}? Yes, that is a valid question, but I needed this to turn a .txt file into a .yml file, for an Array. And YAML wants arrays via leading -. Since I was constantly creating new yaml files that way, and had to add leading - manually, I got tired of it, and simply added that class in November 2021.

class Roebe::RemoveLine

This class can be used to remove one line from a file.

Usage example:

remove_line 5 foobar.md # this removes line number 5 from the file called foobar.md

Presently it can only remove one line, so it is not very flexible. At some point in the future it may be expanded in its general usefulness. For now, it's just kept as simple as possible really.

class Roebe::Modright

This class can be used to automatically change the permissions of files and directories to a preset default. The default values are stored within that class - look at the two constants in this regard on top of the .rb file.

Why was this class created? Sometimes some directories or files may have permissions that the user may not have wanted, so the main idea for this class is that it can restore the "default" permission for files and directories.

Roebe::GUI::Gtk::WlanInformationCenter

This ruby-gtk3 specific class shall help users on linux to set up their wlan-devices. It originated from the older class Roebe::GUI::Gtk::WlanInterface which was too cumbersome to use in general. With this new class, however, even new linux users should be more comfortable in setting up their wlan-devices. A tabbed interface will be used.

Roebe::AddNewlineAfter

This class will simply add a newline after the specified token.

If you want to change the default token then use the method .use_this_token =.

Why was this class created? I sometimes have to look at .html files that are compacted. Since it was annoying to split it up, I wanted a script that does this for me.

class Roebe::GoodNight

class Roebe::GoodNight simply combines class Roebe::At as well as playing some video files or audio files; by default using simpsons movies from my local play list. You may have to adjust this to your use case if you want to re-use this class.

module Documentation

Since as of 17.04.2019 I am slowly integrating all my local documentation in ruby into the Roebe project.

This will take months or years at the least, though. Remember that I gathered ruby-specific knowledge tidbits in the last 20 years; it's spread all over the place on my local filesystem.

Unfortunately that documentation in particular is primarily only available in the german language, so not many other people may benefit from it. I am working to translate some of this into english, but this takes time.

sinatra is presently required to view the documentation.

If you wish to start that sinatra interface, you can do the following from the commandline:

roebe --serve-documentation

To require the documentation manually, you can issue:

require 'roebe/documentation/app.rb'

Note that the gtk-specific part currently (2022) does not work: I plan to move this into the gtk_paradise gem.

Since as of March 2022 ruby-on-rails specific information is stored in the directory doc/ruby_on_rails_tutorial/. This is currently a .cgi file and requires the gem called cyberweb. In the future this may become more flexible, but for now it is stored therein.

Note that since as of July 2022 module Documentation is mildly deprecated. It will be more likely that future documentation will simply reside under doc/ instead.

class Roebe::DateSort

This class, residing at roebe/classes/date_sort.rb, will sort files based on their filenames. As part of the filenames the date should be "embedded" into, e. g. something like "22.02.2022".

I aliased this class towards date_sort and use it in pipes, such as:

ls | date_sort

The Roebe::Shell

The following subsection contains a tutorial as well as extensive documentation for the Roebe::Shell, which is a shell written in the programming language Ruby.

Note that while the primary focus for the Roebe::Shell is the programming language Ruby, I may (re)write parts of it in other programming language. The ruby implementation provides the primary design goal for this shell, though. Other implementations will have to refer to this as the primary specification.

Short changelog pertaining to the partial rewrite in May/June 2023

The Roebe::Shell was partially rewritten and extend in May/June 2023.

The primary reason for this was that I wanted to add support for reline. It is now possible to choose which input mode to use at "run-time".

The three input modes are:

:stdin
:reline
:readline

I still default to :readline, but in the future :reline may replace :readline by default. :stdin is the default and should work best; it is simply just $stdin.gets.chomp really.

You can switch between these at "runtime". For instance:

switchto stdin
switchto reline
switchto readline
switch_to stdin # this works as well

This was tested on June 2023 too, and it works on Windows. In fact, for the time being, :stdin will be the default modus operandi on windows.

Goals for the Roebe::Shell project

The Roebe::Shell project, as part of the Roebe project, shall be a replacement for irb but also for bash in the long run (this is a long-term, distant goal, one day).

Perhaps in the distant future it may also offer features such as those available in zsh, fish or pry. We may also make use of mruby instead and compile in the required tidbits - should make it much faster than before. At the least in theory.

And a GUI component in ruby-gnome, similar to cuiterm; this can be seen in the gtk_paradise project, but it is not quite complete yet.

Keep in mind - it is much easier to speak about goals rather than go and really achieve these goals. When it comes to code, the number one factor simply is time that will be invested into a given project. And time is a limited/finite resource.

Please note that this tutorial assumes that you have a Roebe::Shell instance running.

The Roebe::Shell component

Roebe::Shell can be used as some kind of substitute for IRB or shells such as bash, zsh or fish. The primary use case for Roebe::Shell is interactively, that is to have the user type in commands, and the shell will attempt to make sense of these instructions.

Roebe::Shell was based on the older DiamondShell project, which was abandoned in 2020. Some parts of the code from the DiamondShell project continues to exist in class Roebe::Shell, albeit a lot of it was heavily modified or even removed.

You can start the shell via the above Roebe::Shell.new call, or this simpler toplevel variant:

Roebe.shell

What is a shell, actually?

A shell is essentially a program used to execute other programs - for instance, you can start your editor from the commandline by making use of a shell. A shell is usually interactive: it requires user input, be it from a human being, a computer/robot or from some script.

There are many different shells - UNIX/Linux systems may have csh, bash, zsh, fish. Windows may have the old cmd.exe or the newer powershell. And more recently, say since 2016, you may also use bash on Windows in an easy manner - apparently Microsoft is learning something new these days (e. g. WSL1 or WSL2).

The Roebe::Shell component of the roebe project tries to learn from all of the above shells and how these are used, and combine what seems useful into the Roebe::Shell namespace. I always loved the RPROMPT feature of zsh, for instance - unfortunately, this is on my TODO list, so it is not added yet.

Since as of September 2020, Roebe::Shell makes use of class Roebe::UserInput for obtaining (and working with) user input. I grew tired of having to write the logic into class Roebe::Shell when I instead wanted to focus on dealing with the user input itself, so that I can abstract the details away.

If you need to obtain the configuration settings for a Roebe::Shell, in Hash format, then issue the following command from a running instance of the Roebe::Shell:

config_as_hash

The following examples will showcase what the Roebe::Shell can do, but keep in mind that these are just examples; there may be many more entries to use which are not documented here for lack of space.

If you need to generate a random string, use:

randomstring 5

The number 5 ensures that the length will be 5 characters. This feature may be useful to test something.

If the shell-configuration enables colour-support then you can use RGB colours, if you use it via KDE konsole. Example for this:

darkkhaki hello world!
royalblue this is a test in royalblue

Presently the whole string is specified in that colour, but in the future we may add support for arbitry colouring of the text.

To quickly show all directories in the current working directory, try:

show_directories

To show the current $PATH in use for the running Roebe::Shell instance, try any of the following:

show_path_in_use
showpathinuse

Note that in April 2022 the Roebe::Shell project was again rewritten from scratch. The primary reason as to why this was done was to enable lazy loading from the get go for add-ons; a secondary reason for the rewrite was proper support for windows. I needed a better alternative to (vanilla) cmd.exe, but without the overhead that comes with powershell.

If you want to see which components (add-ons) have been lazy-loaded so far, then issue either one of the following commands inside of a running instance of the Roebe::Shell:

status?
components?

Keep in mind that in particular larger gems may take a few seconds before they are fully loaded. At the time of writing this in May 2022 I myself use 36 different gems and add-ons for the Roebe::shell:

Exiting the roebe-shell

To exit the shell do one of these:

q
exit

Logging & History for the Roebe::Shell component

The Roebe::Shell will, by default, log all commands that the user did input via a keyboard interface. Thus, all these commands (the given input) logged by the Roebe::Shell constitute the history.

These strings will be stored in the yaml file last_commands.yml.

If you do not want to or do not need history support, you can disable it via:

disable history
save config # ← If you wish to make this persistent.

To re-enable history, do:

enable history

Internally this behaviour will toggle the setting enable_history_logging, to false, in that config file; you can also do this at runtime if you do input disable logging or no logging).

There are a lots of enable and disable functionalities available.

Try:

enable HELP
disable HELP

You can also use --help rather than HELP, or just use the ? character such as in:

enable ?

? is assumed to mean "help" here.

? also plays an important role when obtaining extended documentation about the commands available in the help menu. For instance, say you want to understand what touch does.

In this case, you can do this here:

?title
?scp
?touch

The leading ? means that the Roebe::Shell will assume that the user has a question about this built-in method. (touch is like the UNIX touch command; we will use it to create a file. You can also use the alias create_file instead if you want to - there is more than one way to do things in ruby. Pick the one you prefer.)

If a command requires more documentation, send an issue request to add it. (Mostly it follows UNIX/Linux conventions, so touch is used to create a new file, and so forth.)

This will redirect the content of foo.txt into a file called "this_file".

You can benchmark (and thus time) how long it takes to load up the components stored via "lazy loading, by issuing the following:

dia --benchmark

This currently isn't working 100% correctly, due to various reasons; one being that the current way how the Roebe::Shell loads add-ons via Thread.new {} isn't perfect. However had, minor issues aside, dia --benchmark still yields some important information. I could use it in May 2022 to notice some slow-loading add-ons, some of which were mine, which I could then go on and improve upon.

To access this information of your history, you can issue either of these synonymous commands:

h
history?

This will then display the input-history.

You can also use a position of the history at, i.e. place 5, like this:

history 5

This will substitute the history command of position 5. In other words, this allows you to use history you already did input at an earlier time.

You can also use the bash equivalent here:

!-2

Personally I find this less readable, but if you are coming from bash and like this functionality, you can use this in the Roebe::Shell as well.

Please note - we wont append to the history log if the last command entered is the same as the last entry in the history log (keeping duplicates is not so useful).

You can empty/clear the history any given time by doing:

empty history

You can also disable logging of the history by doing:

disable history

And of course you can disable history support on startup of the Roebe::Shell as well:

rda --nohistory # or one of the aliases towards --nohistory

Querying .pc Packages from within the Roebe::Shell

You can query .pc files in a simple manner through the Diamond Shell. pkg-config allows you to query installed libraries on your computer, in partcular software that was compiled from source.'

In order to do so and query the information found in .pc files and whether it is available on your system, you can simply append a ? to the name.

For instance:

 libpng?
 mono?
 xtables?
 ruby?

This will not always work, but it will probably make your life a bit easier sometimes, whenever you want to know which .pc files are installed on your system.

Note that on Windows the above will not work - the reason for this is that most ruby-users on Windows will possibly not have pkg-config .pc files.

Design Statements and Philosophy for the Roebe::Shell

@aliases should contain ALL aliases.

Every string data that the shell gathers - before it is sent to the user - will be stored in a variable. This way you can tap into this variable and make further use of it, for whatever purpose.

@this_file points to the last assigned or otherwise used file. Only this, and only one variable may refer to the last used file.

Undoing actions from within the Roebe::Shell

You can undo certain actions. Right now only file-move actions can be undone. For instance, let us assume that you have a file called "test" in the directory /tmp, and that you moved this file to the directory /home, like so:

mv /tmp/test /home

Now you can do this command:'

undo

And the file will be moved back to its old place.

This is not extremely useful yet, but I will probably add code to allow a more general purpose undo action at a later time.

Creating ISO files from within the Roebe::Shell

You can create .iso files with the Roebe::Shell easily.

One way is to call the following method:

create_interactive_iso

You can also directly create an iso by doing this:

make_iso /path/to/directory/here
make_iso /tmp
make_iso /Depot/Games
make_iso /home/x/data

Determining which user-input-mode to use for the Roebe::Shell

You can use any of the following commandline flags to change the user-input mode (used for obtaining user input into the Roebe::Shell).

Examples:

rdia --use-readline
rdia --use-stdin
rdia --use-reline
rdia --readline
rdia --stdin
rdia --reline

Note that stdin is the default and it works best. Readline and reline give you input-history via the cursor keys, as well as tab-completion, so this is more "fancy" and possibly useful compared to stdin.

Input and the Roebe::Shell

A few words should be given about user input to the Roebe::Shell. These may be useful to understand certain design decisions.

Everything that comes after the first encountered # character will be regarded as a comment.

For instance:

exit # we will exit here. What comes after the # is ignored.

The above command would assume that the user wanted to exit the shell, and the dia-shell will ignore everything that comes after the # (and the # character will also be ignored)

This is basically the same behaviour you can find in other shells as well.

The character ; is treated as an instruction_separator, unless it is found as part of an URL. For example:

cd $J; ll

Is assumed to be two different commands: first a change_directory instruction, then a listing_content of a directory instruction. This is consistent with how other shells act.

Superuser and the Roebe::Shell

To change the superusername (on UNIX like systems), do this:

become new_name become god # now the superusername would be called "god"

You can also show which users are available on a given system.

To do this, issue the following command:

users?

And you can find a specific User ID, such as User ID 11:

user 11
user_id 11

Switching the user input mode

The Roebe::Shell can work with :stdin (aka STDIN), :readline and :reline since as of May 2023.

You can switch the input-mode at runtime via:

switch_to stdin
switch_to :stdin 
switch_to readline
switch_to :readline
switch_to reline
switch_to :reline

Currently I still prefer readline, but in the future we may transition into reline completely. stdin is mostly a failsafe way to use the Roebe::Shell - the default fallback variant.

Gzip and the Roebe::Shell

You can compress a string using gzip/zlib via:

gzip bla

However right now I can not think for a good usage scenario for this ...

Feedback Part of the Roebe::Shell

To get feedback about every Xorg component, do this:

gfeedback all_of_xorg

Note that this will also generate a .html page.

As usual, using "gfeedback help" or "gfeedback ?" will give you some help about this method.

To feedback the version of a program, do this:

programversion cups

To feedback the available programs, do:

aprograms

You can also get feedback about the documentation of Ruby.

docu? Array#sort

You can also omit the leading docu? identifier and just use this instead:

Array#sort

The above would use Ri to feedback information about Ruby.

This syntax here also works:

docu? Array.sort
showdoc Dir.chdir

And you can also grab the documentation for .rb files:'

docu? foobar.rb

Index of the Roebe::Shell

By default, Roebe::Shell assigns every entry in a given directory a number, the so-called index number.

This number is displayed on the left side usually, and it may be used by you as a shortcut to access a specific file as well.

For example, if you have two files in a given directory, called "long_name_of_a_file_1" and "long_name_of_a_file_2" you can use numbers to work with them instead, like so:

cat 1
cat 2

The following small screenshot shows this - the index number can be seen in green colour:

cp 2 $J # This would copy the file at second position
to whatever value is contained in $J.

On my system, this defaults to the directory /Depot/j.

Do note that you can turn off showing the index in your config file (look at the configuration option display_index):

disable display_index
no index

Compiling something from within the Roebe::Shell

If you want to get a list of all programs which can be compiled, do this:

compile help

You can compile i.e. nano by doing:

compile nano

In general the syntax is:

compile <name>

Moving files and directories to new locations within the Roebe::Shell

You can move files and directories to new locations.

This can be done like so:'

mv foo /tmp

The above command would move the file foo to the directory /tmp. This is similar to how bash or zsh acts.

Note that you can also move multiple files.

The syntax for this would be:

mv temp{1,2,3,4} $JJJ

This would try to move these directories or files to whatever value is stored in $JJJ (which, on my system, points to the directory /Depot/jjj).'

Usage of the Roebe::Shell, in Ruby Code

require 'roebe/shell'

Roebe::Shell.run # To startup the Roebe-Shell

# Alternatively, you can also use Roebe::Shell[] as starter.

Features of the Roebe::Shell

Listing the most important features of the Roebe::Shell:

# - backup audio, or data, to usb or hdd.
# - Compiles apps and chain_compiles even more apps.
# - Type news to open some webpages for news stuff.
# - Vim "support", which means you use vim to edit stuff.
# - Trigger certain events.
# - On startup of this shell, you can define some actions which
#   need to be done, i.e "rdia rsong" to play random songs. More
#   about this, please see the section here called "startup".
# - ISO Creation, CD and DVD burning.
# - ri-like browsing behaviour.
# - Open your favourite files by specifing something like "blxorg"
# - Open a local page in your editor by issuing "rf keyword"
# - InBuilt help file.
# use "songs" to view your local songs and songs 44-48
# to play song 44 up to including song 48

It really has a lot more features, it is best to look at the page here - have a look around.

It should include all what is necessary - and if not, then I will add this information here.

Aliases used in the Roebe::Shell

All aliases are kept in the instance variable @aliases.

You can display this variable any time by issuing either of the following two commands:

@aliases
aliases?

To get the content of an alias, either type this:

alias name_of_alias
alias pwr

Positional arguments are also possible (if an alias with that number does not exist, that is):

alias 567

Or simply type the following to get all these aliases:

@aliases

You can of course also unset an alias. I recommend you use this syntax:

unalias name_of_alias
unalias pwr

You can also unalias if you give a number instead. unalias 123 would try to unset the alias at position 123.

To set an alias, you can do something like this:

alias foo=55

This would set the key foo to the value of 55.

As of January 2014, I can download my remote aliases by issuing:'

download_aliases

System Information and the Roebe::Shell

To get System Information do this:

system?

This will use the following class:

SystemChecker.new

Starting irb from within the Roebe::Shell

You can simply start irb from within the Roebe::Shell via:

irb

Email and the Roebe::Shell

Thanks to the mail gem, we can send emails to other people (or to yourself, if you are like Mr. Bean and enjoy reading anything).

Currently (as of December 2015 this is somewhat limited - simply type "email" and an interactive section can be used.

This functionality may be extended at a later time.

Help from within the Roebe::Shell

The helpfile section can be invoked via:

help

The colouring of the helpfile section is done via the class Roebe::Shell::Header.

Additionally, we can display useful help information before we startup.

We do this via:

rda --help

Below is a (partial) screenshot from how the Roebe::Shell Help Menu looked in April 2014:

As of September 2014, documentation was added for the commands displayed when the input "help" is issued. This documentation is stored in the class Roebe::Shell::HelpOptions, residing in the file standalone_classes/documented_help_options.rb.

You can obtain a slightly longer explanation for most of these options by prefix a leading ?, so for instance:

?touch
?grabc
?symlink
?windows

Using Gist from within the Roebe::Shell

You can use Gist from the Roebe::Shell, via the gist gem.'

Example:

gist foobar.rb

This would upload the foobar.rb file to gist github.

Downcasing within the Roebe::Shell

To downcase every file in a given directory (might be useful if you want to downcase VIDEO1.VOB to video1.vob, for instance), simply do one of the following variants:

downcase *
downcase all
downcase everything

Show something from within the Roebe::Shell

You can show files by doing something like:

ll

By default this will not show hidden files. There are at least two ways to show hidden files though, since obviously this is an important part of working with a filesystem.

The first way is to explicitely tell the shell once that you want to see hidden files.

You can do this simply by issuing:

show hidden

From this point onwards, you will always see hidden files.

The other way is to use a switch, such as:

ll --almost-all

This is akin to Bash.

You can show the content of a file via cat, as in:

cat foo.rb

If the file foo.rb does exist, this command will show you the content of that file. If coderay is installed, and if you enabled colours, we will use Coderay on the terminal output to also display colours.

You can disable coderay output, which will try to colourize ruby-code on the commandline, by doing:

disable Coderay
disable coderay # this also works

You can sort the output by doing something like:

sort_by size

Obviously, the above command will sort by size.

Reading the content of files and directories from within the Roebe::Shell

The most obvious way for reading content is by reading a file.

To do this one would do something like:

read_file /location/of/file.txt
read_file /home/x/data/std.bfproject
rfile /etc/hosts

Some aliases exist for this, i.e. "readfile" would work also, as would "cat".'

The configuration option "padding" is also used to pad the file to the left.

You can obtain the current value of padding by doing:

padding?

And you can set it to a new value by doing something like this here:

padding = 15

As of January 2014, the padding of input is done when the roebe-shell reads in a file. This may change at a later time again.

If you do not like any padding at all, you can either set padding to 0, or do this:

disable padding

Disable is the general way to disable some functionality, either as part of the Roebe::Shell, or from the underlying system.

Modes in the Roebe::Shell

There are several modes in the Roebe::Shell, even a hidden mode - the play mode.

If the play mode is active, we will try to play all video files in the currenty directory.

You can set a specific mode by doing something like this:

mode = editor

You can query the currently active mode like so:'

mode?

This would output "edit" in the above example.

Mode-specific code can be found in the file mode.rb.

The idea behind the modes is that we will attempt to provide a "default action" onto a target file when otherwise no action is associated with that file type.

If you type in the name of an existing .mp3 file, we will try to play it. But what if you have some unknown file?

In this case, we may try to open it in the browser, or open it in the editor. And this is the reasoning behind the modes in Roebe::Shell.

The default mode is edit by the way, so the Roebe::Shell will assume that you attempt to edit an existing file.

Features of the Roebe::Shell

There are many features that the Roebe::Shell aims to achieve and implement.

One goal is to function as a replacement to bash and also irb eventually. It is still a long way to go.

Using backticks from within the Roebe::Shell

You can, just as in irb or ruby, use the `` backticks to run a command.

Usage example for this:

`ls`

You can also use longer examples here, such as:

`ps aux`

Repeat the last action in the Roebe::Shell

You can repeat the last action by doing:

~
+
-
++
--

Positional modifiers work too, to some extent. +30 would mean "play the song at position +30 in relative terms to the last song played".

Removing something from within the Roebe::Shell - removing files or directories

You can remove directories via the remove subcomponent i.e. by doing this:

remove foobar/
remove /tmp

See also the file protected_directories.yml.

You can specify directories which should never be removed, within the file protected_directories.yml. I recommend to add the directory / to that yaml file there.

You can also add new directories to this list:

protect /some/directory
protect /tmp

Please also note that you can specify a number as well, e. g. the following would remove the first entry in a directory:

remove 1

This can sometimes be a bit confusing, so in this case you can just use the real name; I once wanted to be able to also make use of numbers, so this is why this functionality exists.

Syntactic sugar also exists. To remove all directories in a given directory, you can issue the following command:

remove all directories

Note that german words also work as aliases to these actions.'

You can also remove files that contain a " " character.

For instance, consider a file that is called foo bar.txt.

In order to remove such a file, try this, including the quotes:

rm "foo bar.txt"

Generating something from within the Roebe::Shell

To generate a new page, issue:

generate BIOS.cgi

This will simply generate a new .cgi file.

Handling the configuration via a standalone rc-file, in the Roebe::Shell

If a file called shellrc exists in the base directory of the Roebe::Shell home directory, then it will try to parse it and use its values. For instance, if you set "colours: false" in this shellrc file, then it will not make use of colours. (You can also use US spelling such as "colors: false").

This is similar to using the yaml files to control the behaviour or other instructions such as "disable colours" at runtime. More about this in the disable-subsection.

You can dump the configuration options by issuing:

dump_config

Parameters for the Roebe::Shell

You can get all the parameters of the methods in the Roebe::Shell.

In order to do this, do the following command from within a running instance of Roebe::Shell:

parameters?

Here is a partial screenshot showing the output of that command:

Debugging in the Roebe::Shell

You can enable or disable debugging in the Roebe::Shell.

The command may be like this:

debug+

To enable debugging.

Whereas:

debug-

can be used to disable debugging.

You can also use the longer variants such as enable_debugging or enable debugging. And of course also disable debuggung - see the other entries for enable and disable functionality.

Calling any method by its name from within the Roebe::Shell:

The general syntax for this procedure is:

cmethod <span class="yel">name</span>

Examples for this:

cmethod foobar # would call the method foobar, if it exists.
cmethod clear_history
cmethod preformed_action?
cmethod history?
cmethod upload_screenshots?

method and cmethod works the same, method is just an alias to cmethod.

To list all available methods (which you could then call with cmethod), do this:

all_methods

Also note that you can get feedback about a method since August 2015 if you pass the name:

method? yel
method? clear_history

Upcasing via the Roebe::Shell

You can upcase directory and file names by doing something like this:

upcase all directories

This would upcase all directories in the current directory.

Obviously you can also upcase single files too:

touch test_file
upcase test_file

Now you will have a file called TEST_FILE.

Conventions for the Roebe::Shell

All * are meant to be a shortcut for "all files". Or more precisely, all files, directories and symlinks. Thus, the user can use * to mean "all entries", essentially.

@this_file and @. Not sure about the differences. I think @this_file is used to denote the main file right now, whereas @ is more like a throwaway variable.

Note that @this_file and @_ may no longer be in use - they were written over a decade ago, and I have not had a look at the code since then.

Using run within an instance of Roebe::Shell

You can "run" a file from within Roebe::Shell. Running a file means that the file will be run via the default application that was registered for this file.

For example, if you do:

run foo.pdf

Then the Roebe::Shell would try to open this file.

This is a bit similar to the command open, but run specifically also works when we have files like .rb files, .py files and so on.
It is a bit like an instruction to execute that file.

Since as of September 2016 you can also use a require-statement to start up a new instance of the Roebe::Shell.

Do the following:

require 'roebe/shell/run'

FTP support and the Roebe::Shell

Now let's talk a bit about the FTP functionality in the Roebe::Shell.

You can upload a whole project by issuing this:

ftp_upload project dia

Of course that task must have been registered somewhere first.

To show all available tasks, do either of these:

show available tasks
stasks

Note that upload is an alias.

Tab-completion may be possible.

Since as of April 2023, this is no longer really that important or in use. I recommend against users using this. I only keep this part available in the event I may re-evaluate support for FTP one day in the future.

Handling birthdays in the Roebe::Shell:

The Roebe::Shell has the - not too overfuly useful - option to display upcoming Birthdays. This requires one to write or define a custom yaml file that keeps track of these birthday dates.

Currently this is set to 5 days in advance.

It will report in ways like this:

 We found these Birthday candidates:                                                                               
 Peter: 11.04.2023

To query this, you can do this:

bday?

If you wish to look n days into the future, you can pass it as an argument:

bday? 30
bday? 120

Do note that the whole Birthday subsection will only work if you actually have such a yaml file defined. If you have not, the whole subsection will be ignored.

Handling Passwords via the Roebe::Shell

To clear the password of your user account, do:

nopasswd

This will simply delete the password.

To show all available passwords, you may also do:

passwords?

The configuration of the Roebe::Shell

This subsection details important configuration files for the Roebe::Shell.

The file default_applications.yml may include which favourite applications are to be used for specific specific file types (and the default open-action for these file types).

In here you can specify which program to use whenever you want to open a .pdf file, open a .png file and so on.'

open $ROEBE_SHELL/lib/roebe/shell/yaml/default_applications.yml

To show the current values set in that file, you can do this:

default_applications?

Note that you can reload the yaml config by doing:

reload configuration'

This will also reload the aliases at run-time.

Another configuration option allows you to display shorter file names, i.e. if a file name is too long we will simply truncate it.

Every available configuration option can be found in the main configuration directory.'

cd $ROEBE_SHELL/lib/diamond_shell/yaml/configuration

For local use I recommend you to only use the saving option.

The following example illustrates this:

config.debug = true

This changes the configuration of the shell during runtime.

To make this change permanent, do this:

save

or

save config

Now, on next startup, we will load this saved config file.

You can also save individual components. For instance, you can save the debug value, or the padding value.

save debug
save padding

But this is no longer that useful. Since as of March 2014, I recommend you to simply to just "save" alone.

If you have set shorten_directory_names to true, then a leading * will indicate that the name was shortened.

You can toggle this at run-time too, and untoggle again, as in:

shorten
unshorten # or "longen"

Note that shorten will also get rid of the ModTime information.

You can also deliberately disable the display of the modification time. In order to do so, do:

no_mod_time

And to undo, do:

show_mod_time

You can modify every configuration option directly like so:

config.use_colours = false

To feedback this option, do this:

config.use_colours

You can also append a ? if you want to:

config.use_colours?

Rather than use config., some aliases exist, such as @configuration, @config and so on. Use whatever suits you best, although config. is probably the shortest and simplest notation for accessing the Roebe::Shell configuration settings.

Of course, if you want to disable the colours, you could also use this:

disable colours

You can reload your original configuration by issuing this:

reload config

This will also reload the colours, so you can use it to change the currently running shell.

The option run_simulation is used to run in a simulation mode - currently this means that we do not actually burn a CD or DVD, no. It means we will feedback which command we would use.

Also note that when you are on windows, you could do something like:

config windows

To conveniently switch to a windows-based configuration.

If you look at the configuration, it is a simple key => value mapping, a hash. You can modify values of this hash in a fairly simple manner:'

editor = bluefish

This would set your editor to bluefish.

You can change specific parts of the config by using aliases.

For instance, this will work to change the location of Firefox:

firefox.location = /Programs/Firefox/Current/bin

Another option is to simply use this instead:

set_browser /Programs/Firefox/Current/bin
set_firefox /Programs/Firefox/Current/bin

Since March 2012 we are using a specialized class called Configuration to handle all configuration aspects of the Roebe::Shell.

You can also query the config directly by issuing a command query such as the following:

config.padding?
config.use_irc?

An alternative syntax also exists such as:

Roebe::Shell.configuration.padding = 5

You can designate another Encoding format to use via the configuration option preferred_encoding.

Additionally, you can overrule the encoding via the method Roebe::Shell.set_encoding(). For instance, to designate to the binary encoding, use this:

Roebe::Shell.set_encoding :binary

I tend to use an ISO encoding, you may use UTF there instead.

This encoding format will be used several times during a Roebe::Shell session so make sure to have it properly set.

Using the special keyword "all" in the Roebe::Shell

You can use the special keyword "all", as an alias towards *.

That way you can apply a common operation on several file objects, for instance:

tovilla; bl 4/all*

This would open all files within the directory at position 4 in the bluefish editor (or whatever else is your defined editor under @config.editor).'

In general, "all" is considered a shortcut for "*", unless a file exists with that name in question.

Triggering Events in the Roebe::Shell

You can trigger (and register) certain events. For instance.

in 5 sekunden trigger wecker

Would register this action to be run in 5 seconds from the time of entering the input..

A german variant of this works as well:

in 3 sekunden starte wecker

Aside from triggering events, we also have some event-like options that can be used to configure the Roebe::Shell.

These can be stored in the configuration file events.yml.

For instance, the event :on_remove_directory will invoke a cleanup script, whenever a directory is removed under the /Programs/ hierarchy (or more accurately, whatever value was set to the PROGRAMS_DIR environment variable).

Appending to a file in a running Roebe::Shell instance

As it is the case with other shells, you can use >> to save something to a file from within the Roebe::Shell:

foobar >> this_new_file

This would save foobar into the file <span class="file">this_new_file</span>.

As a reminder, in Bash it works a bit differently, in that the stream is redirected. In Roebe::Shell, a simplified approach is used.

Also note that you can use macros here, such as the @buffer macro.

For instance, if you do:

@buffer >> foo

Then we will store the content of the buffer into the file foo.'

Note that you can also use > which will create a new file and then add the content to that file.

Saving content into a file, from within the Roebe::Shell

You can save to a file, for instance, by issuing this command:

save to $J/foo

This would save whatever is inside @usher.string into this file. (By default it will append, though this behaviour may be subject to change at a later time.)

Fetching all .ogg/mp3 files in a given dir from within the Roebe::Shell

all ogg
all mp3

Of course you can apply other criterias as well, such as "all php" or something else entirely.

The result will be stored in @file_listing which can be manipulated lateron.

To retrieve it, simply type it in the shell.

@file_listing

Since as of September 2011 the following also works:

@_

Since as of January 2012 it is also possible to shuffle the dataset stored in @file_listing by issuing:

shuffle

Showing the source of a ruby method from within the Roebe::Shell

You can show the source of a ruby method by issuing this command:

show-source run

Copying data in the Roebe::Shell

You can copy a complete directory via the Roebe::Shell. By default, this functionality will try to copy to the current working directory if no (other) argument was given.

For instance, you can test this functionality by doing something like this:

cp to $JJ

Or a bit more verbose than that:

copy_dir to $JJ

Note that the directory specified at $JJ must exist. On my home system this will expand towards /Depot/jj/, by the way.

It is recommended to use the second variant if you wish to copy a directory; copy_dir is a shortcut for copy_directory. Both variants will work fine - they are synonymous.

You can also copy whatever is stored inside @file_listing to another target.

The following example shows this behaviour, by first entering to your directory containing all audio songs, then fetching all .ogg files, then copying them to whatever is held in the environment variable J:

cd $MY_SONGS # go to the directory containing my songs 
all ogg
cp to $J
cp here to # this willc opy the content of @_ variable
to the current working directory
cp to here # Same as above
cp all to $JJ # this copies the content of this directory to 
the environment variable $JJ
cp all to here # Copy to the current directory

More about the environment can be read here.

Please also note that the variable @target_directory can be set to a specific directory like so:

target /Depot/Song

The effect is that this variable can now be used to copy files or directories to this target. So after you have done the above, you can then do this:

cp /Home/OldSongs/

And it will, in this situation, copy it to this directory. If this was not set, a notification will alert the user that the target directory is missing in this action.

Of course, if you manually give another target, then we will use this instead.

If for some reason you want to copy all images under a specific directory to a new target, use this:

cp_images

Note that this will copy to the directory you are in.

Useful to have is that you can also assign all current files in a directory, and then copy these to somewhere else even at a later time.

This works like so:

assign all
cp to here
cp to $J # you can use absolute targets too, of course.

Program URLs and the Roebe::Shell

To get the URL of a program, issue the following command:

programurl wine
programurl ruby
programurl php

Ruby keywords and the Roebe::Shell

To get a list of all ruby keywords, from within an instance of Roebe::Shell, do this:

keywords?

Displaying the weekday of an arbitrary date (dd.mm.yyyy)

If you want to find out what weekday a certain date is, in the dd.mm.yyyy format, then you can use the following invocation example:

wday 13.11.2011
# This day is a Sunday. # ← This will be the result.

wday today
# This day is a Sunday.

wday today?
# This day is a Saturday.

This is just a little convenience feature.

Displaying the content of a file from within the Roebe::Shell

Use cat or get_file_content to display the file content of a file.

For example, if the file is called foobar.txt, do this:

cat foobar.txt

You can specify a range:

cat file 10-20

This would display only line 10 up to 20.

This works only on files, i.e. not on directories.

Also note that this slicing for files should work in general, and can even be extended. Look at playing video for an example.

You can also read a header, via:

header foo
header 5

How many lines will we display that way? By default we will show the first 25 lines, but you can change this setting, by doing something like:

header? 10

This setting can be saved, by issuing save.

Note that if the file is a .rb file, we will try to use the Coderay gem to parse the result.

As of August 2014, we will also allow you to use the last file that was assigned when you use ?:

cat ?

You can append into a file directly by doing this:

cat this_file >> ~/A_FILE_IN_MY_HOME_DIR
cat 4 >> ~/A_FILE_IN_MY_HOME_DIR

Connecting to IRC from within the Roebe::Shell

Although this functionality is no longer that important since as of 2023, here is how it used to work:

irc channel_name_here
irc ruby-lang
irc ruby

(Freenode IRC appears to have disappeared since then.)

Serve local pages in the Roebe::Shell

You can serve local .cgi pages, by issuing this:

serve foobar.cgi
serve PC.cgi
serve /home/x/programming/ruby/src/roebe/lib/roebe/www/thinking_methods/thinking_methods.cgi
serve http://localhost/programming/ruby/src/games_and_rpg_paradise/lib/games_and_rpg_paradise/www/das_schwarze_auge/dsa_computerspiele.cgi

By default this will output the html code onto your console. Additionally, it will save the result into a .html page, within the directory of the Roebe::Shell log directory.

Subdirectories in the Roebe::Shell

You can show the file size of a subdirectory via:

subdir_size?
ssize

I found this useful because sometimes I need to know how many files are in a subdirectory.

The prompt in Roebe::Shell

You can modify the prompt by doing something like this here:

prompt foo

Some options exist in regards to the prompt. For a listing of these, query via help, such as this:

prompt help

# The Disco Prompt may be fun to try out.

You can set a mixed prompt, meaning that directories will be colourized as default, but the / between them will have another colour.

Let's look at a screenshot for this:

And now the code for this:

setprompt mixed

If you wish to clear the prompt again, do this:

prompt nil

Stat in Roebe::Shell

Stat is used similar to the UNIX command stat.

stat some_file

Additionally, we include information from class BeautifulUrl so whatever you did add to that class will work with the stat command too, no matter where that file is.

You can also apply stat on the @_ token, like:

stat @_

Additionally, you can do this:

stat {1,2}
stat 1,2

The above commands would stat the position 1 and 2.

Note that leading file: entries will be removed from the given input.

Creating a new recipe for compiling program, from within the Roebe::Shell

To create a recipe interactively (i.e. write up information about it in a step-by-step fashion), run this command:

interactive_recipe
irecipe

This is part of the rbt gem. We can use this to create a new recipe for installing/compiling a program.

Opening files and the content of directories in the Roebe::Shell

The command open given in an instance of the Roebe::Shell allows you to open files.

Some arguments are used for this method, such as shown in the following example:

open last

This would open the last file (if one was assigned that is). This may be useful when you have opened a local page via some shortcut and want to refer to it. In this case, "last" refers to that file.

This also works for programs and their project URL, for example try this:

pinfo php open

This would give you some information about php, and then open the webpage in a browser.

Popular open-related actions include the following:

open wikipedia
open pdf
open html

Note that you can also open URLs - in this case, we will fire up the browser to load it.

You can open the last assigned file by doing either of the following:

open LAST_FILE
open ?

Note that we will try to glob towards an existing file if we did not find a valid file to open otherwise.

If you want to enter a directory, from within a running instance of a Roebe::Shell, you just type the name of it, or you prefix via "cd", such as in "cd /tmp".

The Roebe::Shell will attempt to enter the upcased version of said diretory as well if it exists, ie if you enter "foobar" dia-shell will also try to enter a dir FOOBAR. (This will happen silently - if a directory called FOOBAR does not exist, we will not generate any warning message at all. This feature exists only due to convenience.)

A partial match may also be possible. For instance, if you have a directory called Reallife/ and you type "realli" then this will be expanded towards Reallife.

Also note that whenever you change the directory we will register the new directory in a yaml file, so that the shell can remember which directory was the last one you worked in. This information is stored in the file last_directory.yml and you can also query this via:

last_directory?

You can use numbers instead of names to enter directories, although this setting can be changed in the configuration for the Roebe::Shell.

If active, then Number 1 will correspond to the first directory, number 2 will correspond to the second directory and so on.

Example:

cd 3 # would enter the third directory

This works with english words as well. For instance, the two following examples mean the same - enter the first directory.

Both examples work:

cd 1
cd first

Note that if there is a directory called FOO and you type "cd FOo", the shell will attempt to correct this to FOO automagically.

You can - by convenience - also enter an archive.

We will assume in this case that you want to extract that specific archive before entering it.

Example showcasing this functionality:

cd rpm* # where rpm* points to the archive rpm-1.0.0.tar.bz2

Also note that the aliases wd1 wd2 etc.. are being treated as instruction to "jump to" specific directories. More about this at the section Jumpers.'

Every time you change directory or copy something, this will also be tracked, in the pseudo-variable $LAST_DIR.

You can use this variable, like so:

cp * /System/Fonts
cd $LAST_DIR
cd $LD

You can also change directory to the last created directory by issuing:

cd !#:1

Take note that if you use cd(), and pass a number to it, we will assume that you wish to enter only directories or archives from the current directory.

You can use the arrow keys too, if you want to navigate.

For instance, alt+left arrow key means "go down one directory level". alt+right arrow key means to (randomly) go up one hierarchy.

Since as of May 2017, if there is a file called NOTIFICATIONS.md in the directory, we will read its content and display said content. That will work only if the file is not empty.

This allows you to give some notifications to your future self, such as if you need to make some changes to files in that directory at a later time - in this case, in case so that you do not forget, simply put such a file into the directory.

Taking a screenshot from within the Roebe::Shell

You can use scrot to make a screenshot, if it is installed on the computer.

A common alias invocation example for this would then go via:

shot

The first argument to this would be an optional name for the .png file that will be created.

Example:

shot my_desktop # This is the same as "shot my_desktop.png"

The second argument is an optional delay for this action, (in seconds), such as:

shot my_desktop 5 # 5 seconds delay

Note that since as of April 2014, the Roebe::Shell will automatically try to upload that screenshot to a remote host if the environmental variable IS_ROEBE is set to 1. Nowadays, since as of 2023 and beyond, I rarely use this functionality anymore, as I upload to imgur instead. But I will retain that feature, in the event that I may need it again one day in the future, or someone else needs it and wants to adjust the code to another FTP site or any other site.

The code for handling screenshots is stored in the file screenshot.rb, by the way.

Usage inside of a running Roebe::Shell instance:

If you manage to start the Roebe::Shell, which should be possible by issuing "dia" (residing in bin/roebe of this gem, but I aliased it to dia because that was its original name from several years ago) you can then issue the help command to show the common functionality available:

help

To see the current version of the Roebe::Shell, do:

version

To generate all keys, do:

generate keys

To remove comments from all .ogg files in a given directory, we can do:

remove_comments *ogg

To stat some files do:

stat test.txt # The simplest variant: you simply pass the name of the file at hand.
stat 1 2 3    # This will stat the files at position 1, 2 or 3.
stat 11,12    # This variant is also possible, if you would like to use it.

If you want to create several new files via one line then you can use the following:

touch {temp1,temp2,temp3,temp4}

This would create the four files called temp1, temp2, temp3 and temp4. The behaviour is similar to UNIX/Linux shells such as bash or zsh.

You can cd into a directory by issuing i.e.:

cd /tmp
cd 1 # Positional arguments are possible as well. This would cd into the first directory.

You can also cd into an archive - this means that we will first extract the archive, then cd into that directory.

Specific example for that:

cd htop-1.0.2.tar.xz

To upload a file, or several files, do:

upload foo.txt
upload *
upload 1,2,3
upload 1-3

To convert formats into one another, you can use the convert() functionality, such as:

convert foo.png foo.pdf
convert bar.mp3 bar.ogg

To show the padding in use, do either:

padding?
show padding

You can see the input history by doing this:

history?

If you don't like this, you can disable it via:

disable history

In general, if you wish to disable something, you do:

disable ENTRY_HERE

To start transmission in the background:

transmission URL_HERE

To sort all files in the current directory by size, do:

sort_by size

To see the available configuration, issue this command:

configuration?

You can also fetch documentation of Ruby Stdlib or Corelib.

Do this:

docu? foobar.rb
docu? Array#sort
docu? Array.push

If you wish to display a celsius to fahrenheit table, do:

celsius

All of these should work. The first way will fetch docu from a .rb file, but right now it will only parse the header - the leading comment, that is, in a .rb file. The other variants make use of Ri to fetch docu.

You can also view the source of a method or the documentation to a method.

Do this:

show-docu-of? yel
show-method-of? yel
$ String.size

Video and audio files can be played if you use mplayer or mpv. On my home system, for instance, I can input the following:

play_video :1

The :1 means to use the first video from the location to where I keep all video files. If the video exists there then it will be played. I use this shortcut to avoid having to type the full path or navigate to the directory where my local video files are stored. I even shorten this to:

pvideo :1

Quite convenient to work with the Roebe::Shell that way! \o/

To create a directory, use something like the following:

mkdir /Depot/j
mkdir /Depot/jj /Depot/jjj # You can provide more than one argument here.
create_directory /Depot/Temp
cdir /tmp/test # And you can use different aliases too; "cdir" stands short for "create_directory".      

To run animated ASCII components, if you have the ascii_paradise gem installed, you can issue:

ascii1
ascii2
ascii55
# or if you prefer, a tiny bit longer
ascii 1
ascii 2
ascii 55

Note that this does not work very well on windows cmd.exe as of May 2022. I may have to look at the reason for that at a later moment in time.

If you want to see which components were "lazy loaded" so far then simply use:

status

To change the title of a cmd.exe window, do this:

windows_title cats    # The title is now "cats".
windows_title foo bar # The title is now "foo bar". 

To find out the current user's home directory you can simply input:

Dir.home # on windows this will yield a result such as C:\Users\debug

By default Roebe::Shell tries to use the Readline module. This is not always desired. If you want to toggle between regular $stdin and readline-mode, then do either of the following:

toggle-user-input
toggle user-input
toggle userinput

Working on windows can be a bit inconvenient, but many UNIX/Linux tools are available on windows as well. For instance, the editor nano works on windows. You can invoke it from the Roebe::Shell via:

nano /Depot/j/foobar.txt # Pass the path to the file to nano. 

Of course this will only work if you have installed the nano-executable on windows too. Use google to find out where to best obtain the nano-executable - I found it from a StackOverflow link in May 2022 - and it works! \o/

To do a silent startup (less verbose) you can do this:

dia --silent-start # or an alias such as --silent-startup and various more.

Normally on startup the method startup() is invoked, but this is not always wanted, such as when you want the start-up of the Roebe::Shell to be faster, or to load less stuff. In this case, to disable that for the current run, start a new instance via:

dia --no-startup

Various other commandline options are available. For instance, you can toggle whether you are on a roebe-system from the commandline via:

dia --is-on-roebe
dia --is-not-on-roebe

The first enables this; the second disables this. I needed this on windows in particular.

Creating files, directories and other things from within the Roebe::Shell

You can create a webpage from within the Roebe::Shell via:

createw location_of_the_directory_goes_in_here
createw /tmp/
createw $IMG/FUN/ANIMALS # $ environment variables work as well
createw $IMG/NJOY/

You can also give a file and split it up. Example for this functionality:

createw BIG_FILE_HERE 3

Would split this file into 3 .html pages.

You can also create simple files. In UNIX Environments, you commonly use "touch file_name" to create a file.

This works when you use quotes too, for instance:

touch "foo bar"
touch "foo bar.md"

Will create a file called "foo bar", including the space.

You can also create multiple files like so:

touch {temp1,temp2,temp3,temp4}'

The Roebe::Shell also tries to be "smart" when it notices you want to create a file. For instance, when you try to create a .rb file, we automatically insert a program skeleton into that .rb file.

This behaviour can be adapted and changed by the user.

Installing software from within a running Roebe::Shell instance

In the future this section is supposed to allow you to install a complete Linux distribution from scratch, by tapping into the RBT project.

For now though, we will focus on installing several packages in one go, such as by compiling them. This will also make use of the RBT project, so make sure to install the rbt gem.

To do this, and install the default system try this command:

install default

Note that this will probably not work any longer, as of 2023. I also do not recommend anyone to try this on your main computer.

At any rate, what this does is it will try to install (compile) all programs listed at installation_procedere.yml/ - which is also part of the rbt gem.

You may have to adjust that .yml file to your own use cases.

Merging files in the Roebe::Shell

You can merge files, such as .ogg files, by issuing this command:

merge x.ogg file1.ogg file2.ogg file3.ogg

You can omit arguments too, as in:

vobmerge # will pickup all .vob files in the directory

Note that most of this functionality may depend on ffmpeg and the multimedia_paradise gem, as that makes it easier for me to maintain that functionality.

Time and waking-up in regards to the Roebe::Shell

I needed a simple way to wake-up from sleep, so the Roebe::Shell eventually plays some music at a designated time - that's how I wake up.

In german this is called a "wecker".

You can set a Wecker, like when you want to wake up at a specific time.

This wecker formula is quite flexible right now:

wecker 6 std 8 minuten
wecker 855 minuten
wecker 2 tage 8 stunden

Time-related queries also work nicely.

For instance, if you wish to find out when the next Weekday is, try:

next sonntag
next sunday

In general, though, I use at, such as via:

at 08:00

This will start at 08:00 o'clock and play some looping audio.

The Clipboard buffer in Roebe::Shell

The Roebe::Shell tries to use a Clipboard buffer.

This file is stored at roebe/shell/clipboard.rb.

The current value of the Clipboard buffer, at the least on Linux systems, can be obtained via:

buffer?
b?

If you wish to assign it to a specific string, do start this with the token:

{

This is the start command for the buffer. I thought that using {} as delimiter to enter into the Buffer directly would be convenient, so that is why I added that feature.

Do note that since as of December 2011 the Roebe::Shell will additionally try to use xclip when using the buffer on Linux. This way, you should be able to manipulate the buffer on your own, as-is.

You can clear the buffer any time by doing the following instruction:

clear buffer

Since as of March 2012 we also use a file called buffer.yml. If this file exists on startup, then we will load it into the current buffer.

Take note that the Roebe::Shell will try to use the Xorg buffer on Linux.

This Xorg buffer understands some special commands such as:

buffer generate ruby

This will generate ruby code.

You can store this buffer to a file, as in the following way:

save buffer to $J/jtj.rb

Notifications for the Roebe::Shell

Presently the format for notifications in the is rather primitive.

One can use the following variant:

At 06.07.2008 15:00:34 send "hey your kitchen burns"
In 20 seconds send "hey your kitchen is really burning!"

If you omit the time, we will assume 12:00:00 as the default.

If you use "in 1000 seconds" then the Roebe::Shell will calculate the proper time automatically.

Viewing a map via Roebe::Shell

You can view a map (Stadtplan in german):

stadtplan landstrasse 22

Right now this defaults to Vienna. However had, it should be possible to extend this to include other cities and locations - I just did not have that use case so far.

If anyone requires this for other cities let me know - it is mostly a hack rather than be based on awesome design considerations.

Finding something from within a running instance of the Roebe::Shell

Obviously any useful shell has to allow its users to find local files and directory.

This is possible via the Roebe::Shell too, although it tends to use and prefer UNIX tools, such as findutils.

Usage example:

dfind threads.rb

This will attempt to find a file called threads.rb on the local filesystem (typically a HDD), and also assign this result to the @last_file variable, which can then be queried via file?.

(In later revisions it was no longer guaranteed that an instance variable called @last_file will be used - but the instruction file? will be guaranteed to work, so for a user this should make very little difference.

You can also find where binaries may be, similar to the UNIX where_is.

Do either of the following, in order to find the binary called tar:

where is tar?
where is tar
where? tar

Burning a DVD or CD .iso file

The Roebe::Shell currently may rely on i.e. libburn or cdrskin and growisofs to burn CD and DVD iso files.

You can simulate a "test" run issuing:

burn test

The program to burn CDs and DVDs can be set in the configuration file.

You can get its current value by doing:

dvd_burn?

Alternatively, you can set the run_simulation variable to true like so:

run_simulation = true

Or just:

enable simulation

Recording something via the Roebe::Shell

You can "record" data with the Roebe::Shell, provided that software was installed that allows one to do so.

Right now this is limited to streamtuner (Audio Streams from the internet).

Then the user may be able to input the following into the shell:

record streamripper'

You may have to install/compile streamripper first.

Right now this is not very sophisticated, but we could, in theory, expand the record functionality to include audio-related data in general, such as recording one's music, and similar use cases.

Jumper directories in the Roebe::Shell

What is a jumper directory?

This is a directory onto which you can "jump to" quickly, e. g. a favourite - similar to bookmarks in a browser. We could thus call jumper directories to be Bookmarks for Terminals.

In other words, thanks to jumpers you can quickly change to another directory. This makes navigating the local filesystem a bit easier, to some extent. Personally I do not really need jumper directories anymore, as I simply have a ton of aliases instead - but for those who do not use many aliases, or simply want to keep the most important directories as quick navigation tool, this functionality of the Roebe::Shell will be retained as it is.

How does this work?

On startup the Roebe::Shell will load various yaml files that constitute the configuration of the Roebe::Shell. This will also include a set of default jumpers - in other words this is done to make our jumpers "persistent".'

The relevant file here is jumper_directories.yml. It will contain all jumpers.

You can add or remove entries from this list of jumpers easily, as the following example will show - how to add this directory as a jumper-directory:

jumper # will set a jumper to the current directory

Past this point you can now jump to this directory.

To see the list of available jumper positions, issue the following command:

jumpers?

To jump specifically to one of these directories, you can also provide a number, as in:

jumpto 3
jto 3 # This alias also works.

Also note that you can use an alternate syntax as well, via cd:

cd ~3

or like this:

wd3

The latter will be treated as "jump to position 3".

It is thus a shorter way to jump to a specific directory, and "wd" will be treated as alias.

wd1

Would mean "jump to first jumper directory", wd2 would mean "jump to second jumper directory", and so forth.

Note that you can remove a jumper again like so:

remove jumper 6
remove_jumper 6
rmjumper 6

This would remove the jumper at position 6.

Personally I prefer the second variant, remove_jumper. It seems to be a useful mnemonic. You can omit the _ of course, so you can use removejumper instead.

You can also integrate different jumpers at run-time. Every file called jumpers.yml will be treated as a jumper directory.

You can add new directories with a jumper.yml file to the configuration file. If anyone wants to extend this further, let me know - personally I am quite happy with how it currently behaves. I do not use jumper-directories that much myself, since, as stated above, I have regular aliases that allow me to quickly change between directories.

Downloading remote files from within the Roebe::Shell

You can download a package like so:

download https://ftp.gnome.org/pub/gnome/sources/pygtksourceview/2.3/pygtksourceview-2.3.0.tar.bz2'

If you want to download to a specific directory, use the "to" keyword like this:

download https://ftp.gnome.org/pub/GNOME/sources/gtk+/3.15/gtk+-3.15.4.tar.xz to /Depot/j
download https://ftp.gnome.org/pub/GNOME/sources/gtkmm/3.17/gtkmm-3.17.50.tar.xz to /Depot/j
download https://download.gnome.org/sources/libxml2/2.11/libxml2-2.11.3.tar.xz to /Depot/jj/

Note that this functionality can work with special targets/variables as well, for your conenvience. For example:

url = http://www.calno.com/evilvte/evilvte-0.3.1.tar.gz'
download url to 1

This would download to the location saved at slot 1, which defaults to ENV['MY_SRC'], or expanded, would become /home/x/src/ on my system.

url in this case is a variable which was asigned to some url before.

Whenever we download something, we will also set the variable @last_downloaded.

You can then use this variable to manipulate the file in question.

For example, to download, and then extract the file, you can use this:

download ftp://ftp.astron.com/pub/file/file-5.03.tar.gz to /Depot/j
extract last_downloaded

Also note that you can download Youtube videos by just passing in the URL of it.

The Roebe::Shell will automatically try to download and also extract the audio file into a .mp3 file.

Handling .pdf files via the Roebe::Shell

If you wish to find all .pdf files on the given computer system, consider using this syntax:

find all pdf

There is also a configuration option called @open_downloaded_pdf_files_at_once.

If this configuration option is true, then the Roebe::Shell will open .pdf files the moment we downloaded them.

You can also generate a new Manual for the Roebe::Shell by issuing:

manual
create manual

This will create a .pdf file.

Also note that you can, thanks to prawn, create a .pdf file out of a .txt file (any text file). We support this in the Roebe::Shell as well.

To do this, issue:

to_pdf foo.txt

Here we assume that foo.txt exists and can be used to create a file called foo.pdf.

The :Shell on Windows

The Roebe::Shell works on Windows too, but some problems may exist there, as Windows is not the main OS for the Roebe::Shell to be tested regularly.

First, to check whether you are running on windows or not, you can use the following method:

Roebe.on_windows?

You can also try out the following invocation example, from within a running instance of a Roebe::Shell:

config windows

Tis should enable some windows-specific configuration settings. But note that this has not been very thoroughly tested and it may not be useful for you. Have a look at the source code and decide whether you want to use it, or simply modify it as-is to your liking.

Conversions in the Roebe::Shell

A conversion, for the purpose of this document, may mean one of the following:

  • to convert a file of type a, into a file of type b.
  • to convert numbers or currencies from one model to the other.

So, for instance, to convert a .mp3 file into an .ogg file would be a conversion. So would the conversion of Celsius into Fahrenheit be a conversion as well - and so on, and so forth.

The following subsection here shows how this is done, as far as the Roebe::Shell is concerned.

To convert 55 celsius to fahrenheit, do this:

convert 55 celsius

You can also output a list of Celsius to fahrenheit table (convert into a table):

convert 10-100 celsius

If you want to convert audio tracks just use this:

convert *mp3 towav

This would convert all mp3 files to .wav files.

Note that to_wav in a running instance of Roebe::Shell would also work.

To convert mp3 into ogg specifically, do:

convert *mp3 toogg

Do take note that the Roebe::Shell can try to automatically convert numbers to file names or directory names.

This setting can be changed in the config file, at the entry:

autoconvert_numbers: true/false

Assignments within the Roebe::Shell

The Roebe::Shell allows the user to assign to a main file.

In order to do so, the user can assign to the main file like this:

asssign foo.txt

Now, in several command actions, like copying, you can omit typing the name when this is done.

Example for this:

copy to here

The above command would copy the main file to the current location, aka Dir.pwd (current working directory).

The Roebe::Shell will do this automatically for at the very least these actions:

copy a file
create a new file
when we play an audio file
when we open a file in an editor
whenever we stat a file
whenever we match to a local URL
whenever we open a file in the browser
whenever we append to a file
whenever we use jp2a
whenever we play a video file
whenever we trigger an action
whenever we create an iso
whenever we read a file

Editing via the Roebe::Shell and editor support

The Roebe::Shell needs to allow the user to deal with existing local files as well as creating new files. This is, for the purpose of this subsection called editing.

To find out which editor is the current main editor in the roebe-shell, do this:

editor?

You can switch to another editor by using seted such as via:

seted bluefish

This setting is persistent, and will be stored in the file editor.yml.

Also note that since as of September 2011, if you try to open a directory, the Roebe::Shell will now open the content of the directory. (Before September 2011, the Roebe::Shell used to display an error message instead.)

You can also open a local file based on the class name, if the file can be found.

For instance:

bl BirthdayNotifications:
bl BirthdayNotifications

The above will try to find a file called birthday_notifications.rb.

If it can be found then we will open it in the editor.

Note that as of 31.07.2015 you can also open a file based on the name of a method defined, if this method is part of the Roebe::Shell Project.

Example:

bl show_completable_commands

This would open the file show.rb because the above method is defined in that file.

Some editors, such as vim, allow you to jump to a specific line position, such as by doing vim foo.txt +55. We attempt to somewhat simulate this behaviour, in the event that you supply a ":" character, and numbers after that.

For instance:

edit foobar.rb:55

We would assume this to mean "edit the file foobar.rb", and "jump to position 55". Currently this works only via vim though.

You can also use the traditional vim syntax directly:

vim $DIA/configuration/configuration.rb +371

Do note that we will also expand aliases. So if you try to open an alias in your editor, we will expand towards the real file that is used.

Available components of the Roebe::Shell

Sometimes you may want to find out whether all add-ons are available (and work) on a given computer system, from within a running roebe-shell.

You can use the following commands to find out whether something is missing or not:

missing?
available_components?

The environment used by the Roebe::Shell and how to modify it

To retrieve the value of an environment variable, do something like this:

e $AUDIO
echo $AUDIO

Note that if you input just $AUDIO then we will cd into that variable if it is a directory. Either way the Roebe::Shell will first report the value of this environment variable, before doing a cd-operation. The cd-operation (change directory) will only be done if such a directory exists.

The key lies in using $ to denote the variable in question, and e is used to echo the content.

If the variable was not found or defined, we will display a little helpful note to the user.

Example:

e $A_VARIABLE_THAT_REALLY_DOES_NOT_EXIST

Also note that if you do something like:

e $L*

Then we will try to feedback all environment variables starting with L.

To feedback all known environment variables, do this:

environment?

You can also sync towards the environment variables.

What this means is the following:

Consider that you have defined an environment variable called $EDITOR.

You can sync towards this by issuing:

sync_to_environment
sync_to_env

This will update the configuration settings, such as by modifying the file called editor.yml which keeps stored which editor we will be using.

The startup of the Roebe::Shell

The Roebe::Shell will have to do some actions whenever it starts up (startup time).

Do keep in mind that there are aliases possible, for the convenience of the user. For instance, the option nocolours and nocolors are synonymous. Also, the user can use either - or --, so, for instance --nocolours will be the same as -nocolours.

You can decide which variant to prefer, on your own.

Following comes a listing of the currently supported commandline-options:

--version Display the version number of this shell. --time show the current time, in HH:MM:SS notation --nocolours disable colours. --run_method run a specific method, then exit. --norc do not load the configuration file(s) on startup. This also will ignore the file diamondrc, should it exist. --extract simply extract something, with the aid of the Roebe::Shell, such as: rda extract all. --help show the various help options, then exit --debug enable debugging for this Roebe::Shell instance --silent-startup we will be rather silent on startup

If you use a -- option that does not exist, the Roebe::Shell will notify you that it does not exist.

You can also invoke a specific method from the Roebe::Shell from the commandline.

Examples:

rdia --runmethod run_pkg_config
rdia --norc

You can also get tab completion on the commandline.

For instance, type the following:

rda --<TAB>

This will complete to --help.

This will also work if you wish to tab-complete on the current files in the working directory of your shell.

So if you have a file called foo.txt, this will work:

rda fo<TAB>

The startup-related code will also attempt to generate a hash that can be used for swift filesystem-navigation. This is done mostly for legacy reasons - in the past I had no aliases to work on windows, but this is no longer the case. That legacy option will be retained for the time being though.

The Roebe::Shell environment

Initially on startup a copy will be made from Roebe.env?.

This can lateron be modified by the user and it is valid for the current run.

Configuration - how to configure the Roebe::Shell

The configuration is kept in the directory configuration/ within the project, and consists of individual .yml files.

The convention for these yaml files is simple - the name of the yaml file in question will become a value on the configuration object, which you can then modify.

For instance, debug.yml can be true or false, and will also be available in the ivariable @config.debug.

Tab completion in the Roebe::Shell - typing a command, then pressing the TAB key

You can tab-complete if you run the Roebe::Shell with Readline support. (If readline is not installed, then we will obtain user input via the traditional $stdin.gets.chomp way)

Simply start to type something such as "ext" then hit the tab key, and it may give you some choices as to which part to tab complete to.

Another example would be:

@configuration.<TAB>

Also, the main case when menu of the Roebe::Shell is also available for tab-completion.

Autocompletion means that if you press the TAB key, you will be able to choose from a selection.

Before explaining this further, give it a try. Start a new instance of Roebe::Shell, and then do this:

extract|TAB|

The |TAB| notation here means "press the tab key here". So first you write extract, and then you press the tab key.

You will get a selection between extract_audio and extract_video and possibly extract_it as well.

Press v and then TAB again. You will have selected video.

The file that handles autocompletion is readline.rb, which you can find in the base/ subdirectory.

Note note that we allow you to autocomplete to the list of available instance variables.

For instance:

@al<TAB>

Would list which instance variables with a name starting with @al exist.

Additionally, all entries found in $PATH will also be completed.

As of August 2014, we will also add support for some completions of the Ruby stdlib.

Since as of September 2015, the roebe-shell will also tab-complete on leading @configuration. entries. This way you can cycle through the available configuration options more quickly.

Next follows an image screenshot for these options:

ASCII components of the Roebe::Shell

You can use some ASCII-related aspects, including ASCII art, via:

to_ascii some_image.jpg
to_ascii 1
to_ascii 2
to_ascii all

Note that this requires the installation of an external program.

In case no match is found, a glob() action will be called before eventually failing.

Encoding used by the Roebe::Shell

You can specify another encoding to be used for the Roebe::Shell, either in a yaml file, or through ruby code like this method call:

Roebe::Shell.set_encoding
Roebe::Shell.set_encoding :binary # to set to the binary encoding, aka ASCII 8-bit.

Of course you can also pass in the full name of the Encoding that you want to use, as a String.

For instance:

Roebe::Shell.set_encoding 'UTF-8'

Roebe::Shell Commandline

You can display the commandline options via:

dia --help

For instance, if you do not want to read in the default yaml config then you can start the Roebe::Shell via:

dia --norc

Registering errors and registering information via the Roebe::Shell

This short subsection just mentions a few methods that may (or should) be called when errors occur.

If a gem is missing then this should be properly registered via:

Roebe::Shell.register_this_missing_gem

That way we could automatically install these missing gems, or at the least inform the user about this properly.

The PID file of the Roebe::Shell component

We will store the PID in a file, typically called pid.yml. On an exit-event, that is when we will exit from a Roebe::Shell instance, we will delete that PID again from that file. That way we can have multiple Roebe::Shell instances running and we can keep track of which ones are running.

Lazy loading by the Roebe::Shell

Upon startup of the Roebe::Shell many components will be loaded in the background, via Thread.new {}.

The main idea behind this is that the user should be able to type instructions the very moment the shell has started. Waiting is no fun, so this should not reduce usability of the shell. This is also called lazy loading.

Unfortunately this currently does not work perfectly well. Sometimes race conditions may happen and warnings are shown. For the time being (May 2022) this will persist. In the future it is planned to remove this constraint and make loading of add-ons trivial, simple and effective.

Browsers and the Roebe::Shell

If you designate a browser then you can easily open pages in that browser. There is even code that can try to auto-detect which browser may be the main browser on a system. This currently only works when a file called browser.yml exists, which points to the browser at hand. If it does, and if "is_roebe?" returns true, and if no file could be found at that particular location, then the auto-detection code will try to find another location where the browser may be installed. But this is not failsafe, it may not work.

As you may have noticed, the project is mostly on stand-by mode, largely due to time constraints. While I am still adding and improving things every now and then, I would not call the project very active really.

I have had lots of ideas to do but either lack of time or lack of knowledge present a block to these ideas.

At any rate, just for anyone who may be curious, what kind of ideas and changes may be necessary, in order to make this project more complete and more useful as well?

An incomplete list would include:

  • We need a full replacement for IRB.

  • We need the ability to synchronize between different Roebe::Shell, including local ones and remote ones.

  • RPROMPT from zsh (optional, not mandatory)

  • Friendly help for newcomers (all those help options must be controllable though, so that advanced users can disable these at their own discretion - see the fish shell that really tries hard to be a newbie-friendly shell).

show-method in the Roebe::Shell

Since as of September 2015, the character $ can be used to show the source code to a method.

Aliases to this feature can be used such as:

show-method
show-source

This allows one to view the source code of a method.

Usage example:

show-method trigger_actions

Getting help from within the Roebe::Shell

You can get help by a leading ? character, such as in:

?upcase

This presently does not work for all methods though. In the future this functionality may be improved.

The home directory of the Roebe::Shell

It is useful to be able to use a designated home directory as far as the Roebe::Shell is concerned.

You can also designate a new (different) home directory for the Roebe::Shell.

In other words, this will be the new directory where we will save files to, and so on.'

The syntax to designate a new home directory, as can be seen if you use --help from the commandline, is as follows:

roebeshell --home-dir=/opt 

Requiring files and projects in the Roebe::Shell

You can require files and projects in the Roebe::Shell via:

require 'sinatra'
require 'thor'

If all works fine then no output will be generated by the running Roebe::Shell.

If the project has not been installed then this will not work, and the user is notified about it, such as via:

require 'THIS_GEM_DOES_NOT_EXIST'

Leading to:

This functionality allows the user to use the Roebe::Shell a bit like IRB - not exactly identical, but somewhat similar.

From within a running instance of the roebe-shell, you can use any of the following commands:

add_require NAME_OF_GEM
add_require roebe
addrequire  foo
addreq      foo

This would add the gem require to the file called:

FILE_ADDITIONAL_REQUIRE_FILES

This can be found in the file roebe/shell/shell/shell.rb.

Handling the PATH variable from within a running instance of the Roebe::Shell

The Roebe::Shell will try to use the $PATH environment variable, if it was set.

All binaries known there will be used for both the completion, and as known-executables. This is similar to how other shells handle the $PATH variable.

Globbing (expanding when * is used) in the Roebe::Shell

In the event that the Roebe::Shell can not find a specific given input, it may try to do a glob event.

First, the shell may try to use a trailing * but if that fails it may try with a leading * as well.

This functionality may be subject to change, though - not always does the user want to expand.

Dictionaries and the Roebe::Shell

A dictionary allows you to translate words from one language to another.

If you have a dictionary file in the YAML format, you can enable autocompletion-support for them.

That is, you can autocomplete via the TAB key on the words.'

In order for this to work, the use_dictionary.yml file must have set a value of true.

This can be done in a running instance of Roebe::Shell like this:

enable dictionary

And to disable this functionality again, use:

disable dictionary
disable askeng

Random stuff via the Roebe::Shell

The file at core/random.rb allows you to do some random things.

For instance, to play a random video you can issue:

random video

Redirect output via the Roebe::Shell

You can redirect the content of a file into another file, similar to bash and zsh.

Consider the following syntax examples:

cat foo.txt >> this_file
cat foo.rb >> bla.txt

Since as of November 2015, output can be redirected into a file, in append-mode.

The above examples will properly append the content of the respective files (foo.txt or foo.rb) into the files given as example above.

The Environment used by the Roebe::Shell

In ruby, the constant variable ENV keeps information about the environment - at the least variables, such as PATH. (More about PATH in another subsection of this document here.)

The Roebe::Shell also keeps a reference copy towards ENV, through @env defined on the top-level namespace. This can be accessed through Roebe::Shell.env?.

To display the ENV variable you can do the following from within a running instance of the Roebe::Shell:

ENV
display_environment

Using the line method call in the Roebe::Shell

You can show a specific line in any file by issuing the following command:

line 55 foobar.rb

Do note that the file in question has to exist, so we expect that foobar.rb, in the above example, exists locally.

The first argument here is the line position, e. g. 55 would mean "fetch me the content of line number 55".

Colour-support in the Roebe::Shell

The Roebe::Shell will use colours if you specified that you want to use colours.

This can be set inside of a running instance of Roebe::Shell, and it can be queried through the method called use_colours?.

This also works if you input this, of course:

use_colours?
usecolours?

This option can be customized within the config file and it can be changed at run-time as well (see the next section how to do so.

If you do not want to use colours, set the variable use_colours to false. This can also be done by issuing:

disable colours</b>

in your running shell.

To enable the colours, logically, you can do enable colours again.

Currently, directories and files will have different colours, as defined in the config file:

colours.yml
cat $ROEBE_SHELL/yaml/colours.yml # Lets display the content.
roebe/shell/yaml/configuration/colours.yml

To get a listing of which colours are used in the shell, do:

colours?

This will display the colours in use too, for instance:

You can then set a new colour live, by doing something like this:

colour_for_directories = red

From this point on, all directories will be displayed in red.

For fun and giggles, you can also randomly switch the colours, just to try out how things will look.'

For this, do:

switch colours
rotate colours
switch
rotate
scolours

Disabling functionality in the Roebe::Shell

If you want to generate certain files, such as foo.rb, a default layout may be autogenerated for this.

This is done by the class CreateFileSkeleton.

This is usually quite helpful, but can sometimes be annoying.

So for that reason, you can simply disable the autogeneration via:

disable autogeneration

To find out whether we will autogenerate files/content for files, do issue the following command:

autogeneration?

To show all available actions for disable-related functionality in the Roebe::Shell, do:

disable HELP

The Roebe::Shell simplifies dealing with audio data in quite a few ways. Consider reading this section carefully if you wish to manipulate audio data with the Roebe::Shell in any way.

You can remove a comment in an OGG File (.ogg) by issuing this:

remove_comment your_ogg_file.ogg

If you want to play several songs and use a range specification, do this:

77-99

This would then play the songs from position 77 to position 99 in the current directory.

Also note that since as of September 2011 you can issue the following command, and we will play the song found in /Depot/Songs/:

play song 33

Whenever you play an audio file via the Roebe::Shell, that file will be stored in an Array.

To find out the last song played, do issue the following command:

last_song?

Since as of November 2011 the Roebe::Shell will try to glob whenever it is attempted to play a multimedia file.

You can convert Audio Formats to one another. For instance, to convert a .mp3 file to a .wav file, you can do this:

assign foo.mp3
convert_to wav # Convert to .wav format.

You can use the Roebe::Shell to elegantly slice .mp3 files.

Currently the Roebe::Shell relies on ffmpeg to do these conversions. Now, how can you slice a .mp3 file with the Roebe::Shell?

Say you have a mp3 file, and file? also reports this.

Specific Example - we first assign a .mp3 file as the main file to work with:

assign Strack_MI1Theme_U2.mp3
file? # => "Strack_MI1Theme_U2.mp3"

Now you can then specify the start position:

cut_start 15

And then the end position

cut_end 45

in n seconds.

To start the actual cutting, do:

cut

To feedback the positions, do:

cut?

This makes use of class CutMultimedia, which is part of the external multimedia_paradise gem.

You can also play all audio files in a given directory.

In order to do this, try this here:

play all audio

This is almost the same as play * except that we will know which files are audio files and which ones are not.

You can add or remove entries to the favourite audio file listing.

To do this, do issue the following command:

add_fav foo.mp3
rem_fav foo.mp3

To show your favourite audios, do:

show favourite audio
show_favourite_audio

Either of these two will work fine.

Information about programs in the Roebe::Shell

You can get information about programs from within a running instance of a Roebe::Shell like this:

pinfo libassuan

You can also use purl, which gives you the url of a program:

purl wine

And to also open this URL, do this:'

purl wine open

This will also set the variable @last_url.

In fact, anything that stores a URL should also keep this information in @last_url. At any time you can retrieve this URL by issuing something like:

open_url
openurl

Note that certain other commands also set this url. A rule of thumb is, that whenever you notice an URL output, then this variable will also be set, and you can then simply use openurl on it easily.

Also note that two commands exist here "url" and "purl". The current way is that if you use "url", and we do not find an URL for it, we will automatically invoke "purl". I added it because gaining information was more convenient to me if I only have to type once.

PATH used by the Roebe::Shell

The ENV['PATH'] variable determines which path is used for ruby, in particular for system() and similar calls.

There are various ways how to manipulate the PATH variable from within Roebe::Shell.

Say that you want to add the PATH variable /System/Index/bin/; then you can issue the following command:

pathgen.add /System/Index/bin/

You may have some local video files.

The Roebe::Shell has some support for that, just as you can use bash or zsh to play a video (and mplayer, mpv or vlc, as software for such files).

You can play videos (or audio-songs), by issuing:

tosongs; mpl 3-5,33 # See the explanation for this line below.

The above instructions chains two commands, actually. The first one, tosongs, is my alias to enter the directory where all audio files ("songs") are kept on my home system. This is simply a cd-alias.

Then, after this command has been issued, we are now in the correct directory, and the next command ("mpl") kicks in. Here mpl is simply an alias of mplayer, even though I tend to use mpv most of the time nowadays.

So, we call mplayer, and we tell it "play the songs from 3-5, as well as song at position 33, in the current working directory".

The ; is a separator in this context, similar to how other shells, such as bash or zsh, operate.

You can chain command instructions separated by ; that way.

Note that you can search on IMDB via the shell too, via:

imdb dou fo sin # this would search for the movie called "dou fo sin".
imdb Finding Nemo # Here we would try to find the movie called "Finding Nemo".

Note that if you invoke "play" without any arguments, if we had assigned a file prior to this, we will simply play this file. This functionality allows a user to work on a "primary" file, without having to type the exact name. This feature is not that useful though - I very rarely use it.

You can also play a video file based on the number or the name of the file in question, if you have registered it in a yaml file prior to that.

Examples for that functionality:

video 125
video taxi driver # This would be the same, if you have a movie called Taxi driver there.

Numbers should work better than requiring of the Roebe::Shell to guess or infer the name. Tab-completion is also available of course.

You can also try to find a random video, via:

video random

You can use numbers, such as the following example shows:

play 1,3,4

This would play the files at position 1, 3 and 4.

Variables used by the Roebe::Shell explained

@_    The variable <b>@_</b> is a throwaway variable. It can be
used for pretty much any data. I sometimes tend to assign all
files in a directory to this variable.

Beautiful URL and how it relates to Roebe::Shell

There is another ruby project called beautiful_url. This project, essentially, maps an input argument (a String), into a longer String - normally a remote URL.

This can also be called from the Roebe::Shell. For example:

beautiful_url Einführung in die Kohlenhydratchemie
burl Einführung in die Kohlenhydratchemie

would display the remote URL of the lecture called Einführung in die Kohlenhydratchemie, aka this as a result:

https://ufind.univie.ac.at/de/course.html?lv=270143&semester=2018S

This can then be opened in the browser from within the Roebe::Shell too:

open_in_browser
openinbrowser

The collapse functionality in Roebe::Shell

Collapse in this context means to display the full path to a given file or directory.

If collapse is set to true, then we will NOT display the full path to a given file or directory.

You can change this behaviour just as any of the other configuration values.

One way doing so would be via:

disable collapse

Extracting from within the Roebe::Shell

To extract something while using the Roebe::Shell, you simply do issue the following command:

extract *tar.bz2

This should work with .lzma files as well.

Additionally you can specify a target location, i.e.:

extract gcc-4.3.1.tar.bz2 /tmp
extract gcc-4.3.1.tar.bz2 to /tmp
extract 1 to $MY_TEMP

All instructions should work and extract the content of the tarball to the specified directory. (This will only work if the directory exists at that location, though.)

To extract the audio from a Flash .flv file, do this:

eaud # or extract_audio

You can also extract all files matching a certain criteria, by doing something like this here:

extract all *bz2

You can also extract all archives given in a directory.'

For example:

extract all archives

would extract all .tar.bz2 .zip .gz and so forth...

Please note that there is a configuration option that will allow you to automatically enter such an extracted directory.
This configuration option is called enter_extracted_directory. Set it o true if you want to automatically enter an extracted tarball.

You can use this from the commandline as well, without properly starting the Roebe::Shell.

Example for this functionality:

rda extract all dontstartup

This would extract all archives in the current directory.

Date format used by the Roebe::Shell

If you input a date format such as dd.mm.yyyy then the Roebe::Shell will display which weekday this refers to.

Compiling via the sql-based compiler class

Since as of August 2022 it is possible to make use of the SQL-based compiler class that is part of the rbt gem.

Invocation example from within the roebe-shell:

sqler kinit
sqler kio
sqler make # and so forth

This was added for convenience reasons mostly, so that we have simple support for this on windows as well, when working with vanilla cmd.exe.

class Roebe::UserInput and the Roebe::Shell

class Roebe::UserInput was removed in May 2022. It was only used in the Roebe::Shell. When the latter was rewritten in May 2022, the need for a separate class Roebe::UserInput was no longer given. I originally assumed that other projects may benefit from this class, but I realised that not a single other project ever made use of that code - so, better to get rid of "dead" code instead.

The gtk-shell interface

There is a GUI for the shell, in ruby-gtk3. It is not the prettiest thing in the world, but I wanted to be able to use a GUI for the shell.

The following picture (taken on IceWM) shows how this may look (in August 2022):

This may not be extremely pretty, but for now getting the functionality to work without any bugs is the most important objective. At a later this may be improved upon, visually as well.

Note that the main functionality for this is implemented via a module. That way it also works for libui as-is - and perhaps for a www-interface (via the web, such as sinatra) too, one day.

I have also tested the libui-shell in August 2022 on windows and it works. It is presently not extremely sophisticated, but I think I can enhance it slowly over the coming months. For instance, to evaluate the content of the user input entry continually whenever it has been changed. In the middle of August 2022 a small modification was made: if you input the '#' (comment) character then this will be treated as an instruction to have hit the enter-key. This is a hackish workaround for the fact that we currently can not get key-events in libui, but I think it works ok-ish and is more convenient to use than click on a separate button via the mouse pointer.

class Roebe::Configuration::Configuration

This class used to be a separate project (a standalone gem), but was integrated into the Roebe namespace as of August 2020.

The main class here, called Configuration, is able to act as a hash-like configuration class, similar to open struct. It must be able to properly interpret $ variables as shell-variables on top of it, via the project called ConvertGlobalEnv.

Currently, every key-value pair that exists as part of our Configuration object must be a standalone yaml file.

If such a file can not be found, but a value exists in our hash, the default behaviour is to create this file automatically. This is another difference to OpenStruct: I really wanted to use a configuration scheme based solely on yaml files, so this was one reason why the Configuration namespace was written/added.

We must keep in mind that internal variables and methods defined on the base class Configuration could conflict with user-defined methods, so we have to be very careful when setting values in class Configuration.

Do note that class Configuration depends in principle on at the least one additional gem:

convert_global_env # install like so: gem install convert_global_env

However had, in May 2022 this dependency is no longer mandatory. You could also use the gem called rcfiles instead; it should be a bit faster and it works better on windows, as windows has problems with ENV (or at the least I had problems with cmd.exe in this regard - thus rcfiles also offers a hardcoded solution to this problem. Having hardcoded values is not as elegant, but better to be ugly than to not work at all).

Support for GraalVM

GraalVM is pretty awesome. In 2022 I am experimenting a LOT with it; if you have not tried using GraalVM yet - or may not have had a use case for Java - I recommend to give GraalVM a try.

I am re-writing some ruby classes found in the roebe gem into Java - not all of them, mind you, but some just for testing purposes.

These can then be compiled as static native binary, at the least on linux.

The commandline flags for this feature go like that:

roebe --graalvm1
roebe --graalvm7 # for instance, refers to the file "Schlafe.java"
roebe --graalvm16

This will take a specific .java file in the main directory and then use GraalVM's native-image to compile them. This will only work if you have graalvm installed, as well as native-image (and ideally upx as well).

You can also turn all these .java files into executables (on linux) via:

roebe --allgraal

This will take quite some time, though. On my home system it takes about 30 minutes; the more .java files are added the longer this will take, so this is really only used by me on a new computer installation.

class Roebe::DirectoryContent (deprecated since as of 2021)

This class can display the content of a directory. I needed this class because I had to obtain information about the local filesystem, and then display this on the commandline, via the WWW and via a GUI. So I required a unified interface.

An older project existed, called show_directory, which was separate and underdocumented. So in September 2020, DirectoryContent was created. The goal is to be extremely well-documented.

Requiring this class is simple:

require 'roebe/classes/directory_content/directory_content.rb'

Using it is simple as well:

Roebe::DirectoryContent.new # Without any arguments it will default to the cwd.
Roebe::DirectoryContent.new(ARGV)
Roebe::DirectoryContent.new('/tmp/')

Internally the instance variable @work_on_this_directory will keep track of the directory that is the target for this class.

All findings from a given directory will be stored in a Hash, aptly named @hash.

Since as of June 2021 this is again different. Use the gem called directory_paradise instead. The above documentation has to be changed, but the internal code has not yet - stay tuned, and keep in mind to transition into directory_paradise instead. The code in directory_paradise should be easier to maintain, too.

class Roebe::ExtractDocumentation

class Roebe::ExtractDocumentation can be used to quickly show the comments for a given method in ruby.

Usage example:

require 'roebe/classes/extract_documentation.rb'
_ = Roebe::ExtractDocumentation.new(['file_here.rb', 'method_name_there']); _.report_result
_ = Roebe::ExtractDocumentation.new(['foobar.rb', 'run']); _.report_result

Or via aliases on the commandline:

edoc $RUBY_ROEBE/classes/wikipedia.rb run

Last argument is the name of the method you want to find out its documentation.

class Roebe::ReportHowManyClassesExistForThisDirectory

This class can report how many ruby classes are in a given directory.

Example output:

A total of 391 classes were discovered in the directory /home/x/programming/ruby/src/rbt/

This does not work too terribly well, but if you just want to get a quick overview then this should work somewhat fine.

class Roebe::ModifyShebangHeader

This class can be used to modify the shebang entry of one (or several) .rb files.

On windows the shebang I use is c:/ruby/bin/ruby. When I set a .rb file to use this shebang line then apache-served .cgi scripts work, so it shows that this does indeed work.

To enable the assumption of a windows-shebang like this pass the options --is-on-windows to this class.

Be careful when using this class - it will not keep any backups, so make sure that you backed up your data prior to running this class.

class Roebe::StartProgram

You can use class Roebe::StartProgram to start any program:

require 'roebe/classes/start_program.rb'
Roebe::StartProgram.new
Roebe::StartProgram.new :firefox

This class was created because some programs, such as chrome, require additional commandline arguments. As I was tired to have this spread out into different aliases, I thought it may be better to bundle this into one class.

class Roebe::DoInstall

class Roebe::DoInstall is used to primarily combine:

./configure --prefix=/usr
make
make install

Into one class.

On my home system I aliased this to "doit", so I just cd to a directory and then invoke "doit".

Example:

cd /home/x/Temp/rbt/php-8.2.0
doit

This will compile php for me, for instance, without me having to type the above three separate commands.

This works not only for GNU configure but also for cmake, meson/ninja and python setup.py files.

Additionally since as of December 2022 a few configure options are available, such as --use-configure. What is this configure option doing?

Take the above example again, where php is compiled.

If I do:

doit --use-configure

rather than:

doit

then the default configure options for PHP, stored in the rbt gem, will be used.

The output would then be this:

./configure --prefix=/usr --enable-bcmath --enable-calendar --enable-cli --enable-dba=shared --enable-force-redirect --disable-libzip

So I don't even have to remember any configure options per se. I just pass that flag onto the class via the commandline.

Various shorter aliases exist for --use-configure such as --coptions.

Counting words

You can use bin/word_count to count the number of words in a string/sentence/document on the commandline.

Roebe::JavaRunner

This small ad-hoc class can be used to quickly pass some java-code (as argument), put it into a .java file and then run/compile that file automatically.

I needed this class so that I can quickly test some java code, perhaps even autogenerate more java code in general. Via Roebe::JavaRunner I can quickly compile any java-code, as-is.

GUIs: Graphical User Interfaces and the roebe project

The roebe gem comes with a few GUI bindings. These are mostly just small things, for demo-purposes, but, in part, also to tie together important functionality with a GUI-use case. An example for this statement is the roebe-shell, which has a (poorly implemented) libui-shell representative (which is rather feature incomplete, as of 2023 still).

For reasons of simplicity I consider www-specific code to be a GUI as well, such as any interface through the sinatra gem. These are not traditional GUIs, but "modern" ones. Either way, the goal is for a user to easily interact with the computer - more easily than, say, a terminal and the commandline would be for most regular users.

Traditionally I have been using ruby-gtk for GUI desktop systems, but since as of 2021 I am also using libui. Expect more libui-centric widgets to be added over the coming years.

To keep track which widgets were ported already the following small table may be useful but it may become outdated eventually:

(1) show_ten_aliases.rb          # Just show the next ten exam topics; evidently only useful on my home system really
(2) wlan_interface.rb            # This is about 80% complete; the combo-box is missing so far and the middle-buttons.
(3) interactive_caesar_cipher.rb # This is mostly complete; could need some minor improvements but for now it's fine.
(4) show_aliases                 # This is mostly complete, about 98%. Perhaps a few minor tweaks but for now it's fine.

Since as of September 2021 I am experimenting with the project called simple_widgets. The idea behind this project is to make it possible to use different GUI toolkits and ad-hoc switch between them. As to whether this will be used for the whole code base remains to be seen.

For now the first widget has been ported onto UniversalWidgets. Invoke this from the commandline via:

roebe --caesar-gtk    # for the gtk variant
roebe --caesar-libui  # for the libui variant

You need ruby-gtk3 and ruby-libui for this, so install these first.

We there use the same code base, but can support both ruby-gtk as well as ruby-libui at the same time. \o/

Since as of August 2022 the ruby-gtk2 bindings have been mildly deprecated. They may remain as part of the roebe gem, but it is unlikely that any new ruby-gtk2 code is added. ruby-gtk3 is better than ruby-gtk2 at this point in time.

Since as of January 2023 there also exists a variant for interactive-cypher for jruby. This one makes use of AWT/Swing. It is not pretty, but the advantage is that we can use jruby, which, in turn, works very well on Windows. In other words, I was able to get the following going on windows too recently:

This was actually taken on Linux + IceWM, but before I did so I tested it on my windows computer, and it works. \o/

Yes, it is not pretty, but I was concerned primarily with getting it to work on windows. That now means I can write GUIs for windows too, via jruby + swing. Expect more widgets to be written in jruby + swing eventually. \o/

In February 2023 toplevel methods called:

Roebe.libui1
Roebe.libui2
Roebe.libui3

Were added. This should make it easier to start the libui-widgets without needing to remember their names. Note that Roebe.libui1 will be guaranted to refer to the libui-shell at all times.

Generating aliases from within the Roebe-namespace

For convenience reasons, the following methods and API calls were added in February 2023:

Roebe.generate_aliases(:for_windows)
Roebe.generate_aliases(:windows)
Roebe.generate_aliases_for_windows
Roebe.generate_aliases(:for_linux)

This will generate a file with doskey-aliases on windows, and for linux it'll use the rcfiles project.

The reason why this toplevel method was added was because I sometimes do not have a computer set up properly yet, so I wanted to just work within the Roebe-namespace, as-is.

Support for jruby and Java

I have only fairly recently (December 2021) started to use jruby more seriously, mostly due to windows support and the swing GUI toolkit for java. On Linux I can use gtk just fine; and we have browsers, for cross-GUIs - but I wanted to be able to offer native windows-support. So jruby seemed like an interesting aspect in this regard.

Right now there is not much to show.

The only change I did was to add commandline support for one GUI so far:

roebe --jcipher
roebe --jruby1

It is not complete either; the ruby-gtk3 variant works better. But I consider this more as a proof-of-concept. Who knows, in the future this part may be extended, to have more jruby support.

Since as of July 2022 I am also planning to port some of the roebe classes into Java. Probably not every class will be ported to Java, but I wanted to make at the least some of these classes available in Java as well.

The following table mentions some of the porting efforts so far:

class name in Ruby class name in Java % ported (estimate)
Roebe::TakeScreenshot TakeScreenshot.java 80%
Roebe::ShowPrimeNumbers ShowPrimeNumbers.java 10%
Roebe::Translate Translate.java 80%
Roebe::ToSquashfs ToSquashfs.java 70%
Roebe::Schlafe Schlafe.java 100%

Cross-language support

The roebe project was initially started in ruby. It also contains quite a lot of .yml files - 136 .yml files in April 2023.

I am using python and Java as well, so it made sense to me to re-implement the core functionality across different programming languages, so that I am more flexible here.

Thus, it was decided to re-create some of the classes found under the Roebe namespace (in ruby) in other programming languages as well. The two primary ones will be python and Java, but I may also add support in C, C++ and perhaps kotlin. The future will show.

The following table shall show this progress:

Ruby Python
delete_empty_files [IMPLEMENTED]

class Roebe::FotoSearcher

I wrote class Roebe::FotoSearcher to collect all local fotos (pictures), and then create a .html page.

Naturally you need your own dataset and probably have to make a few changes in class Roebe::FotoSearcher to make it suit your use cases.

The class can be used to pass the name of the people you want to see on the .html page. For instance, say you have Timmy_the_big_boy_fights_in_the_streets_of_New_York.jpg and another image called Tanya_the_naughty_in_a_park_in_Amsterdam.jpg.

I then invoke the class via my alias foto_seeker, and pass the names into it:

foto_seeker Timmy Tanya
foto_seeker timmy tanya # downcased is fine too

Then a new .html file will be created. This only works if you have the same-named images locally; and you may have to modify the hardcoded path. (It is trivial to extend the class to allow for more dynamic paths, but for my own use cases it already works very well.)

Since as of August 2023 it is also possible to pass in pseudo-symbols, such as :alle_katzen, into this class, from the commandline.

For instance I do the following on the commandline:

foto_gatherer :alle_katzen

alle_katzen is german for all_cats. What this does is it fetches all local images (pictures) of cats that I or anyone else took (and stored locally). Then a new standalone .html page is autogenerated from this.

This depends on a hardcoded array, which is catered to my use case. You may have to adjust it to your own use case if you need the same functionality (and, of course, have such images too; note that :all_cats is an alias to this, so it can be used as well for those who prefer english).

The www-stack and bundled documentation pertaining to this www-stack

In November 2020 I decided to slowly put all my local knowledge base in regards about linux into the roebe-project.

This may not be very useful for other people, as most of that documentation is written in german; but some linux commands may still be useful to know.

The primary reason why this is done is, though, because I sometimes needed this information on another computer system, in order to fix a given problem - in particular when ruby is not YET available on that computer. When ruby is available then I can use ruby to (auto)solve many problems.

There are secondary reasons as to why I decided to include the documentation there, though. One of that secondary reason is that some of that documentation is almost 20 years old by now, so this gives me an opportunity to improve and polish on the information content. In some ways this is a bit like a "wiki", just that I am the only one editing that "wiki" right now. :P

Let's see what happens with this approach in the future.

Note that, unfortunately, the images I use here for the www-stack are NOT included in this gem. There are two reasons for this:

a) the smaller one is that a few of these images may be copyrighted, so I avoid any possible problems by simply not bundling them.

b) the much bigger issue, though, is convenience, or lack of convenience. If all images would be bundled, the size of the gem would be above 50 MB, which is just way too much. If you need images, well, think about it appropriately - for example, a page about statistics may include some images that show statistical data being visually represented. Just google for this and you find adequate images for that; you could then just use these and nobody would notice a huge difference really.

From 2021 to 2023 I decided to put ALL my local knowledge base into the roebe project, if it can be viewed on the www.

class Roebe::ReplaceSpaceWithUnderscore

class Roebe::ReplaceSpaceWithUnderscore class can replace a ' ' character with a '_' underscore character, in a filename. The filename will be changed too.

So, for example, if your local, existing file is called "foo bar.md", then this class will rename this file into a file called "foo_bar.md".

In other words, ' ' characters are effectively eliminated (or, rather replaced via '_', as stated).

Note that the class actually can replace any character and it can also rename incorrectly formed german umlauts in a given filename, so the name of the class is a slight misnomer these days. However had, I have been used to this name, so for the time being the name of the class will stay how it is. (If it helps you can think of the class as a "generic-replacer" too. The default token can also be changed by the user through the commandline.)

The reason why this class was originally written was because some applications struggle with filenames that include a space character. I noticed this when using bash. An alternative is to use "" quotes to pad the filename, but I found that simply removing all annoying characters is much, much, much simpler in the long run - hence why this class was created, and then aliased onto "ething" on my system. ("ething" is "everything" and "everything" was an alias to call that class with a certain parameter via the commandline.)

Since as of September 2023 you can also work only on directories with a ' ' character in the name, and skip working on an files. This can be done through the aptly-named commandline flag --only-directories.

class Roebe::Autodater

This class can change the timestamp of files, based on their own filename.

So, if you have the following filename:

22.02.1989_cat_hits_dog.jpg

Then this class will change the timestamp of that file towards the 22nd of february, 1989.

The class has not been thorougly tested yet though; I only used it to quickly change some local fotos of old places, as I wanted to sort these files not only by filename but also by timestamp, in the event that I may want to change the filename lateron.

Unicode support in the roebe project and Unicode emojis

The roebe project used to contain Unicode "symbols" as well as emojis.

Such unicode-symbols can be printed, if they were registered in the roebe project. One way to do so was via an executable, available at bin/print_this_unicode_symbol.

The old usage example for this, via the commandline, would go as follows:

print_this_unicode_symbol snowman
print_this_unicode_symbol checkmark

This also works via HTML colours.

Example:

print_this_unicode_symbol snowman --slateblue
print_this_unicode_symbol black_knight --orange
print_this_unicode_symbol white_knight*33 --tomato

In January 2024 this was slightly changed, in that Unicode symbols were moved into a separate project, called EmojiParadise. That name is a slight misnomer, as that gem also handles Emojis, but I retained that name because I liked the name.

Some programs, such as ibus, actually require emojis. Since I was tired of manually downloading this, I added this method:

Roebe.download_emojis

You can invoke it from the commandline as well, via:

roebe --download-emoji

Note that this will download into the current working directory, so you may have to navigate to the proper directory prior to invoking this method; or move the .txt files to an appropriate location, such as /usr/share/unicode/emoji.

As of January 2024, the unicode-specific code in the roebe gem now resides in the emoji_paradise gem - so if you want the invocation examples shown above to work, you first have to install the emoji_paradise gem, via:

gem install emoji_paradise

Roebe.actions()

Roebe.actions() was added in March 2024. The idea is that for every important (major) activity, related to the roebe gem, we bundle this through the method Roebe.actions().

This thus constitutes a generic entry point, which in turn can then be used towards other entry points of other gems, without needing to require any specific .rb file or know the class-names of such files, as-is. We thus gain a lot more flexibility that way.

This subsection contains some links that may possibly be useful to you when you are starting to learn ruby, or try to improve some of your own ruby programming skills. I will try to keep this list maintained, but over time the entries may become outdated, so be warned that this is not regularly updated. I will also only try to add content that is somewhat useful - that is, has a minimum level of quality.

matz's blog in japanese (you can use e. g. google translate to read the translated content in english)

https://matz.rubyist.net/

The official Ruby documentation:

https://ruby-doc.org/3.2.2/

Ruby-Talk: the ruby mailing list:

https://rubytalk.org/

Learn to Program, by Chris Pine - an excellent introduction to the Ruby programming language:

https://pine.fm/LearnToProgram/

Ruby Practice Challenges:

https://www.codewars.com/kata/ruby

Chris Neukirchen - the creator of rack and a really great rubyist:

https://leahneukirchen.org/blog/

zenspider's website, as well as the quickref:

https://www.zenspider.com/ https://www.zenspider.com/ruby/quickref.html

Ruby in 20 Minutes - a small tutorial about Ruby:

https://www.ruby-lang.org/en/documentation/quickstart/

The Snack Sound Toolkit for Ruby (2002):

https://rbsnack.sourceforge.net/intro.html

Different Ruby projects by caliban:

https://caliban.org/ruby/

Learning Ruby by Daniel Carrera (2003):

https://edoras.sdsu.edu/doc/ruby/

Contact information and mandatory 2FA (no longer) coming up in 2022 / 2023

If your creative mind has ideas and specific suggestions to make this gem more useful in general, feel free to drop me an email at any time, via:

shevy@inbox.lt

Before that email I used an email account at Google gmail, but in 2021 I decided to slowly abandon gmail, for various reasons. In order to limit the explanation here, allow me to just briefly state that I do not feel as if I want to promote any Google service anymore when the user becomes the end product (such as via data collection by upstream services, including other proxy-services). My feeling is that this is a hugely flawed business model to begin with, and I no longer wish to support this in any way, even if only indirectly so, such as by using services of companies that try to promote this flawed model.

In regards to responding to emails: please keep in mind that responding may take some time, depending on the amount of work I may have at that moment. So it is not that emails are ignored; it is more that I have not (yet) found the time to read and reply. This means there may be a delay of days, weeks and in some instances also months. There is, unfortunately, not much I can do when I need to prioritise my time investment, but I try to consider all feedback as an opportunity to improve my projects nonetheless.

In 2022 rubygems.org decided to make 2FA mandatory for every gem owner eventually:

see https://blog.rubygems.org/2022/06/13/making-packages-more-secure.html

However had, that has been reverted again, so I decided to shorten this paragraph. Mandatory 2FA may exclude users who do not have a smartphone device or other means to 'identify'. I do not feel it is a fair assumption by others to be made that non-identified people may not contribute code, which is why I reject it. Mandatory 2FA would mean an end to all my projects on rubygems.org, so let's hope it will never happen. (Keep in mind that I refer to mandatory 2FA; I have no qualms for people who use 2FA on their own, but this carrot-and-stick strategy by those who control the rubygems infrastructure is a very bad one to pursue.