chezmoi: reorganise repo

This commit is contained in:
js0ny 2025-09-27 15:28:09 +01:00
parent b391e03c87
commit 67a78879db
278 changed files with 102 additions and 182 deletions

View file

@ -0,0 +1,9 @@
$PSHistPath = (Get-PSReadlineOption).HistorySavePath
if (Test-Path $PSHistPath) {
$PSHist = Get-Content $PSHistPath
$PSHist | Group-Object | Sort-Object Count -Descending | Select-Object -First 10 Count, Name
}
else {
Write-Host "No history file found."
}

View file

@ -0,0 +1,43 @@
<#
.SYNOPSIS
Rename files with a specified extension in a folder, padding the numeric part with zeros.
.PARAMETER ext
The extension of the files to rename, without the dot. Default is "md".
.PARAMETER Numeral
If specified, the files will be renamed in the order of their numeric part.
.EXAMPLE
Rename-FilesWithZeroPadding.ps1 -ext "txt"
Renames all files with the extension "txt" in the current folder, padding the numeric part with zeros.
For example: '1.txt', '2.txt', ... '12.txt' -> '01.txt', '02.txt', ... '12.txt'.
.EXAMPLE
Rename-FilesWithZeroPadding.ps1 -Numeral # This set the Numeral switch to false
Renames all files with the default extension "md" in the current folder, in the order of their filenames.
For example: 'file1.md', 'file2.md', ... 'file12.md' -> '01.md', '02.md', ... '12.md'.
#>
param(
[string]$ext = "md",
[switch]$Numeral
)
if ($Numeral) {
$files = $files | Sort-Object { [int]($_.BaseName -replace '\D', '') }
}
else {
$files = Get-ChildItem -Filter "*.$ext" | Sort-Object Name
$fnamecnt = 1
}
$cnt = $files.Count
$paddingLength = $cnt.ToString().Length
foreach ($file in $files) {
if ($Numeral) {
$number = [int]($file.BaseName -replace '\D', '')
$newNumber = $number.ToString().PadLeft($paddingLength, '0')
$newName = "$newNumber.$ext"
}
else {
$newName = ($fnamecnt++).ToString().PadLeft($paddingLength, '0') + ".$ext"
}
Rename-Item -Path $file.FullName -NewName $newName
}

17
home/scripts/Scripts.ps1 Normal file
View file

@ -0,0 +1,17 @@
function CsvToMarkdown {
param( [string]$csv)
$counter = 0
$column = $csv.Split("`n")[0].Split(",").Length
$aHeader = " --- |"
$header = "|" + $aHeader * $column
$csv.replace(",", " | ").Split("`n") | ForEach-Object {
if ($counter -eq 0) {
Write-Output "| $_ |"
$counter++
Write-Output $header
}
else {
Write-Output "| $_ |"
}
}
}

View file

@ -0,0 +1,3 @@
yabai --start-service
skhd --start-service
brew services start sketchybar

View file

@ -0,0 +1,3 @@
yabai --stop-service
skhd --stop-service
brew services stop sketchybar

View file

@ -0,0 +1,3 @@
#!/usr/bin/env bash
curl https://raw.githubusercontent.com/SpaceAceMonkey/dotenv-for-fish/refs/heads/main/dotenv.fish -o "$CHEZMOI_SOURCE_DIR/dot_config/fish/functions/dotenv.fish"

View file

@ -0,0 +1,6 @@
#!/usr/bin/env pwsh
Install-Package PSFzf -Force
Install-Package CompletionPredictor -Force
git clone --depth 1 https://github.com/catppuccin/powershell.git (Join-Path $Env:PSModulePath.Split(':')[0] Catppuccin)

View file

@ -0,0 +1,6 @@
#!/usr/bin/env bash
ya pkg add llanosrocas/yaziline
ya pkg add yazi-rs/plugins:git
ya pkg add Rolv-Apneseth/starship

View file

@ -0,0 +1,10 @@
#!/bin/sh
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}"
test -d "$XDG_CONFIG_HOME/zsh/plugins/zsh-autosuggestions" || git clone --depth 1 https://github.com/zsh-users/zsh-autosuggestions.git "$XDG_CONFIG_HOME/zsh/plugins/zsh-autosuggestions"
test -d "$XDG_CONFIG_HOME/zsh/plugins/zsh-syntax-highlighting" || git clone --depth 1 https://github.com/zsh-users/zsh-syntax-highlighting.git "$XDG_CONFIG_HOME/zsh/plugins/zsh-syntax-highlighting"
test -d "$XDG_CONFIG_HOME/zsh/plugins/zsh-history-substring-search" || git clone --depth 1 https://github.com/zsh-users/zsh-history-substring-search.git "$XDG_CONFIG_HOME/zsh/plugins/zsh-history-substring-search"
test -d "$XDG_CONFIG_HOME/zsh/plugins/zsh-completions" || git clone --depth 1 https://github.com/zsh-users/zsh-completions.git "$XDG_CONFIG_HOME/zsh/plugins/zsh-completions"

View file

@ -0,0 +1,13 @@
#!/bin/sh
XDG_STATE_HOME="${XDG_STATE_HOME:-$HOME/.local/state}"
if [ -f /etc/zshenv ]; then
sudo cp "$CHEZMOI_SOURCE_DIR/dot_config/zsh/global.zshenv" /etc/zshenv
fi
if [ -f /etc/zsh/zshenv ]; then
sudo cp "$CHEZMOI_SOURCE_DIR/dot_config/zsh/global.zshenv" /etc/zsh/zshenv
fi
mkdir -p $XDG_STATE_HOME/zsh

46
home/scripts/update.zsh Normal file
View file

@ -0,0 +1,46 @@
#!/bin/zsh
# $DOTFILES/scripts/update.zsh
# call by `update` alias defined in tools/zsh/alias.zsh
# 使用别名 `update` 引用,别名定义于 tools/zsh/alias.zsh
# Plugins #
# Auto `git pull` on $ZDOTDIR/plugins
for plugin in $ZDOTDIR/plugins/*; do
if [ -d "$plugin" ]; then
cd $plugin
git pull --quiet --no-edit
fi
done
# Update package managers #
# Homebrew, macOS
if command -v brew >/dev/null 2>&1; then
brew update
brew upgrade
fi
# Arch
if command -v pacman >/dev/null 2>&1; then
sudo pacman -Syu
fi
# Debian
if command -v apt >/dev/null 2>&1; then
sudo apt update
sudo apt upgrade
fi
# Fedora
if command -v dnf >/dev/null 2>&1; then
sudo dnf update
fi
# WSL
if command -v winget.exe >/dev/null 2>&1; then
winget.exe upgrade
fi
# macOS - Rime
if [ $(uname) = "Darwin" ]; then
bash ~/plum/rime-install
fi