Skip to content

Commit

Permalink
final edits
Browse files Browse the repository at this point in the history
  • Loading branch information
dtauer committed Dec 5, 2024
1 parent 83f1005 commit 9ce0e77
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 60 deletions.
40 changes: 24 additions & 16 deletions lessons/02-your-env/B-ansible.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,27 @@ realize that you are just working on a "server."
<br>
<br>

## NOTE: feel free to just watch

<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>


## Install ansible
as all adventures start...

Expand Down Expand Up @@ -415,22 +436,9 @@ Your code should look something like this
## OH NO! Crash!
If you are using apt and have to use sudo you should see the following error.
```
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: theprimeagen
<127.0.0.1> EXEC /bin/sh -c 'echo ~theprimeagen && sleep 0'
<127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/theprimeagen/.ansible/tmp `"&& mkdir "` echo /home/theprimeagen/.ansible/tmp/ansible-tmp-1729644436.258113-1776352-80352927742333 `" && echo ansible-tmp-1729644436.258113-1776352-80352927742333="` echo /home/theprimeagen/.ansible/tmp/ansible-tmp-1729644436.258113-1776352-80352927742333 `" ) && sleep 0'
Using module file /usr/lib/python3/dist-packages/ansible/modules/apt.py
<127.0.0.1> PUT /home/theprimeagen/.ansible/tmp/ansible-local-1776140pp0cn_gm/tmp33hhis1k TO /home/theprimeagen/.ansible/tmp/ansible-tmp-1729644436.258113-1776352-80352927742333/AnsiballZ_apt.py
<127.0.0.1> EXEC /bin/sh -c 'chmod u+x /home/theprimeagen/.ansible/tmp/ansible-tmp-1729644436.258113-1776352-80352927742333/ /home/theprimeagen/.ansible/tmp/ansible-tmp-1729644436.258113-1776352-80352927742333/AnsiballZ_apt.py && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'sudo -H -S -n -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-rgqphadrxzwvmzhucbtnjvxefbemoqpt ; /usr/bin/python3 /home/theprimeagen/.ansible/tmp/ansible-tmp-1729644436.258113-1776352-80352927742333/AnsiballZ_apt.py'"'"' && sleep 0'
<127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/theprimeagen/.ansible/tmp/ansible-tmp-1729644436.258113-1776352-80352927742333/ > /dev/null 2>&1 && sleep 0'
fatal: [localhost]: FAILED! => {
"changed": false,
"module_stderr": "sudo: a password is required\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}
```bash
TASK [Install neovim's deps] *********************************************************
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "sudo: a password is required\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
```
Well ansible does have the ability to become the sudo but it needs the creds to
Expand Down
3 changes: 3 additions & 0 deletions lessons/02-your-env/D-neovim.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ With ansible we:

Lets build the same thing, but in the bash script now!

```
gituah: [email protected]:neovim/neovim.git <br>
deps: cmake gettext lua5.1 liblua5.1-0-dev
make: make CMAKE_BUILD_TYPE=RelWithDebInfo
```

<br>
<br>
Expand Down
7 changes: 4 additions & 3 deletions lessons/02-your-env/E-wait.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,11 @@ what about one off scripts?
## Expected Code
```bash
copy_file() {
file=$1
from=$1
to=$2
execute rm $to/$file
execute cp $file $to
name=$(basename $from)
execute rm $from
execute cp $from $to/$name
}

copy_file .specialrc ~/
Expand Down
116 changes: 78 additions & 38 deletions lessons/03-navigation/B-tmux.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ centered around navigation.
1. navigate to any session by directory with fuzzy find
1. run scripts or whatever programs i want when navigating to a directory

** TO GIMP **

<br>
<br>
<br>
Expand Down Expand Up @@ -109,6 +107,11 @@ unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix

# vi key movement for copy/pasta mode
set-window-option -g mode-keys vi
bind -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'

# <WHERE YOUR TMUX CONF GOES> = XDG_CONFIG_HOME/tmux/tmux.conf
# <WHERE YOUR TMUX CONF GOES> = ~/.tmux.conf
bind r source-file <WHERE YOUR TMUX CONF GOES> \; display-message "tmux.conf reloaded"
Expand Down Expand Up @@ -139,7 +142,10 @@ We can even use our fancy new dev-env script to install it!
Lets go through some basic commands about tmux so you can see how they work
with just usage. I will show you the ones I use and some that I don't use

* what is prefix key
ource /home/theprimeagen/.tmux-sessionizer
what is prefix key

### just using <prefix>-* commands
* creating window
* detaching
* attaching
Expand Down Expand Up @@ -309,17 +315,40 @@ From my original points, we still have 4 points left to address to create the
"perfect" navigation system for the terminal

### What I Want
1. DONE :: sessions that last even when i close my terminal
1. ~~sessions that last even when i close my terminal~~
1. multiple running sessions, and these sessions are based on directory
1. DONE :: "tabs" within a session
1. ~~"tabs" within a session~~
1. navigate to any session by directory name "instantly"
1. navigate to any session by directory with fuzzy find
1. run scripts or whatever programs i want when navigating to a directory

<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>

## Lets Address Point 6 First
This is one of the easier points to address
This is one of the easier points to address (a bit weird)

```
6. run scripts or whatever programs i want when navigating to a directory
```

* opens and creates the configuration you want for a project
** gimp **

<br>
<br>
Expand All @@ -339,6 +368,7 @@ This is one of the easier points to address
<br>
<br>


## Opener script

```bash
Expand All @@ -349,6 +379,7 @@ if [[ -x ./.ready-tmux ]]; then
elif [[ -x ~/.ready-tmux ]]; then
~/.ready-tmux
fi
clear
```

<br>
Expand Down Expand Up @@ -395,7 +426,8 @@ with a simple script (don't worry, it'll get a lot better)
We have checked off another component of what I consider a great terminal
experience

> 6. run scripts or whatever programs i want when navigating to a directory
<br>
<br>

But we still have a few left

Expand Down Expand Up @@ -540,6 +572,7 @@ some sort of subset.
### CODE TIME!!
Lets start this MF script (MF = Mother FZF):
* get a selected directory from fzf.
* create a clean tmux session name

<br>
<br>
Expand All @@ -564,14 +597,14 @@ Lets start this MF script (MF = Mother FZF):
#!/usr/bin/env bash

selected=$(find ~/personal -mindepth 1 -maxdepth 1 -type d | fzf)
echo "selected!! $selected"
if [[ -z "$selected" ]]; then
exit 0
fi
selected_name=$(basename $selected | tr ".,: " "____")
echo "selected!! $selected -- selected_name $selected_name"
```

### Ok, lets do some great things
* is there a running session given name
* `:,.` are not allowed as session name
* ` ` we should also remove spaces... but if you use a space in your directory name i dislike you
* there are other non allowed characters, but we will not worry about them
### Lets make the script gooooood
* if there is, navigate to that session
* if there is not, create that session and navigate to it

Expand All @@ -598,24 +631,26 @@ echo "selected!! $selected"
```bash
#!/usr/bin/env bash

selected=$(find ~/personal ~/ ~/.config -maxdepth 1 -mindepth 1 -type d | fzf)
selected=$(find ~/personal -maxdepth 1 -mindepth 1 -type d | fzf)
if [[ -z "$selected" ]]; then
exit 0
fi
selected_name=$(basename "$selected" | tr ",.: " "____")

if tmux has-session -t=$selected_name 2> /dev/null; then
tmux switch-client -t=$selected_name
exit 0
fi

if [[ -z "$TMUX" ]]; then
tmux new-session -s $selected_name -c $selected
exit 0
selected_name=$(basename $selected | tr ".,: " "____")

switch_to() {
if [[ -z "$TMUX" ]]; then
tmux attach-session -t $selected_name
else
tmux switch-client -t $selected_name
fi
}

if tmux has-session -t="$selected_name"; then
switch_to
else
tmux new-session -ds $selected_name -c $selected
switch_to
fi

tmux new-session -ds $selected_name -c $selected
tmux switch-client -t $selected_name
```

<br>
Expand All @@ -636,7 +671,7 @@ tmux switch-client -t $selected_name
<br>
<br>

## Combine our two scripts
## Remember our previous scriptedy-tmux
It would be nice if we could combine our two scripts...

<br>
Expand All @@ -661,24 +696,29 @@ It would be nice if we could combine our two scripts...
```bash
#!/usr/bin/env bash

selected=$(find ~/personal ~/ ~/.config -maxdepth 1 -mindepth 1 -type d | fzf)
selected=$(find ~/personal -maxdepth 1 -mindepth 1 -type d | fzf)
if [[ -z "$selected" ]]; then
exit 0
fi
selected_name=$(basename "$selected" | tr ",.: " "____")
selected_name=$(basename $selected | tr ".,: " "____")

if tmux has-session -t=$selected_name 2> /dev/null; then
tmux switch-client -t=$selected_name
exit 0
fi
switch_to() {
if [[ -z "$TMUX" ]]; then
tmux attach-session -t $selected_name
else
tmux switch-client -t $selected_name
fi

tmux send-keys -t $selected_name "ready-tmux"
tmux send-keys -t $selected_name "welcome to fem"
}

if [[ -z "$TMUX" ]]; then
tmux new-session -s $selected_name -c $selected
if tmux has-session -t="$selected_name"; then
switch_to
else
tmux new-session -ds $selected_name -c $selected
tmux switch-client -t $selected_name
switch_to
fi
tmux send-keys -t $selected_name "ready-tmux"
```

<br>
Expand Down
4 changes: 3 additions & 1 deletion lessons/04-tools/C-unix.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ transformation with them.

* lets replace `foo` with `bar`
* lets replace `foo` or `bar` with `foo,foo` or `bar,bar`
* show how its like vim find / replace

```bash
➜ dev-prod-2 git:(main) cat out | sed 's/: "\(.*\)",/: "\1,\1",/'
Expand Down Expand Up @@ -157,7 +158,8 @@ now lets use parallel to control how fast it requests
<br>

## Just a touch of awk
I don't know a lot of awk and you can do quite a bit, but the little i do know is really good
I don't know a lot of awk and you can do quite a bit, but the little i do know
is really good

```bash
➜ dev-prod-2 git:(main) ✗ ps aux | grep vim | awk '{ sum += $2 } END { print sum }'
Expand Down
6 changes: 4 additions & 2 deletions lessons/04-tools/D-neovim.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ description: "your most used tool is the editor"

## Lets start with your editor
Now i am going to show you around neovim, not because you are going to use
neovim, but its good understand just how hackable it is and perhaps you will be
willing to try it
neovim, or that i am trying to convince you to use neovim. You should use
neovim because you want to explore other ways of editing. Also, its good
understand just how hackable it is and perhaps you will be willing to try it

<br>
<br>
Expand Down Expand Up @@ -96,6 +97,7 @@ over the last few years.
* macros
* commands
* help
* your first init script

<br>
<br>
Expand Down
24 changes: 24 additions & 0 deletions lessons/06-outro/A-outro.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,30 @@ title: "Outro"
description: "goodbye"
---

## Why no AI?
there are two important reasons why i didn't go over AI in this course.
1. i see this rise of behavior in devs "learned helplessness"
1. the products are just moving so fast

<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>


## And this is it
Its the joy of making a better experience that helps keep me engaged as a dev.

Expand Down

0 comments on commit 9ce0e77

Please sign in to comment.