Compare commits
10 Commits
cacd241cca
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 6f1e783a56 | |||
| a9080203f6 | |||
| e384a4ad0c | |||
| bbc0d2f0a1 | |||
| 1af9a937d8 | |||
| 0f9b528471 | |||
| 0bb8f0e5e8 | |||
| 3d22ed9633 | |||
| e86f9d47e7 | |||
| 21129ab5b9 |
19
helix/config.toml
Normal file
19
helix/config.toml
Normal file
@@ -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"]
|
||||
@@ -5,13 +5,23 @@ export alias lla = ls -la
|
||||
export alias lh = ls -lh
|
||||
export alias lt = ls -l | sort-by modified | reverse
|
||||
|
||||
export alias cdi = cd (ls **/ | get name | str join "\n" | fzf)
|
||||
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 {
|
||||
} else if (which ^python3 | is-not-empty) {
|
||||
^python3 ...$rest
|
||||
} else {
|
||||
print "Error: Python is not installed or could not be found."
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
14
nushell/modules/pj_completions.nu
Normal file
14
nushell/modules/pj_completions.nu
Normal file
@@ -0,0 +1,14 @@
|
||||
export-env {
|
||||
$env.config = {
|
||||
completions: {
|
||||
quick: true
|
||||
partial: true
|
||||
algorithm: "fuzzy"
|
||||
case_sensitive: false
|
||||
external: {
|
||||
enable: true
|
||||
max_results: 100
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -81,3 +81,5 @@ export-env {
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
export alias cdi = cd (ls **/ | get name | str join "\n" | fzf)
|
||||
|
||||
33
nushell/modules/pj_helix.nu
Normal file
33
nushell/modules/pj_helix.nu
Normal file
@@ -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."
|
||||
}
|
||||
}
|
||||
}
|
||||
42
nushell/modules/pj_historyhintcomplete.nu
Normal file
42
nushell/modules/pj_historyhintcomplete.nu
Normal file
@@ -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
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
export def --env "pj starship config" [name: string] {
|
||||
if (which ^starship | is-empty) {
|
||||
echo "starship is not installed." | warn
|
||||
echo "starship is not installed."
|
||||
return
|
||||
}
|
||||
$env.starship_config = ($env.NU_POLYJUICE_PATH | path join ".." "starship" $"starship_($name).toml")
|
||||
@@ -8,7 +8,7 @@ export def --env "pj starship config" [name: string] {
|
||||
|
||||
export def --env "pj starship list" [] {
|
||||
if (which ^starship | is-empty) {
|
||||
echo "starship is not installed." | warn
|
||||
echo "starship is not installed."
|
||||
return
|
||||
}
|
||||
ls ($env.NU_POLYJUICE_PATH | path join ".." "starship") -s | get name | parse -r '^(starship_(?<name>.*).toml)$' | get name
|
||||
|
||||
@@ -6,6 +6,9 @@ $env.NU_POLYJUICE_PATH = $env.FILE_PWD
|
||||
|
||||
# modules
|
||||
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 *
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -1,11 +1,56 @@
|
||||
eval "$(fzf --zsh)"
|
||||
|
||||
if [[ -z "$FZF_DEFAULT_COMMAND" ]]; then
|
||||
if (( $+commands[fd] )); then
|
||||
export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude .git'
|
||||
elif (( $+commands[rg] )); then
|
||||
export FZF_DEFAULT_COMMAND='rg --files --hidden --glob "!.git/*"'
|
||||
elif (( $+commands[ag] )); then
|
||||
export FZF_DEFAULT_COMMAND='ag -l --hidden -g "" --ignore .git'
|
||||
fi
|
||||
if (( $+commands[fd] )); then
|
||||
export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude .git'
|
||||
elif (( $+commands[rg] )); then
|
||||
export FZF_DEFAULT_COMMAND='rg --files --hidden --glob "!.git/*"'
|
||||
elif (( $+commands[ag] )); 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
|
||||
|
||||
10
zsh/alias/helix_alias.sh
Normal file
10
zsh/alias/helix_alias.sh
Normal file
@@ -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
|
||||
|
||||
@@ -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."
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -54,7 +55,7 @@ if [[ -f $ZSH_POLYJUICE_PLUGINS_PATH/zsh-syntax-highlighting/zsh-syntax-highligh
|
||||
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
|
||||
source $ZSH_POLYJUICE_PLUGINS_PATH/fzf-tab/fzf-tab.plugin.zsh # relies on fzf itself and zsh-autocomplete plugin
|
||||
fi
|
||||
|
||||
# using starship as prompt
|
||||
|
||||
Reference in New Issue
Block a user