2023 Feb 18
More
git diff
! The git documentation is honestly so good I should stop googling and look there first.git diff - working directory vs. staged
git diff —cached - staged vs HEAD
git diff HEAD - working directory vs HEAD
git diff <commit_hash>..<commit_hash>- …
git diff –merge-base
- compares current branch (committed files..?) to where they split from each other
Now that I’ve been playing around with NeoVim some more, I’m really enjoying just exploring the kickstart.nvim file and discovering all these different things I can do and configure. Also my eyes are getting adjusted to using C-d C-u and it’s been quite helpful. ChatGPT’ing “turn this command into lua for NeoVim config” is very helpful.
NeoVim stuff:
'
is the previous jump “register”. You can manually add to the jump list usingm'
. You can save a jump position withm<letter>
, then go back to that position with'<letter>
. Doesn’t work across files tho :(Add
:vert
to any command that opens a window to make it open via vertical split instead of horizontal.Learned I can configure the telescope layout, as well as open many different things with telescope through it’s different “pickers” i.e. I can map some keys to do
require('telescope.builtin').lsp_implementations
to open implementations of a type with telescope.Also learned there’s a thing called “folds” which I’m not going to look into any further but it lets you hide code temporarily and it’s built into vim.
s
deletes the current letter and goes into insert mode. Knew this had to exist.
Pretty interesting how lazy evaluation can change how you write code. I had the snippet here:
self.keys[start..end].iter().next().and_then(|key| self.map.get_key_value(key))
Which was telling me this was bad because the closure may outlive the current function and yet the closure is borrowing
self
and because the function’s only got a reference toself
it can’t move it out of the function yada yada yada. Sometimes I just want to get to working code and so I take the compiler’s suggestions but sometimes that leads me going back and forth between solutions because the compiler is really smart but not that smart. Then I was thinking…why is the closure going to outlive this function? Which led me to discover that.and_then
is lazily evaluated, and it actually moves the closure out to wherever it needs to be evaluated, which gives me all these errors. I changed my code to:match self.keys[start..end].iter().next() { Some(key) => self.map.get_key_value(key), None => None }
And it worked great because it was now evaluating it before moving the values out. It seems like there should be an
.and_then
function that would let me do exactly what I want, or maybe the compiler should know to maybe not lazily load or something (that probably doesn’t make any sense but you get the idea). But this is how it is.Sometimes these days I catch myself being ever so subconsciously motivated by vanity metrics like my github activity chart or the quantity of my writing or even the feeling of learning by being exposed to different ideas but not really learning (like reading about something but not writing it in my own words or using what I learned in some way). Can’t let this get in the way of what’s really important! Actually learning is often slow and takes a lot of doing. Need to keep focusing on this.
history
is a command that shows your recent commands. Combine withgrep
to find a previous commands you may have forgotten!I want to get super good at using the command line and tools that are built into unix operating systems. How do I do this?