-
-
Notifications
You must be signed in to change notification settings - Fork 46
[Atuin] Module #264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[Atuin] Module #264
Conversation
|
Some thoughts about that from the chat:
|
Seem like it is using |
after install the config looks all commented. so we can overwrite the default and use a custom one. to restore the default |
Yes, most seems commented by default. For me the following ones were uncommented by default: |
This seems to cover the default variables for the sync server Included, IMO to be relative in continued development This still only able to work in "$HOME" "~/" environment. |
|
latest update. restart shell |
|
Issues:
|
ZSH, as we provide it, would be nice to work OOB.
What if we add this functionality system-wide, like our ZSH implementation. Superuser within the script is even changing default shell for all. If Admin of OS do this, user can move back to BASH at any moment. We can do one step less here, to do everything for the users of the system, except enabling it. And give instructions how to enable this feature with a simple (user) step. https://github.com/armbian/configng/blob/main/tools/modules/system/update_skel.sh |
So skel is the way to go for so called global, or as you say since the server url is subject to change maybe should add a default url ["module_atuin,server_url"]="https://services.armbian.de/atuin" |
install remove logout and status for @atuinsh repo atuin
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughA new shell script has been added to manage the installation, removal, and configuration of the Atuin command-line tool. The script defines several functions that handle different commands: showing help, installing Atuin by downloading and extracting its binary, removing Atuin and its configuration files, and resetting settings to defaults. An associative array holds key metadata about the module, such as the author, maintainer, and description. The installation process updates environment configurations, including modifications to the user’s shell configuration file (e.g., ✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (8)
tools/modules/software/module_atuin.sh (8)
16-25: User Environment Setup Consistency.
The logic for determininguser_nameanduser_homeworks correctly. However, update the comment on line 20 to refer to the correct fallback variable ($USERinstead of$user) for clarity.
27-30: Remove or Utilize Unused Variablecondition.
The variableconditionis assigned the result ofcommand -v atuinbut is never used. Consider using it (for example, to check if Atuin is already installed) or remove it if unnecessary.🧰 Tools
🪛 Shellcheck (0.10.0)
[warning] 29-29: condition appears unused. Verify use (or export if used externally).
(SC2034)
31-34: Address Unused Variablecommands.
The array variablecommandsis populated by splitting the example string but is not used elsewhere in the function. If it isn’t required for further processing, consider removing it to simplify the code.🧰 Tools
🪛 Shellcheck (0.10.0)
[warning] 33-33: commands appears unused. Verify use (or export if used externally).
(SC2034)
35-44: Case Statement – Help Command Clarity.
The help command clearly prints usage instructions. No major issues here—but you might consider using the previously readcommandsarray to list available commands for consistency in case you plan to use that variable later.
54-58: Typo in Remove Command Message.
The message"Under constrution Removing $title..."contains a typo ("constrution" should be construction). Please update the message for clarity.- echo "Under constrution Removing $title..." + echo "Under construction: Removing $title..."
35-67: Case Statement Completeness.
The case statement handles all specified commands and provides a default case for unknown inputs. Consider reviewing whether the unusedcommandsvariable should be used here to dynamically list the available commands.
167-180: Duplicate User Environment Handling inremove_atuin.
The logic to setuser_nameanduser_homeis repeated here as inset_atuin(). To reduce duplication and ease maintenance, consider refactoring this into a helper function.
218-220: Typo in Variable Name.
The variableouput_folderappears to have a typo. Consider renaming it tooutput_folderfor clarity.-local ouput_folder=".config/atuin" +local output_folder=".config/atuin"Remember also to update its occurrences in the function.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tools/modules/software/module_atuin.sh(1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
tools/modules/software/module_atuin.sh
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
[warning] 29-29: condition appears unused. Verify use (or export if used externally).
(SC2034)
[warning] 33-33: commands appears unused. Verify use (or export if used externally).
(SC2034)
[warning] 146-146: Tilde does not expand in quotes. Use $HOME.
(SC2088)
🔇 Additional comments (6)
tools/modules/software/module_atuin.sh (6)
113-127: Env File Generation Looks Solid.
The creation of the environment file via a here-document is implemented correctly. The escapes (e.g., for\$PATHand\$HOME) are appropriately handled so that literal values are written to the file.
128-134: .bashrc Update for Env File.
The script appends a source command for~/.atuin/bin/envin the user’s.bashrcif it isn’t already present. This approach is clear; however, ensure that multiple invocations of the installer do not append duplicate lines.
144-147: Appending Atuin Initialization to .bashrc.
The script appends theeval "$(atuin init bash)"command to.bashrcif not already present. This ensures Atuin is initialized in new shell sessions—a good usability improvement.🧰 Tools
🪛 Shellcheck (0.10.0)
[warning] 146-146: Tilde does not expand in quotes. Use $HOME.
(SC2088)
148-150: Final Ownership and Completion.
Usingchown -Ron the Atuin installation directory ensures that all files have the proper ownership. The completion message gives clear feedback to the user.
193-197: Bashrc Cleanup Verification.
Thesedcommands are used to remove Atuin-related lines from.bashrc. Verify that the regex patterns exactly match those lines added during installation to ensure complete removal without accidentally deleting other content.
248-249: Module Invocation Comment Intent.
The last line has the invocation ofmodule_atuincommented out, which is appropriate if the script is meant to be sourced as a module. Confirm that this is the intended usage pattern.
| # Extract the tar.gz file as the user | ||
| echo "Extracting Atuin binary..." | ||
| tar -xvzf "$user_home/atuin.tar.gz" -C "$user_home" | ||
|
|
||
| # Move the binary to the desired location as the user | ||
| echo "Moving Atuin binary to $atuin_dir..." | ||
| mv "$user_home/atuin-aarch64-unknown-linux-gnu/$atuin_binary" "$atuin_dir/$atuin_binary" | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Architecture Directory Mismatch.
The downloaded URL targets an x86_64 binary, yet the script later refers to the directory atuin-aarch64-unknown-linux-gnu when moving the binary and cleaning up. This mismatch can cause the installation to fail. Consider dynamically determining the directory name based on the system architecture or correcting the hard-coded directory to match the downloaded binary.
Example Diff (using dynamic detection):
+ARCH=$(uname -m)
+if [[ "$ARCH" == "x86_64" ]]; then
+ dir_name="atuin-x86_64-unknown-linux-gnu"
+elif [[ "$ARCH" == "aarch64" ]]; then
+ dir_name="atuin-aarch64-unknown-linux-gnu"
+else
+ echo "Unsupported architecture: $ARCH" >&2; exit 1
+fi
...
-mv "$user_home/atuin-aarch64-unknown-linux-gnu/$atuin_binary" "$atuin_dir/$atuin_binary"
+mv "$user_home/$dir_name/$atuin_binary" "$atuin_dir/$atuin_binary"
...
-rm -rf "$user_home/atuin-aarch64-unknown-linux-gnu"
+rm -rf "$user_home/$dir_name"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # Extract the tar.gz file as the user | |
| echo "Extracting Atuin binary..." | |
| tar -xvzf "$user_home/atuin.tar.gz" -C "$user_home" | |
| # Move the binary to the desired location as the user | |
| echo "Moving Atuin binary to $atuin_dir..." | |
| mv "$user_home/atuin-aarch64-unknown-linux-gnu/$atuin_binary" "$atuin_dir/$atuin_binary" | |
| # Determine architecture and directory name | |
| ARCH=$(uname -m) | |
| if [[ "$ARCH" == "x86_64" ]]; then | |
| dir_name="atuin-x86_64-unknown-linux-gnu" | |
| elif [[ "$ARCH" == "aarch64" ]]; then | |
| dir_name="atuin-aarch64-unknown-linux-gnu" | |
| else | |
| echo "Unsupported architecture: $ARCH" >&2; exit 1 | |
| fi | |
| # Extract the tar.gz file as the user | |
| echo "Extracting Atuin binary..." | |
| tar -xvzf "$user_home/atuin.tar.gz" -C "$user_home" | |
| # Move the binary to the desired location as the user | |
| echo "Moving Atuin binary to $atuin_dir..." | |
| mv "$user_home/$dir_name/$atuin_binary" "$atuin_dir/$atuin_binary" | |
| # Clean up | |
| rm -rf "$user_home/$dir_name" |
| function set_atuin() { | ||
| # Define variables | ||
| atuin_url="https://github.com/atuinsh/atuin/releases/download/v18.4.0-beta.3/atuin-x86_64-unknown-linux-gnu.tar.gz" | ||
| atuin_dir="$user_home/.atuin/bin" | ||
| atuin_binary="atuin" | ||
| bash_preexec_file="$user_home/.bash-preexec.sh" | ||
| atuin_bashrc_file="$user_home/.bashrc" | ||
| local user_name user_home |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Local Variable Declaration Order in set_atuin.
In set_atuin(), the variable atuin_dir (and others that depend on user_home) is assigned before the local variables user_name and user_home are declared and set. This can lead to unintended behavior if the environment variables are not as expected. Consider moving the declaration of local user_name user_home to the very beginning of the function.
Example Diff:
-function set_atuin() {
- # Define variables
- atuin_url="https://github.com/atuinsh/atuin/releases/download/v18.4.0-beta.3/atuin-x86_64-unknown-linux-gnu.tar.gz"
- atuin_dir="$user_home/.atuin/bin"
- atuin_binary="atuin"
- bash_preexec_file="$user_home/.bash-preexec.sh"
- atuin_bashrc_file="$user_home/.bashrc"
- local user_name user_home
- if [[ $EUID -eq 0 ]]; then
+function set_atuin() {
+ local user_name user_home
+ # Define variables (user_home will be set below)
+ atuin_url="https://github.com/atuinsh/atuin/releases/download/v18.4.0-beta.3/atuin-x86_64-unknown-linux-gnu.tar.gz"
+ # Temporarily set atuin_dir using $HOME; it will be revised after determining the correct user environment
+ atuin_dir="$HOME/.atuin/bin"
+ atuin_binary="atuin"
+ bash_preexec_file="$HOME/.bash-preexec.sh"
+ atuin_bashrc_file="$HOME/.bashrc"
+ if [[ $EUID -eq 0 ]]; then📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| function set_atuin() { | |
| # Define variables | |
| atuin_url="https://github.com/atuinsh/atuin/releases/download/v18.4.0-beta.3/atuin-x86_64-unknown-linux-gnu.tar.gz" | |
| atuin_dir="$user_home/.atuin/bin" | |
| atuin_binary="atuin" | |
| bash_preexec_file="$user_home/.bash-preexec.sh" | |
| atuin_bashrc_file="$user_home/.bashrc" | |
| local user_name user_home | |
| function set_atuin() { | |
| local user_name user_home | |
| # Define variables (user_home will be set below) | |
| atuin_url="https://github.com/atuinsh/atuin/releases/download/v18.4.0-beta.3/atuin-x86_64-unknown-linux-gnu.tar.gz" | |
| # Temporarily set atuin_dir using $HOME; it will be revised after determining the correct user environment | |
| atuin_dir="$HOME/.atuin/bin" | |
| atuin_binary="atuin" | |
| bash_preexec_file="$HOME/.bash-preexec.sh" | |
| atuin_bashrc_file="$HOME/.bashrc" | |
| if [[ $EUID -eq 0 ]]; then | |
| ... |
|
version should be bumped to v18.5.0 |
|
Closing Stalled but not forgotten. Considering configuration approach |
|
Server version was bumped to 18.6.0 |
|
"This is works for me including the timezone for check logs across along on the clients. Validates in Raspbery pi 4 with Armbian 25.2.2 Bookworm" |
Interesting title. Playing with making a module for basic setup of atuin.
bash "./tools/modules/software/module_atuin" helphttps://docs.atuin.sh/guide/installation/
running installs to $HOME
Not sure how to make this global. maybe module
update_skelmay be a hint?