mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-02 15:17:47 +00:00
Using def --env instead of def-env (#673)
This commit is contained in:
parent
9d02fb1ef8
commit
06d3095ab1
15 changed files with 28 additions and 28 deletions
|
@ -103,7 +103,7 @@ def marks [] {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Goto your bookmark
|
# Goto your bookmark
|
||||||
export def-env goto [
|
export def --env goto [
|
||||||
pth: path@marks # Path to "go to"
|
pth: path@marks # Path to "go to"
|
||||||
] {
|
] {
|
||||||
let prev = $env.PWD
|
let prev = $env.PWD
|
||||||
|
@ -112,7 +112,7 @@ export def-env goto [
|
||||||
}
|
}
|
||||||
|
|
||||||
# Experimental use of `input` instead of completion
|
# Experimental use of `input` instead of completion
|
||||||
export def-env goto_alternative [] {
|
export def --env goto_alternative [] {
|
||||||
let prev = $env.PWD
|
let prev = $env.PWD
|
||||||
list | input list -f | cd $in.path
|
list | input list -f | cd $in.path
|
||||||
change_prev $prev
|
change_prev $prev
|
||||||
|
|
|
@ -8,7 +8,7 @@ export-env {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export def-env main [
|
export def --env main [
|
||||||
command?: string@'nu-complete rbenv',
|
command?: string@'nu-complete rbenv',
|
||||||
...args
|
...args
|
||||||
] {
|
] {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
# adapted from https://github.com/pypa/virtualenv/blob/46f68d67c79f2280554f47f3c21265b3a1e899a4/src/virtualenv/activation/nushell/activate.nu
|
# adapted from https://github.com/pypa/virtualenv/blob/46f68d67c79f2280554f47f3c21265b3a1e899a4/src/virtualenv/activation/nushell/activate.nu
|
||||||
|
|
||||||
export def-env auto-venv-on-enter [
|
export def --env auto-venv-on-enter [
|
||||||
_env: record,
|
_env: record,
|
||||||
] {
|
] {
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Activate conda environment
|
# Activate conda environment
|
||||||
export def-env activate [
|
export def --env activate [
|
||||||
env_name?: string@'nu-complete conda envs' # name of the environment
|
env_name?: string@'nu-complete conda envs' # name of the environment
|
||||||
] {
|
] {
|
||||||
let conda_info = (conda info --envs --json | from json)
|
let conda_info = (conda info --envs --json | from json)
|
||||||
|
@ -73,7 +73,7 @@ export def-env activate [
|
||||||
}
|
}
|
||||||
|
|
||||||
# Deactivate currently active conda environment
|
# Deactivate currently active conda environment
|
||||||
export def-env deactivate [] {
|
export def --env deactivate [] {
|
||||||
let path_name = if "PATH" in $env { "PATH" } else { "Path" }
|
let path_name = if "PATH" in $env { "PATH" } else { "Path" }
|
||||||
$env.$path_name = $env.CONDA_OLD_PATH
|
$env.$path_name = $env.CONDA_OLD_PATH
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ export-env {
|
||||||
$env.CONDA_CURR = null
|
$env.CONDA_CURR = null
|
||||||
}
|
}
|
||||||
|
|
||||||
export def-env activate [name: string] {
|
export def --env activate [name: string] {
|
||||||
if ($env.CONDA_ROOT | is-empty) {
|
if ($env.CONDA_ROOT | is-empty) {
|
||||||
print "Neither Conda nor Mamba is valid."
|
print "Neither Conda nor Mamba is valid."
|
||||||
return
|
return
|
||||||
|
@ -44,7 +44,7 @@ export def-env activate [name: string] {
|
||||||
load-env ({CONDA_CURR: $name} | merge $new_path)
|
load-env ({CONDA_CURR: $name} | merge $new_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
export def-env deactivate [] {
|
export def --env deactivate [] {
|
||||||
if ($env.CONDA_ROOT | is-empty) {
|
if ($env.CONDA_ROOT | is-empty) {
|
||||||
print "Neither Conda nor Mamba is valid."
|
print "Neither Conda nor Mamba is valid."
|
||||||
return
|
return
|
||||||
|
@ -55,7 +55,7 @@ export def-env deactivate [] {
|
||||||
load-env {Path: $env.CONDA_BASE_PATH, PATH: $env.CONDA_BASE_PATH}
|
load-env {Path: $env.CONDA_BASE_PATH, PATH: $env.CONDA_BASE_PATH}
|
||||||
}
|
}
|
||||||
|
|
||||||
export def-env list [] {
|
export def --env list [] {
|
||||||
$env.CONDA_ENVS |
|
$env.CONDA_ENVS |
|
||||||
flatten |
|
flatten |
|
||||||
transpose |
|
transpose |
|
||||||
|
|
|
@ -35,7 +35,7 @@ export-env {
|
||||||
] | str join ";")
|
] | str join ";")
|
||||||
}
|
}
|
||||||
|
|
||||||
export def-env activate [
|
export def --env activate [
|
||||||
--host (-h): string = "x64", # Host architecture, must be x64 or x86 (case insensitive)
|
--host (-h): string = "x64", # Host architecture, must be x64 or x86 (case insensitive)
|
||||||
--target (-t): string = "x64", # Target architecture, must be x64 or x86 (case insensitive)
|
--target (-t): string = "x64", # Target architecture, must be x64 or x86 (case insensitive)
|
||||||
--sdk (-s): string = "latest" # Version of Windows SDK, must be "latest" or a valid version string
|
--sdk (-s): string = "latest" # Version of Windows SDK, must be "latest" or a valid version string
|
||||||
|
@ -133,7 +133,7 @@ export def-env activate [
|
||||||
hide-env MSVS_INCLUDE_PATH
|
hide-env MSVS_INCLUDE_PATH
|
||||||
}
|
}
|
||||||
|
|
||||||
export def-env deactivate [] {
|
export def --env deactivate [] {
|
||||||
if (($env.MSVS_ROOT | is-empty) or ($env.MSVS_MSVC_ROOT | is-empty)) {
|
if (($env.MSVS_ROOT | is-empty) or ($env.MSVS_MSVC_ROOT | is-empty)) {
|
||||||
print "Either Microsoft Visual Studio or MSVC is valid."
|
print "Either Microsoft Visual Studio or MSVC is valid."
|
||||||
return
|
return
|
||||||
|
|
|
@ -12,7 +12,7 @@ use get-weather.nu get_weather
|
||||||
$env.WEATHER = (get_weather | upsert last_run_time { (date now | format date '%Y-%m-%d %H:%M:%S %z')})
|
$env.WEATHER = (get_weather | upsert last_run_time { (date now | format date '%Y-%m-%d %H:%M:%S %z')})
|
||||||
|
|
||||||
#command to run at interval
|
#command to run at interval
|
||||||
def-env timed_weather_run [
|
def --env timed_weather_run [
|
||||||
--interval(-i): duration # The interval duration
|
--interval(-i): duration # The interval duration
|
||||||
] {
|
] {
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# - Air polution condition using airvisual api
|
# - Air polution condition using airvisual api
|
||||||
# - Street address using google maps api
|
# - Street address using google maps api
|
||||||
# - Version 2.0
|
# - Version 2.0
|
||||||
export def-env weatherds [] {
|
export def --env weatherds [] {
|
||||||
get_weather (get_location 0)
|
get_weather (get_location 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ def get_weather [loc] {
|
||||||
|
|
||||||
|
|
||||||
# Get weather for right command prompt (set in config.nu)
|
# Get weather for right command prompt (set in config.nu)
|
||||||
export def-env get_weather_by_interval [INTERVAL_WEATHER] {
|
export def --env get_weather_by_interval [INTERVAL_WEATHER] {
|
||||||
let weather_runtime_file = (($env.HOME) | path join .weather_runtime_file.json)
|
let weather_runtime_file = (($env.HOME) | path join .weather_runtime_file.json)
|
||||||
|
|
||||||
if ($weather_runtime_file | path exists) {
|
if ($weather_runtime_file | path exists) {
|
||||||
|
|
|
@ -14,7 +14,7 @@ def autojump_add_to_database [dir] {
|
||||||
$env.AUTOJUMP_SOURCED = 1
|
$env.AUTOJUMP_SOURCED = 1
|
||||||
autojump --add $dir
|
autojump --add $dir
|
||||||
}
|
}
|
||||||
def-env j [dir] {
|
def --env j [dir] {
|
||||||
$env.AUTOJUMP_SOURCED = 1
|
$env.AUTOJUMP_SOURCED = 1
|
||||||
cd (autojump $dir)
|
cd (autojump $dir)
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ module cdpath {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Change directory with $env.CDPATH
|
# Change directory with $env.CDPATH
|
||||||
export def-env c [dir = "": string@complete] {
|
export def --env c [dir = "": string@complete] {
|
||||||
let span = (metadata $dir).span
|
let span = (metadata $dir).span
|
||||||
let default = if $nu.os-info.name == "windows" {
|
let default = if $nu.os-info.name == "windows" {
|
||||||
$env.USERPROFILE
|
$env.USERPROFILE
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std repeat;
|
use std repeat;
|
||||||
|
|
||||||
# Go up a number of directories
|
# Go up a number of directories
|
||||||
def-env up [
|
def --env up [
|
||||||
limit = 1: int # The number of directories to go up (default is 1)
|
limit = 1: int # The number of directories to go up (default is 1)
|
||||||
] {
|
] {
|
||||||
cd ("." | repeat ($limit + 1) | str join)
|
cd ("." | repeat ($limit + 1) | str join)
|
||||||
|
|
|
@ -16,11 +16,11 @@ def print_st [] {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def-env b64_encode [fn] {
|
def --env b64_encode [fn] {
|
||||||
open $fn | encode base64
|
open $fn | encode base64
|
||||||
}
|
}
|
||||||
|
|
||||||
def-env b64_decode [fn] {
|
def --env b64_decode [fn] {
|
||||||
$fn | decode base64 -b
|
$fn | decode base64 -b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ def 'nu-sloc' [] {
|
||||||
}
|
}
|
||||||
|
|
||||||
#go to dir (via pipe)
|
#go to dir (via pipe)
|
||||||
def-env goto [] {
|
def --env goto [] {
|
||||||
let input = $in
|
let input = $in
|
||||||
cd (
|
cd (
|
||||||
if ($input | path type) == file {
|
if ($input | path type) == file {
|
||||||
|
@ -124,12 +124,12 @@ def-env goto [] {
|
||||||
}
|
}
|
||||||
|
|
||||||
#go to custom bash bin path, must be added last in config.nu
|
#go to custom bash bin path, must be added last in config.nu
|
||||||
def-env goto-bash [] {
|
def --env goto-bash [] {
|
||||||
cd ($env.PATH | last)
|
cd ($env.PATH | last)
|
||||||
}
|
}
|
||||||
|
|
||||||
#cd to the folder where a binary is located
|
#cd to the folder where a binary is located
|
||||||
def-env which-cd [program] {
|
def --env which-cd [program] {
|
||||||
let dir = (which $program | get path | path dirname | str trim)
|
let dir = (which $program | get path | path dirname | str trim)
|
||||||
cd $dir.0
|
cd $dir.0
|
||||||
}
|
}
|
||||||
|
@ -415,7 +415,7 @@ def dmy [] {
|
||||||
}
|
}
|
||||||
|
|
||||||
# create directory and cd into it.
|
# create directory and cd into it.
|
||||||
def-env md [dir] {
|
def --env md [dir] {
|
||||||
mkdir $dir
|
mkdir $dir
|
||||||
cd $dir
|
cd $dir
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# This first command looks for the file with the todo list and
|
# This first command looks for the file with the todo list and
|
||||||
# prints it to the screen.
|
# prints it to the screen.
|
||||||
def-env printer [] {
|
def --env printer [] {
|
||||||
let contents = (
|
let contents = (
|
||||||
# if you haven't setup this environment var,
|
# if you haven't setup this environment var,
|
||||||
# replace `$env.TODO` with the path to your
|
# replace `$env.TODO` with the path to your
|
||||||
|
|
|
@ -31,7 +31,7 @@ module update-path {
|
||||||
| parse-paths
|
| parse-paths
|
||||||
| append (registry query --hklm 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment'| parse-paths)
|
| append (registry query --hklm 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment'| parse-paths)
|
||||||
}
|
}
|
||||||
export def-env update-path [] {
|
export def --env update-path [] {
|
||||||
$env.Path = ($env.Path|append (get-paths-from-registry)|uniq)
|
$env.Path = ($env.Path|append (get-paths-from-registry)|uniq)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue