diff --git a/aliases/README.md b/aliases/README.md new file mode 100644 index 0000000..5662d90 --- /dev/null +++ b/aliases/README.md @@ -0,0 +1,9 @@ +# Custom aliases + +This current directory provides custom aliases. They can be used by importing their exported aliases via: + +```nushell +use path/to//-aliases.nu * +``` + +With `path/to/` being either the relative path of the file to your current working directory or its absolute path. diff --git a/aliases/aws/select-aws-profile.nu b/aliases/aws/select-aws-profile.nu deleted file mode 100644 index ac3f452..0000000 --- a/aliases/aws/select-aws-profile.nu +++ /dev/null @@ -1,38 +0,0 @@ -# This alias lets you choose your aws environment variables with ease. -# -# Dependencies -# * fzf -# -# Installation -# 1. store in ~/.config/nushell/select-aws-profile.nu -# 2. add to your config.nu: `use ~/.config/nushell/select-aws-profile.nu *` -# -# Usage -# select-aws-profile - -export alias select-aws-profile = ( - hide AWS_REGION; - (do { - let creds = (open ($env.HOME + "/.aws/credentials") | from ini) - let selectedProfile = (for it in ($creds | transpose name creds) { echo $it.name } | str join "\n" | fzf | str trim) - if $selectedProfile != "" { - let out = { - AWS_PROFILE: $selectedProfile, - AWS_ACCESS_KEY_ID: ($creds | get $selectedProfile | get "aws_access_key_id"), - AWS_SECRET_ACCESS_KEY: ($creds | get $selectedProfile | get "aws_secret_access_key"), - } - let region = ($creds | get $selectedProfile | get -i "region") - if $region != "" { - $out | insert "AWS_REGION" $region - } else { - $out - } - } - } | load-env); - { - AWS_PROFILE: $env.AWS_PROFILE, - AWS_ACCESS_KEY_ID: $env.AWS_ACCESS_KEY_ID, - AWS_SECRET_ACCESS_KEY: $env.AWS_SECRET_ACCESS_KEY, - AWS_REGION: $env.AWS_REGION - } -) diff --git a/aliases/exa/README.md b/aliases/exa/README.md deleted file mode 100644 index 94161d6..0000000 --- a/aliases/exa/README.md +++ /dev/null @@ -1,15 +0,0 @@ -Some aliases for exa! - -# Preparations -Copy the `nu_aliases_exa.nu` to your `$env.NU_LIB_DIRS` and add the following to -your `config.nu`: - -```nu -use nu_alias_exa.nu * - -# or if you want to add the prefix: -use nu_alias_exa.nu -``` - -For more information of how to load it, click -[here](https://www.nushell.sh/book/modules.html#using-modules). diff --git a/aliases/exa/exa-aliases.nu b/aliases/exa/exa-aliases.nu new file mode 100644 index 0000000..4052220 --- /dev/null +++ b/aliases/exa/exa-aliases.nu @@ -0,0 +1,6 @@ +export alias x = exa --icons +export alias xa = exa --icons --all +export alias xl = exa --long +export alias xla = exa --long --all +export alias xt = exa --icons --tree +export alias xta = exa --icons --tree --all diff --git a/aliases/exa/nu_alias_exa.nu b/aliases/exa/nu_alias_exa.nu deleted file mode 100644 index 12dc3dd..0000000 --- a/aliases/exa/nu_alias_exa.nu +++ /dev/null @@ -1,6 +0,0 @@ -export alias x = exa --icons -export alias xa = exa --icons --all -export alias xl = exa --long -export alias xla = exa --long --all -export alias xt = exa --icons --tree -export alias xta = exa --icons --tree --all diff --git a/aliases/git/README.md b/aliases/git/README.md deleted file mode 100644 index b336d18..0000000 --- a/aliases/git/README.md +++ /dev/null @@ -1,18 +0,0 @@ -Some aliases for common git commands! - -# Preparations -Copy the `nu_aliases_git.nu` to your `$env.NU_LIB_DIRS` and add the following to -your `config.nu`: - -```nu -use nu_alias_git.nu * - -# or if you want to add the prefix: -use nu_alias_git.nu -``` - -For more information of how to load it, click -[here](https://www.nushell.sh/book/modules.html#using-modules). - -# Inspiration -[git.plugin.zsh](https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/git/git.plugin.zsh) diff --git a/aliases/git/nu_alias_git.nu b/aliases/git/git-aliases.nu similarity index 100% rename from aliases/git/nu_alias_git.nu rename to aliases/git/git-aliases.nu diff --git a/modules/aws/select-aws-profile.nu b/modules/aws/select-aws-profile.nu new file mode 100644 index 0000000..860273f --- /dev/null +++ b/modules/aws/select-aws-profile.nu @@ -0,0 +1,45 @@ +# This alias lets you choose your aws environment variables with ease. +# +# Dependencies +# * fzf +# +# Installation +# 1. store in ~/.config/nushell/select-aws-profile.nu +# 2. add to your config.nu: `use ~/.config/nushell/select-aws-profile.nu *` +# +# Usage +# select-aws-profile +export def select-aws-profile [] { + hide AWS_REGION; + + (do { + let creds = (open ($env.HOME + "/.aws/credentials") | from toml) + let selectedProfile = (for it in ($creds | transpose name creds) { + echo $it.name + }) + + selectedProfile = selectedProfile | str join "\n" | fzf | str trim + + if $selectedProfile != "" { + let out = { + AWS_PROFILE: $selectedProfile, + AWS_ACCESS_KEY_ID: ($creds | get $selectedProfile | get "aws_access_key_id"), + AWS_SECRET_ACCESS_KEY: ($creds | get $selectedProfile | get "aws_secret_access_key"), + } + + let region = ($creds | get $selectedProfile | get -i "region") + if $region != "" { + $out | insert "AWS_REGION" $region + } else { + $out + } + } + } | load-env); + + { + AWS_PROFILE: $env.AWS_PROFILE, + AWS_ACCESS_KEY_ID: $env.AWS_ACCESS_KEY_ID, + AWS_SECRET_ACCESS_KEY: $env.AWS_SECRET_ACCESS_KEY, + AWS_REGION: $env.AWS_REGION + } +} \ No newline at end of file