diff --git a/.config/ipython/profile_default/ipython_config.py b/.config/ipython/profile_default/ipython_config.py new file mode 100644 index 0000000..889258b --- /dev/null +++ b/.config/ipython/profile_default/ipython_config.py @@ -0,0 +1,43 @@ +c.TerminalIPythonApp.display_banner = True +c.TerminalInteractiveShell.editing_mode = 'vi' +c.TerminalInteractiveShell.confirm_exit = False + +# Source: https://ipython.readthedocs.io/en/stable/config/details.html#keyboard-shortcuts +def custom_return(shell): + + """This function is required by the API. It takes a reference to + the shell, which is the same thing `get_ipython()` evaluates to. + This function must return a function that handles each keypress + event. That function, named `handle` here, references `shell` + by closure.""" + + def handle(event): + + """This function is called each time `Enter` is pressed, + and takes a reference to a Prompt Toolkit event object. + If the current input starts with a bang or modulo, then + the input is executed, otherwise a newline is entered, + followed by any spaces needed to auto-indent.""" + + # set up a few handy references to nested items... + + buffer = event.current_buffer + document = buffer.document + text = document.text + + if text.startswith('!') or text.startswith('%'): # execute the input... + + buffer.accept_action.validate_and_handle(event.cli, buffer) + + else: # insert a newline with auto-indentation... + + if document.line_count > 1: text = text[:document.cursor_position] + indent = shell.check_complete(text)[1] + buffer.insert_text('\n' + indent) + + # if you just wanted a plain newline without any indentation, you + # could use `buffer.insert_text('\n')` instead of the lines above + + return handle + +c.TerminalInteractiveShell.handle_return = custom_return \ No newline at end of file diff --git a/.config/ipython/profile_default/starup/keymap.py b/.config/ipython/profile_default/starup/keymap.py new file mode 100644 index 0000000..2dae6da --- /dev/null +++ b/.config/ipython/profile_default/starup/keymap.py @@ -0,0 +1,69 @@ +from prompt_toolkit.key_binding import KeyBindings +from prompt_toolkit.key_binding.vi_state import InputMode +from prompt_toolkit.filters import Condition +from IPython import get_ipython + +ip = get_ipython() +key_bindings = KeyBindings() + +@Condition +def in_navigation_mode(): + return ip.pt_app.app.vi_state.input_mode == InputMode.NAVIGATION + +# colemak keymap hnei +@key_bindings.add("n", filter=in_navigation_mode) +def _(event): + "Move cursor down by visual line" + event.current_buffer.auto_down(count=event.arg) + +@key_bindings.add("e", filter=in_navigation_mode) +def _(event): + "Move cursor up by visual line" + event.current_buffer.auto_up(count=event.arg) + +@key_bindings.add("i", filter=in_navigation_mode) +def _(event): + "Move cursor right" + event.current_buffer.cursor_right(count=event.arg) + +# Insert with 'l' and 'L' +@key_bindings.add("l", filter=in_navigation_mode) +def _(event): + "Enter insert mode (similar position to 'i' in Colemak)" + event.app.vi_state.input_mode = InputMode.INSERT + +@key_bindings.add("L", filter=in_navigation_mode) +def _(event): + "Enter insert mode at the beginning of the line" + event.current_buffer.cursor_position += event.current_buffer.document.get_start_of_line_position() + +# Ne[k]st +@key_bindings.add("k", filter=in_navigation_mode) +def _(event): + "Find next match" + event.current_buffer.forward_search() + +@key_bindings.add("K", filter=in_navigation_mode) +def _(event): + "Find previous match" + event.current_buffer.reverse_search() + +# [J]ump +@key_bindings.add("j", filter=in_navigation_mode) +def _(event): + "Move to end of next word" + event.current_buffer.cursor_right_word() + +@key_bindings.add("J", filter=in_navigation_mode) +def _(event): + "Move to end of next word with capital E" + event.current_buffer.cursor_right_word(end=True) + +# Yank to end of line with 'Y' +@key_bindings.add("Y", filter=in_navigation_mode) +def _(event): + "Yank to the end of the line" + text_to_yank = event.current_buffer.document.text_after_cursor + event.app.clipboard.set_text(text_to_yank) + +ip.pt_app.key_bindings = key_bindings diff --git a/.config/ipython/profile_default/starup/magic_ps.py b/.config/ipython/profile_default/starup/magic_ps.py new file mode 100644 index 0000000..d4c5e8a --- /dev/null +++ b/.config/ipython/profile_default/starup/magic_ps.py @@ -0,0 +1,10 @@ +from IPython.core.magic import register_line_magic + +@register_line_magic +def ps(cmd): + output = get_ipython().getoutput(f"powershell -Command {cmd}") + # If no variable is assigned to the output, print it + if get_ipython().last_execution_result is None: + print("\n".join(output)) + else: + return "\n".join(output) diff --git a/.config/lesskey b/.config/lesskey index 150eebe..c497024 100644 --- a/.config/lesskey +++ b/.config/lesskey @@ -1,6 +1,6 @@ # $XDG_CONFIG_HOME/lesskey -- less options # ln -sf $DOTFILES/.config/lesskey $XDG_CONFIG_HOME/lesskey -# Ne +# work for less -V > 582, for mac, use brew install less to override the system less # Format: key action diff --git a/.config/npm/npmrc b/.config/npm/npmrc index 042f19c..222bca4 100644 --- a/.config/npm/npmrc +++ b/.config/npm/npmrc @@ -1,4 +1,6 @@ # export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME"/npm/npmrc +# =========================================================== # $XDG_CONFIG_HOME/npm/npmrc # ln -s $DOTFILES/.config/npm/npmrc $NPM_CONFIG_USERCONFIG +# New-Item -ItemType SymbolicLink -Path $env:NPM_CONFIG_USERCONFIG -Value $env:DOTFILES/.config/npm/npmrc # registry=https://registry.npmmirror.com diff --git a/.config/vim/vimrc b/.config/vim/vimrc index 330e59b..c29f0de 100644 --- a/.config/vim/vimrc +++ b/.config/vim/vimrc @@ -34,6 +34,9 @@ set incsearch set ignorecase set smartcase +set number +set relativenumber + " XDG Directory Specifications " Reference to https://jorenar.com/blog/vim-xdg diff --git a/.gitignore b/.gitignore index 7aadea2..537db61 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,10 @@ *private* .private.env.* +.config/ipython/profile_default/db +.config/ipython/profile_default/log +.config/ipython/profile_default/pid +.config/ipython/profile_default/security +.config/ipython/profile_default/history.sqlite .config/nvim/tt.* .config/nvim/.tests .config/nvim/doc/tags diff --git a/powershell/Config.ps1 b/powershell/Config.ps1 new file mode 100644 index 0000000..cf8f566 --- /dev/null +++ b/powershell/Config.ps1 @@ -0,0 +1,7 @@ +# Use XDG Base Directory Specification and its similar structure for Windows + +# wget +${function:wget} = {wget --hsts-file $XDG_CACHE_HOME/wget-hsts $args} + +# yarn v1 +${function:yarn} = {yarn --use-yarnrc $XDG_CONFIG_HOME/yarn/config.yaml $args} \ No newline at end of file diff --git a/mac/mac_setup.sh b/setup/mac_setup.sh similarity index 86% rename from mac/mac_setup.sh rename to setup/mac_setup.sh index 6a921bf..770fa92 100644 --- a/mac/mac_setup.sh +++ b/setup/mac_setup.sh @@ -1,8 +1,8 @@ -#! /bin/zsh +#! /bin/sh # This script is used to setup a new mac # In a new mac (Sequoia) # Enter the following command in the terminal -#! curl -fsSL https://raw.githubusercontent.com/js0ny/dotfiles/refs/heads/master/mac/mac_setup.sh | sh +#! curl -fsSL https://raw.githubusercontent.com/js0ny/dotfiles/refs/heads/master/setup/mac_setup.sh | sh # Do not use this command echo "Running the setup script" @@ -80,30 +80,10 @@ rm -f ~/.zshrc ~/.zprofile ~/.zsh_history ~/.zshenv rm -rf ~/.zsh_sessions echo "[INFO] Setting Up dotfiles" -mkdir -p $XDG_CONFIG_HOME/conda $XDG_CONFIG_HOME/git $XDG_CONFIG_HOME/ideavim $XDG_CONFIG_HOME/markdownlint $XDG_CONFIG_HOME/pip $XDG_CONFIG_HOME/neovide $XDG_CONFIG_HOME/powershell $XDG_CONFIG_HOME/vscode $XDG_CONFIG_HOME/NuGet $XDG_CONFIG_HOME/vim $XDG_CONFIG_HOME/tmux $XDG_CONFIG_HOME/npm -mkdir -p ~/.config/zellij # Not support XDG_CONFIG_HOME but same directory -mkdir -p $WAKATIME_HOME -mkdir -p $XDG_STATE_HOME/vim/undo $XDG_STATE_HOME/vim/backup $XDG_STATE_HOME/vim/swap $XDG_STATE_HOME/vim/view -# $DOTFILES/.config -ln -sf $DOTFILES/.config/conda/condarc.yaml $XDG_CONFIG_HOME/conda/.condarc -ln -sf $DOTFILES/.config/git/.gitconfig $XDG_CONFIG_HOME/git/config -ln -sf $DOTFILES/.config/ideavim/ideavimrc.vimrc $XDG_CONFIG_HOME/ideavim/ideavimrc -ln -sf $DOTFILES/.config/markdownlint/.markdownlint.json $XDG_CONFIG_HOME/markdownlint/markdownlint.json -ln -sf $DOTFILES/.config/npm/npmrc $NPM_CONFIG_USERCONFIG -ln -sf $DOTFILES/.config/NuGet/NuGet.Config $XDG_CONFIG_HOME/NuGet/NuGet.Config -ln -sf $DOTFILES/.config/nvim/ $XDG_CONFIG_HOME/nvim -ln -sf $DOTFILES/.config/pip/pip.conf $XDG_CONFIG_HOME/pip/pip.conf -ln -sf $DOTFILES/.config/tmux/tmux.conf $XDG_CONFIG_HOME/tmux/tmux.conf -ln -sf $DOTFILES/.config/vim/vimrc $XDG_CONFIG_HOME/vim/vimrc -ln -sf $DOTFILES/.config/zellij/config.kdl ~/.config/zellij/config.kdl -ln -sf $DOTFILES/.config/lesskey $XDG_CONFIG_HOME/lesskey +. $DOTFILES/setup/set_symblink_unix.sh # $DOTFILES/mac ln -sf $DOTFILES/mac/neovide.toml $XDG_CONFIG_HOME/neovide/config.toml ln -sf $DOTFILES/mac/Microsoft.PowerShell_profile.ps1 $XDG_CONFIG_HOME/powershell/Microsoft.PowerShell_profile.ps1 -# $DOTFILES/vscode -ln -sf $DOTFILES/vscode/vscode.vimrc $XDG_CONFIG_HOME/vscode.vimrc -# $DOTFILES root -ln -sf $DOTFILES/.haskeline ~/.haskeline # Brew echo "[INFO] Installing Homebrew" diff --git a/setup/set_symblink_unix.sh b/setup/set_symblink_unix.sh new file mode 100644 index 0000000..c038b3e --- /dev/null +++ b/setup/set_symblink_unix.sh @@ -0,0 +1,22 @@ +#! /bin/sh +mkdir -p $XDG_CONFIG_HOME/conda $XDG_CONFIG_HOME/git $XDG_CONFIG_HOME/ideavim $XDG_CONFIG_HOME/markdownlint $XDG_CONFIG_HOME/pip $XDG_CONFIG_HOME/neovide $XDG_CONFIG_HOME/powershell $XDG_CONFIG_HOME/vscode $XDG_CONFIG_HOME/NuGet $XDG_CONFIG_HOME/vim $XDG_CONFIG_HOME/tmux $XDG_CONFIG_HOME/npm +mkdir -p ~/.config/zellij # Not support XDG_CONFIG_HOME but same directory +mkdir -p $WAKATIME_HOME +mkdir -p $XDG_STATE_HOME/vim/undo $XDG_STATE_HOME/vim/backup $XDG_STATE_HOME/vim/swap $XDG_STATE_HOME/vim/view +# $DOTFILES/.config +ln -sf $DOTFILES/.config/conda/condarc.yaml $XDG_CONFIG_HOME/conda/.condarc +ln -sf $DOTFILES/.config/git/.gitconfig $XDG_CONFIG_HOME/git/config +ln -sf $DOTFILES/.config/ideavim/ideavimrc.vimrc $XDG_CONFIG_HOME/ideavim/ideavimrc +ln -sf $DOTFILES/.config/markdownlint/.markdownlint.json $XDG_CONFIG_HOME/markdownlint/markdownlint.json +ln -sf $DOTFILES/.config/npm/npmrc $NPM_CONFIG_USERCONFIG +ln -sf $DOTFILES/.config/NuGet/NuGet.Config $XDG_CONFIG_HOME/NuGet/NuGet.Config +ln -sf $DOTFILES/.config/nvim/ $XDG_CONFIG_HOME/nvim +ln -sf $DOTFILES/.config/pip/pip.conf $XDG_CONFIG_HOME/pip/pip.conf +ln -sf $DOTFILES/.config/tmux/tmux.conf $XDG_CONFIG_HOME/tmux/tmux.conf +ln -sf $DOTFILES/.config/vim/vimrc $XDG_CONFIG_HOME/vim/vimrc +ln -sf $DOTFILES/.config/zellij/config.kdl ~/.config/zellij/config.kdl +ln -sf $DOTFILES/.config/lesskey $XDG_CONFIG_HOME/lesskey +# $DOTFILES/vscode +ln -sf $DOTFILES/vscode/vscode.vimrc $XDG_CONFIG_HOME/vscode.vimrc +# $DOTFILES root +ln -sf $DOTFILES/.haskeline ~/.haskeline \ No newline at end of file diff --git a/setup/win_setup.ps1 b/setup/win_setup.ps1 new file mode 100644 index 0000000..8ae2e8d --- /dev/null +++ b/setup/win_setup.ps1 @@ -0,0 +1,263 @@ +#!C:\Program Files\WindowsApps\Microsoft.PowerShell_7.4.6.0_x64__8wekyb3d8bbwe\pwsh.EXE +# Run with PowerShell 7 +winget install -e --id Git.Git +git clone https://github.com/js0ny/dotfiles.git ~\.dotfiles +Set-Location -Path ~\.dotfiles +Remove-Item -Force $PROFILE +$DOTFILES = "$HOME\.dotfiles" +New-Item -ItemType SymbolicLink -Path $PROFILE -Target "$DOTFILES\win\Microsoft.PowerShell_profile.ps1" +. $PROFILE +# Install Scoop +Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser +Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression +# Install Chocolatey +# Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) + +# Set Environment Variables +# Use %PATH_EXT% to prevent PATH from being too long +[System.Environment]::SetEnvironmentVariable("Path_EXT_0", "D:\bin", "User") +[System.Environment]::SetEnvironmentVariable("Path_EXT_1", "", "User") +[System.Environment]::SetEnvironmentVariable("Path_EXT_2", "", "User") +$currentPath = [System.Environment]::GetEnvironmentVariable("Path", "User") +if ($currentPath -notlike "*%PATH_EXT%*") { + $currentPath += ";%PATH_EXT_0%;%PATH_EXT_1%;%PATH_EXT_2%" +} +[System.Environment]::SetEnvironmentVariable("Path", $currentPath, "User") +[System.Environment]::SetEnvironmentVariable("PATH_EXT_0", "", [System.EnvironmentVariableTarget]::Machine) +[System.Environment]::SetEnvironmentVariable("PATH_EXT_1", "", [System.EnvironmentVariableTarget]::Machine) +[System.Environment]::SetEnvironmentVariable("PATH_EXT_2", "", [System.EnvironmentVariableTarget]::Machine) +$currentPath = [System.Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine) +if ($currentPath -notlike "*%PATH_EXT%*") { + $currentPath += ";%PATH_EXT_0%;%PATH_EXT_1%;%PATH_EXT_2%" +} +[System.Environment]::SetEnvironmentVariable("Path", $currentPath, [System.EnvironmentVariableTarget]::Machine) +# Simulate XDG Base Directory Specification +$Env:XDG_CONFIG_HOME = "$Env:AppData" +$Env:XDG_DATA_HOME = "$Env:LocalAppData" +$Env:XDG_CACHE_HOME = "$Env:LocalAppData\cache" +$Env:XDG_STATE_HOME = "$Env:LocalAppData\state" +[System.Environment]::SetEnvironmentVariable("XDG_CONFIG_HOME", "$Env:XDG_CONFIG_HOME", "User") +[System.Environment]::SetEnvironmentVariable("XDG_DATA_HOME", "$Env:XDG_DATA_HOME", "User") +New-Item -ItemType Directory -Path "$Env:LocalAppData\cache" -Force +[System.Environment]::SetEnvironmentVariable("XDG_CACHE_HOME", "$Env:XDG_CACHE_HOME", "User") +New-Item -ItemType Directory -Path "$Env:LocalAppData\state" -Force +[System.Environment]::SetEnvironmentVariable("XDG_STATE_HOME", "$Env:XDG_STATE_HOME", "User") +# Add environment variables +[System.Environment]::SetEnvironmentVariable("DOTFILES", "$DOTFILES", "User") +# Set potential environment variables to prevent softwares put their configs in the wrong place +# eg. dotfiles in %UserProfile% +# ~\.aws -> %AppData%\aws :: AWS CLI +New-Item -ItemType Directory -Path "$Env:AppData\aws" -Force +[System.Environment]::SetEnvironmentVariable("AWS_CONFIG_FILE", "$Env:AppData\aws\config", "User") +[System.Environment]::SetEnvironmentVariable("AWS_SHARED_CREDENTIALS_FILE", "$Env:AppData\aws\credentials", "User") +# ~\.azure -> %LocalAppData%\Azure :: Azure CLIcargo install --list +[System.Environment]::SetEnvironmentVariable("AZURE_CONFIG_DIR", "$Env:LocalAppData\Azure", "User") +# ~\.cargo -> %LocalAppData%\Cargo :: Rust https://doc.rust-lang.org/cargo/guide/cargo-home.html +[System.Environment]::SetEnvironmentVariable("CARGO_HOME", "$Env:LocalAppData\Cargo", "User") +# ~\.docker -> %AppData%\dotDocker :: Docker (Docker takes %AppData%\Docker, use dotDocker instead) +[System.Environment]::SetEnvironmentVariable("DOCKER_CONFIG", "$Env:AppData\dotDocker", "User") +# ~\.dotnet -> %LocalAppData%\dotNET :: .NET Core +[System.Environment]::SetEnvironmentVariable("DOTNET_CLI_HOME", "$Env:LocalAppData\dotNET", "User") +# ~\.emacs.d -> %AppData%\.emacs.d :: Emacs (This is default) +# [System.Environment]::SetEnvironmentVariable("EMACS_HOME", "$Env:AppData\emacs.d", "User") +# ~\go -> %LocalAppData%\GO :: golang +[System.Environment]::SetEnvironmentVariable("GOPATH", "$Env:LocalAppData\GO", "User") +# ~\.ipython -> %AppData%\ipython :: IPython +# IPython won't check XDG on Windows https://github.com/ipython/ipython/blob/0615526f80691452f2e282c363bce197c0141561/IPython/utils/path.py#L200 +[System.Environment]::SetEnvironmentVariable("IPYTHONDIR", "$Env:AppData\ipython", "User") +# ~\.julia -> %LocalAppData%\julia :: Julia +[System.Environment]::SetEnvironmentVariable("JULIA_DEPOT_PATH", "$Env:LocalAppData\julia", "User") +# ~\_lesshst -> %LocalAppData%\state\lesshst :: less +[System.Environment]::SetEnvironmentVariable("LESSHISTFILE", "$Env:XDG_STATE_HOME\lesshst", "User") +# %AppData%\less\lesskey :: less +New-Item -ItemType Directory -Path "$Env:AppData\less" -Force +[System.Environment]::SetEnvironmentVariable("LESSKEYIN", "$Env:AppData\less\lesskey", "User") +# ~\.matplotlib -> %LocalAppData%\matplotlib :: Matplotlib +[System.Environment]::SetEnvironmentVariable("MPLCONFIGDIR", "$Env:LocalAppData\matplotlib", "User") +# ~\.npmrc -> %AppData%\npm\npmrc :: npm +[System.Environment]::SetEnvironmentVariable("NPM_CONFIG_USERCONFIG", "$Env:AppData\npm\npmrc", "User") +# ~\.node_repl_history -> %LocalAppData%\state\node\repl_history :: Node.js +New-Item -ItemType Directory -Path "$Env:XDG_STATE_HOME\node" -Force +[System.Environment]::SetEnvironmentVariable("NODE_REPL_HISTORY", "$Env:XDG_STATE_HOME\node\repl_history", "User") +# ~\.ts_node_repl_history -> %LocalAppData%\state\node\ts_node_repl_history :: Node.js +[System.Environment]::SetEnvironmentVariable("TS_NODE_REPL_HISTORY", "$Env:XDG_STATE_HOME\node\ts_node_repl_history", "User") +# ~\.nuget\packages -> %LocalAppData%\cache\NuGet\packages :: NuGet +[System.Environment]::SetEnvironmentVariable("NUGET_PACKAGES", "$Env:XDG_CACHE_HOME\NuGet\packages", "User") +# ~\.omnisharp -> %AppData%\OmniSharp :: OmniSharp +[System.Environment]::SetEnvironmentVariable("OMNISHARPHOME", "$Env:AppData\OmniSharp", "User") +# ~\.python_history -> %LocalAppData%\state\python\python_history :: Python +# Only works for Python 3.13+ https://docs.python.org/3.13/using/cmdline.html#envvar-PYTHON_HISTORY +New-Item -ItemType Directory -Path "$Env:XDG_STATE_HOME\python" -Force +[System.Environment]::SetEnvironmentVariable("PYTHON_HISTORY", "$Env:XDG_STATE_HOME\python\python_history", "User") +# ~\.rustup -> %LocalAppData%\Rustup :: Rust +[System.Environment]::SetEnvironmentVariable("RUSTUP_HOME", "$Env:LocalAppData\Rustup", "User") +# ~\.vimrc -> %AppData%\Vim\_vimrc :: Vim +New-Item -ItemType Directory -Path "$Env:AppData\Vim" -Force +[System.Environment]::SetEnvironmentVariable("VIM", "$Env:AppData\Vim", "User") +# ~\.vuerc -> %AppData%\vue\.vuerc :: Vue CLI +# Currently, Vue CLI doesn't support file path configuration:https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli/lib/confifile +# [System.Environment]::SetEnvironmentVariable("VUE_CLI_CONFIG_PATH", "$Env:AppData\vue\.vuerc", "User") +# ~\.wget-hsts -> %LocalAppData%\cache\wget-hsts :: wget +# Use Alias, wget host file path is not configurable +# ~\.yarnrc -> %AppData%\yarn\config.yaml :: Yarn v1 +# Use Alias, yarnrc path is not configurable + +# Reload required here to make sure the environment variables are set + + +# Set Dotfiles +# $DOTFILES\.config +$folders = @("conda", "git", "ideavim", "ipython", "markdownlint", "npm", "NuGet", "nvim", "pip", "Vim") +foreach ($folder in $folders) { + New-Item -ItemType Directory -Path "$Env:XDG_CONFIG_HOME\$folder" -Force +} +New-Item -ItemType SymbolicLink -Path "$Env:XDG_CONFIG_HOME\conda\.condarc" -Target "$DOTFILES\.config\conda\condarc.yaml" -Force +New-Item -ItemType SymbolicLink -Path "$Env:XDG_CONFIG_HOME\git\config" -Target "$DOTFILES\.config\git\.gitconfig" -Force +New-Item -ItemType SymbolicLink -Path "~\.haskeline" -Target "$DOTFILES\.haskeline" -Force +New-Item -ItemType SymbolicLink -Path "$Env:XDG_CONFIG_HOME\ideavim\.ideavimrc" -Target "$DOTFILES\.config\ideavim\.ideavimrc" -Force +New-Item -ItemType SymbolicLink -Path "$Env:XDG_CONFIG_HOME\ipython" -Target "$DOTFILES\.config\ipython" -Force +# New-Item -ItemType SymbolicLink -Path "~\.markdownlint.json" -Target "$DOTFILES\.markdownlint.json" -Force +New-Item -ItemType SymbolicLink -Path "$Env:XDG_CONFIG_HOME\npm\npmrc" -Target "$DOTFILES\.config\npm\npmrc" -Force +New-Item -ItemType SymbolicLink -Path "$Env:AppData\NuGet\NuGet.Config" -Target "$DOTFILES\.config\NuGet\NuGet.Config" -Force +New-Item -ItemType SymbolicLink -Path "$Env:XDG_CONFIG_HOME\nvim" -Target "$DOTFILES\.config\nvim" -Force +New-Item -ItemType SymbolicLink -Path "$Env:AppData\pip\pip.ini" -Target "$DOTFILES\.config\pip\pip.conf" -Force +New-Item -ItemType SymbolicLink -Path "$Env:XDG_CONFIG_HOME\Vim\_vimrc" -Target "$DOTFILES\.config\vim\vimrc" -Force +New-Item -ItemType SymbolicLink -Path "~\.wslconfig" -Target "$DOTFILES\win\.wslconfig" -Force +New-Item -ItemType SymbolicLink -Path "$Env:AppData\neovide\config.toml" -Target "$DOTFILES\win\neovide.toml" -Force +# New-Item -ItemType SymbolicLink -Path "~\.vscode.vimrc" -Target "$DOTFILES\vscode\vscode.vimrc" Use Absolute Path +# Hide dotfiles +Get-ChildItem -Force -Filter .* -Path $HOME | ForEach-Object { $_.Attributes += "Hidden" } +@( + Join-Path $HOME '.config' + Join-Path $HOME '.dotfiles' +) | ForEach-Object { + $_.Attributes -band -bnot [System.IO.FileAttributes]::Hidden +} +Set-Location $HOME\Documents +# Match WindowsPowerShell and PowerShell +Get-ChildItem -Force -Filter *owerShell | ForEach-Object { $_.Attributes += "Hidden" } + +# Windows Terminal +if (Get-Command wt -ErrorAction SilentlyContinue) { + Write-Output "Windows Terminal (wt) installed" +} else { + winget install -e --id Microsoft.WindowsTerminal +} + +# Uninstall Windows Apps +Get-AppxPackage *solit* | Remove-AppxPackage # 纸牌 +Get-AppxPackage *sound* | Remove-AppxPackage # 錄音機 +Get-AppxPackage *camera* | Remove-AppxPackage # 相機 +Get-AppxPackage *weather* | Remove-AppxPackage # 天氣 +Get-AppxPackage *Map* | Remove-AppxPackage # 地圖 +# Get-AppxPackage *clipchamp* | Remove-AppxPackage # 其實這個還行 + +# Added Packages +scoop bucket add main +scoop bucket add nerd-fonts +scoop bucket add extras +scoop bucket add nonportable + +# CLI Tools +# winget install -e --id GnuWin32.Grep # Use Select-String instead +scoop install main/make +# winget install -e --id GnuWin32.Which # Use Get-Command instead +scoop install main/fzf +scoop install main/ripgrep +scoop install main/wget +scoop install main/wget2 +scoop install main/cmake +scoop install main/bat +scoop install main/zoxide +scoop install main/dos2unix + +# File Management +scoop install extras/everything +scoop install main/7zip +scoop install extras/bandizip +scoop install main/pandoc +scoop install extras/sumatrapdf +winget install -e --id Google.GoogleDrive + +# System Enhancements +scoop install extras/fancontrol +scoop install extras/powertoys +scoop install extras/msiafterburner +winget install -e --id Yuanli.uTools +scoop install extras/geekuninstaller +scoop install extras/flow-launcher +# winget install -e --id AutoHotkey.AutoHotkey +scoop install extras/autohotkey +scoop install nonportable/mactype-np +scoop install extras/diskgenius +# winget install -e --id Nilesoft.Shell +# scoop install umi-ocr-paddle + +# Editor +scoop install main/vim +scoop install main/neovim +scoop install extras/vscodium +scoop install extras/vscode +scoop install extras/neovide + + +# Security +scoop bucket add keyguard https://github.com/AChep/keyguard-repo-scoop +scoop install keyguard/keyguard + +# PKM +scoop install extras/obsidian +winget install -e --id 9P7HPMXP73K4 # Siyuan +scoop install extras/typora +scoop install extras/zotero +scoop install extras/anki +# winget install -e --id Notion.Notion + +# Browser +# Use Microsoft Edge directly +# winget install -e --id TheBrowserCompany.Arc +# winget install -e --id Mozilla.Firefox.Nightly # Not working + +# Programming Languages +winget install -e --id Python.Python.3.13 +winget install -e --id Anaconda.Miniconda3 +winget install -e --id OpenJS.NodeJS +winget install -e --id Rustlang.Rustup +winget install -e --id Microsoft.DotNet.SDK.8 + +# Dev +scoop install extras/docker +scoop install extras/lazygit + +# IDE +scoop install extras/rider + +# Gaming +winget install -e --id Valve.Steam + +# IME +winget install -e --id Rime.Weasel # 小狼毫 Rime + +# Misc +winget install -e --id 9N5LW3JBCXKF --source msstore # MSIX Packaging Tool +winget install -e --id 9PKTQ5699M62 --source msstore # iCloud +winget install -e --id RazerInc.RazerInstaller # Razer Synapse + +# Social +winget install -e --id 9N97ZCKPD60Q --source msstore # Unigram (Telegram client) +winget install -e --id Tencent.QQ.NT +winget install -e --id XPFCKBRNFZQ62G --source msstore # WeChat in Windows Store (MSIX) + +# Others +winget install -e --id Appest.TickTick +winget install -e --id 9NBLGGH4Z1SP --source msstore # ShareX (screen capture) + +# Fonts +scoop install FiraCode-NF +scoop install CascadiaCode-NF +scoop install LXGWWenKai # 霞鹜文楷 +scoop install LXGWWenKaiMono # 霞鹜文楷Mono + +# WSL +scoop install archwsl +wsl --set-version Arch 1 \ No newline at end of file diff --git a/win/Microsoft.PowerShell_profile.ps1 b/win/Microsoft.PowerShell_profile.ps1 index 6730268..b176736 100644 --- a/win/Microsoft.PowerShell_profile.ps1 +++ b/win/Microsoft.PowerShell_profile.ps1 @@ -93,4 +93,4 @@ if (-not ($__lastStartup -eq $_currentDate)) { } Remove-Variable SystemlogFilePath Remove-Variable __lastStartup -Remove-Variable _currentDate \ No newline at end of file +Remove-Variable _currentDate diff --git a/win/setup_win.ps1 b/win/setup_win.ps1 deleted file mode 100644 index 78097c5..0000000 --- a/win/setup_win.ps1 +++ /dev/null @@ -1,153 +0,0 @@ -#!C:\Program Files\WindowsApps\Microsoft.PowerShell_7.4.6.0_x64__8wekyb3d8bbwe\pwsh.EXE -# Run with PowerShell 7 -# Use PowerShell as Administrator -winget install -e --id Git.Git -git clone https://github.com/js0ny/dotfiles.git ~\.dotfiles -Set-Location -Path ~\.dotfiles -Remove-Item -Force $PROFILE -$DOTFILES = "$HOME\.dotfiles" -New-Item -ItemType SymbolicLink -Path $PROFILE -Target "$DOTFILES\win\Microsoft.PowerShell_profile.ps1" -. $PROFILE -# Install Scoop -Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression -# Install Chocolatey -Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) - -# Set Dotfiles -New-Item -ItemType SymbolicLink -Path "$Env:XDG_CONFIG_HOME\conda\.condarc" -Target "$DOTFILES\.config\conda\condarc.yaml" -New-Item -ItemType SymbolicLink -Path "$Env:XDG_CONFIG_HOME\git\config" -Target "$DOTFILES\.config\git\.gitconfig" -New-Item -ItemType SymbolicLink -Path "~\.haskline" -Target "$DOTFILES\.haskline" -New-Item -ItemType SymbolicLink -Path "~\.ideavimrc" -Target "$DOTFILES\.ideavimrc" -New-Item -ItemType SymbolicLink -Path "~\.markdownlint.json" -Target "$DOTFILES\.markdownlint.json" -New-Item -ItemType SymbolicLink -Path "~\.npmrc" -Target "$DOTFILES\.npmrc" -New-Item -ItemType SymbolicLink -Path "~\.pip.conf" -Target "$DOTFILES\.pip.conf" -New-Item -ItemType SymbolicLink -Path "~\.wslconfig" -Target "$DOTFILES\win\.wslconfig" -New-Item -ItemType SymbolicLink -Path "~\.vscode.vimrc" -Target "$DOTFILES\vscode\vscode.vimrc" -# Hide dotfiles -Get-ChildItem -Force -Filter .* | ForEach-Object { $_.Attributes += "Hidden" } - -# Windows Terminal -if (Get-Command wt -ErrorAction SilentlyContinue) { - Write-Output "Windows Terminal (wt) installed" -} else { - winget install -e --id Microsoft.WindowsTerminal -} - -# Uninstall Windows Apps -Get-AppxPackage *solit* | Remove-AppxPackage # 纸牌 -Get-AppxPackage *sound* | Remove-AppxPackage # 錄音機 -Get-AppxPackage *camera* | Remove-AppxPackage # 相機 -Get-AppxPackage *weather* | Remove-AppxPackage # 天氣 -Get-AppxPackage *Map* | Remove-AppxPackage # 地圖 -# Get-AppxPackage *clipchamp* | Remove-AppxPackage # 其實這個還行 - -# Added Packages -scoop bucket add main -scoop bucket add nerd-fonts -scoop bucket add extras -scoop bucket add nonportable - -# CLI Tools -# winget install -e --id GnuWin32.Grep # Use Select-String instead -scoop install main/make -# winget install -e --id GnuWin32.Which # Use Get-Command instead -scoop install main/fzf -scoop install main/ripgrep -scoop install main/wget -scoop install main/wget2 -scoop install main/cmake -scoop install main/bat -scoop install main/zoxide -scoop install main/dos2unix - -# File Management -scoop install extras/everything -scoop install main/7zip -scoop install extras/bandizip -scoop install main/pandoc -scoop install extras/sumatrapdf -winget install -e --id Google.GoogleDrive - -# System Enhancements -scoop install extras/fancontrol -scoop install extras/powertoys -scoop install extras/msiafterburner -winget install -e --id Yuanli.uTools -scoop install extras/geekuninstaller -scoop install extras/flow-launcher -# winget install -e --id AutoHotkey.AutoHotkey -scoop install extras/autohotkey -scoop install nonportable/mactype-np -scoop install extras/diskgenius -# winget install -e --id Nilesoft.Shell -# scoop install umi-ocr-paddle - -# Editor -scoop install main/vim -scoop install main/neovim -scoop install extras/vscodium -scoop install extras/vscode -scoop install extras/neovide - - -# Security -scoop bucket add keyguard https://github.com/AChep/keyguard-repo-scoop -scoop install keyguard/keyguard - -# PKM -scoop install extras/obsidian -winget install -e --id 9P7HPMXP73K4 # Siyuan -scoop install extras/typora -scoop install extras/zotero -scoop install extras/anki -# winget install -e --id Notion.Notion - -# Browser -# Use Microsoft Edge directly -# winget install -e --id TheBrowserCompany.Arc -# winget install -e --id Mozilla.Firefox.Nightly # Not working - -# Programming Languages -winget install -e --id Python.Python.3.13 -winget install -e --id Anaconda.Miniconda3 -winget install -e --id OpenJS.NodeJS -winget install -e --id Rustlang.Rustup -winget install -e --id Microsoft.DotNet.SDK.8 - -# Dev -scoop install extras/docker -scoop install extras/lazygit - -# IDE -scoop install extras/rider - -# Gaming -winget install -e --id Valve.Steam - -# IME -winget install -e --id Rime.Weasel # 小狼毫 Rime - -# Misc -winget install -e --id 9N5LW3JBCXKF --source msstore # MSIX Packaging Tool -winget install -e --id 9PKTQ5699M62 --source msstore # iCloud -winget install -e --id RazerInc.RazerInstaller # Razer Synapse - -# Social -winget install -e --id 9N97ZCKPD60Q --source msstore # Unigram (Telegram client) -winget install -e --id Tencent.QQ.NT -winget install -e --id XPFCKBRNFZQ62G --source msstore # WeChat in Windows Store (MSIX) - -# Others -winget install -e --id Appest.TickTick -winget install -e --id 9NBLGGH4Z1SP --source msstore # ShareX (screen capture) - -# Fonts -scoop install FiraCode-NF -scoop install CascadiaCode-NF -scoop install LXGWWenKai # 霞鹜文楷 -scoop install LXGWWenKaiMono # 霞鹜文楷Mono - -# WSL -scoop install archwsl -wsl --set-version Arch 1 \ No newline at end of file diff --git a/zsh/.zshenv b/zsh/.zshenv index 1a78651..9c83239 100644 --- a/zsh/.zshenv +++ b/zsh/.zshenv @@ -1,5 +1,5 @@ # ~/.zshenv -# ln -s $DOTFILES/zsh/.zshenv ~/.zshenv +# ln -s $DOTFILES/zsh/.zshenv $ZDOTDIR/.zshenv # This file is sourced by all zsh sessions upon startup. # Use XDG Base Directory Specification @@ -16,3 +16,5 @@ export ZDOTDIR="${XDG_CONFIG_HOME}/zsh" # Also put in /etc/zsh/zshenv # or /etc/zshenv in macOS +# sudo cp $DOTFILES/zsh/.zshenv /etc/zsh/zshenv +# sudo cp $DOTFILES/zsh/.zshenv /etc/zshenv diff --git a/zsh/config.zsh b/zsh/config.zsh index a0d14a5..ed0e8fc 100644 --- a/zsh/config.zsh +++ b/zsh/config.zsh @@ -18,16 +18,38 @@ VISUAL="nvim" # Use XDG Base Directory Specification # +# ~/.azure/ -> $XDG_DATA_HOME/azure/ +export AZURE_CONFIG_DIR="$XDG_DATA_HOME"/azure +# ~/.cgdb/ -> $XDG_CONFIG_HOME/cgdb/ +export CGDB_DIR="$XDG_CONFIG_HOME"/cgdb +# ~/.nv -> $XDG_CACHE_HOME/nv (CUDA) +# macOS does not have Cuda; Check if CUDA is installed +if [ "$(uname)" != "Darwin" ] && [ -d "/usr/local/cuda" ]; then + export CUDA_CACHE_PATH="$XDG_CACHE_HOME"/nv +fi +# ~/.docker -> $XDG_CONFIG_HOME/docker +export DOCKER_CONFIG="$XDG_CONFIG_HOME"/docker # ~/.dotnet -> $XDG_DATA_HOME/dotnet export DOTNET_CLI_HOME="$XDG_DATA_HOME"/dotnet # ~/.gnupg -> $XDG_CONFIG_HOME/gnupg export GNUPGHOME="$XDG_DATA_HOME"/gnupg # ~/go -> $XDG_DATA_HOME/go export GOPATH="$XDG_DATA_HOME"/go -# ~/.node_repl_history -> $XDG_STATE_HOME/node/repl_history -export NODE_REPL_HISTORY="$XDG_STATE_HOME"/node/repl_history -# ~/.npmrc -> $XDG_CONFIG_HOME/npm/npmrc -export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME"/npm/npmrc +# ~/.juliaup/ -> $XDG_DATA_HOME/julia/ +export JULIA_DEPOT_PATH="$XDG_DATA_HOME/julia:$JULIA_DEPOT_PATH" +# Check if node is installed +if command -v node > /dev/null; then + # ~/.node_repl_history -> $XDG_STATE_HOME/node/repl_history + export NODE_REPL_HISTORY="$XDG_STATE_HOME"/node/repl_history + # ~/.ts_node_repl_history -> $XDG_STATE_HOME/node/ts_node_repl_history + export TS_NODE_REPL_HISTORY="$XDG_STATE_HOME"/node/ts_node_repl_history + # ~/.npmrc -> $XDG_CONFIG_HOME/npm/npmrc + export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME"/npm/npmrc + # ~/.npm -> $XDG_CACHE_HOME/npm + export NPM_CONFIG_INIT_MODULE="$XDG_CONFIG_HOME"/npm/config/npm-init.js + export NPM_CONFIG_CACHE="$XDG_CACHE_HOME"/npm + export NPM_CONFIG_TMP="$XDG_RUNTIME_DIR"/npm +fi # ~/.python_history -> $XDG_DATA_HOME/python/history # Works only with Python 3.13.0a3 and later export PYTHON_HISTORY="$XDG_DATA_HOME"/python/history @@ -39,7 +61,7 @@ export W3M_DIR="$XDG_DATA_HOME"/w3m # ~/.wakatime/ -> $XDG_CONFIG_HOME/wakatime/ export WAKATIME_HOME="$XDG_CONFIG_HOME/wakatime" # ~/.wget-hsts -> $XDG_DATA_HOME/wget-hsts -alias wget='wget --hsts-file="$XDG_DATA_HOME/wget-hsts"' +alias wget='wget --hsts-file="$XDG_CACHE_HOME/wget-hsts"' # ~/.z -> $XDG_DATA_HOME/z export _Z_DATA="$XDG_DATA_HOME/z" # ~/.zcompdump* -> $XDG_CACHE_HOME/zsh/zcompdump*