Skip to content
Avindra Goolcharan edited this page Jan 28, 2021 · 2 revisions

⚠️ The following docs are archival and do not apply to the existing dirp program ⚠️

Previously, the core code was implemented in Bash. The notes on the Bash implementation can be found below.


dir, in its original form, was enormously simple and easy to write due to Bash 4's built-in support for map. However, MacOS's Bash is permanently stuck on 3 due to software licensing incompatibilities. Furthermore, implementing dirp in any particular shell language necessitates having the host shell packaged on the system.

At some point, it became clear that the Bash maps prevented using the features consistently from other shells like Fish. Thus, the Config file as it exists today was born, so that multiple shells could reference the same data.

Lazy man's Bash configuration

💀 Note this is not supported anymore after moving to the new config file format. Use the new format, which enables usage of dir in Fish and Bash.

The global data structure called folders in (~/.config/dir/list) was an associative array (i.e., hash/map). This is a convenient way to get a HashMap/Dictionary entity inside of a shell script, as the array was simply defined as-is via the source command.

A sample with intended usage can be found below:

#!/bin/bash

declare -A folders
folders=( \
  #["Downloads"]="/mnt/tr200/Downloads" \
  ["PXE Server"]="/mnt/tr200/ISOS" \
  ["Videos"]="/mnt/space/Videos" \
  ["Games"]="/mnt/space/Games" \
  ["shared memory (/dev/shm)"]="/dev/shm" \
)
Clone this wiki locally