turns out I want .obisidian/ after all
This commit is contained in:
parent
aaaa53ec8a
commit
05fc570b1e
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +0,0 @@
|
||||
.obsidian
|
10
.obsidian/app.json
vendored
Normal file
10
.obsidian/app.json
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"vimMode": true,
|
||||
"promptDelete": false,
|
||||
"pdfExportSettings": {
|
||||
"pageSize": "Letter",
|
||||
"landscape": false,
|
||||
"margin": "0",
|
||||
"downscalePercent": 100
|
||||
}
|
||||
}
|
4
.obsidian/appearance.json
vendored
Normal file
4
.obsidian/appearance.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"baseFontSize": 10,
|
||||
"accentColor": ""
|
||||
}
|
15
.obsidian/core-plugins.json
vendored
Normal file
15
.obsidian/core-plugins.json
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
[
|
||||
"file-explorer",
|
||||
"global-search",
|
||||
"switcher",
|
||||
"graph",
|
||||
"backlink",
|
||||
"tag-pane",
|
||||
"page-preview",
|
||||
"note-composer",
|
||||
"command-palette",
|
||||
"editor-status",
|
||||
"markdown-importer",
|
||||
"word-count",
|
||||
"file-recovery"
|
||||
]
|
22
.obsidian/graph.json
vendored
Normal file
22
.obsidian/graph.json
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"collapse-filter": false,
|
||||
"search": "",
|
||||
"showTags": true,
|
||||
"showAttachments": false,
|
||||
"hideUnresolved": false,
|
||||
"showOrphans": true,
|
||||
"collapse-color-groups": true,
|
||||
"colorGroups": [],
|
||||
"collapse-display": true,
|
||||
"showArrow": false,
|
||||
"textFadeMultiplier": 0,
|
||||
"nodeSizeMultiplier": 1,
|
||||
"lineSizeMultiplier": 1,
|
||||
"collapse-forces": false,
|
||||
"centerStrength": 0.518713248970312,
|
||||
"repelStrength": 10,
|
||||
"linkStrength": 1,
|
||||
"linkDistance": 250,
|
||||
"scale": 0.48669242494486276,
|
||||
"close": false
|
||||
}
|
1
.obsidian/hotkeys.json
vendored
Normal file
1
.obsidian/hotkeys.json
vendored
Normal file
@ -0,0 +1 @@
|
||||
{}
|
114
.obsidian/workspace
vendored
Normal file
114
.obsidian/workspace
vendored
Normal file
@ -0,0 +1,114 @@
|
||||
{
|
||||
"main": {
|
||||
"id": "66f4b1ddd493c3b6",
|
||||
"type": "split",
|
||||
"children": [
|
||||
{
|
||||
"id": "89414a5dc7f8e3db",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "markdown",
|
||||
"state": {
|
||||
"file": "Fixing a non booting linux install.md",
|
||||
"mode": "source",
|
||||
"source": false
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"direction": "vertical"
|
||||
},
|
||||
"left": {
|
||||
"id": "f3c19b035169a5bc",
|
||||
"type": "split",
|
||||
"children": [
|
||||
{
|
||||
"id": "0f7ecc25e4b2fce4",
|
||||
"type": "tabs",
|
||||
"children": [
|
||||
{
|
||||
"id": "19b91ab6f5b5c1c3",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "file-explorer",
|
||||
"state": {}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "6d63db4e1d9b6e93",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "search",
|
||||
"state": {
|
||||
"query": "",
|
||||
"matchingCase": false,
|
||||
"explainSearch": false,
|
||||
"collapseAll": false,
|
||||
"extraContext": false,
|
||||
"sortOrder": "alphabetical"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"direction": "horizontal",
|
||||
"width": 100
|
||||
},
|
||||
"right": {
|
||||
"id": "0608333cb897247b",
|
||||
"type": "split",
|
||||
"children": [
|
||||
{
|
||||
"id": "4c76cb9ac0e6e5bb",
|
||||
"type": "tabs",
|
||||
"children": [
|
||||
{
|
||||
"id": "4d77de4c3ab4a54e",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "backlink",
|
||||
"state": {
|
||||
"file": "Fixing a non booting linux install.md",
|
||||
"collapseAll": false,
|
||||
"extraContext": false,
|
||||
"sortOrder": "alphabetical",
|
||||
"showSearch": false,
|
||||
"searchQuery": "",
|
||||
"backlinkCollapsed": false,
|
||||
"unlinkedCollapsed": false
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "bc19f0281f611b4a",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "tag",
|
||||
"state": {
|
||||
"sortOrder": "frequency",
|
||||
"useHierarchy": true
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"direction": "horizontal",
|
||||
"width": 300,
|
||||
"collapsed": true
|
||||
},
|
||||
"active": "89414a5dc7f8e3db",
|
||||
"lastOpenFiles": [
|
||||
"Setting up SSH keys.md",
|
||||
"Enabling fingerprint authentication on Zephyrus G15.md",
|
||||
"Installing Arch.md",
|
||||
"Fixing supergfxctl black screen on dedicated mode.md",
|
||||
"WiFi not working after pacman -Syu.md",
|
||||
"wlan0 disabled after restart or wake from hibernate.md",
|
||||
"unable to connect to wpa-enterprise via iwd.md",
|
||||
"The basics of Git.md",
|
||||
"Ohm's Law.md",
|
||||
"Argumentative Essay - Griffin.md"
|
||||
]
|
||||
}
|
150
.obsidian/workspace.json
vendored
Normal file
150
.obsidian/workspace.json
vendored
Normal file
@ -0,0 +1,150 @@
|
||||
{
|
||||
"main": {
|
||||
"id": "66f4b1ddd493c3b6",
|
||||
"type": "split",
|
||||
"children": [
|
||||
{
|
||||
"id": "58c4a23aeeb7e477",
|
||||
"type": "tabs",
|
||||
"children": [
|
||||
{
|
||||
"id": "89414a5dc7f8e3db",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "markdown",
|
||||
"state": {
|
||||
"file": "Fixing a non booting linux install.md",
|
||||
"mode": "source",
|
||||
"source": false
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "323a3c0418ab0e3c",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "markdown",
|
||||
"state": {
|
||||
"file": "Understanding how to handle paths for Ash.md",
|
||||
"mode": "source",
|
||||
"source": false
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "8273f02b7c4eb75b",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "markdown",
|
||||
"state": {
|
||||
"file": "Writing a completely functional shell in Rust.md",
|
||||
"mode": "source",
|
||||
"source": false
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"currentTab": 2
|
||||
}
|
||||
],
|
||||
"direction": "vertical"
|
||||
},
|
||||
"left": {
|
||||
"id": "f3c19b035169a5bc",
|
||||
"type": "split",
|
||||
"children": [
|
||||
{
|
||||
"id": "0f7ecc25e4b2fce4",
|
||||
"type": "tabs",
|
||||
"children": [
|
||||
{
|
||||
"id": "19b91ab6f5b5c1c3",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "file-explorer",
|
||||
"state": {
|
||||
"sortOrder": "alphabetical"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "6d63db4e1d9b6e93",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "search",
|
||||
"state": {
|
||||
"query": "",
|
||||
"matchingCase": false,
|
||||
"explainSearch": false,
|
||||
"collapseAll": false,
|
||||
"extraContext": false,
|
||||
"sortOrder": "alphabetical"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"direction": "horizontal",
|
||||
"width": 100
|
||||
},
|
||||
"right": {
|
||||
"id": "0608333cb897247b",
|
||||
"type": "split",
|
||||
"children": [
|
||||
{
|
||||
"id": "4c76cb9ac0e6e5bb",
|
||||
"type": "tabs",
|
||||
"children": [
|
||||
{
|
||||
"id": "4d77de4c3ab4a54e",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "backlink",
|
||||
"state": {
|
||||
"file": "Writing a completely functional shell in Rust.md",
|
||||
"collapseAll": false,
|
||||
"extraContext": false,
|
||||
"sortOrder": "alphabetical",
|
||||
"showSearch": false,
|
||||
"searchQuery": "",
|
||||
"backlinkCollapsed": false,
|
||||
"unlinkedCollapsed": false
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "bc19f0281f611b4a",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "tag",
|
||||
"state": {
|
||||
"sortOrder": "frequency",
|
||||
"useHierarchy": true
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"direction": "horizontal",
|
||||
"width": 300,
|
||||
"collapsed": true
|
||||
},
|
||||
"ribbon": {
|
||||
"mostRecentAction": ""
|
||||
},
|
||||
"active": "8273f02b7c4eb75b",
|
||||
"lastOpenFiles": [
|
||||
"Understanding how to handle paths for Ash.md",
|
||||
"wlan0 disabled after restart or wake from hibernate.md",
|
||||
"Writing a completely functional shell in Rust.md",
|
||||
"unable to connect to wpa-enterprise via iwd.md",
|
||||
"The basics of Git.md",
|
||||
"Fixing a non booting linux install.md",
|
||||
"Setting up SSH keys.md",
|
||||
"Enabling fingerprint authentication on Zephyrus G15.md",
|
||||
"Installing Arch.md",
|
||||
"Fixing supergfxctl black screen on dedicated mode.md"
|
||||
]
|
||||
}
|
13
Understanding how to handle paths for Ash.md
Normal file
13
Understanding how to handle paths for Ash.md
Normal file
@ -0,0 +1,13 @@
|
||||
#notes #programming #rust
|
||||
|
||||
|
||||
Absolute paths function as intended
|
||||
`cd .` takes you to the bianary location
|
||||
#### Relative Paths
|
||||
- Paths that are relative can be appended to the current dir
|
||||
- `..` should strip the directory before it from the path
|
||||
- `.` can be entirely removed from the absolute path and the endpoint will not be changed
|
||||
|
||||
|
||||
### The Solution:
|
||||
As it turns out, both Windows and Unix have prebuilt functions that handle cleaning up paths, that are implemented under `std::fs::canonicalize` https://doc.rust-lang.org/std/fs/fn.canonicalize.html
|
28
Writing a completely functional shell in Rust.md
Normal file
28
Writing a completely functional shell in Rust.md
Normal file
@ -0,0 +1,28 @@
|
||||
I set out on project Ash for a a variety of small reasons:
|
||||
- I wanted to better learn how a shell interacts with an operating system, how it calls different commands
|
||||
- I wanted to get better at writing scaleable code
|
||||
|
||||
## The Beginnings
|
||||
I happened upon [this](https://brennan.io/2015/01/16/write-a-shell-in-c/) article about writing a shell in C, and was fascinated by the way it was written. It was fascinated by the extremely approchable way the article was written, with function calls defined first, and the actual contents of the function filled out later. Then it could be explained what each function does and why it's there, without relying too heavily on language specific semantics. This made it a great stepping stone, even though it's intended for the C programming language.
|
||||
|
||||
I started by writing a very basic framework to obtain user input as a string. As of right now, it's not an entire I/O lock, and so features like tab autocomplete or capturing Ctrl + C to stop the program from being exited are not currently functional. It functions as a loop that:
|
||||
- Captures user input
|
||||
- Seperates the user input into a list by spaces(this should probably changed later to account for features like `|, >, ;, &&`, which don't necessarily need a space)
|
||||
- It then checks the first argument to see if it's a builtin shell command(`cd`, `help`, `exit`)
|
||||
|
||||
I found it interesting that `cd` is not an operating system utility, it's a shell utility, and when `cd` is run, it tells the next commands run what directory they were run from. In Rust this is implemented as [current_dir()](https://doc.rust-lang.org/std/process/struct.Command.html) for the Command struct. Initially I actually had a lot of trouble with relative and absolute paths. You can create a functional path by simply appending the relative path to the current absolute path, seperated by `/` (or `\` for Windows). While this is technically functional, it's really not elegant at all. I was ending up with valid file paths like `//./home/../home/./../etc/.`, and felt there must be a better solution. I didn't bother checking to see if Rust had a valid method for it, because I didn't know how to put "cleaning up a file pathpath" into a clean, google-able statement, and I felt I could better understand the process behind parsing it if I implemented it myself. I sat down, absolutely stumped, Obsidian open, writing out various logical rules to clean paths up. I ended up with a few simple precepts that *seemed* mostly functional, but ended up missing edge cases, or having flat out unexplained behavior. The nonfunctional rules are below:
|
||||
- Paths that are relative can be appended to the current dir, then
|
||||
- `..` should strip the non-`..` directory before it from the path
|
||||
- `.` can be entirely removed from the absolute path and the endpoint will not be changed
|
||||
|
||||
This logic was flawed enough that exasperated and tired, I googled it, hoping that someone had made a crate that cleaned it up, or maybe there was some regex I could use. As it turns out, both Windows and Unix have prebuilt functions that handle cleaning up paths, that are implemented under `std::fs::canonicalize` ([docs](https://doc.rust-lang.org/std/fs/fn.canonicalize.html)).
|
||||
|
||||
- If no builtin commands are found, it passes it over to system exec handler. In C, processes must be started by forking the current process to a new thread, creating an exact copy with the `fork()` system call. You then instruct the new thread to replace itself with another process with the `exec()` call. Rust however, has a method that spawns new programs with `std::process::Command`. The first argument in the string is passed as the process to start, and each of the new arguments is passed to the process as an array of arguments with `.args()`, eg: `ls /bin` would start a new `ls` process, and pass `/bin` as an argument.
|
||||
|
||||
### The Future
|
||||
I would like to improve on this project and make it good enough that it's daily driveable. Plans for new features include:
|
||||
- Switching to a complete IO lock, this allows new features like:
|
||||
- Tab autocomplete
|
||||
- Capturing interrrupts
|
||||
- A fully featured configuration file that allows changing prompts and behaviors
|
||||
- Implementing the rest of the functionality that I use regularly, including redirects, pipes, and `;` or `&&`
|
Loading…
Reference in New Issue
Block a user