Git for the color blind and other tips

Here are several tips that have helped me, someone who uses Windows most of the time and Linux some of the time, finds color coded output a visual nightmare and prefers simplicity.

Ignore File-mode Changes on Windows

Git thinks executable files have changed when going between ‘nix and Windows systems, when it’s only that the file mode is being interpreted differently. On a Windows system, set your global config (~/.gitconfig) to ignore file mode changes. You may also need to check the local (repository) configuration.

Check your global and local configs:

$ git config --global core.filemode
$ cd gitrepo
$ git config core.filemode

Set configuration to ignore file mode changes (as needed):

$ git config --global core.filemode false
$ cd gitrepo
$ git config core.filemode false

Disable Color-coded Git Output

Many developers couldn’t live without color-coded command-line output, but you may find (as I do) that less than perfect color vision combined with high ambient lighting and some screen glare results in a display that is largely incompressible.

To disable color-coded output in a particular repository::

$ git config color.ui false
$ git config color.diff false
$ git config color.status false
$ git config color.branch false
$ git config color.interactive false

To globally disable color coding, add the –global option (but be aware you may also need to configure the global ~/.config file) .

Use .gitignore

Applications can dynamically generate files, such as compiled templates, that you don’t want Git to do anything with. Achievo writes files to achievotmp/, which can be added to the project’s .gitignore file (which may already be done if you are cloning the canonical project repository in GitHub).

achievotmp/

Also, your development environment, especially is you are using an IDE (Integrated Development Environment) such as PhpStorm or NetBeans, may create its own project directory that you also want Git to ignore. Because this is developer-specific, add an entry to your global ~/.gitignore file for Git to ignore them.

.idea/

Further Reading

Yes, open source software still has a license…

Someone recently posted to a popular electronics consultant forum:

Great thing about using opensource tools is that there is no problem with licenses, because there are none.

What they were trying to say (and acknowledged afterwards) was that open source software doesn’t require purchasing a license. Open source software still has a license – either a permissive license such as the BSD or MIT license, or a copyleft license such as the GNU GPL.

I’m not making the point to single anyone out or to intentionally be pedantic, it’s a common simplification but overlooks the importance of the license. Without the license it’s unlikely any significant open source software would exist, and clearly we appreciate the existence of open source software.

The open source license limits the liability of the developer (who would willingly be liable for damages if their code didn’t work correctly in a situation that was never anticipated or intended?), and copyleft licenses further prevent creation of closed-source variants, which is a philosophical must for many open source developers.

Open source software has been with us now for over 40 years, the BSD license was first used in 1980, the GNU GPL was first used in 1989 and the Linux kernel was released using the GNU GPL in 1992. At least for me, it’s hard to imagine where software development would be today if we hadn’t have been able to stand on the shoulders of the giants who came before us.

Install PyCharm Community on Linux Mint 21.3

The Linux Mint Software Manager includes the popular Python IDE PyCharm Community, but it’s a Flathub Flatpak and cannot access Python modules installed by Software Manager as System Packages.

For example, after using Software Manager to install Python3 and Python3-tk (System Packages) and PyCharm Community (Flathub Flatpak), try running a simple “Hello, world!” script in PyCharm that opens a Tkinter window:

import tkinter as tk

root = tk.Tk()

w = tk.Label(root, text="Hello, world!")
w.pack()

root.mainloop()

Instead of a Tkinter window appearing, PyCharm shows the error:

ModuleNotFoundError: No module named 'tkinter'

The error is because the execution environment of the PyCharm Flatpak is separate from the main system, where the tkinter module has been installed.

I’m sure there are other solutions and workarounds, but the simplest solution for me was switching to the official tarball release from JetBrains. PyCharm from the JetBrains release will execute in the main system and have access to all the modules installed there.

Download the release .tar.gz archive for Linux from JetBrains (https://www.jetbrains.com/pycharm/download/?section=linux). After it has downloaded, navigate to your ~/Downloads directory using the GUI file manager (Nemo) and double-click the archive to open it in Archive Manager. Drag the “pycharm-community-yyyy-x.y” folder from Archive Manager to a convenient location where PyCharm will be executed from (I put the folder in my home directory, aka ~ aka /home/username/).

As described in the Install-Linux-tar.txt file in the archive, PyCharm is executed using the bin/pycharm.sh shell script. The first time PyCharm is executed it will create configuration files stored in ~/.config/JetBrains/… (the Install-Linux-tar.txt file has more details).

For convenience, I added the path to pycharm.sh to my bash shell path so I can execute PyCharm from a terminal session without having to remember the full path. To do this, I added the following line to the end of ~/.bashrc:

export PATH="$HOME/bin:$HOME/pycharm-community-2023.3.3/bin:$PATH"

I also added a menu entry for PyCharm to the Programming folder in the Linux Mint menu for convenient desktop access.

To do this, right-click on the Linux Mint menu button and select Configure, then Menu, Open the menu editor, Programming folder and finally New Item. Click the Browse button and browse to pycharm.sh to create the command line, enter a Name (and if you wish a comment), click the icon box and search for a PyCharm logo, leave the “Launch in terminal” box unchecked, and finally click OK to close the menu editor. For more detailed instructions, search the web for adding a launcher to the Linux Mint menu.

Now PyCharm has no trouble opening a Tkinter window.