summaryrefslogtreecommitdiff
path: root/mut
diff options
context:
space:
mode:
authorMike Vink <59492084+ivi-vink@users.noreply.github.com>2025-01-21 00:09:13 +0100
committerMike Vink <59492084+ivi-vink@users.noreply.github.com>2025-01-21 00:09:13 +0100
commite0ee5c9e96c18702e263562c1c1c6ce30ba30056 (patch)
treee38eb54d9938884a803ebfeccd6507860c2c87a3 /mut
parente647fa6f769d77fa0ca2a5b13eea05e22b9ab6ca (diff)
make nushell work
Diffstat (limited to 'mut')
-rw-r--r--mut/DefaultKeyBinding.dict69
-rw-r--r--mut/aerospace/aerospace.toml7
-rwxr-xr-xmut/bin/dmenu2
-rwxr-xr-xmut/bin/passmenu9
-rwxr-xr-xmut/bin/pnsh-nvim2
-rw-r--r--mut/keuze/kies/InputField.swift44
-rw-r--r--mut/keuze/kies/Layout.swift14
-rw-r--r--mut/keuze/kies/Settings.swift12
-rw-r--r--mut/keuze/kies/main.swift36
-rw-r--r--mut/nushell/config.nu12
-rw-r--r--mut/nushell/env.nu5
11 files changed, 147 insertions, 65 deletions
diff --git a/mut/DefaultKeyBinding.dict b/mut/DefaultKeyBinding.dict
new file mode 100644
index 0000000..8d39f47
--- /dev/null
+++ b/mut/DefaultKeyBinding.dict
@@ -0,0 +1,69 @@
+{
+/* Keybindings for emacs emulation. Compiled by Jacob Rus.
+ *
+ * This is a pretty good set, especially considering that many emacs bindings
+ * such as C-o, C-a, C-e, C-k, C-y, C-v, C-f, C-b, C-p, C-n, C-t, and
+ * perhaps a few more, are already built into the system.
+ *
+ * BEWARE:
+ * This file uses the Option key as a meta key. This has the side-effect
+ * of overriding Mac OS keybindings for the option key, which generally
+ * make common symbols and non-english letters.
+ */
+
+ /* Ctrl shortcuts */
+ "^l" = "centerSelectionInVisibleArea:"; /* C-l Recenter */
+ // "^/" = "undo:"; /* C-/ Undo */
+ // "^_" = "undo:"; /* C-_ Undo */
+ "^ " = "setMark:"; /* C-Spc Set mark */
+ "^\@" = "setMark:"; /* C-@ Set mark */
+ "^w" = "deleteToMark:"; /* C-w Delete to mark */
+
+
+ /* Incremental search. */
+/* Uncomment these lines If Incremental Search IM is installed */
+/* "^s" = "ISIM_incrementalSearch:"; /* C-s Incremental search */
+/* "^r" = "ISIM_reverseIncrementalSearch:"; /* C-r Reverse incremental search */
+/* "^g" = "abort:"; /* C-g Abort */
+
+
+ /* Meta shortcuts */
+ "~f" = "moveWordForward:"; /* M-f Move forward word */
+ "~b" = "moveWordBackward:"; /* M-b Move backward word */
+ "~<" = "moveToBeginningOfDocument:"; /* M-< Move to beginning of document */
+ "~>" = "moveToEndOfDocument:"; /* M-> Move to end of document */
+ "~v" = "pageUp:"; /* M-v Page Up */
+ "~/" = "complete:"; /* M-/ Complete */
+ "~c" = ( "capitalizeWord:", /* M-c Capitalize */
+ "moveForward:",
+ "moveForward:");
+ "~u" = ( "uppercaseWord:", /* M-u Uppercase */
+ "moveForward:",
+ "moveForward:");
+ "~l" = ( "lowercaseWord:", /* M-l Lowercase */
+ "moveForward:",
+ "moveForward:");
+ "~d" = "deleteWordForward:"; /* M-d Delete word forward */
+ "^w" = "deleteWordBackward:"; /* C-w Delete word backward */
+ "^~h" = "deleteWordBackward:"; /* M-C-h Delete word backward */
+ "~\U007F" = "deleteWordBackward:"; /* M-Bksp Delete word backward */
+ "~t" = "transposeWords:"; /* M-t Transpose words */
+ // "~\@" = ( "setMark:", /* M-@ Mark word */
+ // "moveWordForward:",
+ // "swapWithMark");
+ // "~h" = ( "setMark:", /* M-h Mark paragraph */
+ // "moveToEndOfParagraph:",
+ // "swapWithMark");
+
+ /* C-x shortcuts */
+ // "^x" = {
+ // "u" = "undo:"; /* C-x u Undo */
+ // "k" = "performClose:"; /* C-x k Close */
+ // "^f" = "openDocument:"; /* C-x C-f Open (find file) */
+ // "^x" = "swapWithMark:"; /* C-x C-x Swap with mark */
+ // "^m" = "selectToMark:"; /* C-x C-m Select to mark*/
+ // "^s" = "saveDocument:"; /* C-x C-s Save */
+ // "^w" = "saveDocumentAs:"; /* C-x C-w Save as */
+ // };
+
+}
diff --git a/mut/aerospace/aerospace.toml b/mut/aerospace/aerospace.toml
index bb30cbe..c5e9a16 100644
--- a/mut/aerospace/aerospace.toml
+++ b/mut/aerospace/aerospace.toml
@@ -89,11 +89,18 @@ automatically-unhide-macos-hidden-apps = false
# See: https://nikitabobko.github.io/AeroSpace/commands#exec-and-forget
# You can uncomment the following lines to open up terminal with alt + enter shortcut
# (like in i3)
+ cmd-shift-d = 'exec-and-forget source /etc/profile; PATH="$HOME/.local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:$PATH" passmenu'
+ cmd-d = 'exec-and-forget source /etc/profile; PATH="$HOME/.local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:$PATH" dmenu'
cmd-enter = '''exec-and-forget osascript -e '
tell application "Ghostty"
activate
end tell'
'''
+ cmd-w = '''exec-and-forget osascript -e '
+ tell application "Chrome"
+ activate
+ end tell'
+ '''
# See: https://nikitabobko.github.io/AeroSpace/commands#layout
cmd-slash = 'layout tiles horizontal vertical'
diff --git a/mut/bin/dmenu b/mut/bin/dmenu
new file mode 100755
index 0000000..2442c2c
--- /dev/null
+++ b/mut/bin/dmenu
@@ -0,0 +1,2 @@
+#!/bin/sh
+/Applications/dmenu-mac.app/Contents/MacOS/dmenu-mac "$@"
diff --git a/mut/bin/passmenu b/mut/bin/passmenu
index 345c0ae..d323930 100755
--- a/mut/bin/passmenu
+++ b/mut/bin/passmenu
@@ -2,8 +2,13 @@
shopt -s nullglob globstar
dmenu=dmenu
+copy() {
+ xclip -f | xclip -f -sel c
+}
if [ "$(uname)" = "Darwin" ]; then
- dmenu="/opt/homebrew/bin/dmenu-mac"
+ copy() {
+ pbcopy
+ }
fi
(
@@ -20,6 +25,6 @@ fi
[[ -n $password ]] || exit
- pass show "$password" | head -n1 | xclip -f | xclip -f -sel c
+ pass show "$password" | head -n1 | copy
) >/tmp/debug 2>&1
diff --git a/mut/bin/pnsh-nvim b/mut/bin/pnsh-nvim
index bc417c0..592cdee 100755
--- a/mut/bin/pnsh-nvim
+++ b/mut/bin/pnsh-nvim
@@ -7,7 +7,6 @@ if not ($desktop_open_pipe | path exists) {
let args = (
"--init" +
-" --entrypoint=/usr/bin/nu" +
" --env=TERM=xterm-ghostty" +
$" --env=TERMINFO=($env.TERMINFO)" +
" --env=_ZO_DATA_DIR=/hostfs/.local/share/zoxide" +
@@ -34,4 +33,5 @@ $" --volume=($env | default "/var/run" XDG_RUNTIME_DIR | get XDG_RUNTIME_DIR)/do
--pnsh-host-bindfs-disabled
--pnsh-docker-extra-args=$"($args)"
--docker-image=pionativedev.azurecr.io/pionative/pnsh-nvim
+ --docker-tag=latest
)
diff --git a/mut/keuze/kies/InputField.swift b/mut/keuze/kies/InputField.swift
index 6e8e27c..96a503d 100644
--- a/mut/keuze/kies/InputField.swift
+++ b/mut/keuze/kies/InputField.swift
@@ -11,7 +11,7 @@ import Cocoa
class InputField: NSTextField, NSTextFieldDelegate {
var appDelegate: AppDelegate!
-
+
init(appDelegate: AppDelegate) {
super.init(frame: layouts.inputRect)
self.appDelegate = appDelegate
@@ -33,34 +33,32 @@ class InputField: NSTextField, NSTextFieldDelegate {
cell?.isScrollable = true
autoresizingMask = [NSView.AutoresizingMask.width]
}
-
+
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
-
+
func control(_ control: NSControl, textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool {
- if (commandSelector == #selector(NSStandardKeyBindingResponding.cancelOperation(_:))){
- appDelegate.cancel()
- return true
- }
- if (commandSelector == #selector(NSStandardKeyBindingResponding.insertNewline(_:))){
- appDelegate.handleSelect()
- return true
+ switch (commandSelector) {
+ case #selector(NSStandardKeyBindingResponding.cancelOperation(_:)):
+ appDelegate.cancel()
+ return true
+ case #selector(NSStandardKeyBindingResponding.insertNewline(_:)):
+ appDelegate.handleSelect()
+ return true
+ case #selector(NSStandardKeyBindingResponding.moveUp(_:)):
+ appDelegate.handleMoveUp()
+ return true
+ case #selector(NSStandardKeyBindingResponding.moveDown(_:)):
+ appDelegate.handleMoveDown()
+ return true
+ case #selector(NSStandardKeyBindingResponding.insertTab(_:)):
+ return true
+ default:
+ return false
}
- if (commandSelector == #selector(NSStandardKeyBindingResponding.moveUp(_:))){
- appDelegate.handleMoveUp()
- return true
- }
- if (commandSelector == #selector(NSStandardKeyBindingResponding.moveDown(_:))){
- appDelegate.handleMoveDown()
- return true
- }
- if (commandSelector == #selector(NSStandardKeyBindingResponding.insertTab(_:))){
- return true
- }
- return false
}
-
+
func controlTextDidChange(_ obj: Notification) {
appDelegate.handleInputChange(input: stringValue)
}
diff --git a/mut/keuze/kies/Layout.swift b/mut/keuze/kies/Layout.swift
index cf04eb0..da87fc3 100644
--- a/mut/keuze/kies/Layout.swift
+++ b/mut/keuze/kies/Layout.swift
@@ -10,32 +10,32 @@ import Foundation
class Layout {
let DIVIDER_HEIGHT: CGFloat = 9
-
+
var lineHeight: CGFloat {
return ceil(NSString(string: "TEST").size(withAttributes: [.font: settings.font]).height) + 0;
}
-
+
var windowRect: NSRect {
return NSMakeRect(0, 0, settings.windowWidth, settings.windowHeight)
}
-
+
var containerRect: NSRect {
return NSMakeRect(settings.windowPadding, settings.windowPadding, windowRect.width - settings.windowPadding * 2, windowRect.height - settings.windowPadding * 2)
}
-
+
var listRect: NSRect {
return NSMakeRect(containerRect.minX, containerRect.minY, containerRect.width, containerRect.height - lineHeight - DIVIDER_HEIGHT)
}
-
+
var dividerRect: NSRect {
return NSMakeRect(containerRect.minX, listRect.maxY + DIVIDER_HEIGHT / 2, containerRect.width, 1)
}
-
+
var promptRect: NSRect {
let stringWidth = ceil(NSString(string: settings.promptText!).size(withAttributes: [.font: settings.font]).width) + 4;
return NSMakeRect(containerRect.minX, containerRect.maxY - lineHeight, stringWidth, lineHeight)
}
-
+
var inputRect: NSRect {
return NSMakeRect(promptRect.maxX, containerRect.maxY - lineHeight, containerRect.width - promptRect.width, lineHeight)
}
diff --git a/mut/keuze/kies/Settings.swift b/mut/keuze/kies/Settings.swift
index ab2c3df..ea9353d 100644
--- a/mut/keuze/kies/Settings.swift
+++ b/mut/keuze/kies/Settings.swift
@@ -10,15 +10,17 @@ import Foundation
import Cocoa
class Settings {
-
+
var promptText: String? {
var prompt = UserDefaults.standard.string(forKey: "p")
if (prompt != nil) {
prompt = prompt! + ":"
+ } else {
+ prompt = "|"
}
return prompt
}
-
+
var font: NSFont? {
let fn = UserDefaults.standard.string(forKey: "fn")
let fs = UserDefaults.standard.integer(forKey: "fs")
@@ -28,17 +30,17 @@ class Settings {
}
return NSFont(name: fn!, size: fontSize)
}
-
+
var windowPadding: CGFloat {
let val = UserDefaults.standard.integer(forKey: "pd")
return val == 0 ? 12 : CGFloat(val)
}
-
+
var windowHeight: CGFloat {
let val = UserDefaults.standard.integer(forKey: "h")
return val == 0 ? 310 : CGFloat(val)
}
-
+
var windowWidth: CGFloat {
let val = UserDefaults.standard.integer(forKey: "w")
return val == 0 ? 500 : CGFloat(val)
diff --git a/mut/keuze/kies/main.swift b/mut/keuze/kies/main.swift
index a20922d..9268650 100644
--- a/mut/keuze/kies/main.swift
+++ b/mut/keuze/kies/main.swift
@@ -11,7 +11,7 @@ import Cocoa
import Darwin
class AppDelegate: NSObject, NSApplicationDelegate {
-
+
var window: Window!
var dataSource: DataSource!
var promptText: PromptText!
@@ -19,15 +19,15 @@ class AppDelegate: NSObject, NSApplicationDelegate {
var inputField: InputField!
var tableView: TableView!
var scrollView: NSScrollView!
-
+
func applicationDidBecomeActive(_ notification: Notification) {
-
+
}
-
+
func applicationDidResignActive(_ notification: Notification) {
cancel();
}
-
+
func receiveStdin() -> [String] {
var lines: [String] = []
while let line = readLine() {
@@ -35,7 +35,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
return lines
}
-
+
func applicationDidFinishLaunching(_ notification: Notification)
{
if (settings.promptText == nil) {
@@ -51,25 +51,25 @@ class AppDelegate: NSObject, NSApplicationDelegate {
fputs("No data was received on stdin\n", stderr)
exit(1)
}
-
+
window = Window()
dataSource = DataSource()
dataSource.updateItems(items)
-
+
setupPromptText()
setupDivider()
setupInputField()
setupList()
-
+
window.showWindow()
app.activate(ignoringOtherApps: true)
}
-
+
func setupPromptText() {
promptText = PromptText(text: settings.promptText!)
window.contentView!.addSubview(promptText)
}
-
+
func setupDivider() {
divider = NSBox(frame: layouts.dividerRect)
divider.boxType = .custom
@@ -77,32 +77,32 @@ class AppDelegate: NSObject, NSApplicationDelegate {
divider.borderWidth = 0
window.contentView!.addSubview(divider)
}
-
+
func setupInputField() {
inputField = InputField(appDelegate: self);
window.contentView!.addSubview(inputField)
window.makeFirstResponder(inputField)
}
-
+
func handleInputChange(input: String) {
dataSource.updateSort(query: input)
tableView.reloadData()
}
-
+
func handleMoveUp() {
tableView.selectRowAbove()
}
-
+
func handleMoveDown() {
tableView.selectRowBelow()
}
-
+
func handleSelect() {
let value = dataSource.sortedItems[tableView.selectedRow]
fputs(value, stdout)
cancel()
}
-
+
func setupList() {
scrollView = NSScrollView(frame: layouts.listRect)
tableView = TableView(dataSource: dataSource)
@@ -117,7 +117,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
scrollView.automaticallyAdjustsContentInsets = false
window.contentView!.addSubview(scrollView)
}
-
+
func cancel() {
exit(0)
}
diff --git a/mut/nushell/config.nu b/mut/nushell/config.nu
index 3fb5613..a381700 100644
--- a/mut/nushell/config.nu
+++ b/mut/nushell/config.nu
@@ -1,6 +1,6 @@
-if ($env | default "" DOCKER_NAME | get DOCKER_NAME | is-empty) {
- try {pnsh-nvim}
-}
+# if ($env | default "" DOCKER_NAME | get DOCKER_NAME | is-empty) {
+# try {pnsh-nvim}
+# }
# Nushell Config File
#
# version = "0.99.1"
@@ -912,9 +912,3 @@ let pistarchio_dir = $"($env.HOME)/Programming/Pionative/pistarchio"
$env.PISTARCHIO_STACKS_DIR = $pistarchio_dir + "/stacks"
$env.PISTARCHIO_LIBRARY_DIR = $pistarchio_dir + "/library"
$env.PISTARCHIO_VENDOR_DESTINATION_DIR = $pistarchio_dir + "/../clients"
-
-try {
- if (uname | get "operating-system") == "Darwin" {
- $env.PATH = ["/opt/homebrew/bin" "/opt/X11/bin" "/opt/local/bin" "/opt/local/sbin"] ++ $env.PATH
- }
-}
diff --git a/mut/nushell/env.nu b/mut/nushell/env.nu
index 01f1fb7..b186624 100644
--- a/mut/nushell/env.nu
+++ b/mut/nushell/env.nu
@@ -94,6 +94,11 @@ use std "path add"
# $env.PATH = ($env.PATH | split row (char esep))
# path add /some/path
# path add ($env.CARGO_HOME | path join "bin")
+try {
+ if (uname | get "operating-system") == "Darwin" {
+ $env.PATH = ["/opt/homebrew/bin" "/opt/X11/bin" "/opt/local/bin" "/opt/local/sbin"] ++ $env.PATH
+ }
+}
path add ($env.HOME | path join ".local" "bin")
$env.PATH = ($env.PATH | uniq)