Skip to content

Instantly share code, notes, and snippets.

@SebastianGrans
SebastianGrans / nice_ls_colors.md
Last active December 25, 2023 14:41
Better `ls` colors

Directories with 777 permissions look pretty ugly when you list files (see first example in picture below). This happens if you do ls in /mnt/c/ in WSL.

image

Simply changing the background to light gray makes a big difference. While I was fiddling around I discovered that I quite like having directories to be orange.

You can change this by simply adding the following line to your .bashrc/.zshrc/etc. Make sure to put it before the line source $ZSH/oh-my-zsh.sh, otherwise the autocompletion will use the default colors. source

@SebastianGrans
SebastianGrans / WSLandOhMyZsh.md
Created December 21, 2023 11:39
WSL and `oh my zsh`

Is your zsh really slow when you go to a git repository in /mnt/c/ even though you don't have the git plugin enabled? It's probably because you use a oh my zsh theme that has the git info in it.

A popular theme is robbyrussel which has the git integration built in. In ~/.oh-my-zsh/themes/robbyrussell.zsh-theme you will find the following line:

PROMPT+=' $(git_prompt_info)'
@SebastianGrans
SebastianGrans / README.md
Created December 3, 2023 20:00
Using Expect in Windows

Using Expect in Windows

My usecase for Expect is to automatically log in to a device over telnet, so that I don't have to write the password every time.

The easiest way is to simply run the expect script from WSL, but I'm lazy and want to run it directly from PowerShell. Here's how:

  1. Install Expect in your WSL distro
  2. Place your expect sript in your WSL home folder ~/script.expect (remember to make it executable)
@SebastianGrans
SebastianGrans / Microsoft.PowerShell_profile.ps1
Last active December 2, 2023 16:55
Useful thinsg to put in your PowerShell `$PROFILE`
# Copy last command to clipboard
function cl() {
$last_command = (Get-History -Count 1).CommandLine
Set-Clipboard -Value $last_command
}
# Copy absolute path of a file or folder to clipboard
function cap($path) {
Set-Clipboard -Value (Resolve-Path $path)
}
@SebastianGrans
SebastianGrans / README.md
Last active November 28, 2023 20:40
Prevent Firefox from blinding you when opening new tabs

I use Darkreader to give any website a dark mode, which I highly recommend. Even with this plugin, there are breif moments when opening links, that the browser displays an entirely white screen. Thankfully, this can be mitigated!

  1. Enable toolkit.legacyUserProfileCustomizations.stylesheets in about:config
  2. Create a folder, /chrome/, in your Firefox profile folder
  • You can find the folder by going to about:support
  • On Windows: C:\Users\<user>\AppData\Roaming\Mozilla\Firefox\Profiles\<profile>.default-release\chrome\userChrome.css
  1. Add the following .css files.
  2. Restart Firefox
@SebastianGrans
SebastianGrans / README.md
Last active March 14, 2023 10:03
TIL about Mermaid diagrams and that GitHub supports it in Markdown!

Mermaid Diagrams

GitHub supports Mermaid diagrams and renders them directly in Markdown files.

They aren't rendered in the preview tab, so it's best to design them else-where. With mermaid.live, for instance.

Example

Here's a basic example of the syntax and the resulting diagram:

@SebastianGrans
SebastianGrans / README.md
Last active November 28, 2022 08:29
Disable scroll hijacking

Some websites hijack the scrollwheel in order to implement smooth scrolling and other annoying stuff. The following javascript snippet can disable such features.

Create a bookmark, and add the javascript code to the address part of the bookmark. When you stumble upon a hijacking website, you simply click on the bookmark.

You can also use extensions like tampermonkey to automate this process.

Source: https://superuser.com/a/1263145

@SebastianGrans
SebastianGrans / README.md
Last active February 17, 2022 15:18
Fix green tint when watching videos in fullscreen on MacOS

EDIT: Ignore this. It doesn't seem to work all the time anyway. Disable hardware acceleration in chrome instead.

TL;DR: If your screen gets a green tint when playing full screen videos. Resetting the mouse cursor size to 1 fixes it. The script below does that automatically for you.

When I play videos in fullscreen, I get some strange strange green tint over the video. A quick googling told me that simply resetting the cursor size to it's standard size should fix this. link

This does indeed work, even though my cursor size is always the default. But it only works temporarily...

Digging into the accessibility menu every time it happens is annoying, so I needed a script of some form. Thankfully the Stackoverflow user @Jw C showed me how its done! link

@SebastianGrans
SebastianGrans / function.sh
Last active January 20, 2022 23:51
Cycle the bluetooth connection to a device on MacOS
# The bluetooth connection to my stereo started crackling after being connected for a while.
# Reconnecting to it solved the problem, but got annoying to do manually.
#
# Installation:
# 1. Get the following dependencies
# * blueutil - https://github.com/toy/blueutil
# * terminal-notifier (optional) - https://github.com/julienXX/terminal-notifier
# 2. Find the MAC address of the bluetooth device of interest using `blueutil`
# * `blueutil --paired`
# 3. Add the function to your .bashrc (or .zshrc, etc.)
@SebastianGrans
SebastianGrans / MacOS_Software.md
Last active November 13, 2022 21:48
Various utility software that I use on MacOS

Update

I realized that almost all of these app can be installed easily via Brew. So first step would be to install Brew as instructed on their website.

Then simply run:

brew install iterm2 bettertouchtool bpython brave-browser vscodium vlc google-drive alt-tab git spotify monitorcontrol dozer