Gwen Bell Visit Decent

Tech Resources

This is a collection of tech pieces I've written gathered here for reference. Added a gloss at top for your searching convenience.

1. Git aliases

2. Clopen

3. Command Line Essentials

4. Concatenate

5. Mosh

6.Vim

7.Computing History


1. Git Aliases

Git aliases are great once you have the Git fundamentals down.

If you already know what git pull origin master is and you spend all day typing that into your command line, you know how much faster it'll be to write

% gpom

instead.

TJ Holowaychuk wrote the guide to doing this. Watch his 9 minute screencast on aliases, you might find it nutrient rich. A faster, smoother Git workflow leads to a more focused day on the command line.

2. Clopen

Here's one of the bad code habits I had the hardest time breaking. Remembering to close what's opened while coding.

When you open

'

Close it with

'

When you open

{

close with

}

How to break this habit?

Easy. When you open a bracket, close it. Only then do you use the backarrow key to write what goes into the now opened and closed brackets.

So,

{}

rather than

{

then

}

Of course this means backarrowing more than you might want, and doing so is annoying. What is more annoying is openings with no closings that throw up an error at compile time.

Everything that opens must be closed (unless it's a self-closing tag, obviously).

Save this

syntax on

in your .vimrc folder, in the off chance you forget. If you want to just try syntax highlighting in vim, hit escape, then

:syntax on

Either way, a visual reminder to close what you've opened.

3. Command Line Essentials

If you were switching off an Apple operating system and onto a Linux machine, what commands would you want to know first?

--message received from someone reading gwenbell.com

My response: If I were switching off an Apple machine and onto a Linux machine for the first time today, here's what I'd want to know.

The command line things I'd want to know

  • Where the command line is located

If I didn't know where the command line was, the first thing I'd want to do is find it. Since I'm on a Linux box right now, I don't know how to unfind it. I rarely work on anything other than the command line. Last week when I was doing a big archive purge I used gnome to run through photo deletion fast, but soon as I wrapped that project up I got back to dwm (tiling window manager).

  • First few UNIX commands

    mkdir

    cd

    ls

    cp

    mv

    pwd

In order from top to bottom

  • make directory to make a new folder

  • change directories

  • list what's in a directory

  • copy one thing over another (use with care -- better to use 'mv' then delete the original)

  • move one thing to another place

  • print working directory to know where you are in the file structure

  • tree

I'd want to know about that.

du -h

and

du -sh

too.

Let's you know where you are, how your files look and how much more there is to delete.

4. Concatenate

% cat index.html

does what you'd think (cats the file, reads and then outputs the contents of the file you just cat'd to standard output), but did you know

cat

is (probably, according to my research today) the oldest UNIX utility. And it's derived from

catenate

which is itself connected to

concatenate

which means to connect one thing to another.

5. Mosh

Last week I decided to try mosh, the mobile shell.

My internet connection is inconsistent, so when I'm using mutt, say, to check email, say, over SSH I'll be mid-way through responding to a message when the connection drops. Or, I'm using Profanity (an XMPP-based chat client) and don't know whether the message I sent was received, nor whether I've received the whole message that was sent this direction. That was the pain point. While reviewing Git reset docs, I ran across a developer who linked to another developer who'd written a piece on Mosh.

With mosh, I know when the connection lags because it alerts me to the fact. I also know when a message has been sent over the UDP connection and when it has not (while I'm typing and it's not yet sent, the words are underlined; once sent, the underlines disappear). It's not all that different than SSH in terms of usability, and to start using it it's

mosh username at yourdomainname.com

the same way you'd log into your server.

Upon entering the mobile shell, things look the same as SSHing in, and

tmux attach

reconnects you to an always-live Profanity session (if you do indeed have an always-live XMPP-based chat session, and if you detach correctly, with...

ctrl b

d

For those of us already on Arch, mosh is a

sudo pacman -Syu mosh

away.

6. Vim

how do I cd into Writing? what does cd mean?

-- question received via gwenbell.com

$ cd

means change directory. Quick command line crash course with your UNIXy essentials.

cd change directory
cd .. go back one level
ls list contents of a directory. That and $ pwd will tell you where you are
mkdir make directory
rm -rf delete everything in a directory (use with care)
cp copy. You do

$ cp [filename] to [new location you want the file to go]

Best to use

$ mv

instead and delete the original once you've moved it to its new location. Delete is permanent, it's not a trashcan icon from which you can recover later.

This is my command line

g% ls
Builds Decent Downloads Code Photos Writing
g% cd Code/gwenbell
g% ls
g% vim layouts/index.jade

When I hit enter I'll be able to edit the front page of my site, the layouts/index.jade file. This is how it looks right now.

extends layout

block content
  h2 #{title}
  ul
    each blog in collections.blog
      li
        a(href="/" + blog.path + "/")= blog.title
        span  - #{moment(blog.date).format('MMMM Do YYYY')}
  div!= contents

Edit something and now hit escape and then

:wc

to save the updates

Then I hit enter.

Then I'll do

git add layouts/index.jade

to add the file name, then

git commit -m

to add a commit message

Then

git push origin master

on local

then

git pull origin master

remote.

Then a

$ node build

and reload your site to see updates.

7. Computing History

  1. Things Every Hacker Once Knew

January 30th 2017

Aboard an Append Only Log ➡

⬅ Mind Right



About · Archive2017