repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

nushell: update configuration for version 0.61.0

25941d13bf3598f26bf83b3caa5035bb3a2e0ca9

Oliver Jan Krylow <olver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (21)

.gitignore

Modified
5 5 bootstripper/win32/cross9
6 6 tresor/box_do_key
7 7 nushell/zoxide.nu
8 +nushell/history.txt

COMMANDS.md

Added
new file mode 100644
1 +## Commands to remember
3 +- ouch: compress and decompress archives
4 +- sd: search and replace
5 +- fd: find files recursively
6 +- diskonaut: explore file system visually for large files
7 +- btm (bottom): system overview
8 +- rg: search file contents
9 +- bat: show file content
10 +- mdcat: render markdown in the terminal
11 +- tokei: count lines of code
12 +- hyperfine: benchmark tool
13 +- menyoki: capture screenshots, record gifs
14 +- rpick: Choose something out of predefined model using fancy algorithms
15 +- tldr: tool documentation
16 +- grex: regular expression pattern generator
17 +- xh: make HTTP requests
18 +- watchexec: filesystem watcher
19 +- viu: view images in terminal (blocky approximation)
20 +- licensor: print a license text
21 +- pastel: manage colors
22 +- hexyl: terminal hex viewer
23 +- gib: generate gitignore files
24 +- ix (indexa): global file search
25 +- silicon: code pretty picture generator
26 +- eva: calculator
27 +- bandwhich: show network traffic information
28 +- so: search Stack Exchange
29 +- linky: check markdown for broken links
30 +- comrak: render markdown to html
31 +- hx: terminal code editor
32 +- xplr: terminal file explorer

EJ-PC-00363.symlinks

Modified
7 7 topgrade/topgrade.windows.toml
8 8 ~/AppData/Roaming/topgrade.toml
10 -nushell/config.nu
11 -~/AppData/Roaming/nushell/config.nu
13 -nushell/plugin.nu
14 -~/AppData/Roaming/nushell/plugin.nu
10 +nushell
11 +~/AppData/Roaming/nushell
16 13 bottom
17 14 ~/AppData/Roaming/bottom

TODO.md

Modified
1 1 # To-Do
3 -## Commands to remember
5 -- sd: search and replace
6 -- fd: find files recursively
7 -- diskonaut: explore file system visually for large files
8 -- btm (bottom): system overview
9 -- rg: search file contents
10 -- bat: show file content
11 -- mdcat: render markdown in the terminal
12 -- tokei: count lines of code
13 -- hyperfine: benchmark tool
14 -- menyoki: capture screenshots, record gifs
15 -- rpick: Choose something out of predefined model using fancy algorithms
16 -- tldr: tool documentation
17 -- grex: regular expression pattern generator
18 -- xh: make HTTP requests
19 -- watchexec: filesystem watcher
20 -- viu: view images in terminal (blocky approximation)
21 -- licensor: print a license text
22 -- pastel: manage colors
23 -- hexyl: terminal hex viewer
24 -- gib: generate gitignore files
25 -- ix (indexa): global file search
26 -- silicon: code pretty picture generator
27 -- eva: calculator
28 -- bandwhich: show network traffic information
29 -- so: search Stack Exchange
30 -- linky: check markdown for broken links
31 -- comrak: render markdown to html
32 -- hx: terminal code editor
34 -## Stuff to do
36 -- [ ] port nushell config to new config script
37 -- [ ] expand nugu theme to wezterm and eclipse
3 +- [ ] expand nugu theme to wezterm and eclipse, and more
38 4 - [ ] rewrite bootstripper and java commmands with zig. how to run them? precompile? zig run?
39 5 - [ ] encrypt box key
40 6 - [ ] get SIM card to work on x230
7 +- [ ] write svn completions for nushell
8 +- [ ] interactive zoxide jump function with skim
9 +- [x] port nushell config to new config script
42 -## Done
44 -- [x] ditch nvim for hx in EDITOR, give up IDE in terminal
45 -- [x] how to abstract configs differences per platform? templates are painful to work with.
46 -- [x] abstract indexa config for windows / linux
47 -- [x] kill thy babbies: remove obsolete java commands. nu has builtins now for checksums and for random uuids
48 -- [x] use [systemd user] instance to manage env vars
49 -- [x] what to do about ssh and GPG keys? or secrets in general?
50 - - [x] say goodbye to GPG, too hard to manage.
51 -- [x] how to handle java tools in `tools` cross platform?
52 -- [x] sumneko on linux
53 -- [x] is there something like glow but in rust?
54 -- [x] get indexa config into dotfiles?
56 -[systemd user]: https://wiki.archlinux.org/title/Systemd/User

helix/config.toml

Modified
5 5 true-color = true
6 6 line-number = "relative"
7 7 auto-completion = false
8 +auto-pairs = false
9 10 [editor.lsp]
10 11 display-messages = true
17 18 [editor.file-picker]
18 19 hidden = false
20 -[editor.auto-pairs]
21 -'(' = ')'
22 -'{' = '}'
23 -'[' = ']'
24 -'"' = '"'
25 -"'" = "'"
26 -'`' = '`'
27 -'<' = '>'

nushell/config.nu

