Posts tagged: linux

All posts with the tag "linux"

127 posts latest post 2026-04-18
Publishing rhythm
Mar 2026 | 1 posts

How I configure git

Git [1] can be a bit tricky to get configured correctly. I often stumble into config issues weeks after setting up a new machine that I did not even notice. These are my notes to remind me how I configure git. Identity # [2] git config --global user.name "John Doe" git config --global user.email [email protected] rebase # [3] editor # [4] git config --global core.editor nvim default branch # [5] git config --global init.defaultBranch main push to current bransh wihtout setting upstream # [6] git config --global push.default current Autostash # [7] git config pull.rebase true git config rebase.autoStash true References: [1]: /glossary/git/ [2]: #identity [3]: #rebase [4]: #editor [5]: #default-branch [6]: #push-to-current-bransh-wihtout-setting-upstream [7]: #autostash

python lsp setup

Setting up python with the native nvim>0.5 lsp was mr lsp-config # [1] https://github.com/neovim/nvim-lspconfig lua << EOF require'lspconfig'.pyright.setup{} EOF pyls#190 # [2] https://github.com/palantir/python-language-server/issues/190 lspconfig.pyls.setup { cmd = {"pyls"}, filetypes = {"python"}, settings = { pyls = { configurationSources = {"flake8"}, plugins = { jedi_completion = {enabled = true}, jedi_hover = {enabled = true}, jedi_references = {enabled = true}, jedi_signature_help = {enabled = true}, jedi_symbols = {enabled = true, all_scopes = true}, pycodestyle = {enabled = false}, flake8 = { enabled = true, ignore = {}, maxLineLength = 160 }, mypy = {enabled = false}, isort = {enabled = false}, yapf = {enabled = false}, pylint = {enabled = false}, pydocstyle = {enabled = false}, mccabe = {enabled = false}, preload = {enabled = false}, rope_completion = {enabled = false} } } }, on_attach = on_attach } mypy # [3] Getting mypy working with ...

How I navigate tmux in 2021

change_speed = (speed) => [...document.querySelectorAll('video')].map(v => v.playbackRate=v.playbackRate+speed) In 2021 I changed the way I navigate between tmux sessions big time. Now I can create, kill, switch with ease, and generally keep work separated into logical groups. Update # [1] Since making this post, I have made ~20 other posts in short form that all have a YouTube video to go along with them you can find them all on my tmux-playlist [2]. Chris Toomey’s [3] Tmux Course # [4] I took Chris’s tmux course [5] in December 2020 and it was fantastic. Even as a seasoned tmux user, I learned quite a bit. Before the course, I was proficient in navigating within each of my tmux sessions but rarely started more than one session. A few months later, I have adopted a lot of what I learned from Chris and made it my own. I am now keeping projects to their own session and can move between them fluidly with just a few keystrokes. For high-traffic projects, I have them bound to a si...

Trim unused git branches

Trim branches no longer on origin # [1] git remote prune origin --dry-run git remote prune origin Find branches already merged # [2] git checkout main # list remote branches that have already been merged into main git branch -r --merged # list local branches that have already been merged into main git branch --merged References: [1]: #trim-branches-no-longer-on-origin [2]: #find-branches-already-merged

Create a Virtual File Gallery with Symlinks

Creating a directory that is a union of several directories can be achieved with a few symlinks at the command line. Creating a Virtual File Gallery # [1] Here is how I am creating a virtual directory of all my projects that is a combination of both work and not-work projects. I am creating symlinks for every directory under ~/work and ~/git. rm -rf ~/projects mkdir ~/projects ln -sf ~/work/* ~/projects ln -sf ~/git/* ~/projects ⚠ Notice that first I am recreating the directory each time. This will ensure that any project that is deleted from their actual directory is removed from the virtual gallery. Updating the gallery # [2] Since links are always kept up to date without any extra work, all the data is still in the same place it started. But as new directories are added to any project directory they will not be automatically added to the virtual gallery. - cron - bashrc/zshrc If you’re concerned about system resources, you can add it to a cron job to run at a regular sch...

📝 Docker Deep Dive - Notes

https://www.hanselminutes.com/784/doing-open-source-with-brian-douglas Play With Docker # [1] A handy way to try weird things in docker is using play-with-docker [2]. You get a four hour session for free, after four hours everything will be deleted, but you can start a new session. Installing Docker on Linux # [3] Installing on Ubuntu. wget -qO- https://get.docker.com/ | sh Running Docker commands without sudo # [4] In order to run docker commands without using sudo you need to add docker to your group. sudo usermod -aG docker ubuntu Architecture and Theory # [5] Container - Isolated area of an OS with resource usage limits applied. Namespaces and Control Groups are hard, which is why containers were unusable by mortals before docker. Namespaces # [6] Isolation Each container looks and feels like a regular OS. It has its own eth0, users, kernel. These are completely isolated from every other container running on the system. Namespaces are analogous to what Hypervisors d...
Live Substitution In Neovim

Live Substitution In Neovim

Replacing text in vim can be quite frustrating especially since it doesn’t have live feedback to what is changing. Today I was watching Josh Branchaud’s Vim-Unalphabet series on Youtuve and realized that his vim was doing this and I had to have it. https://twitter.com/_WaylonWalker/status/1346081617199198210 How to do it # [1] I had to do a bit of searching and found a great post from vimcasts [2] that shows exactly how to get the live search and replace highlighting using inccomand :h inccommand # [3] 'inccommand' 'icm' string (default "") global "nosplit": Shows the effects of a command incrementally, as you type. "split" : Also shows partial off-screen results in a preview window. Works for |:substitute|, |:smagic|, |:snomagic|. |hl-Substitute| If the preview is too slow (exceeds 'redrawtime') then 'inccommand' is automatically disabled until |Command-line-mode| is done. Add this to your config # [4] I believe that this is a neovim only feature, add it into your ~...

Newsboat

Web browsers are a black hole of productivity. I try to use them as little as possible when it is time to focus. I try to use help, ?, or ?? with ipython, or –help at the command line as much as possible. What about that time I am trying to see what my online friends are posting on their sites? I used to used google reader quite heavily before that was taken down. Newsboat # [1] I am going to give a terminal rss reader a try for a bit and see how that goes for me. I have really struggled to get into an rss reader since google reader died. installation # [2] I installed with the reccomended snap for Ubuntu. sudo snap install newsboat Adding feeds # [3] super simple Running help for newsboat directed me towards their config files at the bottom. ❯ newsboat --help newsboat r2.22 usage: /snap/newsboat/3849/usr/local/bin/newsboat [-i <file>|-e] [-u <urlfile>] [-c <cachefile>] [-x <command> ...] [-h] -e, --export-to-opml export OPML feed to stdout -r, --refresh-on-start refresh f...

Find and Replace in the Terminal.

grepr # [1] grepr() {grep -iRl "$1" | xargs sed -i "s/$1/$2/g"} ```bash grepr() {grep -iRl "$1" | xargs sed -i "s/$1/$2/g"} grepd # [2] grepd() {grep -iRl "$1" | xargs sed -i "/^$1/d"} CocSearch # [3] :CocSearch published: false -g *.md References: [1]: #grepr [2]: #grepd [3]: #cocsearch

Creating Reusable Bash Scripts

Bash is a language that is quite useful for automation no matter what language you write in. Bash can do so many powerful system-level tasks. Even if you are on windows these days you are likely to come across bash inside a cloud VM, Continuous Integration, or even inside of docker. I have three techniques that help me write more composable bash scripts. - functions [1] - Arguments [2] - positional arguments [3] - All Arguments [4] - Error Handling [5] - main script [6] --- Functions # [1] Break scripts down into reusable components Functions in bash are quite simple. They are something that I wish I would have started using long ago. They make your code much more reusable. I often use them in my aliases as well since they can simplify the process and allow more flexibility. syntax #!/bin/sh # hello_world hello_world () { echo "hello world" } Source the file to load the function and run it from the terminal. run it source hello_world hello_world outputs hello world ...

New Machine for developing Tests with TestProject.io

Today I setup a new machine on Digital Ocean to use with TestProject.io, Here are my installation notes. apt update && apt upgrade -y apt install zsh chsh zsh sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" curl -fsSL https://starship.rs/install.sh | bash echo 'eval "$(starship init zsh)"' >> ~/.zshrc # python sudo apt update sudo apt install python3-pip -y echo 'alias python=python3' >> ~/.zshrc echo 'alias pip=pip3' >> ~/.zshrc # pipx apt install python3-venv pip install pipx pipx install black pipx install shell-functools pip install ipython # docker sudo apt update sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" sudo apt update sudo apt install docker-ce # docker-compose sudo curl -L "https://g...
1 min read

Out of Space

This morning I logged into my machine and was nearly out of space - 64GB miniconda3! - 5GB conda cache - 4GM pip cache - 34GB docker Find it # [1] [2] These are the commands that I often use to reclaim space. Its so easy to fill up small vm’s in the cloud, or in my case today let your dev machine go way too long without a good cleanup. Show Remaining Space on Drives # [3] This shows us where to start and gives a baseline of how much space we have reclaimed. df -h show largest files in current directory # [4] Next keep drilling into directories that are big and running this command to see whats big inside of it. When you find somethign that you are willing to part with rm -rf <directory> it and check df -h to see if you have enough reclaimed yet. du . -h --max-depth=1 Honestly I rarely bother unless the directory is in the GB’s of space. A super simple filter for that is to just grep for G. du . -h --max-depth=1 | grep G conda # [5] How Many? # [6] As a first baseline...
2 min read

Supercharge Zsh Startup

I have been using oh-my-zsh successfully for about 2 years now. But lately my startup time has been really bothersome. It has grown to the point where it was taking about 5.5s to startup a shell! This is ok if I am going to spend some time in here for awhile and do some work that benefits from all of the autocompletions, plugins, and shortcuts that oh-my-zsh brings. But to only jump in to run a handful of commands is infuriating. 📑 My Setup # [1] I believe the real issue is io speed on wsl. I have some remote servers with similar configs that are 10x faster or more, loading in 100s of milliseconds rather than seconds. Sourcing all of the individual plugin files are just too much for it. 💨 How Fast can it be # [2] Quick side note: your zsh config is controled by your ~/.zshrc file. This file can source other files, load plugins, or run literally anything. Time the initial time time zsh -c exit Move your ~/.zshrc config file. mv ~/.zshrc ~/.zshrc-back Time the fastest startup p...

📝 Bash Notes

Bash is super powerful. File System Full # [1] Show Remaining Space on Drives df -h show largest files in current directory du . -h --max-depth=1 Move files then symlink them mkdir /mnt/mounted_drive mv ~/bigdir /mnt/mounted_drive ln -s /mnt/mounted_drive/bigdir ~/bigdir Fuzzy One Liners # [2] a() {source activate "$(conda info --envs | fzf | awk '{print $ edit in vim vf() { fzf | xargs -r -I % $EDITOR % ;} cat a file vf() { fzf | xargs -r -I % $EDITOR % ;} bash execute bf() { bash "$(fzf)" } git [3] add gadd() { git status -s | fzf -m | awk '{print $2}' | xargs git add && git status -s} git reset greset() { git status -s | fzf -m | awk '{print $2}' |xargs git reset && git status -s} Kill a process fkill() {kill $(ps aux | fzf | awk '{print($2)}')} Finding things # [4] Files # [5] fd-find [6] is amazing for finding files, it even respects your .gitignore file 😲. Install with apt install fd-find. fd md ag -g python find . -n "*.md" ++Vanilla Bonus Content # [7] ** sh...