Cleaning
This commit is contained in:
parent
b08325c2cf
commit
abd11f65b9
|
@ -1,4 +1,6 @@
|
|||
source ~/.config/nushell/config/init.nu
|
||||
source ~/.config/nushell/config/extra.nu
|
||||
source ~/.config/nushell/config/mount.nu
|
||||
source ~/.config/nushell/config/config.nu
|
||||
source ~/.config/nushell/config/aliases.nu
|
||||
source ~/.config/nushell/config/git.nu
|
||||
|
@ -8,7 +10,5 @@ source ~/.config/nushell/config/gclone.nu
|
|||
source ~/.config/nushell/config/pass.nu
|
||||
source ~/.config/nushell/config/docker.nu
|
||||
source ~/.config/nushell/config/xrandr.nu
|
||||
source ~/.config/nushell/config/extra.nu
|
||||
source ~/.config/nushell/config/extra.nu
|
||||
source ~/.config/nushell/config/tfetch.nu
|
||||
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
# startx checks if disks are mounted
|
||||
def startx [] {
|
||||
# I'm used to running startx right after I login, to this first mount my
|
||||
# disks and then runs startx.
|
||||
mount-disk
|
||||
|
||||
# Then I run startx
|
||||
/bin/startx
|
||||
}
|
||||
|
||||
# mount my encrypted disks
|
||||
def mount-disk [] {
|
||||
|
||||
# If there is no $env.PRIMARY_DISK_UUID, we don't have to decrypt / mount anything
|
||||
if not ("PRIMARY_DISK_UUID" in $env) {
|
||||
return
|
||||
}
|
||||
|
||||
# In my home on my encrypted partition, I have an empty file in ~/.mounted,
|
||||
# this way, I can easily check if my encrypted partition is mounted or not.
|
||||
if ("~/.mounted"| path exists) {
|
||||
print -en "already mounted\n"
|
||||
return
|
||||
}
|
||||
|
||||
mut passphrase = ""
|
||||
|
||||
# On my computer, I have two disks, one NVMe with my OS, and one HDD with
|
||||
# more space. I want three attempts at typing the passphrase.
|
||||
for retry in [1, 2, 3] {
|
||||
|
||||
# Because they're encrypted with the same passphrase, I read the
|
||||
# passphrase once, and then decrypt both disks.
|
||||
sudo echo -n
|
||||
let local_passphrase = (input -s "Enter your passphrase: ")
|
||||
print -en "\n"
|
||||
|
||||
# Mount the NVMe encrypted partition
|
||||
let mounted = do { $local_passphrase | sudo cryptsetup luksOpen ("/dev/disk/by-uuid/" + $env.PRIMARY_DISK_UUID) luks } | complete
|
||||
|
||||
# If mounted correctly, break this loop and mount other partitions.
|
||||
if $mounted.exit_code == 0 {
|
||||
print -en (ansi green_bold) "Passphrase correct\n" (ansi reset)
|
||||
$passphrase = $local_passphrase
|
||||
break
|
||||
} else if $retry == 3 {
|
||||
# If the third attempt failed, exit
|
||||
error make {msg: "couldn't decrypt disk"}
|
||||
} else {
|
||||
print -en (ansi red_bold) "Passphrase incorrect, please try again\n" (ansi reset)
|
||||
}
|
||||
}
|
||||
|
||||
sudo mount /dev/mapper/luks /home
|
||||
|
||||
if ("SECONDARY_DISK_UUID" in $env) {
|
||||
$passphrase | sudo cryptsetup luksOpen ("/dev/disk/by-uuid/" + $env.SECONDARY_DISK_UUID) luks2
|
||||
sudo mount /dev/mapper/luks2 /mnt
|
||||
}
|
||||
|
||||
# Some services cannot be started on boot because my encrypted drives are
|
||||
# not mounted yet, so I mount them here.
|
||||
systemctl start --user pueued
|
||||
sudo systemctl start docker
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
# nushell puts prompt at bottom of terminal on resize, so it's preferable to start on the bottom of the terminal
|
||||
|
||||
let has_tfetch = not (which tfetch | is-empty)
|
||||
|
||||
# tfetch takes 19 lines, 21 with prompt
|
||||
let height = (stty size | split row " " | get 0 | into int) - 21
|
||||
let height = (stty size | split row " " | get 0 | into int) - (if $has_tfetch { 21 } else { 0 })
|
||||
|
||||
# skip lines so that the prompt starts at the bottom of the terminal
|
||||
for i in 0..<$height {
|
||||
|
@ -9,4 +11,6 @@ for i in 0..<$height {
|
|||
}
|
||||
|
||||
# Start tfetch
|
||||
tfetch
|
||||
if $has_tfetch {
|
||||
tfetch
|
||||
}
|
||||
|
|
|
@ -234,20 +234,20 @@ $env.EDITOR = nvim
|
|||
$env.RUST_BACKTRACE = full
|
||||
|
||||
# Gclone env
|
||||
$env.GCLONE_PATH = '/home/thomas/git'
|
||||
$env.GCLONE_PATH = $env.HOME + '/git'
|
||||
$env.GCLONE_FORCE_SSH = true
|
||||
|
||||
# Python virtual env
|
||||
$env.VIRTUAL_ENV = '/home/thomas/.venv'
|
||||
$env.VIRTUAL_ENV = $env.HOME + '/.venv'
|
||||
|
||||
# To add entries to PATH (on Windows you might use Path), you can use the following pattern:
|
||||
# $env.PATH = ($env.PATH | split row (char esep) | prepend '/some/path')
|
||||
$env.PATH = ($env.PATH
|
||||
| split row (char esep)
|
||||
| prepend '/home/thomas/.config/polymny/bin'
|
||||
| prepend '/home/thomas/.config/dotfiles/bin'
|
||||
| prepend '/home/thomas/.config/dotfiles/bin-extra'
|
||||
| prepend '/home/thomas/.cargo/bin'
|
||||
| prepend '/home/thomas/.npmbin/bin'
|
||||
| prepend '/home/thomas/.venv/bin'
|
||||
| prepend ($env.HOME + '/.config/polymny/bin')
|
||||
| prepend ($env.HOME + '/.config/dotfiles/bin')
|
||||
| prepend ($env.HOME + '/.config/dotfiles/bin-extra')
|
||||
| prepend ($env.HOME + '/.cargo/bin')
|
||||
| prepend ($env.HOME + '/.npmbin/bin')
|
||||
| prepend ($env.HOME + '/.venv/bin')
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue