Compare commits
24 Commits
0a6abee3f4
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 183c765b07 | |||
| fe6a79626f | |||
| b8c94de6c6 | |||
| fdacaab656 | |||
| 2241e10f47 | |||
| 1768d9971e | |||
| 0d208b29d0 | |||
| 8b36c0019f | |||
| ed6dadd5eb | |||
| 4a912cf7e7 | |||
| 59051a86c5 | |||
| d6e7b8b81f | |||
| 6f1e783a56 | |||
| a9080203f6 | |||
| e384a4ad0c | |||
| bbc0d2f0a1 | |||
| 1af9a937d8 | |||
| 0f9b528471 | |||
| 0bb8f0e5e8 | |||
| 3d22ed9633 | |||
| e86f9d47e7 | |||
| 21129ab5b9 | |||
| cacd241cca | |||
| 05b2a28b94 |
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
alias ..='cd ..'
|
||||
alias ...='cd ../..'
|
||||
alias ....='cd ../../..'
|
||||
alias .....='cd ../../../..'
|
||||
alias ......='cd ../../../../..'
|
||||
alias -- -='cd -'
|
||||
|
||||
alias ls='ls --color=auto'
|
||||
alias l='ls -lFh'
|
||||
alias la='ls -lAFh'
|
||||
alias lr='ls -tRFh'
|
||||
alias lt='ls -ltFh'
|
||||
alias ll='ls -l'
|
||||
alias ldot='ls -ld .*'
|
||||
alias lss='ls -1FSsh'
|
||||
alias lS='lss'
|
||||
alias lart='ls -1Fcart'
|
||||
alias lrt='ls -1Fcrt'
|
||||
alias lsr='ls -lARFh'
|
||||
alias lsn='ls -1'
|
||||
|
||||
alias grep='grep --color'
|
||||
alias sgrep='grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS}'
|
||||
alias t='tail -f'
|
||||
|
||||
alias weather='curl wttr.in'
|
||||
alias moon='curl wttr.in/Moon'
|
||||
alias quote='curl -s https://api.quotable.io/random | jq -r .content'
|
||||
alias joke='curl -s -H "Accept: application/json" https://icanhazdadjoke.com/ | jq -r .joke'
|
||||
alias dadjoke='curl -s -H "Accept: application/json" https://icanhazdadjoke.com/ | jq -r .joke'
|
||||
|
||||
alias dud='du -d 1 -h'
|
||||
alias ff='find . -type f -name'
|
||||
|
||||
alias h='history'
|
||||
alias hgrep='history | grep'
|
||||
alias help='man'
|
||||
alias p='ps -f'
|
||||
alias sortnr='sort -n -r'
|
||||
alias unexport='unset'
|
||||
|
||||
alias rm='rm -i'
|
||||
alias cp='cp -i'
|
||||
alias mv='mv -i'
|
||||
|
||||
# Interactive directory picker from nushell cdi behavior.
|
||||
cdi() {
|
||||
if ! command -v fzf >/dev/null 2>&1; then
|
||||
echo "fzf is not installed."
|
||||
return 1
|
||||
fi
|
||||
|
||||
local selected_dir
|
||||
selected_dir="$(find . -type d 2>/dev/null | sed 's#^\./##' | fzf)"
|
||||
[[ -n "$selected_dir" ]] && cd "$selected_dir"
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
pj_helix() {
|
||||
local helix_bin
|
||||
local hx_bin
|
||||
|
||||
helix_bin=$(type -P helix)
|
||||
hx_bin=$(type -P hx)
|
||||
|
||||
if [[ -n "$helix_bin" ]]; then
|
||||
command "$helix_bin" -c "$BASH_POLYJUICE_HELIX_CONFIG_FILE" "$@"
|
||||
elif [[ -n "$hx_bin" ]]; then
|
||||
command "$hx_bin" -c "$BASH_POLYJUICE_HELIX_CONFIG_FILE" "$@"
|
||||
else
|
||||
echo "HELIX/HX is not installed"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
helix() {
|
||||
pj_helix "$@"
|
||||
}
|
||||
|
||||
hx() {
|
||||
pj_helix "$@"
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
py() {
|
||||
if command -v py >/dev/null 2>&1; then
|
||||
command py "$@"
|
||||
elif command -v python3 >/dev/null 2>&1; then
|
||||
command python3 "$@"
|
||||
else
|
||||
echo "Error: Python is not installed or could not be found."
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
pyclean() {
|
||||
find "${@:-.}" -type f -name "*.py[co]" -delete
|
||||
find "${@:-.}" -type d -name "__pycache__" -delete
|
||||
find "${@:-.}" -depth -type d -name ".mypy_cache" -exec rm -r "{}" +
|
||||
find "${@:-.}" -depth -type d -name ".pytest_cache" -exec rm -r "{}" +
|
||||
}
|
||||
|
||||
alias pygrep='grep -nr --include="*.py"'
|
||||
alias pyserver='python3 -m http.server'
|
||||
|
||||
py_create_default_venv() {
|
||||
local venv_parent
|
||||
venv_parent="$(dirname "$BASH_POLYJUICE_DEFAULT_PYTHON_VENV")"
|
||||
|
||||
if ! command -v uv >/dev/null 2>&1; then
|
||||
echo "uv command not found. Please install uv first."
|
||||
return 1
|
||||
fi
|
||||
|
||||
mkdir -p "$venv_parent"
|
||||
|
||||
if [[ -d "$BASH_POLYJUICE_DEFAULT_PYTHON_VENV" && -f "$BASH_POLYJUICE_DEFAULT_PYTHON_VENV/bin/activate" ]]; then
|
||||
(
|
||||
cd "$venv_parent" || exit 1
|
||||
uv sync
|
||||
)
|
||||
else
|
||||
(
|
||||
cd "$venv_parent" || exit 1
|
||||
uv init --name gvenv
|
||||
uv sync
|
||||
)
|
||||
fi
|
||||
}
|
||||
|
||||
py_vrun() {
|
||||
local current_dir="$PWD"
|
||||
local venv_names=(".venv" "venv" ".virtualenv" "env")
|
||||
local venv_path=""
|
||||
local found_name=""
|
||||
local max_depth=20
|
||||
local depth=0
|
||||
local venv_name
|
||||
|
||||
echo "searching nearest python virtual environment..."
|
||||
|
||||
while [[ "$current_dir" != "/" && "$current_dir" != "$HOME" && "$depth" -lt "$max_depth" ]]; do
|
||||
for venv_name in "${venv_names[@]}"; do
|
||||
if [[ -d "$current_dir/$venv_name" && -f "$current_dir/$venv_name/bin/activate" ]]; then
|
||||
venv_path="$current_dir/$venv_name"
|
||||
found_name="$venv_name"
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
current_dir="$(dirname "$current_dir")"
|
||||
((depth++))
|
||||
done
|
||||
|
||||
if [[ -z "$venv_path" && -d "$BASH_POLYJUICE_DEFAULT_PYTHON_VENV" && -f "$BASH_POLYJUICE_DEFAULT_PYTHON_VENV/bin/activate" ]]; then
|
||||
venv_path="$BASH_POLYJUICE_DEFAULT_PYTHON_VENV"
|
||||
found_name="$(basename "$BASH_POLYJUICE_DEFAULT_PYTHON_VENV")"
|
||||
fi
|
||||
|
||||
if [[ -n "$venv_path" ]]; then
|
||||
if [[ -n "${VIRTUAL_ENV:-}" ]]; then
|
||||
if [[ "$VIRTUAL_ENV" == "$venv_path" ]]; then
|
||||
echo "already activated: $venv_path"
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "another virtual environment is already activated: $(basename "$VIRTUAL_ENV")"
|
||||
read -r -p "Switch to $(basename "$(dirname "$venv_path")")/$found_name? (y/N): " -n 1 reply
|
||||
echo
|
||||
if [[ ! "$reply" =~ ^[Yy]$ ]]; then
|
||||
return 0
|
||||
fi
|
||||
deactivate >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
echo "activating virtual environment: $venv_path/bin/activate"
|
||||
# shellcheck disable=SC1090
|
||||
source "$venv_path/bin/activate"
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "no python virtual environment found."
|
||||
return 1
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [[ -n "${BASH_VERSION:-}" ]]; then
|
||||
_profile_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
[[ -f "$_profile_dir/bashrc" ]] && source "$_profile_dir/bashrc"
|
||||
unset _profile_dir
|
||||
fi
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [[ -z "${BASH_VERSION:-}" ]]; then
|
||||
echo "Unsupported shell"
|
||||
return 1 2>/dev/null || exit 1
|
||||
fi
|
||||
|
||||
_bash_polyjuice_source="${BASH_SOURCE[0]}"
|
||||
export BASH_POLYJUICE_PATH="$(cd "$(dirname "$_bash_polyjuice_source")" && pwd)"
|
||||
export BASH_POLYJUICE_SETTINGS_PATH="$BASH_POLYJUICE_PATH/settings"
|
||||
export BASH_POLYJUICE_ALIASES_PATH="$BASH_POLYJUICE_PATH/aliases"
|
||||
export BASH_POLYJUICE_FUNCTIONS_PATH="$BASH_POLYJUICE_PATH/functions"
|
||||
export BASH_POLYJUICE_INTEGRATIONS_PATH="$BASH_POLYJUICE_PATH/integrations"
|
||||
export BASH_POLYJUICE_KEYBINDINGS_PATH="$BASH_POLYJUICE_PATH/keybindings"
|
||||
export BASH_POLYJUICE_STARSHIP_CONFIG_FILE="$BASH_POLYJUICE_PATH/../starship/starship_default.toml"
|
||||
export BASH_POLYJUICE_HELIX_CONFIG_FILE="$BASH_POLYJUICE_PATH/../helix/config.toml"
|
||||
|
||||
for _file in "$BASH_POLYJUICE_SETTINGS_PATH"/*.sh; do
|
||||
[[ -f "$_file" ]] && source "$_file"
|
||||
done
|
||||
|
||||
for _file in "$BASH_POLYJUICE_ALIASES_PATH"/*.sh; do
|
||||
[[ -f "$_file" ]] && source "$_file"
|
||||
done
|
||||
|
||||
for _file in "$BASH_POLYJUICE_FUNCTIONS_PATH"/*.sh; do
|
||||
[[ -f "$_file" ]] && source "$_file"
|
||||
done
|
||||
|
||||
for _file in "$BASH_POLYJUICE_INTEGRATIONS_PATH"/*.sh; do
|
||||
[[ -f "$_file" ]] && source "$_file"
|
||||
done
|
||||
|
||||
for _file in "$BASH_POLYJUICE_KEYBINDINGS_PATH"/*.sh; do
|
||||
[[ -f "$_file" ]] && source "$_file"
|
||||
done
|
||||
|
||||
unset _file
|
||||
unset _bash_polyjuice_source
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
pj_check() {
|
||||
local missing=0
|
||||
local cmd
|
||||
|
||||
for cmd in zoxide fzf starship python3 jq; do
|
||||
if ! command -v "$cmd" >/dev/null 2>&1; then
|
||||
echo "$cmd is not installed."
|
||||
missing=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ "$missing" -eq 0 ]]; then
|
||||
echo "All core tools are available."
|
||||
fi
|
||||
}
|
||||
|
||||
pj_check_tools() {
|
||||
local cmd
|
||||
for cmd in git python cargo verilator iverilog javac sbt; do
|
||||
if ! command -v "$cmd" >/dev/null 2>&1; then
|
||||
echo "$cmd is not installed."
|
||||
fi
|
||||
done
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
pj_starship() {
|
||||
local config_file_dir
|
||||
config_file_dir="$(dirname "$BASH_POLYJUICE_STARSHIP_CONFIG_FILE")"
|
||||
|
||||
case "$1" in
|
||||
list)
|
||||
ls "$config_file_dir"
|
||||
;;
|
||||
set)
|
||||
local target
|
||||
target="$config_file_dir/starship_$2.toml"
|
||||
if [[ -f "$target" ]]; then
|
||||
export STARSHIP_CONFIG="$target"
|
||||
echo "Starship config set to '$target'"
|
||||
else
|
||||
echo "Config '$target' does not exist."
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
reset)
|
||||
export STARSHIP_CONFIG="$BASH_POLYJUICE_STARSHIP_CONFIG_FILE"
|
||||
;;
|
||||
*)
|
||||
echo "Usage: pj_starship <command> [args]"
|
||||
echo "Commands:"
|
||||
echo " list List available Starship configs in the polyjuice directory."
|
||||
echo " set <name> Select a config by base name (omit the .toml extension)."
|
||||
echo " reset Reset Starship to the default polyjuice configuration."
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [[ -z "${FZF_DEFAULT_COMMAND:-}" ]]; then
|
||||
if command -v fd >/dev/null 2>&1; then
|
||||
export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude .git'
|
||||
elif command -v rg >/dev/null 2>&1; then
|
||||
export FZF_DEFAULT_COMMAND='rg --files --hidden --glob "!.git/*"'
|
||||
elif command -v ag >/dev/null 2>&1; then
|
||||
export FZF_DEFAULT_COMMAND='ag -l --hidden -g "" --ignore .git'
|
||||
fi
|
||||
fi
|
||||
|
||||
if command -v fzf >/dev/null 2>&1; then
|
||||
if [[ -f "$HOME/.fzf.bash" ]]; then
|
||||
source "$HOME/.fzf.bash"
|
||||
elif [[ -f "/usr/share/fzf/key-bindings.bash" ]]; then
|
||||
source "/usr/share/fzf/key-bindings.bash"
|
||||
[[ -f "/usr/share/fzf/completion.bash" ]] && source "/usr/share/fzf/completion.bash"
|
||||
elif [[ -f "/usr/share/doc/fzf/examples/key-bindings.bash" ]]; then
|
||||
source "/usr/share/doc/fzf/examples/key-bindings.bash"
|
||||
[[ -f "/usr/share/doc/fzf/examples/completion.bash" ]] && source "/usr/share/doc/fzf/examples/completion.bash"
|
||||
fi
|
||||
fi
|
||||
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if command -v starship >/dev/null 2>&1; then
|
||||
export STARSHIP_CONFIG="${STARSHIP_CONFIG:-$BASH_POLYJUICE_STARSHIP_CONFIG_FILE}"
|
||||
eval "$(starship init bash)"
|
||||
fi
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if command -v zoxide >/dev/null 2>&1; then
|
||||
eval "$(zoxide init --cmd z bash)"
|
||||
fi
|
||||
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if ! command -v fzf >/dev/null 2>&1; then
|
||||
return
|
||||
fi
|
||||
|
||||
_pj_readline_append() {
|
||||
local text="$1"
|
||||
[[ -z "$text" ]] && return 0
|
||||
READLINE_LINE="${READLINE_LINE:0:READLINE_POINT}${text}${READLINE_LINE:READLINE_POINT}"
|
||||
READLINE_POINT=$((READLINE_POINT + ${#text}))
|
||||
}
|
||||
|
||||
__pj_fzf_file_widget() {
|
||||
local selected_file
|
||||
local command_to_run
|
||||
|
||||
if command -v fd >/dev/null 2>&1; then
|
||||
command_to_run='fd --type f --hidden --exclude .git | fzf'
|
||||
elif command -v rg >/dev/null 2>&1; then
|
||||
command_to_run='rg --files --hidden --glob "!.git/*" | fzf'
|
||||
elif command -v ag >/dev/null 2>&1; then
|
||||
command_to_run='ag -l --hidden -g "" --ignore .git | fzf'
|
||||
else
|
||||
command_to_run='find . -type f 2>/dev/null | fzf'
|
||||
fi
|
||||
|
||||
selected_file="$(eval "$command_to_run")"
|
||||
_pj_readline_append "$selected_file"
|
||||
}
|
||||
|
||||
__pj_fzf_dir_widget() {
|
||||
local selected_dir
|
||||
local command_to_run
|
||||
|
||||
if command -v fd >/dev/null 2>&1; then
|
||||
command_to_run='fd --type d --hidden --no-ignore --exclude .git | fzf'
|
||||
else
|
||||
command_to_run='find . -type d 2>/dev/null | fzf'
|
||||
fi
|
||||
|
||||
selected_dir="$(eval "$command_to_run")"
|
||||
_pj_readline_append "$selected_dir"
|
||||
}
|
||||
|
||||
__pj_fzf_history_widget() {
|
||||
local selected_command
|
||||
|
||||
selected_command="$({ HISTTIMEFORMAT= history; } | sed 's/^[[:space:]]*[0-9]\+[[:space:]]*//' | fzf --height 40% --reverse --border)"
|
||||
_pj_readline_append "$selected_command"
|
||||
}
|
||||
|
||||
# Alt-f: file selector, Alt-d: directory selector, Alt-h: history selector
|
||||
bind -x '"\ef":__pj_fzf_file_widget'
|
||||
bind -x '"\ed":__pj_fzf_dir_widget'
|
||||
bind -x '"\eh":__pj_fzf_history_widget'
|
||||
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Preferred editor for local and remote sessions.
|
||||
if command -v helix >/dev/null 2>&1; then
|
||||
export EDITOR="helix"
|
||||
elif command -v nvim >/dev/null 2>&1; then
|
||||
export EDITOR="nvim"
|
||||
else
|
||||
export EDITOR="vim"
|
||||
fi
|
||||
|
||||
export OS="$(uname -s)"
|
||||
export BASH_POLYJUICE_DEFAULT_PYTHON_VENV="$HOME/.default_pyvenv/.venv"
|
||||
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
export HISTFILE="${HISTFILE:-$HOME/.bash_history}"
|
||||
export HISTSIZE=50000
|
||||
export HISTFILESIZE=10000
|
||||
export HISTCONTROL="ignoreboth:erasedups"
|
||||
export HISTTIMEFORMAT="%F %T "
|
||||
|
||||
shopt -s histappend
|
||||
shopt -s cmdhist
|
||||
shopt -s lithist
|
||||
|
||||
# Keep history synchronized across interactive shells.
|
||||
if [[ -z "${BASH_POLYJUICE_HISTORY_INITIALIZED:-}" ]]; then
|
||||
export BASH_POLYJUICE_HISTORY_INITIALIZED=1
|
||||
if [[ -n "${PROMPT_COMMAND:-}" ]]; then
|
||||
PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}"
|
||||
else
|
||||
PROMPT_COMMAND="history -a; history -n"
|
||||
fi
|
||||
fi
|
||||
@@ -0,0 +1,19 @@
|
||||
theme = "onedark"
|
||||
|
||||
[editor]
|
||||
line-number = "relative"
|
||||
cursorline = true
|
||||
cursorcolumn = true
|
||||
default-yank-register = "+"
|
||||
continue-comments = true
|
||||
|
||||
[editor.statusline]
|
||||
left = ["mode", "spinner", "read-only-indicator", "file-modification-indicator", "version-control"]
|
||||
center = ["file-name", "total-line-numbers", "position-percentage"]
|
||||
right = ["diagnostics", "selections", "position", "file-encoding", "file-line-ending", "file-type"]
|
||||
separator = "│"
|
||||
mode.normal = "NORMAL"
|
||||
mode.insert = "INSERT"
|
||||
mode.select = "SELECT"
|
||||
diagnostics = ["warning", "error"]
|
||||
workspace-diagnostics = ["warning", "error"]
|
||||
@@ -1,19 +0,0 @@
|
||||
alias l = ls
|
||||
alias ll = ls -l
|
||||
alias la = ls -a
|
||||
alias lla = ls -la
|
||||
alias lh = ls -lh
|
||||
alias lt = ls -l | sort-by modified | reverse
|
||||
|
||||
alias cdi = cd (ls **/ | get name | str join "\n" | fzf)
|
||||
|
||||
if $env.OS == "Windows_NT" {
|
||||
|
||||
} else {
|
||||
alias py = python3
|
||||
}
|
||||
|
||||
alias weather = curl wttr.in
|
||||
alias moon = curl wttr.in/Moon
|
||||
alias quote = curl https://api.quotable.io/random | from json | get content
|
||||
alias dadjoke = curl -H "Accept: application/json" https://icanhazdadjoke.com/ | from json | get joke
|
||||
Vendored
@@ -1,9 +0,0 @@
|
||||
use pj_starship.nu
|
||||
use pj_zoxide.nu
|
||||
|
||||
export def --env init [] {
|
||||
# zoxide
|
||||
pj_zoxide init
|
||||
# starship
|
||||
pj_starship init
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
export alias l = ls
|
||||
export alias ll = ls -l
|
||||
export alias la = ls -a
|
||||
export alias lla = ls -la
|
||||
export alias lh = ls -lh
|
||||
export alias lt = ls -l | sort-by modified | reverse
|
||||
|
||||
export alias .. = cd ..
|
||||
export alias ... = cd ../..
|
||||
export alias .... = cd ../../..
|
||||
export alias ..... = cd ../../../..
|
||||
export alias ...... = cd ../../../../..
|
||||
export alias ....... = cd ../../../../../..
|
||||
export alias ........ = cd ../../../../../../..
|
||||
export alias .......... = cd ../../../../../../../..
|
||||
|
||||
|
||||
export def py [...rest: string] {
|
||||
if (which ^py | is-not-empty) {
|
||||
^py ...$rest
|
||||
} else if (which ^python3 | is-not-empty) {
|
||||
^python3 ...$rest
|
||||
} else {
|
||||
print "Error: Python is not installed or could not be found."
|
||||
}
|
||||
}
|
||||
|
||||
export alias weather = curl wttr.in
|
||||
export alias moon = curl wttr.in/Moon
|
||||
export alias quote = curl https://api.quotable.io/random | from json | get content
|
||||
export alias dadjoke = curl -H "Accept: application/json" https://icanhazdadjoke.com/ | from json | get joke
|
||||
@@ -0,0 +1,14 @@
|
||||
export-env {
|
||||
$env.config = {
|
||||
completions: {
|
||||
quick: true
|
||||
partial: true
|
||||
algorithm: "fuzzy"
|
||||
case_sensitive: false
|
||||
external: {
|
||||
enable: true
|
||||
max_results: 100
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
# History
|
||||
const fzf_history_selector = {
|
||||
name: fzf_history_selector
|
||||
modifier: alt
|
||||
keycode: char_h
|
||||
mode: [emacs, vi_insert, vi_normal]
|
||||
event: [
|
||||
{
|
||||
send: executehostcommand
|
||||
cmd: "
|
||||
let result = history
|
||||
| reverse
|
||||
| get command
|
||||
| str replace --all (char newline) ' '
|
||||
| to text
|
||||
| fzf --height 40% --reverse --border;
|
||||
commandline edit --append $result;
|
||||
commandline set-cursor --end
|
||||
"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
const fzf_file_selector = {
|
||||
name: fzf_file_selector
|
||||
modifier: alt
|
||||
keycode: char_f
|
||||
mode: [emacs, vi_insert, vi_normal]
|
||||
event: [
|
||||
{
|
||||
send: executehostcommand
|
||||
cmd: "
|
||||
let result = (ls **/* | where type == 'file' | get name | to text | fzf --height 40% --reverse --border);
|
||||
commandline edit --append $result;
|
||||
commandline set-cursor --end
|
||||
"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
const fzf_dir_selector = {
|
||||
name: fzf_dir_selector
|
||||
modifier: alt
|
||||
keycode: char_d
|
||||
mode: [emacs, vi_insert, vi_normal]
|
||||
event: [
|
||||
{
|
||||
send: executehostcommand
|
||||
cmd: "
|
||||
let result = (ls **/ | where type == 'dir' | get name | to text | fzf --height 40% --reverse --border);
|
||||
commandline edit --append $result;
|
||||
commandline set-cursor --end
|
||||
"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
# Update the $env.config
|
||||
export-env {
|
||||
# Only append if not already present (check by name)
|
||||
let has_history_menu = $env.config.keybindings | any {|kb| $kb.name == "fzf_history_selector"}
|
||||
if not $has_history_menu {
|
||||
$env.config.keybindings = $env.config.keybindings | append [
|
||||
$fzf_history_selector
|
||||
]
|
||||
}
|
||||
|
||||
# Only append if not already present (check by name)
|
||||
let has_fzf_file_selector = $env.config.keybindings | any {|kb| $kb.name == "fzf_file_selector"}
|
||||
if not $has_fzf_file_selector {
|
||||
$env.config.keybindings = $env.config.keybindings | append [
|
||||
$fzf_file_selector
|
||||
]
|
||||
}
|
||||
|
||||
# Only append if not already present (check by name)
|
||||
let has_fzf_dir_selector = $env.config.keybindings | any {|kb| $kb.name == "fzf_dir_selector"}
|
||||
if not $has_fzf_dir_selector {
|
||||
$env.config.keybindings = $env.config.keybindings | append [
|
||||
$fzf_dir_selector
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
export alias cdi = cd (ls **/ | get name | str join "\n" | fzf)
|
||||
@@ -0,0 +1,33 @@
|
||||
export-env {
|
||||
$env.PJ_HELIX_CONFIG_PATH = $env.NU_POLYJUICE_PATH | path join ".." "helix" "config.toml"
|
||||
}
|
||||
|
||||
export def hx [...rest: string] {
|
||||
if (which ^helix | is-not-empty) {
|
||||
^helix -c $env.PJ_HELIX_CONFIG_PATH ...$rest
|
||||
} else if (which ^hx | is-not-empty) {
|
||||
^hx -c $env.PJ_HELIX_CONFIG_PATH ...$rest
|
||||
} else {
|
||||
print "Helix editor not found."
|
||||
if ($env.OS == "Windows_NT") {
|
||||
print "You can install Helix via `winget install Helix.Helix`"
|
||||
} else {
|
||||
print "You can install Helix from package managers."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export def helix [...rest: string] {
|
||||
if (which ^helix | is-not-empty) {
|
||||
^helix -c $env.PJ_HELIX_CONFIG_PATH ...$rest
|
||||
} else if (which ^hx | is-not-empty) {
|
||||
^hx -c $env.PJ_HELIX_CONFIG_PATH ...$rest
|
||||
} else {
|
||||
print "Helix editor not found."
|
||||
if ($env.OS == "Windows_NT") {
|
||||
print "You can install Helix via `winget install Helix.Helix`"
|
||||
} else {
|
||||
print "You can install Helix from package managers."
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
const alt_l_history_completion = {
|
||||
name: alt_l_history_completion
|
||||
modifier: alt
|
||||
keycode: char_l
|
||||
mode: [emacs, vi_insert, vi_normal]
|
||||
event: {
|
||||
until: [
|
||||
{ send: historyhintcomplete }
|
||||
{ send: menuright }
|
||||
{ send: right }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
const alt_uppercasel_history_completion = {
|
||||
name: alt_uppercasel_history_completion
|
||||
modifier: alt_shift
|
||||
keycode: char_l
|
||||
mode: [emacs, vi_insert, vi_normal]
|
||||
event: {
|
||||
until: [
|
||||
{ send: historyhintwordcomplete }
|
||||
{ edit: movewordright, select: false}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
export-env {
|
||||
let has_alt_l_history_completion = $env.config.keybindings | where name == "alt_l_history_completion" | is-not-empty
|
||||
if not $has_alt_l_history_completion {
|
||||
$env.config.keybindings = $env.config.keybindings | append [
|
||||
$alt_l_history_completion
|
||||
]
|
||||
}
|
||||
|
||||
let has_alt_uppercasel_history_completion = $env.config.keybindings | where name == "alt_uppercasel_history_completion" | is-not-empty
|
||||
if not $has_alt_uppercasel_history_completion {
|
||||
$env.config.keybindings = $env.config.keybindings | append [
|
||||
$alt_uppercasel_history_completion
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,682 @@
|
||||
def _pj_detect_os_key [] {
|
||||
let host_name = (((sys host | get name?) | default ($nu.os-info.name? | default "")) | into string | str downcase)
|
||||
if ($host_name | str contains "darwin") {
|
||||
return "Macos"
|
||||
}
|
||||
if ($host_name | str contains "windows") {
|
||||
return "Windows"
|
||||
}
|
||||
|
||||
let os_release = if ("/etc/os-release" | path exists) {
|
||||
"/etc/os-release"
|
||||
} else if ("/usr/lib/os-release" | path exists) {
|
||||
"/usr/lib/os-release"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
|
||||
if ($os_release != "") {
|
||||
let id_line = (open $os_release | lines | where {|l| $l | str starts-with "ID=" } | get 0?)
|
||||
let id = if ($id_line == null) { "" } else { (($id_line | str replace "ID=" "") | str trim -c '"') }
|
||||
match ($id | str downcase) {
|
||||
"alpine" => "Alpine"
|
||||
"alma" => "AlmaLinux"
|
||||
"almalinux" => "AlmaLinux"
|
||||
"amzn" => "Amazon"
|
||||
"arch" => "Arch"
|
||||
"artix" => "Artix"
|
||||
"centos" => "CentOS"
|
||||
"debian" => "Debian"
|
||||
"endeavouros" => "EndeavourOS"
|
||||
"fedora" => "Fedora"
|
||||
"garuda" => "Garuda"
|
||||
"gentoo" => "Gentoo"
|
||||
"kali" => "Kali"
|
||||
"linuxmint" => "Mint"
|
||||
"manjaro" => "Manjaro"
|
||||
"mariner" => "Mariner"
|
||||
"nixos" => "NixOS"
|
||||
"nobara" => "Nobara"
|
||||
"opensuse" => "openSUSE"
|
||||
"opensuse-leap" => "openSUSE"
|
||||
"opensuse-tumbleweed" => "openSUSE"
|
||||
"ol" => "OracleLinux"
|
||||
"pop" => "Pop"
|
||||
"raspbian" => "Raspbian"
|
||||
"rhel" => "RedHatEnterprise"
|
||||
"rocky" => "RockyLinux"
|
||||
"solus" => "Solus"
|
||||
"sles" => "SUSE"
|
||||
"opensuse-slowroll" => "openSUSE"
|
||||
"ubuntu" => "Ubuntu"
|
||||
"void" => "Void"
|
||||
_ => "Linux"
|
||||
}
|
||||
} else {
|
||||
if ($host_name | str contains "linux") {
|
||||
"Linux"
|
||||
} else {
|
||||
"Unknown"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def _pj_os_symbol_from_key [key: string] {
|
||||
match $key {
|
||||
"Alpaquita" => " "
|
||||
"Alpine" => " "
|
||||
"AlmaLinux" => " "
|
||||
"Amazon" => " "
|
||||
"Android" => " "
|
||||
"Arch" => " "
|
||||
"Artix" => " "
|
||||
"CachyOS" => " "
|
||||
"CentOS" => " "
|
||||
"Debian" => " "
|
||||
"DragonFly" => " "
|
||||
"Emscripten" => " "
|
||||
"EndeavourOS" => " "
|
||||
"Fedora" => " "
|
||||
"FreeBSD" => " "
|
||||
"Garuda" => " "
|
||||
"Gentoo" => " "
|
||||
"HardenedBSD" => " "
|
||||
"Illumos" => " "
|
||||
"Kali" => " "
|
||||
"Linux" => " "
|
||||
"Mabox" => " "
|
||||
"Macos" => " "
|
||||
"Manjaro" => " "
|
||||
"Mariner" => " "
|
||||
"MidnightBSD" => " "
|
||||
"Mint" => " "
|
||||
"NetBSD" => " "
|
||||
"NixOS" => " "
|
||||
"Nobara" => " "
|
||||
"OpenBSD" => " "
|
||||
"openSUSE" => " "
|
||||
"OracleLinux" => " "
|
||||
"Pop" => " "
|
||||
"Raspbian" => " "
|
||||
"Redhat" => " "
|
||||
"RedHatEnterprise" => " "
|
||||
"RockyLinux" => " "
|
||||
"Redox" => " "
|
||||
"Solus" => " "
|
||||
"SUSE" => " "
|
||||
"Ubuntu" => " "
|
||||
"Unknown" => " "
|
||||
"Void" => " "
|
||||
"Windows" => " "
|
||||
_ => " "
|
||||
}
|
||||
}
|
||||
|
||||
def _pj_os_symbol [] {
|
||||
let key = ($env.PJ_OS_KEY? | default (_pj_detect_os_key))
|
||||
_pj_os_symbol_from_key $key
|
||||
}
|
||||
|
||||
def _pj_palette_default [] {
|
||||
{
|
||||
c_reset: (ansi reset)
|
||||
c_os: (ansi '#6b6b6b')
|
||||
c_user: (ansi '#4ca47b')
|
||||
c_root: (ansi '#c2295b')
|
||||
c_host: (ansi '#4ca47b')
|
||||
c_ssh: (ansi '#d65d0e')
|
||||
c_dir: (ansi '#9d8fbe')
|
||||
c_c: (ansi '#306898')
|
||||
c_cpp: (ansi '#306898')
|
||||
c_rust: (ansi '#000000')
|
||||
c_zig: (ansi '#306898')
|
||||
c_python: (ansi '#4685b7')
|
||||
c_git: (ansi '#4ca47b')
|
||||
c_alert: (ansi '#c2295b')
|
||||
c_time: (ansi '#a6356f')
|
||||
c_duration: (ansi '#a6356f')
|
||||
c_shell: (ansi cyan_bold)
|
||||
c_indicator_ok: (ansi green_bold)
|
||||
c_indicator_err: (ansi red_bold)
|
||||
c_right_error: (ansi red_bold)
|
||||
}
|
||||
}
|
||||
|
||||
def _pj_palette [] {
|
||||
($env.PJ_PROMPT_PALETTE? | default (_pj_palette_default))
|
||||
}
|
||||
|
||||
def _pj_detect_user [] {
|
||||
let name = (try { whoami } catch { "" } | into string | str trim)
|
||||
if ($name != "") {
|
||||
return $name
|
||||
}
|
||||
|
||||
($env.USER? | default ($env.USERNAME? | default "user"))
|
||||
}
|
||||
|
||||
def _pj_runtime_default [] {
|
||||
let user = (_pj_detect_user)
|
||||
let host = (sys host | get hostname? | default "")
|
||||
{
|
||||
user: $user
|
||||
is_root: ($user == "root")
|
||||
host: $host
|
||||
in_ssh: (($env.SSH_CONNECTION? | default "") != "" or ($env.SSH_TTY? | default "") != "")
|
||||
}
|
||||
}
|
||||
|
||||
def _pj_runtime [] {
|
||||
(_pj_runtime_default)
|
||||
}
|
||||
|
||||
def _pj_first_version [text: string] {
|
||||
let parsed = ($text | parse -r '(?<ver>\d+(?:\.\d+)+)')
|
||||
if (($parsed | length) > 0) {
|
||||
($parsed | get ver.0)
|
||||
} else {
|
||||
""
|
||||
}
|
||||
}
|
||||
|
||||
def _pj_cmd_duration_ms [] {
|
||||
let raw = ($env.CMD_DURATION_MS? | default 0)
|
||||
let kind = ($raw | describe)
|
||||
if ($kind == "int") {
|
||||
return $raw
|
||||
}
|
||||
if ($kind == "duration") {
|
||||
return (($raw | into int) / 1_000_000)
|
||||
}
|
||||
|
||||
let s = ($raw | into string | str trim)
|
||||
let parsed = ($s | parse -r '^(?<n>\d+)')
|
||||
if (($parsed | length) > 0) {
|
||||
(($parsed | get n.0) | into int)
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
def _pj_format_duration [ms: int] {
|
||||
if ($ms < 1000) {
|
||||
return $"($ms)ms"
|
||||
}
|
||||
|
||||
let ms_part = ($ms mod 1000)
|
||||
if ($ms < 60_000) {
|
||||
let s = ($ms // 1000)
|
||||
return $"($s)s ($ms_part)ms"
|
||||
}
|
||||
|
||||
if ($ms < 3_600_000) {
|
||||
let total_s = ($ms // 1000)
|
||||
let s = ($total_s mod 60)
|
||||
let m = ($total_s // 60)
|
||||
return $"($m)m ($s)s ($ms_part)ms"
|
||||
}
|
||||
|
||||
let total_s = ($ms // 1000)
|
||||
let s = ($total_s mod 60)
|
||||
let total_m = ($total_s // 60)
|
||||
let m = ($total_m mod 60)
|
||||
let h = ($total_m // 60)
|
||||
$"($h)h ($m)m ($s)s ($ms_part)ms"
|
||||
}
|
||||
|
||||
def _pj_is_path_within [path: string, base: string] {
|
||||
if ($base == "") {
|
||||
return false
|
||||
}
|
||||
if ($path == $base) {
|
||||
return true
|
||||
}
|
||||
($path | str starts-with $"($base)/")
|
||||
}
|
||||
|
||||
def _pj_git_root_normalized [] {
|
||||
if (which ^git | is-empty) {
|
||||
return ""
|
||||
}
|
||||
|
||||
let top = (^git rev-parse --show-toplevel | complete)
|
||||
if ($top.exit_code != 0) {
|
||||
return ""
|
||||
}
|
||||
|
||||
let raw = (($top.stdout | str trim) | str replace -a "\\" "/")
|
||||
if ($raw == "/") {
|
||||
"/"
|
||||
} else {
|
||||
($raw | str trim -r -c "/")
|
||||
}
|
||||
}
|
||||
|
||||
def _pj_truncate_pwd [pwd: string, length: int = 4] {
|
||||
let home = (($nu.home-dir? | default ($nu.home-path? | default ($env.HOME? | default ""))) | into string)
|
||||
let normalized_pwd_raw = (($pwd | into string) | str replace -a "\\" "/")
|
||||
let normalized_home_raw = (($home | into string) | str replace -a "\\" "/")
|
||||
|
||||
let normalized_pwd = if ($normalized_pwd_raw == "/") {
|
||||
"/"
|
||||
} else {
|
||||
($normalized_pwd_raw | str trim -r -c "/")
|
||||
}
|
||||
|
||||
let normalized_home = if ($normalized_home_raw == "/") {
|
||||
"/"
|
||||
} else {
|
||||
($normalized_home_raw | str trim -r -c "/")
|
||||
}
|
||||
|
||||
let in_home = if ($normalized_home == "") {
|
||||
false
|
||||
} else {
|
||||
(_pj_is_path_within $normalized_pwd $normalized_home)
|
||||
}
|
||||
|
||||
let repo_root = (_pj_git_root_normalized)
|
||||
let in_repo = (_pj_is_path_within $normalized_pwd $repo_root)
|
||||
|
||||
if $in_repo {
|
||||
let repo_name = ($repo_root | path basename)
|
||||
let rel = if ($normalized_pwd == $repo_root) {
|
||||
""
|
||||
} else {
|
||||
($normalized_pwd | str substring (($repo_root | str length) + 1)..)
|
||||
}
|
||||
|
||||
let rel_parts = if ($rel == "") {
|
||||
[]
|
||||
} else {
|
||||
($rel | split row "/" | where {|it| $it != "" })
|
||||
}
|
||||
|
||||
let keep_rel_count = if ($length <= 1) { 0 } else { $length - 1 }
|
||||
let shown_rel_parts = if (($rel_parts | length) <= $keep_rel_count) {
|
||||
$rel_parts
|
||||
} else {
|
||||
($rel_parts | last $keep_rel_count)
|
||||
}
|
||||
|
||||
if (($shown_rel_parts | length) == 0) {
|
||||
return $"…/($repo_name)"
|
||||
} else {
|
||||
return $"…/($repo_name)/($shown_rel_parts | str join '/')"
|
||||
}
|
||||
}
|
||||
|
||||
let shown = if $in_home {
|
||||
let rest = ($normalized_pwd | str substring ($normalized_home | str length)..)
|
||||
if ($rest == "") { "~" } else { $"~($rest)" }
|
||||
} else {
|
||||
$normalized_pwd
|
||||
}
|
||||
|
||||
if ($shown == "~") {
|
||||
return "~"
|
||||
}
|
||||
|
||||
let parts = if ($shown | str starts-with "~/") {
|
||||
($shown | str substring 2.. | split row "/" | where {|it| $it != "" })
|
||||
} else if ($shown | str starts-with "/") {
|
||||
($shown | str substring 1.. | split row "/" | where {|it| $it != "" })
|
||||
} else if ($shown =~ '^[A-Za-z]:(/|$)') {
|
||||
let start = if ($shown =~ '^[A-Za-z]:/') { 3 } else { 2 }
|
||||
($shown | str substring $start.. | split row "/" | where {|it| $it != "" })
|
||||
} else {
|
||||
($shown | split row "/" | where {|it| $it != "" })
|
||||
}
|
||||
|
||||
let prefix = if ($shown | str starts-with "~/") {
|
||||
"~/"
|
||||
} else if ($shown | str starts-with "/") {
|
||||
"/"
|
||||
} else if ($shown =~ '^[A-Za-z]:(/|$)') {
|
||||
let drive = ($shown | str substring 0..1)
|
||||
$"($drive)/"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
|
||||
if (($parts | length) <= $length) {
|
||||
if ($prefix == "") { ($parts | str join "/") } else { $"($prefix)($parts | str join '/')" }
|
||||
} else {
|
||||
let tail = ($parts | last $length | str join "/")
|
||||
$"($prefix)…/($tail)"
|
||||
}
|
||||
}
|
||||
|
||||
def _pj_git_info [] {
|
||||
if (which ^git | is-empty) {
|
||||
return {
|
||||
branch: ""
|
||||
changed: 0
|
||||
untracked: 0
|
||||
stashed: 0
|
||||
ahead: 0
|
||||
behind: 0
|
||||
}
|
||||
}
|
||||
|
||||
let repo_check = (^git rev-parse --is-inside-work-tree | complete)
|
||||
if ($repo_check.exit_code != 0 or (($repo_check.stdout | str trim) != "true")) {
|
||||
return {
|
||||
branch: ""
|
||||
changed: 0
|
||||
untracked: 0
|
||||
stashed: 0
|
||||
ahead: 0
|
||||
behind: 0
|
||||
}
|
||||
}
|
||||
|
||||
let branch_result = (^git branch --show-current | complete)
|
||||
let branch = ($branch_result.stdout | str trim)
|
||||
let branch_text = if ($branch != "") {
|
||||
$branch
|
||||
} else {
|
||||
let head_result = (^git rev-parse --short HEAD | complete)
|
||||
if ($head_result.exit_code == 0) {
|
||||
($head_result.stdout | str trim)
|
||||
} else {
|
||||
""
|
||||
}
|
||||
}
|
||||
|
||||
let status = (^git status --porcelain=2 --branch | complete)
|
||||
if ($status.exit_code != 0) {
|
||||
return {
|
||||
branch: $branch_text
|
||||
changed: 0
|
||||
untracked: 0
|
||||
stashed: 0
|
||||
ahead: 0
|
||||
behind: 0
|
||||
}
|
||||
}
|
||||
|
||||
let lines = ($status.stdout | lines)
|
||||
let changed = ($lines | where {|l| ($l | str starts-with "1 ") or ($l | str starts-with "2 ") or ($l | str starts-with "u ") } | length)
|
||||
let untracked = ($lines | where {|l| $l | str starts-with "? " } | length)
|
||||
let stashed = ((^git stash list | complete).stdout | lines | length)
|
||||
let ab = ($lines | where {|l| $l | str starts-with "# branch.ab " } | get 0?)
|
||||
|
||||
let ahead = if ($ab == null) {
|
||||
0
|
||||
} else {
|
||||
let m = (($ab | parse -r '# branch.ab \+(?<a>\d+) -(?<b>\d+)') | get 0?)
|
||||
if ($m == null) { 0 } else { (($m | get a) | into int) }
|
||||
}
|
||||
|
||||
let behind = if ($ab == null) {
|
||||
0
|
||||
} else {
|
||||
let m = (($ab | parse -r '# branch.ab \+(?<a>\d+) -(?<b>\d+)') | get 0?)
|
||||
if ($m == null) { 0 } else { (($m | get b) | into int) }
|
||||
}
|
||||
|
||||
{
|
||||
branch: $branch_text
|
||||
changed: $changed
|
||||
untracked: $untracked
|
||||
stashed: $stashed
|
||||
ahead: $ahead
|
||||
behind: $behind
|
||||
}
|
||||
}
|
||||
|
||||
def _pj_git_branch_module [p: record] {
|
||||
let git = (_pj_git_info)
|
||||
let branch = ($git.branch | default "")
|
||||
|
||||
mut status_parts = []
|
||||
if (($git.changed | default 0) > 0) {
|
||||
$status_parts = ($status_parts | append $"($p.c_alert)!($git.changed)($p.c_reset)")
|
||||
}
|
||||
if (($git.untracked | default 0) > 0) {
|
||||
$status_parts = ($status_parts | append $"($p.c_alert)?($git.untracked)($p.c_reset)")
|
||||
}
|
||||
if (($git.stashed | default 0) > 0) {
|
||||
$status_parts = ($status_parts | append $"($p.c_alert)\$($git.stashed)($p.c_reset)")
|
||||
}
|
||||
if (($git.ahead | default 0) > 0) {
|
||||
$status_parts = ($status_parts | append $"($p.c_alert)⇡($git.ahead)($p.c_reset)")
|
||||
}
|
||||
if (($git.behind | default 0) > 0) {
|
||||
$status_parts = ($status_parts | append $"($p.c_alert)⇣($git.behind)($p.c_reset)")
|
||||
}
|
||||
|
||||
let git_status = if (($status_parts | length) > 0) {
|
||||
$" (($status_parts | str join ' '))"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
|
||||
if ($branch == "") {
|
||||
""
|
||||
} else {
|
||||
$"($p.c_git)on ($branch)($git_status) ($p.c_reset)"
|
||||
}
|
||||
}
|
||||
|
||||
def _pj_has_glob [pattern: string] {
|
||||
((glob $pattern | length) > 0)
|
||||
}
|
||||
|
||||
def _pj_c_version [] {
|
||||
if (which ^cc | is-empty) {
|
||||
return ""
|
||||
}
|
||||
let out = (^cc --version | complete)
|
||||
_pj_first_version (($out.stdout | str trim) + " " + ($out.stderr | str trim))
|
||||
}
|
||||
|
||||
def _pj_cpp_version [] {
|
||||
if (which ^'c++' | is-empty) {
|
||||
return ""
|
||||
}
|
||||
let out = (^'c++' --version | complete)
|
||||
_pj_first_version (($out.stdout | str trim) + " " + ($out.stderr | str trim))
|
||||
}
|
||||
|
||||
def _pj_rust_version [] {
|
||||
if (which ^rustc | is-empty) {
|
||||
return ""
|
||||
}
|
||||
let out = (^rustc --version | complete)
|
||||
_pj_first_version (($out.stdout | str trim) + " " + ($out.stderr | str trim))
|
||||
}
|
||||
|
||||
def _pj_zig_version [] {
|
||||
if (which ^zig | is-empty) {
|
||||
return ""
|
||||
}
|
||||
let out = (^zig version | complete)
|
||||
_pj_first_version (($out.stdout | str trim) + " " + ($out.stderr | str trim))
|
||||
}
|
||||
|
||||
def _pj_python_version [] {
|
||||
if (which ^python | is-not-empty) {
|
||||
let out = (^python --version | complete)
|
||||
return (_pj_first_version (($out.stdout | str trim) + " " + ($out.stderr | str trim)))
|
||||
}
|
||||
|
||||
if (which ^python3 | is-not-empty) {
|
||||
let out = (^python3 --version | complete)
|
||||
return (_pj_first_version (($out.stdout | str trim) + " " + ($out.stderr | str trim)))
|
||||
}
|
||||
|
||||
""
|
||||
}
|
||||
|
||||
def _pj_python_venv [] {
|
||||
let venv = ($env.VIRTUAL_ENV? | default "")
|
||||
if ($venv != "") {
|
||||
return ($venv | path basename)
|
||||
}
|
||||
($env.CONDA_DEFAULT_ENV? | default "")
|
||||
}
|
||||
|
||||
def _pj_lang_segments [] {
|
||||
let has_c = ((_pj_has_glob "*.c") or (_pj_has_glob "*.h"))
|
||||
let has_cpp = ((_pj_has_glob "*.cpp") or (_pj_has_glob "*.cc") or (_pj_has_glob "*.cxx") or (_pj_has_glob "*.hpp") or (_pj_has_glob "*.hh") or (_pj_has_glob "*.hxx"))
|
||||
let has_rust = (("Cargo.toml" | path exists) or (_pj_has_glob "*.rs"))
|
||||
let has_zig = (("build.zig" | path exists) or (_pj_has_glob "*.zig"))
|
||||
let has_python = (("pyproject.toml" | path exists) or ("requirements.txt" | path exists) or (".python-version" | path exists) or (_pj_has_glob "*.py"))
|
||||
|
||||
mut out = []
|
||||
if $has_c {
|
||||
let v = (_pj_c_version)
|
||||
if ($v != "") {
|
||||
$out = ($out | append $" v($v)")
|
||||
} else {
|
||||
$out = ($out | append "")
|
||||
}
|
||||
}
|
||||
|
||||
if $has_cpp {
|
||||
let v = (_pj_cpp_version)
|
||||
if ($v != "") {
|
||||
$out = ($out | append $" v($v)")
|
||||
} else {
|
||||
$out = ($out | append "")
|
||||
}
|
||||
}
|
||||
|
||||
if $has_rust {
|
||||
let v = (_pj_rust_version)
|
||||
if ($v != "") {
|
||||
$out = ($out | append $" v($v)")
|
||||
} else {
|
||||
$out = ($out | append "")
|
||||
}
|
||||
}
|
||||
|
||||
if $has_zig {
|
||||
let v = (_pj_zig_version)
|
||||
if ($v != "") {
|
||||
$out = ($out | append $" v($v)")
|
||||
} else {
|
||||
$out = ($out | append "")
|
||||
}
|
||||
}
|
||||
|
||||
if $has_python {
|
||||
let pyver = (_pj_python_version)
|
||||
let venv = (_pj_python_venv)
|
||||
let py_base = if ($pyver != "") { $" v($pyver)" } else { "" }
|
||||
if ($venv != "") {
|
||||
$out = ($out | append $"($py_base) \(($venv)\)")
|
||||
} else {
|
||||
$out = ($out | append $py_base)
|
||||
}
|
||||
}
|
||||
|
||||
$out
|
||||
}
|
||||
|
||||
def _pj_shell_module [p: record] {
|
||||
$"($p.c_shell) nu ($p.c_reset)"
|
||||
}
|
||||
|
||||
def _pj_time_module [p: record] {
|
||||
let now = (date now | format date "%R")
|
||||
$"($p.c_time) ($now) ($p.c_reset)"
|
||||
}
|
||||
|
||||
def _pj_duration_module [p: record] {
|
||||
let ms = (_pj_cmd_duration_ms)
|
||||
let duration_text = (_pj_format_duration $ms)
|
||||
$"($p.c_duration) ($duration_text) ($p.c_reset)"
|
||||
}
|
||||
|
||||
def _pj_left_prompt [] {
|
||||
let p = (_pj_palette)
|
||||
let runtime = (_pj_runtime)
|
||||
|
||||
let user_color = if ($runtime.is_root | default false) { $p.c_root } else { $p.c_user }
|
||||
|
||||
let host_part = if ($runtime.in_ssh | default false) {
|
||||
$"($p.c_host)@($runtime.host)($p.c_reset)($p.c_ssh) ($p.c_reset)"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
|
||||
let shell_part = (_pj_shell_module $p)
|
||||
let dir = (_pj_truncate_pwd $env.PWD 4)
|
||||
let git_part = (_pj_git_branch_module $p)
|
||||
|
||||
let langs = (_pj_lang_segments)
|
||||
let lang_parts = ($langs | each {|seg|
|
||||
if ($seg | str starts-with "") {
|
||||
$"($p.c_python)via ($seg) ($p.c_reset)"
|
||||
} else if ($seg | str starts-with "") {
|
||||
$"($p.c_rust)via ($seg) ($p.c_reset)"
|
||||
} else if ($seg | str starts-with "") {
|
||||
$"($p.c_cpp)via ($seg) ($p.c_reset)"
|
||||
} else if ($seg | str starts-with "") {
|
||||
$"($p.c_c)via ($seg) ($p.c_reset)"
|
||||
} else if ($seg | str starts-with "") {
|
||||
$"($p.c_zig)via ($seg) ($p.c_reset)"
|
||||
} else {
|
||||
$seg
|
||||
}
|
||||
})
|
||||
|
||||
let time_part = (_pj_time_module $p)
|
||||
let duration_part = (_pj_duration_module $p)
|
||||
|
||||
mut out = ""
|
||||
$out = $"($out)($p.c_os)(_pj_os_symbol)($p.c_reset)"
|
||||
$out = $"($out)($user_color)($runtime.user)($p.c_reset)"
|
||||
if ($host_part != "") { $out = $"($out)($host_part)" }
|
||||
$out = $"($out)($shell_part)"
|
||||
$out = $"($out)($p.c_dir) ($dir) ($p.c_reset)"
|
||||
if ($git_part != "") { $out = $"($out)($git_part)" }
|
||||
for m in $lang_parts {
|
||||
$out = $"($out)($m)"
|
||||
}
|
||||
$out = $"\n($out)($time_part)($duration_part)\n"
|
||||
$out
|
||||
}
|
||||
|
||||
def _pj_prompt_indicator [] {
|
||||
let p = (_pj_palette)
|
||||
if (($env.LAST_EXIT_CODE? | default 0) == 0) {
|
||||
$"($p.c_indicator_ok)❯($p.c_reset) "
|
||||
} else {
|
||||
$"($p.c_indicator_err)❯($p.c_reset) "
|
||||
}
|
||||
}
|
||||
|
||||
def _pj_right_prompt [] {
|
||||
let p = (_pj_palette)
|
||||
if (($env.LAST_EXIT_CODE? | default 0) != 0) {
|
||||
$"($p.c_right_error)Exit code: ($env.LAST_EXIT_CODE)($p.c_reset)"
|
||||
} else {
|
||||
$""
|
||||
}
|
||||
}
|
||||
|
||||
export-env {
|
||||
load-env {
|
||||
PJ_PROMPT_PALETTE: (_pj_palette_default)
|
||||
PJ_OS_KEY: (_pj_detect_os_key)
|
||||
PROMPT_MULTILINE_INDICATOR: ":"
|
||||
PROMPT_INDICATOR: {||
|
||||
_pj_prompt_indicator
|
||||
}
|
||||
PROMPT_INDICATOR_VI_INSERT: ""
|
||||
PROMPT_INDICATOR_VI_NORMAL: ""
|
||||
PROMPT_COMMAND: {||
|
||||
_pj_left_prompt
|
||||
}
|
||||
PROMPT_COMMAND_RIGHT: {||
|
||||
_pj_right_prompt
|
||||
}
|
||||
config: ($env.config? | default {} | merge {
|
||||
render_right_prompt_on_last_line: true
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,38 @@
|
||||
export def --env config [name: string] {
|
||||
$env.starship_config = ($env.NU_POLYJUICE_PATH | path join ".." "starship" $"starship_($name).toml")
|
||||
export def --env "pj starship config" [name: string] {
|
||||
if (which ^starship | is-empty) {
|
||||
echo "starship is not installed."
|
||||
return
|
||||
}
|
||||
let cfg = ($env.NU_POLYJUICE_PATH | path join ".." "starship" $"starship_($name).toml")
|
||||
$env.STARSHIP_CONFIG = $cfg
|
||||
}
|
||||
|
||||
export def --env init [] {
|
||||
let starship_nushell_path = ($env.NU_POLYJUICE_AUTOLOAD_DIRS | path join "starship.nu")
|
||||
if ($starship_nushell_path | path exists) {
|
||||
rm $starship_nushell_path
|
||||
export def --env "pj starship list" [] {
|
||||
if (which ^starship | is-empty) {
|
||||
echo "starship is not installed."
|
||||
return
|
||||
}
|
||||
ls ($env.NU_POLYJUICE_PATH | path join ".." "starship") -s | get name | parse -r '^(starship_(?<name>.*).toml)$' | get name
|
||||
}
|
||||
|
||||
export def "pj starship doctor" [] {
|
||||
let installed = ((which ^starship | length) > 0)
|
||||
let prompt_type = ($env.PROMPT_COMMAND? | describe)
|
||||
let right_prompt_type = ($env.PROMPT_COMMAND_RIGHT? | describe)
|
||||
let prompt_cmd = (($env.PROMPT_COMMAND? | to nuon --serialize) | default "<not-set>")
|
||||
let right_prompt_cmd = (($env.PROMPT_COMMAND_RIGHT? | to nuon --serialize) | default "<not-set>")
|
||||
let prompt_uses_starship = ($prompt_cmd | str contains "starship' prompt")
|
||||
let right_prompt_uses_starship = ($right_prompt_cmd | str contains "starship' prompt")
|
||||
|
||||
{
|
||||
starship_installed: $installed
|
||||
starship_path: ((which ^starship | get path.0?) | default "<not-found>")
|
||||
starship_version: (if $installed { (^starship --version | str trim) } else { "<not-installed>" })
|
||||
STARSHIP_SHELL: ($env.STARSHIP_SHELL? | default "<not-set>")
|
||||
STARSHIP_CONFIG: ($env.STARSHIP_CONFIG? | default "<not-set>")
|
||||
prompt_command_type: $prompt_type
|
||||
prompt_command_uses_starship: $prompt_uses_starship
|
||||
prompt_command_right_type: $right_prompt_type
|
||||
prompt_command_right_uses_starship: $right_prompt_uses_starship
|
||||
}
|
||||
starship init nu | save -f $starship_nushell_path
|
||||
}
|
||||
|
||||
@@ -1,7 +1,99 @@
|
||||
export def --env init [] {
|
||||
let zoxide_nushell_path = ($env.NU_POLYJUICE_AUTOLOAD_DIRS | path join "zoxide.nu")
|
||||
if ($zoxide_nushell_path | path exists) {
|
||||
rm $zoxide_nushell_path
|
||||
# export def --env init [] {
|
||||
# let zoxide_nushell_path = ($env.NU_POLYJUICE_AUTOLOAD_DIRS | path join "zoxide.nu")
|
||||
# if ($zoxide_nushell_path | path exists) {
|
||||
# rm $zoxide_nushell_path
|
||||
# }
|
||||
# zoxide init nushell --cmd z | save -f $zoxide_nushell_path
|
||||
# }
|
||||
|
||||
|
||||
|
||||
|
||||
# Code generated by zoxide. DO NOT EDIT.
|
||||
|
||||
# =============================================================================
|
||||
#
|
||||
# Hook configuration for zoxide.
|
||||
#
|
||||
|
||||
# Initialize hook to add new entries to the database.
|
||||
export-env {
|
||||
$env.config = (
|
||||
$env.config?
|
||||
| default {}
|
||||
| upsert hooks { default {} }
|
||||
| upsert hooks.env_change { default {} }
|
||||
| upsert hooks.env_change.PWD { default [] }
|
||||
)
|
||||
let __zoxide_hooked = (
|
||||
$env.config.hooks.env_change.PWD | any { try { get __zoxide_hook } catch { false } }
|
||||
)
|
||||
if not $__zoxide_hooked {
|
||||
$env.config.hooks.env_change.PWD = ($env.config.hooks.env_change.PWD | append {
|
||||
__zoxide_hook: true,
|
||||
code: {|_, dir| zoxide add -- $dir}
|
||||
})
|
||||
}
|
||||
zoxide init nushell --cmd z | save -f $zoxide_nushell_path
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
#
|
||||
# When using zoxide with --no-cmd, alias these internal functions as desired.
|
||||
#
|
||||
|
||||
# Jump to a directory using only keywords.
|
||||
def --env --wrapped __zoxide_z [...rest: string] {
|
||||
let path = match $rest {
|
||||
[] => {'~'},
|
||||
[ '-' ] => {'-'},
|
||||
[ $arg ] if ($arg | path expand | path type) == 'dir' => {$arg}
|
||||
_ => {
|
||||
zoxide query --exclude $env.PWD -- ...$rest | str trim -r -c "\n"
|
||||
}
|
||||
}
|
||||
cd $path
|
||||
}
|
||||
|
||||
# Jump to a directory using interactive search.
|
||||
def --env --wrapped __zoxide_zi [...rest:string] {
|
||||
cd $'(zoxide query --interactive -- ...$rest | str trim -r -c "\n")'
|
||||
}
|
||||
|
||||
# Jump to git repository root when currently inside a repository.
|
||||
def --env __zoxide_zg [] {
|
||||
if (which ^git | is-empty) {
|
||||
return
|
||||
}
|
||||
|
||||
let top = (^git rev-parse --show-toplevel | complete)
|
||||
if ($top.exit_code != 0) {
|
||||
return
|
||||
}
|
||||
|
||||
let root = ($top.stdout | str trim -r -c "\n")
|
||||
if ($root != "") {
|
||||
cd $root
|
||||
}
|
||||
}
|
||||
|
||||
# =============================================================================
|
||||
#
|
||||
# Commands for zoxide. Disable these using --no-cmd.
|
||||
#
|
||||
|
||||
export alias z = __zoxide_z
|
||||
export alias zi = __zoxide_zi
|
||||
export alias zg = __zoxide_zg
|
||||
|
||||
# =============================================================================
|
||||
#
|
||||
# Add this to your env file (find it by running `$nu.env-path` in Nushell):
|
||||
#
|
||||
# zoxide init nushell | save -f ~/.zoxide.nu
|
||||
#
|
||||
# Now, add this to the end of your config file (find it by running
|
||||
# `$nu.config-path` in Nushell):
|
||||
#
|
||||
# source ~/.zoxide.nu
|
||||
#
|
||||
# Note: zoxide only supports Nushell v0.89.0+.
|
||||
|
||||
+7
-10
@@ -3,15 +3,12 @@ $env.config.show_banner = false
|
||||
|
||||
# Terminal Polyjuice Files's Path
|
||||
$env.NU_POLYJUICE_PATH = $env.FILE_PWD
|
||||
$env.NU_POLYJUICE_CACHE_PATH = $env.NU_POLYJUICE_PATH + "/cache"
|
||||
$env.NU_POLYJUICE_AUTOLOAD_DIRS = ($nu.user-autoload-dirs)
|
||||
|
||||
# modules
|
||||
use modules/pj.nu
|
||||
use modules/pj_starship.nu
|
||||
use modules/pj_zoxide.nu
|
||||
|
||||
source aliases/pj_aliases.nu
|
||||
|
||||
# starship
|
||||
pj_starship config "default"
|
||||
use modules/pj_aliases.nu *
|
||||
use modules/pj_completions.nu *
|
||||
use modules/pj_helix.nu *
|
||||
use modules/pj_fzf.nu *
|
||||
use modules/pj_zoxide.nu *
|
||||
use modules/pj_historyhintcomplete.nu *
|
||||
use modules/pj_prompt.nu *
|
||||
|
||||
@@ -9,16 +9,18 @@ $git_status\
|
||||
$c\
|
||||
$cpp\
|
||||
$rust\
|
||||
$golang\
|
||||
$nodejs\
|
||||
$scala\
|
||||
$haskell\
|
||||
$zig\
|
||||
$python\
|
||||
$time\
|
||||
$cmd_duration\
|
||||
$line_break\
|
||||
$character"""
|
||||
|
||||
# $golang\
|
||||
# $nodejs\
|
||||
# $scala\
|
||||
# $haskell\
|
||||
|
||||
palette = 'terminal_polyjuice'
|
||||
|
||||
[palettes.terminal_polyjuice]
|
||||
|
||||
@@ -53,7 +53,7 @@ alias -g P="2>&1| pygmentize -l pytb"
|
||||
|
||||
alias dud='du -d 1 -h'
|
||||
(( $+commands[duf] )) || alias duf='du -sh *'
|
||||
(( $+commands[fd] )) || alias fd='find . -type d -name'
|
||||
# (( $+commands[fd] )) || alias fd='find . -type d -name'
|
||||
alias ff='find . -type f -name'
|
||||
|
||||
alias h='history'
|
||||
|
||||
+47
-2
@@ -1,5 +1,3 @@
|
||||
eval "$(fzf --zsh)"
|
||||
|
||||
if [[ -z "$FZF_DEFAULT_COMMAND" ]]; then
|
||||
if (( $+commands[fd] )); then
|
||||
export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude .git'
|
||||
@@ -9,3 +7,50 @@ if [[ -z "$FZF_DEFAULT_COMMAND" ]]; then
|
||||
export FZF_DEFAULT_COMMAND='ag -l --hidden -g "" --ignore .git'
|
||||
fi
|
||||
fi
|
||||
|
||||
# alt-f to search files with fzf
|
||||
function fzf-file-widget() {
|
||||
local selected_file
|
||||
local command_to_run="fzf"
|
||||
if (( $+commands[fd] )); then
|
||||
command_to_run="fd --type f --hidden --exclude .git | fzf"
|
||||
elif (( $+commands[rg] )); then
|
||||
command_to_run='rg --files --hidden --glob "!.git/*" | fzf'
|
||||
elif (( $+commands[ag] )); then
|
||||
command_to_run='ag -l --hidden -g "" --ignore .git | fzf'
|
||||
else
|
||||
command_to_run='find . -type f | fzf'
|
||||
fi
|
||||
selected_file=$(eval $command_to_run)
|
||||
LBUFFER+="$selected_file"
|
||||
}
|
||||
# alt-f to trigger file search
|
||||
zle -N fzf-file-widget
|
||||
bindkey '\ef' fzf-file-widget
|
||||
|
||||
|
||||
# alt-d to search directories with fzf
|
||||
function fzf-directory-widget() {
|
||||
local selected_dir
|
||||
local command_to_run
|
||||
if (( $+commands[fd] )); then
|
||||
command_to_run="fd --type d --hidden --no-ignore --exclude .git | fzf"
|
||||
else
|
||||
command_to_run='find . -type d | fzf'
|
||||
fi
|
||||
selected_dir=$(eval $command_to_run)
|
||||
LBUFFER+="$selected_dir"
|
||||
}
|
||||
# alt-d to trigger directory search
|
||||
zle -N fzf-directory-widget
|
||||
bindkey '\ed' fzf-directory-widget
|
||||
|
||||
# alt-h to search command history with fzf
|
||||
function fzf-history-widget() {
|
||||
local selected_command
|
||||
selected_command=$(fc -frl 1 | fzf | awk '{$1=$2=$3=""; gsub(/^ +/, ""); print}')
|
||||
LBUFFER+="$selected_command"
|
||||
}
|
||||
# alt-h to trigger history search
|
||||
zle -N fzf-history-widget
|
||||
bindkey '\eh' fzf-history-widget
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
if (( $+commands[helix] )); then
|
||||
alias helix="helix -c $ZSH_POLYJUICE_HELIX_CONFIG_FILE"
|
||||
alias hx="helix -c $ZSH_POLYJUICE_HELIX_CONFIG_FILE"
|
||||
elif (( $+commands[hx] )); then
|
||||
alias helix="hx -c $ZSH_POLYJUICE_HELIX_CONFIG_FILE"
|
||||
alias hx="hx -c $ZSH_POLYJUICE_HELIX_CONFIG_FILE"
|
||||
else
|
||||
alias helix="echo HELIX is not installed"
|
||||
alias hx="echo HELIX/HX is not installed"
|
||||
fi
|
||||
@@ -22,9 +22,9 @@ function pj_check() {
|
||||
fi
|
||||
|
||||
# check for oh-my-zsh
|
||||
if [[ ! -d $ZSH_POLYJUICE_PLUGINS_PATH/ohmyzsh ]]; then
|
||||
echo "oh-my-zsh is not installed."
|
||||
fi
|
||||
# if [[ ! -d $ZSH_POLYJUICE_PLUGINS_PATH/ohmyzsh ]]; then
|
||||
# echo "oh-my-zsh is not installed."
|
||||
# fi
|
||||
|
||||
# check for zoxide
|
||||
if (( ! $+commands[zoxide] )); then
|
||||
|
||||
+14
-14
@@ -73,20 +73,20 @@ function pj_install_plugins() {
|
||||
fi
|
||||
|
||||
# git clone oh-my-zsh
|
||||
if [ ! -d "$ZSH_POLYJUICE_PLUGINS_PATH"/ohmyzsh ]; then
|
||||
echo "Oh My Zsh is not downloaded. Downloading..."
|
||||
# git clone https://github.com/ohmyzsh/ohmyzsh.git "$PATH_OHMYZSH"
|
||||
git clone https://gitee.com/mirrors/ohmyzsh.git "$ZSH_POLYJUICE_PLUGINS_PATH"/ohmyzsh
|
||||
else
|
||||
cd "$ZSH_POLYJUICE_PLUGINS_PATH"/ohmyzsh
|
||||
if [ ! -d .git ]; then
|
||||
echo "Oh My Zsh is not a git repository. Please remove $ZSH_POLYJUICE_PLUGINS_PATH/ohmyzsh and try again."
|
||||
else
|
||||
echo "Oh My Zsh is already exist. Updating..."
|
||||
git pull
|
||||
fi
|
||||
cd -
|
||||
fi
|
||||
# if [ ! -d "$ZSH_POLYJUICE_PLUGINS_PATH"/ohmyzsh ]; then
|
||||
# echo "Oh My Zsh is not downloaded. Downloading..."
|
||||
# # git clone https://github.com/ohmyzsh/ohmyzsh.git "$PATH_OHMYZSH"
|
||||
# git clone https://gitee.com/mirrors/ohmyzsh.git "$ZSH_POLYJUICE_PLUGINS_PATH"/ohmyzsh
|
||||
# else
|
||||
# cd "$ZSH_POLYJUICE_PLUGINS_PATH"/ohmyzsh
|
||||
# if [ ! -d .git ]; then
|
||||
# echo "Oh My Zsh is not a git repository. Please remove $ZSH_POLYJUICE_PLUGINS_PATH/ohmyzsh and try again."
|
||||
# else
|
||||
# echo "Oh My Zsh is already exist. Updating..."
|
||||
# git pull
|
||||
# fi
|
||||
# cd -
|
||||
# fi
|
||||
|
||||
echo "All plugins are installed/updated. Run 'exec zsh' to apply changes."
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# "[interop] appendWindowsPath=false" in /etc/wsl.conf is setted
|
||||
# Append VSCode on Windows into PATH so that vscode can be used in WSL
|
||||
export PATH=$PATH:'/mnt/c/Users/gwbei/AppData/Local/Programs/Microsoft VS Code/bin/'
|
||||
export PATH=$PATH:'/mnt/c/Users/gwbei/AppData/Local/Programs/Zed/bin/zed'
|
||||
|
||||
# Language and encoding related
|
||||
export LC_ALL=C.UTF-8
|
||||
@@ -21,6 +21,7 @@ export ZSH_POLYJUICE_ALIAS_PATH="$ZSH_POLYJUICE_PATH/alias"
|
||||
export ZSH_POLYJUICE_SETTINGS_PATH="$ZSH_POLYJUICE_PATH/settings"
|
||||
export ZSH_POLYJUICE_FUNCTIONS_PATH="$ZSH_POLYJUICE_PATH/functions"
|
||||
export ZSH_POLYJUICE_STARSHIP_CONFIG_FILE="$ZSH_POLYJUICE_PATH/../starship/starship_default.toml"
|
||||
export ZSH_POLYJUICE_HELIX_CONFIG_FILE="$ZSH_POLYJUICE_PATH/../helix/config.toml"
|
||||
|
||||
# Load basic settings `zsh/settings`
|
||||
for _file in "$ZSH_POLYJUICE_SETTINGS_PATH"/*.sh; do
|
||||
@@ -40,21 +41,48 @@ for _file in "$ZSH_POLYJUICE_FUNCTIONS_PATH"/*.sh; do
|
||||
done
|
||||
unset _file
|
||||
|
||||
# Load Plugins
|
||||
if [[ -f $ZSH_POLYJUICE_PLUGINS_PATH/zsh-autosuggestions/zsh-autosuggestions.zsh ]]; then
|
||||
# macOS configuration
|
||||
if [[ $OS == "Darwin" ]]; then
|
||||
# Load Plugins
|
||||
if [[ -f $ZSH_POLYJUICE_PLUGINS_PATH/zsh-autocomplete/zsh-autocomplete.plugin.zsh ]]; then
|
||||
zstyle ':autocomplete:async' enabled no
|
||||
source $ZSH_POLYJUICE_PLUGINS_PATH/zsh-autocomplete/zsh-autocomplete.plugin.zsh
|
||||
fi
|
||||
if [[ -f $ZSH_POLYJUICE_PLUGINS_PATH/fzf-tab/fzf-tab.plugin.zsh ]]; then
|
||||
source $ZSH_POLYJUICE_PLUGINS_PATH/fzf-tab/fzf-tab.plugin.zsh # should load before autosuggestions/syntax-highlighting
|
||||
fi
|
||||
if [[ -f $ZSH_POLYJUICE_PLUGINS_PATH/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh ]]; then
|
||||
source $ZSH_POLYJUICE_PLUGINS_PATH/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh
|
||||
fi
|
||||
if [[ -f $ZSH_POLYJUICE_PLUGINS_PATH/zsh-autosuggestions/zsh-autosuggestions.zsh ]]; then
|
||||
ZSH_AUTOSUGGEST_STRATEGY=(history)
|
||||
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20
|
||||
ZSH_AUTOSUGGEST_MANUAL_REBIND=1
|
||||
|
||||
source $ZSH_POLYJUICE_PLUGINS_PATH/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh
|
||||
|
||||
unset ZSH_AUTOSUGGEST_USE_ASYNC
|
||||
_zsh_autosuggest_bind_widgets
|
||||
bindkey '^[l' autosuggest-accept # alt-L to accept autosuggestion
|
||||
fi
|
||||
else
|
||||
# Load Plugins
|
||||
if [[ -f $ZSH_POLYJUICE_PLUGINS_PATH/zsh-autocomplete/zsh-autocomplete.plugin.zsh ]]; then
|
||||
source $ZSH_POLYJUICE_PLUGINS_PATH/zsh-autocomplete/zsh-autocomplete.plugin.zsh
|
||||
fi
|
||||
if [[ -f $ZSH_POLYJUICE_PLUGINS_PATH/fzf-tab/fzf-tab.plugin.zsh ]]; then
|
||||
source $ZSH_POLYJUICE_PLUGINS_PATH/fzf-tab/fzf-tab.plugin.zsh # should load before autosuggestions/syntax-highlighting
|
||||
fi
|
||||
if [[ -f $ZSH_POLYJUICE_PLUGINS_PATH/zsh-autosuggestions/zsh-autosuggestions.zsh ]]; then
|
||||
source $ZSH_POLYJUICE_PLUGINS_PATH/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh
|
||||
ZSH_AUTOSUGGEST_STRATEGY=(history completion)
|
||||
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20
|
||||
bindkey '^[l' autosuggest-accept # alt-L to accept autosuggestion
|
||||
fi
|
||||
if [[ -f $ZSH_POLYJUICE_PLUGINS_PATH/zsh-autocomplete/zsh-autocomplete.plugin.zsh ]]; then
|
||||
source $ZSH_POLYJUICE_PLUGINS_PATH/zsh-autocomplete/zsh-autocomplete.plugin.zsh
|
||||
fi
|
||||
if [[ -f $ZSH_POLYJUICE_PLUGINS_PATH/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh ]]; then
|
||||
fi
|
||||
if [[ -f $ZSH_POLYJUICE_PLUGINS_PATH/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh ]]; then
|
||||
source $ZSH_POLYJUICE_PLUGINS_PATH/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh
|
||||
fi
|
||||
if [[ -f $ZSH_POLYJUICE_PLUGINS_PATH/fzf-tab/fzf-tab.plugin.zsh ]]; then
|
||||
source $ZSH_POLYJUICE_PLUGINS_PATH/fzf-tab/fzf-tab.plugin.zsh # relies on fzf itself and zsh-autosuggestions plugin
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# using starship as prompt
|
||||
|
||||
Reference in New Issue
Block a user