- Dotfiles - Thoughtbot
- Console/Shell
- Password Manager
- Regolith - Tiling I3-based Window Manager
- Ubuntu
- Tmux
- Prefix
- Meta
- Help, key bindings
- Resource config files
- New named session
- Rename a session
- Kill a session
- Kill the current session
- Detach from a session
- List sessions
- Switch to the next and previous sessions
- Attach to the last session
- List key bindings
- Selecting text
- Scroll through the terminal
- Copy/Paste in panes with tmux buffers
- Paste buffers in Tmux
- Tmux Plugin Manager
- tmux-continuum and tmux-resurrect
- Panes in Tmux
- Vim
- System clipboard access (linux)
- System clipboard access (mac)
- Edit commands
- Leader key
- Go to definition/file/etc
- Go to matching brace
- Go to changes
- Folding
- The gutter column
- Count words, characters, etc
- Macros
- List registers
- Change inner word
- Changes
- Apply an edit to each line in a region
- Reverse the order of lines
- Ex mode substitutions
- Searching in Vim
- Built-in completion
- Quickfix and location list
- CtrlP and FZF
- Display full error messages
- Debugging syntax or plugin issues with syntime
- Colortest
- Color schemes
- List loaded scripts/plugins
- vim-plug
- Surround
- YouCompleteMe (ycm)
- Fugitive for Git
- NERDTree file navigator
- vim-vinegar
- vim-hug-neovim-rpc pythonx error
- Neovim
- Find command - Ripgrep
- Git and GitHub
- SSH notes
pkg-config
notes- Delete empty directories
- Hex dumps
- Bat (replacement for cat)
- Image, Video, and Audio conversion
- cheat.sh
- MacOS
- PyWhat
- FuckIt.py
- zoxide
- seq
- jot
I'm using the Thoughtbot Dotfiles with a few local overrides. Thanks to Greg as usual, for turning me on to Thoughtbot. More instructions are on the repo page, as well as the readme for the local overrides.
Clone the Thoughtbot Dotfiles repo, and then install rcm:
git clone git://github.com/thoughtbot/dotfiles.git ~/dotfiles
sudo add-apt-repository ppa:martin-frost/thoughtbot-rcm
sudo apt-get update
sudo apt-get install rcm
env RCRC=$HOME/dotfiles/rcrc rcup
Now rcup
can be run without the environment variable set.
- Trigger fzf and place the result at the command line:
C-t
- Change directory to the result of fzf:
M-c
(Alt-c
) - Change directory to the result of fzf:
cd **<tab>
- Search command history with fzf:
C-r
Emacs keybindings work, but that's a pain with C-a
mapped for tmux. Vim keys
work for navigating the list with Ctrl
-- C-k
to go up, C-j
to go down,
etc. Select items with enter
or tab
.
fzf --multi
Then use C-k
and C-j
to navigate the list and tab
to toggle selection of
each desired item.
fzf --cycle
- cycle from the end to the beginning and vice versafzf --reverse
- reverse the list
fzf --preview 'bat --color=always --line-range :50 {}'
Remember to create symlinks from fd
to fdfind
and bat
to batcat
. And set
the $FZF_...
variables in zshrc.local
before sourcing the fzf shell script.
Show results for src
but exclude espnet
and __pycache__
:
> src !espnet !__pycache__
As outlined in the
readme, fzf has a trigger sequence for completions -- **
. Change the trigger sequence with $FZF_COMPLETION_TRIGGER
.
vi **<tab>
ssh **<tab>
kill <tab>
- search for processes by name (no trigger sequence needed)export **<tab>
I haven't found a great way to use this yet, but it's promising.
echo '' | fzf --print-query --preview-window wrap --preview 'cat some_file.json | jq {q}'
KeepassXC on Ubuntu, soon to be on Mac and Windows (when needed)
Regolith Linux has both a standalone distro and a window manager that can be installed on an existing Ubuntu installation. The latter is what I'm using.
To install on Ubuntu:
sudo add-apt-repository ppa:regolith-linux/release
sudo apt update
sudo apt install regolith-desktop i3xrocks-net-traffic i3xrocks-cpu-usage i3xrocks-time
Then logout or restart. When logging in with gdm, select the gear icon and choose Regolith.
Common Keys:
Super
is the window key on my laptopSuper+Shift+?
- open the shortcut/launcher appSuper+Enter
- terminalSuper+Shift+Enter
- browserSuper+Space
- launch an appSuper+Shift+q
- quit an appSuper+c
- settingsSuper+1,2,...
- activate the numbered workspaceSuper+f
- toggle fullscreen for the active windowSuper+arrows
- navigate through tiled apps in a workspaceSuper+Tab
- cycle through apps (instead ofAlt+Tab
)
Super+arrows
- pin a window to the left or right or maximize itSuper+h
- hide (minimize) a window
Ubuntu Screenshots and Screencasts
Prt Scrn
Shift + Prt Scrn
To record the screen I'm using Peek. It has a draggable region and options for saving as a gif, webm, or mp4.
xrandr --listactivemonitors
xrandr --listmonitors
xrandr
When getting the annoying "does not have a release file" errors with apt
, to
remove a repository manually, use add-apt-repository
(if ppa-purge
is not
installed or doesn't work). To remove:
sudo add-apt-repository -r ppa:<name>/<repo>
A troublesome one for me:
sudo add-apt-repository -r ppa:twodopeshaggy/drive
When determining how many parallel jobs to pass to make -j
, use nproc
:
nproc
12
You can use make -j$(nproc)
but I'm sparing a few by using make -j8
.
To see info on all running services that are listening on the network:
ss -atpu
An active response indicates it's running:
sudo systemctl is-active systemd-resolved.service
active
sudo systemd-resolve --flush-caches
sudo systemctl is-active network-manager
active
sudo service network-manager restart
sudo service network-manager status
sudo apt install inxi
Network info:
inxi -n
nmcli
nmcli show devices
iw dev
iw phy
lshw -C network
- I'm currently running:
- Tmux v3.0a on Ubuntu Linux
- An outdated Tmux 2.3 on Mac (need to update)
- Tmux Cheat Sheet
I map my prefix/leader to C-a
for easier typing.
On Mac, in iTerm2, I edit my session to remap the left alt key as Meta (Esc+), more info:
<prefix> ?
tmux source ~/.tmux.conf
<prefix> :source ~/.tmux.conf
To start a new session with <name>
:
tmux new -s <name>
:new -s <name>
<prefix> $
tmux kill-session -t <name>
<prefix> x
Then confirm.
<prefix> d
tmux ls
Switch sessions quickly and visually with:
<prefix> s
<prefix> (
<prefix> )
tmux a
tmux list-keys
or
<prefix> :list-keys
or
<prefix> ?
Hold shift and select text to copy from the terminal.
Enable scroll/copy mode:
<prefix> [
Then use normal navigation (h/j/k/l
) to navigate.
Disable with:
q
More here, including info on changing key bindings to match vim.
- Enable scroll/copy mode:
<prefix> [
- Enter visual select mode:
<space>
-
Navigate to select a region
-
Copy the region:
<prefix> w
- Paste the copied text:
<prefix> ]
- Enable scroll/copy mode:
<prefix> [
- Enter visual select mode:
v
-
Navigate to select a region
-
Copy the region:
y
- Paste the copied text:
<prefix> P
List paste buffers:
<prefix>:list-buffers
or:
<prefix>=
Show the current buffer:
<prefix>:show-buffer
Show the second buffer:
<prefix>:show-buffer -b 2
Save the current paste buffer to a file named filename.txt:
<prefix>:save-buffer filename.txt
Using tpm
See the install instructions. Most recently:
- Clone the repo to
~/.tmux/plugins/tpm
:
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
- Source the tmux config file (this assumes you have the proper entries in the file):
tmux source ~/.tmux.conf
<prefix> I
I'm using tmux-resurrect and tmux-continuum for saving and restoring tmux sessions. Sessions are auto-saved every 15 minutes, but sometimes I manually save them.
<prefix> C-s
<prefix> C-r
To avoid extra steps starting tmux and then restoring, I use an alias to automate it. This is from this issue filed on tmux-resurrect.
alias mux='pgrep -vx tmux > /dev/null && \
tmux new -d -s delete-me && \
tmux run-shell $TMUX_DIR/plugins/tmux-resurrect/scripts/restore.sh && \
tmux kill-session -t delete-me && \
tmux attach || tmux attach'
Note that this relies on setting $TMUX_DIR
, which I do in ~/dotfiles-local/zshrc.local
:
TMUX_DIR=$HOME/.tmux
<prefix>"
With mapping:
<prefix>-
<prefix>%
With mapping:
<prefix>|
To rearrange panes, cycle through arrangements, use the space/spc key:
<prefix><space>
I hit this on accident periodically, so it's good to know how to correct it.
<prefix>h/j/k/l
<prefix> z
From this question
Add this mapping:
bind -r a select-pane -t .+1 \; resize-pane -Z
Then cycle through zoomed with <prefix> a
, a
, a
, ...
<prefix> !
<prefix> x
Move the current pane left:
<prefix> {
Move the current pane right:
<prefix> }
Check for the proper compile flags:
vim --version | grep clipboard
You should have +clipboard
and +xterm_clipboard
. If not then install another
vim, I used vim-gnome
:
sudo apt install vim-gnome
Now you should have +clipboard
and +xterm_clipboard
. More info on the Vim
Tips Wiki.
set clipboard=unnamed
set clipboard=unnamedplus
Use "+y
to yank (copy) to the system clipboard.
To copy to the system clipboard (or primary clipboard) on macos:
"+y
or:
"*y
For more info:
:help quoteplus
or:
:help quotestar
Also see accessing the system clipboard.
Edit the previous file: :e#
Also: <leader><space>
, for me: <space><space>
To show your leader key:
:echo mapleader
or
:let mapleader
If it's the space key, it might show up as empty. To see this more explicitly, run:
:nmap showleader :echo('leader key is "<Leader>"')<Esc>| exec 'norm showleader'|
nun showleader
When using space as the leader it prints:
leader key is " "
For a keyword under the cursor:
gd
for the local definitiongD
for the global definitiong*
andg#
to search forward/backwardgf
to open the file under the cursorg]
to jump to a tag definition:dj /foo
to jump to the definition of a class or function matching the patternfoo
. Seeset define
for the specification of a definition.
To jump between matching braces or supported keyword pairs (Ex: #ifdef/#endif
), use the percent key:
%
g;
- Go to the next older change.g,
- Go to the next newer change.
I mostly only use folding for large data files, like json files.
Enable:
:set foldmethod=syntax
Commands:
za
toggle a foldzc
close a foldzo
open a fold
Sometimes it's useful to disable the left gutter column (used by syntax checkers etc) when you want to copy and paste text. How:
:set signcolumn=no
To reenable it:
:set signcolumn=auto
To count characters, bytes, words, and lines in a selection, select a region and type:
g C-g
This also works on the entire document with no selection active.
Yes, this can be done with surround.vim instead.
- Press
q
and a<register>
to record into to begin recording, for example:qa
- Press
viwo<Esc>
to go to the beginning of the current word, if not already there. Usingwb
will work, except where the word is at the end of a file. - Press
i
to insert and type a quote"
(or single quote or other surround character you want to use) and then<Esc>
to leave insert mode. - Press
e
to move to the end of the word. - Press
a
to append and type a quote"
again, then<Esc>
. - Press
q
to write to the register.
To use, move the cursor within a word, and press @<register>
, for example: @a
.
To repeat the last macro, use @@
.
To list registers, including copied text and recorded macros:
:registers
To change the word the cursor is within (vs cw
):
ciw
To change the word the cursor is within including the following space:
caw
List the changes for the current buffer:
:changes
Navigate changes:
g;
to navigate to the position of the previous changeg,
to navigate to the position of the next change
c-v
to enter visual block mode- Highlight the region
- Make the edit (ex:
I foo
to prepend " foo" to each line) esc
- For a region, either specify line numbers or use
v
to highlight a region :g/^/m123
, where 123 is the destination line number- To explicitly specify line numbers, use
:10,20g/^/m9
to reverse lines from 10 to 20.
Some substitutions for ex mode:
%
= the current filename:!file % readme.md: ASCII text, with very long lines Press ENTER or type command to continue
<cword>
= sub the current word under the cursor
For more: :help cmdline-special
The word boundary specifiers for vim regex syntax are \<
and \>
. To search
for "the" surrounded by word boundaries:
/\<the\>
Vim includes several handy completion options which can reduce the need for a
plugin. See :h ins-completion
for more info. A subset:
C-x C-n
- complete from keywords in the current fileC-x C-i
- complete from keywords in the current file and included filesC-x C-f
- complete from filenamesC-x C-l
- complete from whole lines in the fileC-x C-d
- complete from definitions or macrosC-x C-]
- complete from tagsC-x C-u
- compete from a user-definedcompletefunc
function (see:h completefunc
)C-x C-v
- complete from vim command line options
Use C-n
and C-p
to navigate through the completion list.
The quickfix list and location list are two modes that allow processing lists of data related to the file being edited.
To move between either the quickfix list or location list and the main window,
use the same window navigation keys - C-w <hjkl>
.
The quickfix list is global to the current session of vim.
:copen
- Open the quickfix window.:ccl
or:cclose
- Close the quickfix window.:cnext
or:cn
- Go to the next item on the list.:cprev
or:cp
- Go to the previous item on the list.:cfirst
- Go to the first item on the list.:clast
- Go to the last item on the list.:cc <n>
- Go to the nth item on the list.:cdo
- run a command for each item in the list:cfdo
- run a command for each file in the list
To search and replace in a project with :cdo
:
:grep foo -r **/*.py
:cdo s/foo/bar/ | update
- to operate on each match or, to operate on each file::cfdo %s/foo/bar/g | update
:cfdo bd
- to close the opened buffers
The location list is similar to quickfix but is local to the current buffer.
:lopen
- Open the location list.:lcl
or:lclose
- Close the location list.:lnext
- Go to the next item on the list.:lprev
- Go to the previous item on the list.:lfirst
- Go to the first item on the list.:llast
- Go to the last item on the list.:ll <n>
- Go to the nth item on the list.:ldo
- run a command for each item in the list:lfdo
- run a command for each file in the list
To get CtrlP fuzzy file open working, I installed fzf from github:
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
And then edit the dotfiles to move the insertions into the local overrides.
Find files:
:Files [path]
Find Git files:
:GFiles [path]
Find in buffers:
:Buffers
To find text in files - Ripgrep:
:Rg [pattern]
:messages
- Turn syntime on
:syntime on
-
Cause a redraw or edit (
C-l
or:e <file>
) -
Generate a report.
:syntime report
:runtime syntax/colortest.vim
:colorscheme
:colorscheme <tab>
:colorscheme elflord
Others that are ok:
- industry
- koehler
- pablo
- ron
- torte
- zellner
:scriptnames
To search the loaded scripts
:filter /pattern/ scriptnames
Thoughtbot uses vim-plug as the default
vim plugin manager. To install a plugin, edit ~/.vimrc.bundles.local
(which
should symlink to your local overrides, and add an entry for a plugin like this:
Plug 'maxmellon/vim-jsx-pretty'
Then source .vimrc (or exit and return) and run the install command:
:so ~/.vimrc
:PlugInstall
Sometimes I've found that I have to put the full github path in for some plugins, as can be seen in the bundle file in my local overrides. I also remove some problematic plugins installed by Thoughtbot's defaults.
Delete or comment out the Plug
entry, then reload .vimrc
or restart, and run
:PlugClean
.
Some examples:
Key/Command | Effect |
---|---|
cs"' |
Change a surround from "double" to 'single' |
cs"[ |
Change a surround from "double" to [brackets] |
If receiving the error "The ycmd server SHUT DOWN (restart with :YcmRestartServer)" on launching vim, you may need to launch the ycm server:
cd ~/.vim/bundle/YouCompleteMe
./install.py
I had to update ycm due to some issues with an update of golang. Steps I took:
cd ~/.vim/bundle/YouCompleteMe/third_party/ycmd
git checkout master
git pull
git submodule update --init --recursive
./build.py --go-completer
fugitive.vim is a git integration for vim.
Some commands:
Key/Command | Effect |
---|---|
:Git |
summary/status |
:Git diff or :Gdiff |
Show diffs |
:Git blame or :Gblame |
Show blame |
:Git mergetool & :Git difftool |
Load diffs into quickfix |
:Ggrep and :Glgrep |
Git grep |
:Git add % |
stage the current file |
Note: I currently have this disabled while trying vim-vinegar
.
Key/Command | Effect |
---|---|
:NERDTree |
open NERDTree |
o or Enter |
open a file or expand a directory |
C-arrows |
navigate between NERDTree and an open file |
m |
open the file menu, which allows creating and deleting files and directories |
B |
open bookmarks |
:q |
close NERDTree |
I map <leader>ne
to open NERDTree:
nmap <leader>ne :NERDTree<cr>
vim-vinegar is an alternative file navigation plugin.
Key/Command | Effect |
---|---|
- |
Replace the current buffer with a directory listing, or move up a level if already in vim-vinegar |
I |
Toggle displaying hidden files and netrw header info |
y. |
Yank the absolute path for the file under the cursor |
~ |
Navigate to your home directory |
. |
Start a : command sequence with the path of the file, ex: .grep foo |
! |
Start a shell command with the path of the file, ex: !chmod +x |
Error:
[vim-hug-neovim-rpc] Vim(pythonx):ModuleNotFoundError: No module named 'neovim'
Fix:
- Make sure that vim has been compiled with python3 support by running
:ver
or:echo has('python3')
- Run
pip3 install pynvim
- Run
pip3 install neovim
NvChad is a set of Neovim config that provides a lot of defaults.
- Backup or remove existing nvim config
mv ~/.config/nvim ~/tmp/dot_config_nvim.backup
mv ~/.local/share/nvim ~/tmp/dot_local_share_nvim.backup
- Install a nerdfont
Visit nerdfonts.com.
- Clone the repo into your config location
git clone git@github.com:NvChad/NvChad.git ~/.config/nvim --depth 1
- Run Neovim to see the notes, etc.
To update, run:
:nvChadUpdate
The default NvChad leader is space/spc
. Pressing the leader and waiting will cause a modal help box to appear.
Key/Command | Effect |
---|---|
<leader> + ch |
Show the NvChad Cheatsheet |
<leader> + th |
Show the theme selector (C-n /C-p for navigation) |
C-n |
Toggle NvimTree |
<leader> + ff |
Find a file |
<leader> + fb |
Find a file in the open buffers |
<leader> + / |
Toggle comment |
<leader> + h |
Horizontal shell |
<leader> + v |
Vertical shell |
To check which plugins are installed:
:TSInstallInfo
To install the syntax highlighting plugin for a given language or file:
:TSInstall <type>
Key/Command | Effect |
---|---|
<tab> , <shift><tab> |
Cycle through open buffers |
<leader> + x |
Close a buffer |
Use C-n
to toggle NvimTree for file browsing.
Key/Command | Effect |
---|---|
m |
Toggle marking a file |
a |
Create a file |
c |
Copy a file |
p |
Paste a file |
r |
Rename a file |
To install a patched nerd font on Mac:
brew tap homebrew/cask-fonts
brew install font-jetbrains-mono-nerd-font
Commentary.vim - also works with vim
gcc
- toggle comment on a line (or a count of lines)gc
- toggle comment for a motion (use with visual mode)
Use Ripgrep:
rg <pattern>
rg -i <case-insensitive pattern>
rg -l <pattern>
rg -tpy <pattern>
rg --files | rg <pattern>
By default, ripgrep will ignore binary files, hidden files, and files listed in .gitignore files. This behavior can be changed, from the usage:
-u, --unrestricted
Reduce the level of "smart" searching. A single -u won't respect .gitignore
(etc.) files. Two -u flags will additionally search hidden files and
directories. Three -u flags will additionally search binary files.
-uu is roughly equivalent to grep -r and -uuu is roughly equivalent to grep -a -r.
Another way to specifically ignore version control ignore files such as
.gitignore files is to use --no-ignore-vcs
:
rg --no-ignore-vcs <pattern>
rg -uuu <pattern>
rg -uuu --files | rg -uuu <pattern>
rg \
--no-ignore-vcs \ # Don't read version control files for ignores
-g '!*.txt' \ # Exclude files matching *.txt
-g '!*config*' \ # Exclude files matching *config*
-li '�foo�' \ # Search for "foo" surrounded by word boundaries, ignoring case
./src # Search in ./src
git log -p
git log --graph -p --all
git diff --cached [filename]
or:
git diff --staged [filename]
git diff HEAD^ HEAD
Show the diff of all changes from when a branch (branch2) branched off from a parent branch (branch1):
git diff branch2...branch1
git diff -u --no-prefix > some_patch.diff
Apply the patch:
patch -p0 -i some_patch.diff
git stash save -p "some message"
Some options:
y - stash
n - don't stash
q - quit
a - stash this hunk and all later hunks in the file
d - don't stash this hunk or any later hunks in the file
git remote -v
git remote set-url origin git@github.com:path/to/repo.git
Ex:
git remote set-url origin git@github.com:andypayne/dev_cheatsheet.git
Github now recommmends cloning over HTTPS in their setup guide. No reasons are provided in the guide, but it could be because of the extra key exchange and ssh setup steps.
You can use a credential helper to cache your github credentials when using HTTPS, as described in this article.
All with relative date, name, and subject:
git log --pretty="%h %ar %an %s"
The last two commits with only the abbreviated hashes:
git log -2 --pretty=%h
Get the last two commits:
git log -2 --pretty=%h
78dbbb2
96f95df
Revert to the commit before the last one:
git revert --no-commit 96f95df..HEAD
Combo (untested):
git revert --not-commit `git log -2 --pretty=%h | tail -n 1`..HEAD
Revert and push:
git revert --continue
git push
Add an upstream repo to a fork:
git remote add upstream git@github.com:user/repo.git
Merge updates from the upstream repo into a fork:
git fetch upstream
git checkout master
git merge upstream/master
Without fast-forwarding:
git merge --no-ff upstream/master
Add a submodule to a project:
git submodule add git@github.com:user/repo.git
Update a submodule:
git submodule update --remote
- Generate a key on the local system, if not yet done.
RSA:
ssh-keygen -t rsa
Ed25519:
ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -C "user@example.com"
- Copy the public key to the remote system.
ssh-copy-id -i ~/.ssh/id_rsa.pub username@remote.server
- Try it.
Check for a library/module (OpenCV in this example):
pkg-config --exists --print-errors opencv4
Add /usr/local/lib/pkgconfig
as a location (set PKG_CONFIG_PATH
in dotfiles):
mkdir /usr/local/lib/pkgconfig
cp opencv4.pc /usr/local/lib/pkgconfig/
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
pkg-config --exists --print-errors opencv4
echo $?
0
Using find to delete empty directories from base/path
:
find base/path -type d -empty -delete
The xxd
command can be used to do hex dumps:
echo "foobar" | xxd
00000000: 666f 6f62 6172 0a foobar.
bat is a cat alternative with syntax highlighting and git integration.
Install on Ubuntu:
apt install bat
Install on Mac:
brew install bat
Example use with tail -f
:
tail -f /var/log/syslog | bat --paging=never -l log
───────┬────────────────────────────────────────────────────────────────────────
│ STDIN
───────┼────────────────────────────────────────────────────────────────────────
1 │ Aug 26 09:55:54 host lircd[1288]: lircd-0.10.0[1288]: Error: Cannot glob /sys/class/rc/rc0/input[0-9]*/event[0-9]*
2 │ Aug 26 09:55:54 host lircd-0.10.0[1288]: Error: Cannot glob /sys/class/rc/rc0/input[0-9]*/event[0-9]*
...
With Inkscape:
inkscape -z -w 512 -h 512 image.svg -e image.png
ffprobe video.mp4
This is useful for loading as a media capture file in Chrome.
With ffmpeg
:
ffmpeg -i video.mp4 -pix_fmt yuv420p video.y4m
As aac
:
ffmpeg -y -i video.mp4 -f aac -vn audio.aac
As wav
:
ffmpeg -y -i video.mp4 -f wav -vn audio.wav
cheat.sh has a nice interface for getting help and examples for common commands. My convenience alias for it is:
cheat() {
curl cheat.sh/"$@" | bat
}
To enable key repeats on Mac, set this and then restart:
defaults write -g ApplePressAndHoldEnabled -bool false
To fix a drifting clock on MacOS, force a time server sync:
sudo sntp -sS time.apple.com
PyWhat is a tool for reporting what some unknown data is likely to be. So far I haven't been able to use it for much.
Install and get help:
pip install pywhat && pywhat --help
Example usage:
$ pywhat "123-45-6789"
Possible Identification
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Matched Text ┃ Identified as ┃ Description ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 123-45-6789 │ American Social Security Number │ An American Identification Number │
└──────────────┴─────────────────────────────────┴───────────────────────────────────┘
I haven't tried FuckIt.py yet, but it sounds useful. From the docs: "FuckIt.py uses state-of-the-art technology to make sure your Python code runs whether it has any right to or not. Some code has an error? Fuck it."
One way to use it is by replacing import
:
import fuckit
#import some_shitty_module
fuckit('some_shitty_module')
some_shitty_module.some_function()
zoxide - on my todo list to try - "zoxide is a blazing fast replacement for your cd command, inspired by z and z.lua. It keeps track of the directories you use most frequently, and uses a ranking algorithm to navigate to the best match."
Also see modern unix.
The seq
command will output sequences of numbers.
$ seq 1 10
1
2
3
4
5
6
7
8
9
10
A format string can be passed in:
seq -f "some_file_%02.0f.txt" 100 104
some_file_100.txt
some_file_101.txt
some_file_102.txt
some_file_103.txt
some_file_104.txt
A separator can be specified:
seq -s ":" 4 12
4:5:6:7:8:9:10:11:12:
Zero pad to equal width:
seq -w 0 50000 150000
000000
050000
100000
150000
The jot
command will output sequences of random numbers.
jot <reps> <begin> <end>
$ jot 10 1 4
1
1
2
2
2
3
3
3
4
4
Specifying digits of precision:
jot -p 2 5 3 4
3.00
3.25
3.50
3.75
4.00
Specifying a string to repeat:
jot -b hmm 3
hmm
hmm
hmm
Specifying a character to repeat:
jot -c - A F
A
B
C
D
E
F
Generating random numbers in a range:
jot -r 8 10 15
15
11
14
12
14
10
13
14
Specifying a format string:
jot -w "Num: %03d" 3 10
Num: 010
Num: 011
Num: 012
seq
and jot
can produce the same sequences:
seq 5 10
==jot 6 5
seq 5 10
==jot - 5 10