diff --git a/.gitignore b/.gitignore index 58064ae..bff7cd0 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ nvim/lazyvim.json test/ *.gz *.tar -*.zip \ No newline at end of file +*.zip +*_private/ \ No newline at end of file diff --git a/mac/Microsoft.PowerShell_profile.ps1 b/mac/Microsoft.PowerShell_profile.ps1 index 548d261..8f92c79 100644 --- a/mac/Microsoft.PowerShell_profile.ps1 +++ b/mac/Microsoft.PowerShell_profile.ps1 @@ -2,100 +2,21 @@ $DOTFILES = "$HOME\.dotfiles" -### PSReadLine ### +### Load Configs ### -Set-PSReadLineOption -EditMode vi # Vi Keybindings -Set-PSReadLineOption -PredictionViewStyle ListView # Prediction View Style -Set-PSReadLineOption -PredictionSource HistoryAndPlugin # Prediction Source -Set-PSReadLineOption -ContinuationPrompt "`e[36m CR > " # Continuation Prompt +Get-ChildItem -Path $DOTFILES\powershell -Filter *.ps1 | ForEach-Object {. $_} +Get-ChildItem -Path $DOTFILES\powershell_private -Filter *.ps1 | ForEach-Object {. $_} -### Keybindings ### - -Set-PSReadLineKeyHandler -Chord "Ctrl+f" -Function ForwardWord - -### Navigator ### - -# Relative navigation # - -# ${function:~} = { Set-Location -Path ~ } cd is better -${function:...} = { Set-Location -Path ../.. } -${function:....} = { Set-Location -Path ../../.. } -${function:.....} = { Set-Location -Path ../../../.. } -${function:......} = { Set-Location -Path ../../../../.. } - -# Absolute navigation # - -${function:docs} = { Set-Location -Path ~/Documents } -${function:down} = { Set-Location -Path ~/Downloads } -${function:dt} = { Set-Location -Path ~/Desktop } -${function:mytmp} = { Set-Location -Path ~/Temp } -${function:one} = { Set-Location -Path ~/OneDrive } -${function:doku} = { Set-Location -Path ~/doku && Get-ChildItem } - -### Aliases ### +## Aliases ### # PowerShell Equivalents # -Set-Alias "touch" "New-Item" -Set-Alias "ll" "Get-ChildItem" Set-Alias "curl" "Invoke-WebRequest" Set-Alias "man" "Get-Help" Set-Alias "kill" "Stop-Process" +Set-Alias "open" "Invoke-Item" # Use ii instead of open # Dev # -${function:shcfg} = { code $PROFILE } ${function:zshcfg} = { nvim ~/.zshrc } -${function:bashcfg} = { nvim ~/.bashrc } -${function:reload} = { Invoke-Expression $PROFILE } -${function:csi} = { dotnet script } -${function:pulldots} = { Set-Location -Path $DOTFILES && git pull } -Set-Alias "pwshcfg" "shcfg" -Set-Alias "cl" "clang" -Set-Alias "cl++" "clang++" -Set-Alias "clang" "clang -std=c99" -Set-Alias "clang++" "clang++ -std=c++2b" - -# Python & Conda # - -Set-Alias "python3" "python" -Set-Alias "pip3" "pip" -Set-Alias "py" "python" -Set-Alias "pyact" "conda activate" -Set-Alias "pylsenv" "conda env list" -Set-Alias "pydeact" "conda deactivate" -Set-Alias "pymkenv" "conda create --name" - -# Editors # - -Set-Alias "v" "nvim" -Set-Alias "c" "code" -Set-Alias "gvi" "neovide" - -# Miscs # - -Set-Alias mcd CreateAndSet-Directory - -### Functions ### - -function tc { param ( [string] $filename) - New-Item $filename && code $filename -} - -function tv { param ( [string] $filename) - New-Item $filename && nvim $filename -} - -function cdls { param( [string] $dirname) - Set-Location $dirname && Get-ChildItem -} - - - -### Modules ### - -Import-Module CompletionPredictor -# Import-Module syntax-highlighting - -### Misc ### - +${function:bashcfg} = { nvim ~/.bashrc } \ No newline at end of file diff --git a/mac/readme.md b/mac/readme.md new file mode 100644 index 0000000..e69de29 diff --git a/powershell/bw.ps1 b/powershell/bw.ps1 deleted file mode 100644 index cde2fc4..0000000 --- a/powershell/bw.ps1 +++ /dev/null @@ -1,33 +0,0 @@ -function Get-Password { - param ( - [Parameter(Mandatory = $true)] - [string]$Name, - [Boolean]$Hidden = $true - ) - $result = (bw list items --search $Name | ConvertFrom-Json).login | Select-Object -Property username, password - if ($result.Length -eq 0) { - Write-Host -ForegroundColor Red "No password found" - return - } - elseif ($result.Length -gt 1) { - Write-Host -ForegroundColor Red "More than one password found, please specify" - $counter = 0 - foreach ($username in $result.username) { - Write-Host "["$counter "]" $username - $counter++ - } - $selector = Read-Host -MaskInput "Select the username" - if ($result[$selector] -eq "") { - Write-Host -ForegroundColor Red "Invalid selection" - return - } - $result = $result[$selector] - } - if ($Hidden) { - Write-Host -ForegroundColor Green "Password copied to clipboard" - Set-Clipboard -Value $result.password - } else { - Write-Host $result - } - return $result -} \ No newline at end of file diff --git a/powershell/forex.ps1 b/powershell/forex.ps1 deleted file mode 100644 index 52664d4..0000000 --- a/powershell/forex.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -$_userForexToday = (Get-Content ~/.forex | ConvertFrom-Json).conversion_rates - -function Update-ForexData { - ((Invoke-WebRequest "$_userForexUrl").Content | ConvertFrom-Json).conversion_rates > ~/.forex -} -function Get-ExchangeRate { - param ( - [string] $From, - [string] $To = "CNY", - [double] $Value = 1 - ) - if (-not $from) { - Get-ForexOverview - return - } - Write-Host $From : $To " " -NoNewline -ForegroundColor DarkGreen - ($Value * ($_userForexToday.$To / $_userForexToday.$From)) | Write-Host -ForegroundColor DarkBlue -} - -function Get-ForexOverview { - Get-ExchangeRate -From GBP -To CNY -Value 1 - Get-ExchangeRate -From USD -To CNY -Value 1 - Get-ExchangeRate -From HKD -To CNY -Value 1 - Get-ExchangeRate -From EUR -To CNY -Value 1 - Get-ExchangeRate -From CNY -To JPY -Value 1 -} - -Set-Alias "forex" "Get-ExchangeRate" \ No newline at end of file diff --git a/powershell/shared.ps1 b/powershell/shared.ps1 new file mode 100644 index 0000000..16de582 --- /dev/null +++ b/powershell/shared.ps1 @@ -0,0 +1,86 @@ +### PSReadLine ### + +Set-PSReadLineOption -EditMode vi # Vi Keybindings +Set-PSReadLineOption -PredictionViewStyle ListView +Set-PSReadLineOption -PredictionSource HistoryAndPlugin +Set-PSReadLineOption -ContinuationPrompt "`e[36m CR > " + +### Keybindings ### + +Set-PSReadLineKeyHandler -Chord "Ctrl+Shift+f" -Function ForwardWord +Set-PSReadLineKeyHandler -Chord "Ctrl+Shift+b" -Function BackwardWord +Set-PSReadLineKeyHandler -Chord "Alt+f" -Function ForwardChar +Set-PSReadLineKeyHandler -Chord "Ctrl+b" -Function BackwardChar +Set-PSReadLineKeyHandler -Chord "Ctrl+p" -Function HistorySearchBackward +Set-PSReadLineKeyHandler -Chord "Ctrl+n" -Function HistorySearchForward +Set-PSReadLineKeyHandler -Chord "Ctrl+a" -Function BeginningOfLine +Set-PSReadLineKeyHandler -Chord "Ctrl+e" -Function EndOfLine + +### Navigator ### + +# Relative navigation # + +# ${function:~} = { Set-Location -Path ~ } cd is better +${function:...} = { Set-Location -Path ..\.. } +${function:....} = { Set-Location -Path ..\..\.. } +${function:.....} = { Set-Location -Path ..\..\..\.. } +${function:......} = { Set-Location -Path ..\..\..\..\.. } + +# Absolute navigation # + +${function:docs} = { Set-Location -Path ~/Documents } +${function:down} = { Set-Location -Path ~/Downloads } +${function:dt} = { Set-Location -Path ~/Desktop } +${function:mytmp} = { Set-Location -Path ~/Temp } +${function:one} = { Set-Location -Path ~/OneDrive } +${function:doku} = { Set-Location -Path ~/doku && Get-ChildItem } + +### Alias ### + +# Shell Equivalents # + +Set-Alias "touch" "New-Item" +${function:ll} = { Get-ChildItem -Force } + +# Shell Configurations # + +${function:shcfg} = { code $PROFILE } +Set-Alias "pwshcfg" "shcfg" +${function:reload} = { . $PROFILE } +${function:pulldots} = { Set-Location -Path $DOTFILES && git pull } + +# Editors # + +Set-Alias "v" "nvim" +Set-Alias "c" "code" +Set-Alias "gvi" "neovide" + +# File Creation # + +function mkcd { param ( [string] $dirname) mkdir $dirname && Set-Location $dirname } +function tc { param ( [string] $filename) New-Item $filename && code $filename } +function tv { param ( [string] $filename) New-Item $filename && nvim $filename } +function cdls { param( [string] $dirname) Set-Location $dirname && Get-ChildItem } + +### Dev ### + +# .NET # + +${function:csi} = { dotnet repl --default-kernel csharp} +${function:fsi} = { dotnet repl --default-kernel fsharp} + +# Python & Conda # + +Set-Alias "py" "python" +${function:pyact} = { conda activate $args[0] } +${function:pydact} = { conda deactivate } +${function:pylsenvs} = { conda env list } +${function:pymkenv} = { conda create --name $args[0] } +${function:pyrmenv} = { conda remove --name $args[0] --all } + +# C & C++ # + + +### Modules ### + +Import-Module CompletionPredictor \ No newline at end of file diff --git a/readme.md b/readme.md index ea90b33..6fd7612 100644 --- a/readme.md +++ b/readme.md @@ -4,6 +4,7 @@ - [Windows](./win/readme.md) - [Linux](./linux/readme.md) +- [Mac](./mac/readme.md) - [Neovim](./nvim/readme.md) - [VSCode](./vscode/readme.md) @@ -14,10 +15,5 @@ - [pip](./pip.conf) - [npm](./.npmrc) +- [conda](./.condarc) - -### Scripts - -- [Install Neovim *nix](./install_nvim.sh) -- [Set Mirror *nix](./set_mirror.sh) -- [Set Mirror PowerShell](./set_mirror.ps1) \ No newline at end of file diff --git a/win/Microsoft.PowerShell_profile.ps1 b/win/Microsoft.PowerShell_profile.ps1 index 8cd0628..a98c81f 100644 --- a/win/Microsoft.PowerShell_profile.ps1 +++ b/win/Microsoft.PowerShell_profile.ps1 @@ -5,56 +5,13 @@ $DOTFILES = "$HOME\Documents\.dotfiles" ### Load Configs ### Get-ChildItem -Path $DOTFILES\powershell -Filter *.ps1 | ForEach-Object {. $_} - -### PSReadLine ### - -Set-PSReadLineOption -EditMode vi # Vi Keybindings -Set-PSReadLineOption -PredictionViewStyle ListView # Prediction View Style -Set-PSReadLineOption -PredictionSource HistoryAndPlugin # Prediction Source -Set-PSReadLineOption -ContinuationPrompt "`e[36m CR > " # Continuation Prompt - -### Keybindings ### - -Set-PSReadLineKeyHandler -Chord "Ctrl+Shift+f" -Function ForwardWord -Set-PSReadLineKeyHandler -Chord "Ctrl+Shift+b" -Function BackwardWord -Set-PSReadLineKeyHandler -Chord "Alt+f" -Function ForwardChar -Set-PSReadLineKeyHandler -Chord "Ctrl+b" -Function BackwardChar -Set-PSReadLineKeyHandler -Chord "Ctrl+p" -Function HistorySearchBackward -Set-PSReadLineKeyHandler -Chord "Ctrl+n" -Function HistorySearchForward -Set-PSReadLineKeyHandler -Chord "Ctrl+a" -Function BeginningOfLine -Set-PSReadLineKeyHandler -Chord "Ctrl+e" -Function EndOfLine - -### Navigator ### - -# Relative navigation # - -# ${function:~} = { Set-Location -Path ~ } cd is better -${function:...} = { Set-Location -Path ..\.. } -${function:....} = { Set-Location -Path ..\..\.. } -${function:.....} = { Set-Location -Path ..\..\..\.. } -${function:......} = { Set-Location -Path ..\..\..\..\.. } - -# Absolute navigation # - -${function:docs} = { Set-Location -Path ~\Documents } -${function:down} = { Set-Location -Path ~\Downloads } -${function:dt} = { Set-Location -Path ~\Desktop } -${function:mytmp} = { Set-Location -Path ~\Temporary } -${function:one} = { Set-Location -Path ~\OneDrive } -${function:doku} = { Set-Location -Path ~\MyDocuments && Get-ChildItem } +Get-ChildItem -Path $DOTFILES\powershell_private -Filter *.ps1 | ForEach-Object {. $_} ### Aliases ### # Shell Equivalents # -Set-Alias "touch" "New-Item" -function open { - if ($args.Count -eq 0) { - explorer.exe . - } else { - explorer.exe $args[0] - } -} +Set-Alias "open" "Invoke-Item" # Use ii instead of explorer.exe # Shell Configurations # @@ -62,11 +19,6 @@ ${function:shcfg} = { code $PROFILE } ${function:reload} = { . $PROFILE } ${function:pulldots} = { Set-Location -Path $DOTFILES && git pull } Set-Alias "pwshcfg" "shcfg" - -# Dotnet # - -${function:csi} = { dotnet script } - # C & C++ # # Set-Alias "cl" "clang" @@ -78,13 +30,8 @@ ${function:csi} = { dotnet script } Set-Alias "python3" "python" Set-Alias "pip3" "pip" -Set-Alias "py" "python" -${function:pyact} = { conda activate $args[0] } -${function:pylsenvs} = { conda env list } -${function:pydact} = { conda deactivate } -${function:pymkenv} = { conda create --name $args[0] } -# # Git # +# Git # # Set-Alias "g" "git" # Set-Alias "ginit" "git init" @@ -104,26 +51,14 @@ ${function:pymkenv} = { conda create --name $args[0] } ${function:wsl1} = {wsl.exe --distribution Debian} ${function:wsl2} = {wsl.exe --distribution Ubuntu-22.04} -# Editors # - -Set-Alias "v" "nvim" -Set-Alias "c" "code" -Set-Alias "gvi" "neovide" # Miscs # - -### Functions ### - -function mkcd { param ( [string] $dirname) mkdir $dirname && Set-Location $dirname} -function tc { param ( [string] $filename) New-Item $filename && code $filename } -function tv { param ( [string] $filename) New-Item $filename && nvim $filename } -function cdls { param( [string] $dirname) Set-Location $dirname && Get-ChildItem } - ### Modules ### Import-Module -Name Microsoft.WinGet.CommandNotFound #f45873b3-b655-43a6-b217-97c00aa0db58 Import-Module CompletionPredictor +# Import-Module syntax-highlighting # Buggy ### Misc ###