Modified
1 1 # Nushell Config File
3 -# GLOBAL VARIABLES
4 -let-env NURC_DIR = ($nu.config-path | path dirname | path expand)
5 -let-env DOTFILES = ($env.NURC_DIR| path join ".." | path expand)
6 -let-env TODO = ($env.DOTFILES | path join "TODO.md")
8 -# ALIASES
9 -alias cat = bat
10 -alias vim = hx
11 -alias edit = hx
12 -alias e = hx
14 -alias ll = exa --group-directories-first --classify --long --icons --git
15 -alias la = exa --group-directories-first --classify --all --long --icons --git
16 -alias tr = exa --tree
18 -alias grep = rg
20 -# CUSTOM LITTLE JAVA COMMANDS
21 -alias aes = java (build-string $env.DOTFILES /tools/ aes.java)
22 -alias download = java (build-string $env.DOTFILES /tools/ download.java)
23 -alias download_jar = java (build-string $env.DOTFILES /tools/ download_jar.java)
26 -# MY STDLIB UTIL MISC HELPER FUNCTIONS
28 -# Check whether table in pipeline has a column with given name
29 -def "has-column?" [
30 - name: string # Name of the column to check for
31 -] {
32 - pivot | any? Column0 == $name
35 -# Flattens a table into a string separated by a single space character.
36 -def to-string [] { flatten | into string | str collect ' ' }
38 -# FUNCTIONS
40 -# Render my To-Do file in the terminal
41 -def todo [] { mdcat $env.TODO }
42 -# Open my To-Do file for editing
43 -def "todo edit" [] { hx $env.TODO }
44 -# Show the nushell config
45 -def config [] { bat $nu.config-path }
46 -# Open the Nushell configuration file for editing
47 -def "config edit" [] { hx $nu.config-path }
49 -def github-upload-key [
50 - title: string # Name the key, so you will remember what it is used for
51 - key: path # Path to the PUBLIC key
52 -] {
53 - if ($key | path exists) {
54 - echo (build-string "uploading ssh public key " (ansi gi) $key (ansi reset) " with title " (ansi gb) $title (ansi reset) " to GitHub.")
55 - echo (char newline)
56 - let encrypted_token_path = (build-string $env.DOTFILES / tresor / 4cef0ce3-da3a-4f16-9412-2d094b4f7445)
57 - let decrypted_token_path = (build-string $env.DOTFILES / tresor / gh_token)
58 - aes decrypt $encrypted_token_path $decrypted_token_path
59 - let token = (open --raw $decrypted_token_path)
60 - let key_content = (open --raw $key)
61 - rm -f $decrypted_token_path
62 - let result = (do -i { xh --bearer $token https://api.github.com/user/keys (build-string title = $title) (build-string key = $key_content) | from json})
63 - if ($result | has-column? errors) {
64 - let message = ($result | get message)
65 - let url = ($result | get documentation_url)
66 - let errors = ($result | get errors)
67 - echo (build-string (ansi rb) $message (ansi reset) (char newline))
68 - echo (char newline)
69 - $errors | each {
70 - | it |
71 - let resource = ($it | get resource)
72 - let code = ($it | get code)
73 - let field = ($it | get field)
74 - let message = ($it | get message)
75 - echo (build-string (ansi ui) $resource : $code : $field ": " (ansi rb) $message (ansi reset) (char newline))
76 - }
77 - echo (build-string "Further information: " (ansi yi) $url (ansi reset) (char newline))
78 - } else {
79 - let id = ($result | get id)
80 - let key = ($result | get key)
81 - let title = ($result | get title)
82 - let created_at = ($result | get created_at)
83 - echo (build-string "[" ID : $id "]" " key with title " (ansi gb) $title (ansi reset) " was created at " (ansi yi) $created_at (ansi reset) "." (char newline) )
84 - echo (build-string (ansi wu) "PUBLIC SSH KEY:" (ansi reset))
85 - echo (char newline)
86 - echo ($key | ansi gradient --fgstart 0xaefe9f --fgend 0xfefefe)
87 - echo (char newline)
88 - }
89 - } else {
90 - echo (build-string "key " (ansi rb) $key (ansi reset) " not found!")
91 - echo (char newline)
92 - }
95 -# Shows git log in a pretty table
96 -def glog [
97 - ...rest: string # Extra arguments to git log
98 -] {
99 - git log --pretty=%h»¦«%s»¦«%aN»¦«%aE»¦«%aD -n 25 $rest | lines | split column "»¦«" commit subject name email date | update date { get date | into datetime} | sort-by date
102 -# Open manual page.
103 -# On Windows, a man web page is opened.
104 -def man [
105 - ...rest: string # Arguments to man
106 -] {
107 - if (sys).host.name == "Windows" {
108 - start (build-string https://man.archlinux.org/man/ ($rest | to-string))
109 - } else {
110 - ^man $rest
111 - }
114 -# Search the given query on the web with the default browser in DuckDuckGo.
115 -def web [
116 - ...rest:string # The search query
117 -] {
118 - let query = (build-string "https://duckduckgo.com/?q=" ($rest | to-string))
119 - if (sys).host.name == "Windows" {
120 - # There seems to be an issue with the nu start command on windows: It does not handle URLs
121 - # Using windows command for now:
122 - start $query
123 - } else {
124 - xdg-open $query
125 - }
128 -# Custom integration of zoxide into nushell.
129 -# Since nushell 0.60.0 the autogenerated code of zoxide is no longer useful.
130 -# =============================================================================
132 -# Hook configuration for zoxide.
135 -# Hook to add new entries to the database.
136 -# This hook gets exported out of the module so that it can be integrated inot the prompt
137 -def zoxide_hook [] {
138 - shells
139 - | where active == true
140 - | get path
141 - | each { | path | zoxide add -- $path }
142 - | ignore
145 -# =============================================================================
147 -# Jump to a directory using only keywords.
148 -def-env zoxide_jump [...rest:string] {
149 -let span = (metadata $rest).span
150 - #normalize path
151 - let pwd = ($env.PWD | path expand)
152 - let z_jump = ( do --ignore-errors { zoxide query --exclude $pwd -- $rest } )
154 - if ($z_jump | empty?) {
155 - error make {
156 - msg: "Zoxide could not find any match for the given query.",
157 - label: {
158 - text: "no matches for this query",
159 - start: $span.start,
160 - end: $span.end
161 - }
162 - }
163 - }
165 - # zoxide returns even single results with a newline at the end...
166 - cd ($z_jump | str trim --right --char (char newline) )
169 -alias z = zoxide_jump
171 -# Map of paths to icons.
172 -# These will be used to replace certain path segments in the prompt for example.
173 -# Order these paths for precedence.
174 -let icons = [
175 - [path icon];
176 - [/home/oli/Workspace "🧬"]
177 - [/home/oli "🏡"]
178 - ]
180 -# Uses a special escape code to set the window title of the terminal emulator.
181 -# This will be ignored in terminal emulator, that do not support that escape code.
182 -# The title to be set is derived from the current working directory.
183 -# Special types of directories, e.g. HOME, get custom icons.
184 -def set_window_title [] {
185 - # normalize path
186 - let pwd = ( $env.PWD | path expand )
187 - let icon = if ($icons | any? path == $pwd) { ( $icons | where path == $pwd | get icon.0 ) } else { "📁" }
188 - echo ([ (ansi title) $icon " " ( $pwd | path basename ) (ansi reset) ] | str collect)
191 -def get_vcs_path [] {
192 - #normalize path
193 - let pwd = ($env.PWD | path expand)
195 - let svn_relative_cmd = ( do --ignore-errors { svn info --show-item relative-url --no-newline $pwd } | complete )
196 - let svn_relative_path = if ($svn_relative_cmd.exit_code == 0) { $" 🐢 ($svn_relative_cmd.stdout)" }
198 - let git_status = ( gstat )
199 - let git_branch = if ( $git_status.branch != "no_branch" ) { $"  ($git_status.branch)" }
201 - [
202 - $svn_relative_path
203 - $git_branch
204 - ] | str collect
207 -def create_left_prompt [] {
209 - zoxide_hook
211 - set_window_title
213 - # normalize path
214 - let pwd = ($env.PWD | path expand)
215 - let pwd = ($icons | reduce --fold $pwd { |item, accumulator| $accumulator | str find-replace $item.path $item.icon })
216 - let truncate_level = 5
217 - let truncate_symbol = "…/"
218 - let path_segment = if ($pwd | path split | length) >= $truncate_level { ($pwd | path dirname --num-levels 2 --replace $truncate_symbol ) } else { $pwd }
220 - let vcs_segment = get_vcs_path
222 - [
223 - (ansi dark_gray)
224 - $path_segment
225 - (ansi reset)
226 - (ansi green)
227 - $vcs_segment
228 - (ansi reset)
229 - ] | str collect
232 -def create_right_prompt [] {
233 - let time_segment = ([
234 - (date now | date format '%d.%m %R')
235 - ] | str collect)
237 - let command_status_segment = if $env.LAST_EXIT_CODE == 0 { " ✔ " } else { $"(ansi red) ✖ (ansi reset)" }
238 - let command_duration_segment = if ($env.CMD_DURATION_MS|into int) > 50 { build-string $"($env.CMD_DURATION_MS)ms" | into duration }
240 - [
241 - (ansi red_bold)
242 - $command_duration_segment
243 - (ansi reset)
244 - (ansi dark_gray)
245 - $command_status_segment
246 - (ansi reset)
247 - (ansi dark_gray)
248 - $time_segment
249 - (ansi reset)
250 - ] | str collect
253 -# Use nushell functions to define your right and left prompt
254 -let-env PROMPT_COMMAND = { create_left_prompt }
255 -let-env PROMPT_COMMAND_RIGHT = { create_right_prompt }
257 -# The prompt indicators are environmental variables that represent
258 -# the state of the prompt
259 -let-env PROMPT_INDICATOR = $"(ansi purple) · (ansi reset)"
260 -let-env PROMPT_INDICATOR_VI_INSERT = $"(ansi purple_reverse) : (ansi reset)"
261 -let-env PROMPT_INDICATOR_VI_NORMAL = $"(ansi purple_bold) · (ansi reset)"
262 -let-env PROMPT_MULTILINE_INDICATOR = $"(ansi purple_dimmed)·· (ansi reset)"
264 -# Specifies how environment variables are:
265 -# - converted from a string to a value on Nushell startup (from_string)
266 -# - converted from a value back to a string when running external commands (to_string)
267 -# Note: The conversions happen *after* config.nu is loaded
268 -let-env ENV_CONVERSIONS = {
269 - "PATH": {
270 - from_string: { |s| $s | split row (char esep) }
271 - to_string: { |v| $v | str collect (char esep) }
272 - }
273 - "Path": {
274 - from_string: { |s| $s | split row (char esep) }
275 - to_string: { |v| $v | str collect (char esep) }
276 - }
2 +use environment.nu *
3 +use table.nu *
4 +use os.nu *
5 +use prompt.nu *
6 +use aliases.nu *
7 +use todo.nu *
8 +use git.nu *
279 10 # for more information on themes see
280 11 # https://github.com/nushell/nushell/blob/main/docs/How_To_Coloring_and_Theming.md
346 77 filesize_format: "auto" # b, kb, kib, mb, mib, gb, gib, tb, tib, pb, pib, eb, eib, zb, zib, auto
347 78 edit_mode: emacs # emacs, vi
348 79 max_history_size: 10000
349 - menu_config: {
350 - columns: 4
351 - col_width: 20 # Optional value. If missing all the screen width is used to calculate column width
352 - col_padding: 2
353 - text_style: cyan
354 - selected_text_style: cyan_reverse
355 - marker: " | "
356 - }
357 - history_config: {
358 - page_size: 10
359 - selector: "!"
360 - text_style: cyan
361 - selected_text_style: cyan_reverse
362 - marker: "? "
363 - }
80 + sync_history_on_enter: true # Enable to share the history between multiple sessions, else you have to close the session to persist history to file
81 + menus: [
82 + # Configuration for default nushell menus
83 + # Note the lack of souce parameter
84 + {
85 + name: completion_menu
86 + only_buffer_difference: false
87 + marker: "| "
88 + type: {
89 + layout: columnar
90 + columns: 4
91 + col_width: 20 # Optional value. If missing all the screen width is used to calculate column width
92 + col_padding: 2
93 + }
94 + style: {
95 + text: green
96 + selected_text: green_reverse
97 + description_text: yellow
98 + }
99 + }
101 + name: history_menu
102 + only_buffer_difference: true
103 + marker: "? "
104 + type: {
105 + layout: list
106 + page_size: 10
108 + style: {
109 + text: green
110 + selected_text: green_reverse
111 + description_text: yellow
115 + name: help_menu
116 + only_buffer_difference: true
117 + marker: "? "
118 + type: {
119 + layout: description
120 + columns: 4
121 + col_width: 20 # Optional value. If missing all the screen width is used to calculate column width
122 + col_padding: 2
123 + selection_rows: 4
124 + description_rows: 10
126 + style: {
127 + text: green
128 + selected_text: green_reverse
129 + description_text: yellow
132 + # Example of extra menus created using a nushell source
133 + # Use the source field to create a list of records that populates
134 + # the menu
136 + name: commands_menu
137 + only_buffer_difference: false
138 + marker: "# "
139 + type: {
140 + layout: columnar
141 + columns: 4
142 + col_width: 20
143 + col_padding: 2
145 + style: {
146 + text: green
147 + selected_text: green_reverse
148 + description_text: yellow
150 + source: { |buffer, position|
151 + $nu.scope.commands
152 + | where command =~ $buffer
153 + | each { |it| {value: $it.command description: $it.usage} }
157 + name: vars_menu
158 + only_buffer_difference: true
159 + marker: "# "
160 + type: {
161 + layout: list
162 + page_size: 10
164 + style: {
165 + text: green
166 + selected_text: green_reverse
167 + description_text: yellow
169 + source: { |buffer, position|
170 + $nu.scope.vars
171 + | where name =~ $buffer
172 + | sort-by name
173 + | each { |it| {value: $it.name description: $it.type} }
177 + name: commands_with_description
178 + only_buffer_difference: true
179 + marker: "# "
180 + type: {
181 + layout: description
182 + columns: 4
183 + col_width: 20
184 + col_padding: 2
185 + selection_rows: 4
186 + description_rows: 10
188 + style: {
189 + text: green
190 + selected_text: green_reverse
191 + description_text: yellow
193 + source: { |buffer, position|
194 + $nu.scope.commands
195 + | where command =~ $buffer
196 + | each { |it| {value: $it.command description: $it.usage} }
364 200 keybindings: [
365 - {
366 202 name: completion_menu
367 203 modifier: none
368 204 keycode: tab
244 + # Keybindings used to trigger the user defined menus
409 - name: reload_config
410 - modifier: none
411 - keycode: f5
412 - mode: emacs
413 - event: {
414 - send: executehostcommand,
415 - cmd: $"source '($nu.config-path)'"
416 - }
417 - }
246 + name: commands_menu
247 + modifier: control
248 + keycode: char_t
249 + mode: [emacs, vi_normal, vi_insert]
250 + event: { send: menu name: commands_menu }
253 + name: vars_menu
254 + modifier: control
255 + keycode: char_y
256 + mode: [emacs, vi_normal, vi_insert]
257 + event: { send: menu name: vars_menu }
260 + name: commands_with_description
261 + modifier: control
262 + keycode: char_u
263 + mode: [emacs, vi_normal, vi_insert]
264 + event: { send: menu name: commands_with_description }
265 + } ]
268 +# CUSTOM COMPLETIONS
270 +module svn {
271 + def "complete svn subcommands" [] {
272 + ^svn help
273 + | lines
274 + | skip until { | line | $line | str starts-with "Available subcommands:" }
275 + | skip 1
276 + | each { |line| $line | str trim }
277 + | take until { |line| $line | empty? }
278 + | split column " "
279 + | get column1
282 + def "complete svn add paths" [] {
283 + ^svn status --depth files
284 + | lines
285 + | parse "{mode} {file}"
286 + | str trim
287 + | where mode == ?
288 + | get file
291 + def "complete svn revert paths" [] {
292 + ^svn status --depth files
293 + | lines
294 + | parse "{mode} {file}"
295 + | where mode == M
296 + | str trim
297 + | get file
300 + def "complete svn depth" [] { ['empty', 'files', 'immediates', 'infinity'] }
302 + def "complete svn changelists" [] {
303 + ^svn status --depth files
304 + | lines
305 + | parse "--- Changelist '{changelist}':"
306 + | get --ignore-errors changelist
309 + # Subversion is a tool for version control.
310 + # For additional information, see http://subversion.apache.org/
311 + export extern svn [
312 + subcommand?: string@"complete svn subcommands" # for help on a specific subcommand.
313 + --version # to see the program version and RA modules
314 + --quiet # to see just the version number
315 + --verbose # to see dependency versions as well
318 + # help (?, h): Describe the usage of this program or its subcommands.
319 + # usage: help [SUBCOMMAND...]
320 + export extern "svn help" [
321 + subcommand?: string@"complete svn subcommands" # for help on a specific subcommand.
322 + --verbose(-v) # also show experimental subcommands and options
325 + # FIXME: https://github.com/nushell/nushell/issues/5012
326 + # rest parameters do not play well with completions yet
327 + # the `paths` parameter should be `...paths`
329 + # Put new files and directories under version control.
330 + export extern "svn add" [
331 + paths: path@"complete svn add paths" # unversioned PATHs for addition
332 + --targets: path # pass contents of file ARG as additional args
333 + --non-recursive(-N) # obsolete; same as --depth=empty
334 + --depth: string@"complete svn depth" # limit operation by depth ARG ('empty', 'files', 'immediates', or 'infinity')
335 + --quiet(-q) # print nothing, or only summary information
336 + --force # ignore already versioned paths
337 + --no-ignore # disregard default and svn:ignore and svn:global-ignores property ignores
338 + --auto-props # enable automatic properties
339 + --no-auto-props # disable automatic properties
340 + --parents # add intermediate parents
343 + export extern "svn revert" [
344 + paths: path@"complete svn revert paths"
345 + --targets: path # pass contents of file as additional args
346 + --recursive(-R) # descend recursively, same as --depth=infinity
347 + --depth: string@"complete svn depth" # limit operation by depth ARG ('empty', 'files', 'immediates', or 'infinity')
348 + --quiet(-q) # print nothing, or only summary information
349 + --changelist: string@"complete svn changelists" # operate only on members of changelist ARG
350 + --remove-added # reverting an added item will remove it from disk
354 +use svn *

nushell/env.nu

Added
new file mode 100644
1 +# Specifies how environment variables are:
2 +# - converted from a string to a value on Nushell startup (from_string)
3 +# - converted from a value back to a string when running external commands (to_string)
4 +# Note: The conversions happen *after* config.nu is loaded
5 +let-env ENV_CONVERSIONS = {
6 + "PATH": {
7 + from_string: { |s| $s | split row (char esep) }
8 + to_string: { |v| $v | str collect (char esep) }
9 + }
10 + "Path": {
11 + from_string: { |s| $s | split row (char esep) }
12 + to_string: { |v| $v | str collect (char esep) }
13 + }
16 +# Directories to search for scripts when calling source or use
17 +let-env NU_LIB_DIRS = [
18 + ($nu.config-path | path dirname | path join 'tools'),
19 + ($nu.config-path | path dirname | path join 'modules'),
20 + ($nu.config-path | path dirname | path join 'completions')
23 +# Directories to search for plugin binaries when calling register
24 +let-env NU_PLUGIN_DIRS = [
25 + ($nu.config-path | path dirname | path join 'plugins'),
26 + ($env.CARGO_HOME | path join 'bin'),

nushell/modules/aliases.nu

Added
new file mode 100644
1 +# Semantic aliases
2 +export alias view = bat
3 +export alias list = exa --group-directories-first --classify --all --long --icons --git
4 +export alias tree = exa --tree
5 +export alias look = xplr
6 +export alias browse = firefox
7 +export alias edit = hx
9 +# CUSTOM LITTLE JAVA COMMANDS
10 +export alias aes = java (build-string $env.DOTFILES /tools/ aes.java)
11 +export alias download = java (build-string $env.DOTFILES /tools/ download.java)
12 +export alias download_jar = java (build-string $env.DOTFILES /tools/ download_jar.java)
14 +# Open manual page.
15 +# On Windows, a man web page is opened.
16 +export def man [
17 + ...rest: string # Arguments to man
18 +] {
19 + if $env.WIN32? {
20 + ^start (build-string https://man.archlinux.org/man/ ($rest | to-string))
21 + } else {
22 + ^man $rest
23 + }
26 +# Search the given query on the web with the default browser in DuckDuckGo.
27 +export def web [
28 + ...rest:string # The search query
29 +] {
30 + let query = (build-string "https://duckduckgo.com/?q=" ($rest | to-string))
31 + if $env.WIN32? {
32 + # There seems to be an issue with the nu start command on windows: It does not handle URLs
33 + # Using windows command for now:
34 + ^start $query
35 + } else {
36 + xdg-open $query
37 + }

nushell/modules/environment.nu

Added
new file mode 100644
1 +# To add entries to PATH (on Windows you might use Path), you can use the following pattern:
2 +# export env PATH { ($env.PATH | prepend '/some/path') }
3 +#TODO CARGO_HOME
5 +# GLOBAL VARIABLES
7 +export env WIN32? { (sys).host.name =~ "Windows" }
8 +export env NURC_DIR { ($nu.config-path| path expand | path dirname) }
9 +export env DOTFILES { ($env.NURC_DIR| path join ".." | path expand) }
10 +export env WORKSPACE { if $env.WIN32? { "W:" } else { "~/Workspace" } }

nushell/modules/git.nu

Added
new file mode 100644
1 +export def github-upload-key [
2 + title: string # Name the key, so you will remember what it is used for
3 + key: path # Path to the PUBLIC key
4 +] {
5 + if ($key | path exists) {
6 + echo (build-string "uploading ssh public key " (ansi gi) $key (ansi reset) " with title " (ansi gb) $title (ansi reset) " to GitHub.")
7 + echo (char newline)
8 + let encrypted_token_path = (build-string $env.DOTFILES / tresor / 4cef0ce3-da3a-4f16-9412-2d094b4f7445)
9 + let decrypted_token_path = (build-string $env.DOTFILES / tresor / gh_token)
10 + aes decrypt $encrypted_token_path $decrypted_token_path
11 + let token = (open --raw $decrypted_token_path)
12 + let key_content = (open --raw $key)
13 + rm -f $decrypted_token_path
14 + let result = (do -i { xh --bearer $token https://api.github.com/user/keys (build-string title = $title) (build-string key = $key_content) | from json})
15 + if ($result | has-column? errors) {
16 + let message = ($result | get message)
17 + let url = ($result | get documentation_url)
18 + let errors = ($result | get errors)
19 + echo (build-string (ansi rb) $message (ansi reset) (char newline))
20 + echo (char newline)
21 + $errors | each {
22 + | it |
23 + let resource = ($it | get resource)
24 + let code = ($it | get code)
25 + let field = ($it | get field)
26 + let message = ($it | get message)
27 + echo (build-string (ansi ui) $resource : $code : $field ": " (ansi rb) $message (ansi reset) (char newline))
28 + }
29 + echo (build-string "Further information: " (ansi yi) $url (ansi reset) (char newline))
30 + } else {
31 + let id = ($result | get id)
32 + let key = ($result | get key)
33 + let title = ($result | get title)
34 + let created_at = ($result | get created_at)
35 + echo (build-string "[" ID : $id "]" " key with title " (ansi gb) $title (ansi reset) " was created at " (ansi yi) $created_at (ansi reset) "." (char newline) )
36 + echo (build-string (ansi wu) "PUBLIC SSH KEY:" (ansi reset))
37 + echo (char newline)
38 + echo ($key | ansi gradient --fgstart 0xaefe9f --fgend 0xfefefe)
39 + echo (char newline)
40 + }
41 + } else {
42 + echo (build-string "key " (ansi rb) $key (ansi reset) " not found!")
43 + echo (char newline)
44 + }
47 +# Shows git log in a pretty table
48 +export def glog [
49 + ...rest: string # Extra arguments to git log
50 +] {
51 + git log --pretty=%h»¦«%s»¦«%aN»¦«%aE»¦«%aD -n 25 $rest | lines | split column "»¦«" commit subject name email date | update date { get date | into datetime} | sort-by date

nushell/modules/os.nu

Added
new file mode 100644
2 +# Opens the given resource in the operating systems preferred application.
3 +export def start [
4 + ...rest: string # Paths or URLs the OS should open for you.
5 +] {
6 + if $env.WIN32? {
7 + $rest | each { |thing| ^start $thing}
8 + } else {
9 + $rest | each { |thing| ^xdg-open $thing }
10 + }

nushell/modules/prompt.nu

Added
new file mode 100644
1 +# Custom integration of zoxide into nushell.
2 +# Since nushell 0.60.0 the autogenerated code of zoxide is no longer useful.
3 +# =============================================================================
4 +#
5 +# Hook configuration for zoxide.
6 +#
8 +# Hook to add new entries to the database.
9 +# This hook gets exported out of the module so that it can be integrated inot the prompt
10 +def zoxide-hook [] {
11 + shells
12 + | where active == true
13 + | get path
14 + | each { | path | zoxide add -- $path }
15 + | ignore
18 +# =============================================================================
20 +# Jump to a directory using only keywords.
21 +export def-env zoxide-jump [...rest:string] {
22 + let span = (metadata $rest).span
23 + #normalize path
24 + let pwd = ($env.PWD | path expand)
25 + let z_jump = ( do --ignore-errors { zoxide query --exclude $pwd -- $rest } )
27 + if ($z_jump | empty?) {
28 + error make {
29 + msg: "Zoxide could not find any match for the given query.",
30 + label: {
31 + text: "no matches for this query",
32 + start: $span.start,
33 + end: $span.end
34 + }
35 + }
36 + }
38 + # zoxide returns even single results with a newline at the end...
39 + cd ($z_jump | str trim --right --char (char newline) )
42 +export alias z = zoxide-jump
44 +# Map of paths to icons.
45 +# These will be used to replace certain path segments in the prompt for example.
46 +# Order these paths for precedence.
47 +def icons [] {
48 + [
49 + [path icon];
50 + [/home/oli/Workspace "🧬"]
51 + [/home/oli "🏡"]
52 + ]
53 +}
55 +# Uses a special escape code to set the window title of the terminal emulator.
56 +# This will be ignored in terminal emulator, that do not support that escape code.
57 +# The title to be set is derived from the current working directory.
58 +# Special types of directories, e.g. HOME, get custom icons.
59 +def set-window-title [] {
60 + # normalize path
61 + let pwd = ( $env.PWD | path expand )
62 + let icon = if (icons | any? path == $pwd) { ( icons | where path == $pwd | get icon.0 ) } else { "📁" }
63 + # Some terminals freeze, if they do not support this OSC
64 + if (env | any? name == TERM_PROGRAM) && $env.TERM_PROGRAM == WezTerm {
65 + echo ([ (ansi title) $icon " " ( $pwd | path basename ) (ansi reset) ] | str collect)
66 + }
69 +def get_vcs_path [] {
70 + #normalize path
71 + let pwd = ($env.PWD | path expand)
73 + let svn_relative_cmd = ( do --ignore-errors { ^svn info --show-item relative-url --no-newline $pwd } | complete )
74 + let svn_relative_path = if ($svn_relative_cmd.exit_code == 0) { $" 🐢 ($svn_relative_cmd.stdout)" }
76 + let git_status = ( gstat )
77 + let git_branch = if ( $git_status.branch != "no_branch" ) { $"  ($git_status.branch)" }
79 + [
80 + $svn_relative_path
81 + $git_branch
82 + ] | str collect
85 +def create_left_prompt [] {
86 + zoxide-hook
87 + set-window-title
89 + # normalize path
90 + let pwd = ($env.PWD | path expand)
91 + let pwd = (icons | reduce --fold $pwd { |item, accumulator| $accumulator | str replace $item.path $item.icon })
92 + let truncate_level = 5
93 + let truncate_symbol = "…/"
94 + let path_segment = if ($pwd | path split | length) >= $truncate_level { ($pwd | path dirname --num-levels 2 --replace $truncate_symbol ) } else { $pwd }
96 + let vcs_segment = get_vcs_path
98 + [
99 + (ansi dark_gray)
100 + $path_segment
101 + (ansi reset)
102 + (ansi green)
103 + $vcs_segment
104 + (ansi reset)
105 + ] | str collect
108 +def create_right_prompt [] {
109 + let time_segment = ([
110 + (date now | date format '%d.%m %R')
111 + ] | str collect)
113 + let command_status_segment = if $env.LAST_EXIT_CODE == 0 { " ✔ " } else { $"(ansi red) ✖ (ansi reset)" }
114 + let command_duration_segment = if ($env.CMD_DURATION_MS|into int) > 50 { build-string $"($env.CMD_DURATION_MS)ms" | into duration }
116 + [
117 + (ansi red_bold)
118 + $command_duration_segment
119 + (ansi reset)
120 + (ansi dark_gray)
121 + $command_status_segment
122 + (ansi reset)
123 + (ansi dark_gray)
124 + $time_segment
125 + (ansi reset)
126 + ] | str collect
129 +# Use nushell functions to define your right and left prompt
130 +export env PROMPT_COMMAND { {create_left_prompt} }
131 +export env PROMPT_COMMAND_RIGHT { {create_right_prompt} }
133 +# The prompt indicators are environmental variables that represent
134 +# the state of the prompt
135 +export env PROMPT_INDICATOR { $"(ansi purple) · (ansi reset)" }
136 +export env PROMPT_INDICATOR_VI_INSERT { $"(ansi purple_reverse) : (ansi reset)" }
137 +export env PROMPT_INDICATOR_VI_NORMAL { $"(ansi purple_bold) · (ansi reset)" }
138 +export env PROMPT_MULTILINE_INDICATOR { $"(ansi purple_dimmed)·· (ansi reset)" }

nushell/modules/table.nu

Added
new file mode 100644
1 +# Check whether table in pipeline has a column with given name
2 +export def "has-column?" [
3 + name: string # Name of the column to check for
4 +] {
5 + pivot | any? Column0 == $name
6 +}
8 +# Flattens a table into a string separated by a single space character.
9 +export def to-string [] { flatten | into string | str collect ' ' }

nushell/modules/todo.nu

Added
new file mode 100644
1 +# Render my To-Do file in the terminal
2 +export def todo [] { mdcat ($env.DOTFILES | path join "TODO.md") }
3 +# Open my To-Do file for editing
4 +export def "todo edit" [] { hx ($env.DOTFILES | path join "TODO.md")}
5 +# Open a list of commands, that I would like to remember to use
6 +export def "todo commands" [] { mdcat ($env.DOTFILES | path join "COMMANDS.md") }

nushell/plugin.nu

Modified
2 2 register /home/oli/.cargo/bin/nu_plugin_gstat -e json {
3 3 "name": "gstat",
4 4 "usage": "Get the git status of a repo",
5 5 "extra_usage": "",
6 + "search_terms": [],
6 7 "required_positional": [],
7 8 "optional_positional": [

nushell/tools/cargo_tools.nu

Added
new file mode 100644
1 +let cargo_crates = [
2 + "sd"
3 + "fd-find"
4 + "ripgrep"
5 + "eva"
6 + "watchexec-cli"
7 + "mdcat"
8 + "hexyl"
9 + "hyperfine"
10 + "so"
11 + "tealdeer"
12 + "tokei"
13 + "bottom"
14 + "bat"
15 + "pastel"
16 + "diskonaut"
17 + "menyoki"
18 + "rpick"
19 + "grex"
20 + "xh"
21 + "comrak"
22 + "bandwhich"
23 + "linky"
24 + "viu"
25 + "licensor"
26 + "gib"
27 + "silicon"
30 +let cargo_git_crates = [
31 + "https://github.com/mosmeh/indexa"
34 +def install_hx [] {
35 + cd $env.WORKSPACE
36 + git clone https://github.com/helix-editor/helix
37 + cd helix
38 + cargo install --path helix-term
39 + hx --grammar fetch
40 + hx --grammar build
43 +export def install[] {
44 + cargo install --locked $cargo_crates
45 + cargo install --locked nu --all-features
46 + $cargo_git_crates | each {|it| cargo install --locked --git $it }
47 + install_hx

pop-os.symlinks

Modified
7 7 cargo/config.toml
8 8 ~/.cargo/config.toml
10 -nushell/config.nu
11 -~/.config/nushell/config.nu
13 -nushell/plugin.nu
14 -~/.config/nushell/plugin.nu
10 +nushell
11 +~/.config/nushell
16 13 stackoverflow/so
17 14 ~/.config/so

tools/cargo_tools.nu

Deleted
deleted file mode 100644
1 -let cargo_crates = [
2 - "sd"
3 - "fd-find"
4 - "ripgrep"
5 - "eva"
6 - "watchexec-cli"
7 - "mdcat"
8 - "hexyl"
9 - "hyperfine"
10 - "so"
11 - "tealdeer"
12 - "tokei"
13 - "bottom"
14 - "bat"
15 - "pastel"
16 - "diskonaut"
17 - "menyoki"
18 - "rpick"
19 - "grex"
20 - "xh"
21 - "comrak"
22 - "bandwhich"
23 - "linky"
24 - "viu"
25 - "licensor"
26 - "gib"
27 - "silicon"
28 -]
30 -let cargo_git_crates = [
31 - "https://github.com/mosmeh/indexa"
32 -]
34 -echo "CARGO CRATES"
35 -echo $cargo_crates
36 -echo "CARGO GIT CRATES"
37 -echo $cargo_git_crates
38 -echo "CUSTOM INSTALLS"
39 -echo "hx"
41 -def install_hx [] {
42 - cd ~/Workspace #TODO make WORKSPACE env var
43 - git clone https://github.com/helix-editor/helix
44 - cd helix
45 - cargo install --path helix-term
46 - ln -s ~/Workspace/helix/runtime ~/.config/helix/runtime
47 - hx --grammar fetch
48 - hx --grammar build
49 -}
51 -cargo install $cargo_crates
53 -$cargo_git_crates | each {|it| cargo install --git $it }
55 -install_hx

topgrade/topgrade.linux.toml

Modified
42 42 # Dateisystem-Indexer ix erfrischen
43 43 "Indexa Update" = "ix --update"
45 -# Rebuild Sumneko lua langua server
46 -"Rebuild Sumneko LSP" = "cd ~/Workspace/lua-language-server; git submodule update --init --recursive ; cd 3rd/luamake ; ./compile/install.sh ; cd ../.. ; ./3rd/luamake/luamake rebuild"
48 45 # Update hx editor
49 -"Update helix" = "cd ~/Workspace ; git clone -q https://github.com/helix-editor/helix ; cd helix ; git pull ; ln -s ~/Workspace/helix/runtime /home/oli/.config/helix/ ; cargo install --path helix-term ; hx --grammar fetch ; hx --grammar build"
46 +"Update helix" = "cd ~/Workspace ; git clone -q https://github.com/helix-editor/helix ; cd helix ; git pull ; ln -s ~/Workspace/helix/runtime /home/oli/.config/helix/ ; cargo install --path helix-term ; hx --grammar fetch ; hx --grammar build"

topgrade/topgrade.windows.toml

Modified
44 44 # Dateisystem-Indexer ix erfrischen
45 45 "Indexa Update" = "ix --update"
47 -# Rebuild Sumneko lua langua server
48 -"Rebuild Sumneko LSP" = "cd ~/Workspace/lua-language-server; git submodule update --init --recursive ; cd 3rd/luamake ; ./compile/install.sh ; cd ../.. ; ./3rd/luamake/luamake rebuild"

x230.symlinks

Modified
7 7 cargo/config.toml
8 8 ~/.cargo/config.toml
10 -nushell/config.nu
11 -~/.config/nushell/config.nu
13 -nushell/plugin.nu
14 -~/.config/nushell/plugin.nu
10 +nushell
11 +~/.config/nushell
16 13 icc/thinkpad_x230.icc
17 14 ~/.config/icc/thinkpad_x230.icc