Skip to content

Instantly share code, notes, and snippets.

@alishersadikov
Forked from lsaville/command-diary.md
Created January 22, 2018 21:47
Show Gist options
  • Save alishersadikov/cc30598b88c127107e39ad74772ff433 to your computer and use it in GitHub Desktop.
Save alishersadikov/cc30598b88c127107e39ad74772ff433 to your computer and use it in GitHub Desktop.

11/15/2017

Replace a string across files in a directory:

find . -type f | xargs sed -i "s/#{phone}/#{link_to phone, \"tel:#{phone_raw}\", class: 'active-states-state__link'}g"

11/20/2017

Open last command in default editor

fc

11/21/2017

Start command in default editor

ctrl-x ctrl-e

11/28/2017

Symlinking Dotfiles

I've got a dotfiles folder living in the git dir where I keep my dotfiles for git control purposes.

move the dotfile you want (I'll be referring to my i3 config file): mv ~/.config/i3/config ~/git/dotfiles/config

symlink the dotfile so it can be loaded: ln -s ~/git/dotfiles/config ~/.config/i3/config

I always forget the syntax: ln -s followed by <where the file actually lives> followed by <where I want to file to pretend to live>

1/12/2018

Running sed nondestructively first

I want to test my sed string on a file, or many files before doing something wild. sed -n "s/search-term/replacement/p" file-name

I also can do a count on occurances across a directory to compare after the change ag -Q "search-term" | wc -l

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment