Posts tagged: cli
All posts with the tag "cli"
This morning I had a machine crash on me and came back to an error.
Error
zsh: corrupt history file /home/u_walkews/.zsh_history
Dammit I don’t want to redo my shell history, I checked with a clanker and they
came up with this solution using strings that only prints printable
characters.
cp ~/.zsh_history ~/.zsh_history.bak
mv ~/.zsh_history ~/.zsh_history.corrupt
touch ~/.zsh_history
chmod 600 ~/.zsh_history
strings ~/.zsh_history.corrupt > ~/.zsh_history
chmod 600 ~/.zsh_history
I’ve been deploying my site old school for most of this year, rsync to a volume mounted to nginx. I ran into an issue today where I updated my site and all of the pages updated first, followed by upload. The issue this created was that the new cache busted css files were not up yet and the site had no styles for a brief period during upload.
I found that delaying updates and delaying deletes until the new content exists first solves this problem pretty well. Theres still possiblility of jank while uploading to a live directory and not doing some sort of hot swap, but I’m good with this low budget option for now.
sync:
rsync -rlt --delete --omit-dir-times \
--info=progress2 \
--delay-updates \
--delete-delay \
./output/ \
server:/mnt/mysite
To ignore commands that start with a space character, use the
HIST_IGNORE_SPACE option in bash or zsh.
setopt HIST_IGNORE_SPACE
Today I found a way to test model syntax, cause the clankers always get the exact model name that copilot wants wrong.
copilot --model claude-sonnet-4.5 -p "Reply with OK" --allow-all --no-ask-user -s
copilot --model gpt-5.4 -p "Reply with OK" --allow-all --no-ask-user -s
Ses_3444b09b1ffexter3elfg5qqtg
I Built A Tmux Session Switcher
In the age of agents sometimes work gets done on so many different worktrees
and branches its hard to tell if there is already a PR or any of them or not,
the great gh cli has us covered.
gh pr list --head fix/markata-go-connections-graph
Vaulted Secrets Without Git Churn
When using two GitHub accounts the gh cli gives very easy gh auth switch workflow from the cli.
from the docs
gh auth switch –help Switch the active account for a GitHub host.
This command changes the authentication configuration that will be used when running commands targeting the specified GitHub host.
If the specified host has two accounts, the active account will be switched
automatically. If there are more than two accounts, disambiguation will be
required either through the --user flag or an interactive prompt.
# list accounts
gh auth status
# switch accounds (interactive if more than 2, i've never seen this personally)
gh auth switch
setting COLUMNS env var to a number greater than 0 will make the terminal resize to that number of columns.
COLUMNS=80 uvx --from rich-cli rich myscript.py
Note
Not all programs respct the COLUMNS env var, but rich does, and a lot of
stuff I’m building uses rich.
I discovered this when I was trying to make a low effort readme generated from the code, but did not depend on the size of terminal it was ran on.
# justfile
readme:
echo "# Workspaces" > README.md
echo "" >> README.md
echo '``` bash' >> README.md
COLUMNS=80 ./workspaces.py --help >> README.md
echo '```' >> README.md
The tea command for gitea (used by forgejo) has a flag for login. With gitea
you can have multiple accounts logged in. When you try to run a command such
as repo create it will prompt you which login to use, but I learned that you
can bake it in to all of them with --login <login-name>
❯ tea repo create --name deleteme --description 'for example'
┃ NOTE: no gitea login detected, whether falling back to login 'git.waylonwalker.com'?
tea repo create --name deleteme --description 'for example' --login git.wayl.one
Today I learned how to use tar over ssh to save hours in file transfers. I keep all of my projects in ~/git (very creative I know, I’ve done it for years and haven’t changed). I just swapped out my main desktop from bazzite to hyprland, and wanted to get all of my projects back. Before killing my bazzite install I moved everything over (16GB of many small files), it took over 14 hours, maybe longer. I had started in the morning and just let it churn.
This was not going to happen for re-seeding all of my projects on my new system, I knew there had to be a better way, I looked at rsync, but for seeding I ran into this tar over ssh technique and it only took me 6m51s to pull all of my projects off of my remote server.
ssh [email protected] 'tar -C /tank/git -cpf - .' \
| tar -C "$HOME/git" -xpf -
I am a linux user through and through. Desktop, server, vms, containers,
everything except my phone is linux. With this I spend a lot of time in the
terminal, and have been a long time user of !! to rerun the last command, but
with the ability to tack something on at the beginning or end.
TIL about fc, which opens the last command in your shell history in your
$EDITOR or pass in your editor -e nvim.
Rcap of how !! works #
!! pronounces bang bang and will run the last command in your history.
ls -l
!! | wc -l
# ls -l | wc -l
sudo !!
# sudo ls -l | wc -l
!!:s/-l/-l \/tmp
# sudo ls -l /tmp | wc -l
fc enters the chat #
Now making complex edits in your shell can be a bit of a chore, so fc moves
this work to your $EDITOR.
fc
This pops open your $EDITOR with the last command in your history.
sudo ls -l | wc -l
Shell History #
fc shows up in shell history, but !! does not, !! gets replaced by the
command that it becomes.
Up Arrow #
yaya yaya, I know you can also up-arrow c-e, but what fun is that, it’s barely a
flex. fc just looks big brained and like you really know what you are doing.
You can unset multiple environment variables at once. I did not know this was a
thing, its something that ended up happening organically on a call and asking
someone to run unset. They had never done it before and did not know how it
works, but did exactly as I said instead of what I meant. I like this handy
shortcut doing it in one line rather than each one individually, I will be
using this in the future. You might need this for something like
running aws cli commands with localstack.
unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_DEFAULT_REGION