Compare commits
12 Commits
0a6abee3f4
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 6f1e783a56 | |||
| a9080203f6 | |||
| e384a4ad0c | |||
| bbc0d2f0a1 | |||
| 1af9a937d8 | |||
| 0f9b528471 | |||
| 0bb8f0e5e8 | |||
| 3d22ed9633 | |||
| e86f9d47e7 | |||
| 21129ab5b9 | |||
| cacd241cca | |||
| 05b2a28b94 |
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"]
|
||||||
@@ -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
|
|
||||||
0
nushell/cache/.gitkeep
vendored
0
nushell/cache/.gitkeep
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
|
|
||||||
}
|
|
||||||
31
nushell/modules/pj_aliases.nu
Normal file
31
nushell/modules/pj_aliases.nu
Normal file
@@ -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
|
||||||
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
85
nushell/modules/pj_fzf.nu
Normal file
85
nushell/modules/pj_fzf.nu
Normal file
@@ -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)
|
||||||
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
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
56
nushell/modules/pj_prompt.nu
Normal file
56
nushell/modules/pj_prompt.nu
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
export def --env "pj starship config" [name: string] {
|
||||||
|
if (which ^starship | is-empty) {
|
||||||
|
echo "starship is not installed."
|
||||||
|
return
|
||||||
|
}
|
||||||
|
$env.starship_config = ($env.NU_POLYJUICE_PATH | path join ".." "starship" $"starship_($name).toml")
|
||||||
|
}
|
||||||
|
|
||||||
|
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-env {
|
||||||
|
if (which ^starship | is-not-empty) {
|
||||||
|
$env.STARSHIP_SHELL = "nu"
|
||||||
|
load-env {
|
||||||
|
STARSHIP_SESSION_KEY: (random chars -l 16)
|
||||||
|
PROMPT_MULTILINE_INDICATOR: (
|
||||||
|
^'starship' prompt --continuation
|
||||||
|
)
|
||||||
|
|
||||||
|
# Does not play well with default character module.
|
||||||
|
# TODO: Also Use starship vi mode indicators?
|
||||||
|
PROMPT_INDICATOR: ""
|
||||||
|
|
||||||
|
PROMPT_COMMAND: {||
|
||||||
|
# jobs are not supported
|
||||||
|
(
|
||||||
|
^'starship' prompt
|
||||||
|
--cmd-duration $env.CMD_DURATION_MS
|
||||||
|
$"--status=($env.LAST_EXIT_CODE)"
|
||||||
|
--terminal-width (term size).columns
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
config: ($env.config? | default {} | merge {
|
||||||
|
render_right_prompt_on_last_line: true
|
||||||
|
})
|
||||||
|
|
||||||
|
PROMPT_COMMAND_RIGHT: {||
|
||||||
|
(
|
||||||
|
^'starship' prompt
|
||||||
|
--right
|
||||||
|
--cmd-duration $env.CMD_DURATION_MS
|
||||||
|
$"--status=($env.LAST_EXIT_CODE)"
|
||||||
|
--terminal-width (term size).columns
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$env.starship_config = ($env.NU_POLYJUICE_PATH | path join ".." "starship" $"starship_default.toml")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
export def --env config [name: string] {
|
|
||||||
$env.starship_config = ($env.NU_POLYJUICE_PATH | path join ".." "starship" $"starship_($name).toml")
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
starship init nu | save -f $starship_nushell_path
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,81 @@
|
|||||||
export def --env init [] {
|
# export def --env init [] {
|
||||||
let zoxide_nushell_path = ($env.NU_POLYJUICE_AUTOLOAD_DIRS | path join "zoxide.nu")
|
# let zoxide_nushell_path = ($env.NU_POLYJUICE_AUTOLOAD_DIRS | path join "zoxide.nu")
|
||||||
if ($zoxide_nushell_path | path exists) {
|
# if ($zoxide_nushell_path | path exists) {
|
||||||
rm $zoxide_nushell_path
|
# rm $zoxide_nushell_path
|
||||||
}
|
# }
|
||||||
zoxide init nushell --cmd z | save -f $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}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
#
|
||||||
|
# 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")'
|
||||||
|
}
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
#
|
||||||
|
# Commands for zoxide. Disable these using --no-cmd.
|
||||||
|
#
|
||||||
|
|
||||||
|
export alias z = __zoxide_z
|
||||||
|
export alias zi = __zoxide_zi
|
||||||
|
|
||||||
|
# =============================================================================
|
||||||
|
#
|
||||||
|
# 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+.
|
||||||
|
|||||||
@@ -3,15 +3,12 @@ $env.config.show_banner = false
|
|||||||
|
|
||||||
# Terminal Polyjuice Files's Path
|
# Terminal Polyjuice Files's Path
|
||||||
$env.NU_POLYJUICE_PATH = $env.FILE_PWD
|
$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
|
# modules
|
||||||
use modules/pj.nu
|
use modules/pj_aliases.nu *
|
||||||
use modules/pj_starship.nu
|
use modules/pj_completions.nu *
|
||||||
use modules/pj_zoxide.nu
|
use modules/pj_helix.nu *
|
||||||
|
use modules/pj_fzf.nu *
|
||||||
source aliases/pj_aliases.nu
|
use modules/pj_zoxide.nu *
|
||||||
|
use modules/pj_historyhintcomplete.nu *
|
||||||
# starship
|
use modules/pj_prompt.nu *
|
||||||
pj_starship config "default"
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ alias -g P="2>&1| pygmentize -l pytb"
|
|||||||
|
|
||||||
alias dud='du -d 1 -h'
|
alias dud='du -d 1 -h'
|
||||||
(( $+commands[duf] )) || alias duf='du -sh *'
|
(( $+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 ff='find . -type f -name'
|
||||||
|
|
||||||
alias h='history'
|
alias h='history'
|
||||||
|
|||||||
@@ -1,11 +1,56 @@
|
|||||||
eval "$(fzf --zsh)"
|
|
||||||
|
|
||||||
if [[ -z "$FZF_DEFAULT_COMMAND" ]]; then
|
if [[ -z "$FZF_DEFAULT_COMMAND" ]]; then
|
||||||
if (( $+commands[fd] )); then
|
if (( $+commands[fd] )); then
|
||||||
export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude .git'
|
export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude .git'
|
||||||
elif (( $+commands[rg] )); then
|
elif (( $+commands[rg] )); then
|
||||||
export FZF_DEFAULT_COMMAND='rg --files --hidden --glob "!.git/*"'
|
export FZF_DEFAULT_COMMAND='rg --files --hidden --glob "!.git/*"'
|
||||||
elif (( $+commands[ag] )); then
|
elif (( $+commands[ag] )); then
|
||||||
export FZF_DEFAULT_COMMAND='ag -l --hidden -g "" --ignore .git'
|
export FZF_DEFAULT_COMMAND='ag -l --hidden -g "" --ignore .git'
|
||||||
fi
|
fi
|
||||||
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
|
fi
|
||||||
|
|
||||||
# check for oh-my-zsh
|
# check for oh-my-zsh
|
||||||
if [[ ! -d $ZSH_POLYJUICE_PLUGINS_PATH/ohmyzsh ]]; then
|
# if [[ ! -d $ZSH_POLYJUICE_PLUGINS_PATH/ohmyzsh ]]; then
|
||||||
echo "oh-my-zsh is not installed."
|
# echo "oh-my-zsh is not installed."
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
# check for zoxide
|
# check for zoxide
|
||||||
if (( ! $+commands[zoxide] )); then
|
if (( ! $+commands[zoxide] )); then
|
||||||
|
|||||||
@@ -73,20 +73,20 @@ function pj_install_plugins() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# git clone oh-my-zsh
|
# git clone oh-my-zsh
|
||||||
if [ ! -d "$ZSH_POLYJUICE_PLUGINS_PATH"/ohmyzsh ]; then
|
# if [ ! -d "$ZSH_POLYJUICE_PLUGINS_PATH"/ohmyzsh ]; then
|
||||||
echo "Oh My Zsh is not downloaded. Downloading..."
|
# echo "Oh My Zsh is not downloaded. Downloading..."
|
||||||
# git clone https://github.com/ohmyzsh/ohmyzsh.git "$PATH_OHMYZSH"
|
# # git clone https://github.com/ohmyzsh/ohmyzsh.git "$PATH_OHMYZSH"
|
||||||
git clone https://gitee.com/mirrors/ohmyzsh.git "$ZSH_POLYJUICE_PLUGINS_PATH"/ohmyzsh
|
# git clone https://gitee.com/mirrors/ohmyzsh.git "$ZSH_POLYJUICE_PLUGINS_PATH"/ohmyzsh
|
||||||
else
|
# else
|
||||||
cd "$ZSH_POLYJUICE_PLUGINS_PATH"/ohmyzsh
|
# cd "$ZSH_POLYJUICE_PLUGINS_PATH"/ohmyzsh
|
||||||
if [ ! -d .git ]; then
|
# if [ ! -d .git ]; then
|
||||||
echo "Oh My Zsh is not a git repository. Please remove $ZSH_POLYJUICE_PLUGINS_PATH/ohmyzsh and try again."
|
# echo "Oh My Zsh is not a git repository. Please remove $ZSH_POLYJUICE_PLUGINS_PATH/ohmyzsh and try again."
|
||||||
else
|
# else
|
||||||
echo "Oh My Zsh is already exist. Updating..."
|
# echo "Oh My Zsh is already exist. Updating..."
|
||||||
git pull
|
# git pull
|
||||||
fi
|
# fi
|
||||||
cd -
|
# cd -
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
echo "All plugins are installed/updated. Run 'exec zsh' to apply changes."
|
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
|
# "[interop] appendWindowsPath=false" in /etc/wsl.conf is setted
|
||||||
# Append VSCode on Windows into PATH so that vscode can be used in WSL
|
# 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/Microsoft VS Code/bin/'
|
||||||
|
export PATH=$PATH:'/mnt/c/Users/gwbei/AppData/Local/Programs/Zed/bin/zed'
|
||||||
|
|
||||||
# Language and encoding related
|
# Language and encoding related
|
||||||
export LC_ALL=C.UTF-8
|
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_SETTINGS_PATH="$ZSH_POLYJUICE_PATH/settings"
|
||||||
export ZSH_POLYJUICE_FUNCTIONS_PATH="$ZSH_POLYJUICE_PATH/functions"
|
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_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`
|
# Load basic settings `zsh/settings`
|
||||||
for _file in "$ZSH_POLYJUICE_SETTINGS_PATH"/*.sh; do
|
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
|
source $ZSH_POLYJUICE_PLUGINS_PATH/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh
|
||||||
fi
|
fi
|
||||||
if [[ -f $ZSH_POLYJUICE_PLUGINS_PATH/fzf-tab/fzf-tab.plugin.zsh ]]; then
|
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
|
fi
|
||||||
|
|
||||||
# using starship as prompt
|
# using starship as prompt
|
||||||
|
|||||||
Reference in New Issue
Block a user