diff --git a/alib2std/src/alib/registration b/alib2std/src/alib/registration
new file mode 100644
index 0000000000000000000000000000000000000000..dd84d0e75a31a39f572054b2e8c292a215c8f634
--- /dev/null
+++ b/alib2std/src/alib/registration
@@ -0,0 +1 @@
+#include <extensions/registration.hpp>
diff --git a/alib2std/src/extensions/registration.hpp b/alib2std/src/extensions/registration.hpp
new file mode 100644
index 0000000000000000000000000000000000000000..94f816cf23e6c4edb827e3a33b69dc9a76ec7b03
--- /dev/null
+++ b/alib2std/src/extensions/registration.hpp
@@ -0,0 +1,50 @@
+/*
+ * registration.hpp
+ *
+ * This file is part of Algorithms library toolkit.
+ * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
+
+ * Algorithms library toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * Algorithms library toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with Algorithms library toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Created on: Jan 26, 2019
+ * Author: Jan Travnice
+ */
+
+#ifndef __REGISTRATION_HPP_
+#define __REGISTRATION_HPP_
+
+#include <functional>
+
+namespace ext {
+
+class Register {
+	std::function < void ( ) > m_finish;
+public:
+	template < class InitCallback, class FinalizeCallback >
+	Register ( InitCallback init, FinalizeCallback finish ) : m_finish ( finish ) {
+		init ( );
+	}
+
+	template < class InitCallback >
+	Register ( InitCallback init ) : Register ( init, [](){} ) {
+	}
+
+	~Register ( ) {
+		m_finish ( );
+	}
+};
+
+} /* namespace ext */
+
+#endif /* __REGISTRATION_HPP_ */
diff --git a/aql2/src/prompt/Prompt.cpp b/aql2/src/prompt/Prompt.cpp
index ed66482e1a76ae26b9929347c3f7dcf00eaa5c37..44638d9a61ae2eaccfe4763102312295c3489a86 100644
--- a/aql2/src/prompt/Prompt.cpp
+++ b/aql2/src/prompt/Prompt.cpp
@@ -11,8 +11,6 @@
 
 Prompt::Prompt ( cli::Environment environment ) : m_history_file ( std::string ( std::getenv ( "HOME" ) ) + "/.aql_history" ), m_environment ( std::move ( environment ) ) {
 	ReadlinePromptHistory::readHistory ( m_history_file.c_str ( ) );
-	// register readline completion function, pass environment
-	rl_attempted_completion_function = ReadlinePromptCompletion::readline_completion;
 }
 
 Prompt::~Prompt ( ) {
diff --git a/aql2/src/prompt/ReadlinePromptCompletion.cpp b/aql2/src/prompt/ReadlinePromptCompletion.cpp
index 615116ed06165df4b9dddfe863f0185b0e7fae7f..873f2b547690d07b7de979f0640af343ff1cef32 100644
--- a/aql2/src/prompt/ReadlinePromptCompletion.cpp
+++ b/aql2/src/prompt/ReadlinePromptCompletion.cpp
@@ -5,8 +5,15 @@
  *	  Author: Tomas Pecka
  */
 
+#include <alib/registration>
+
 #include "ReadlinePromptCompletion.h"
 
+static ext::Register instance ( [ ] ( ) {
+		// register readline completion function, pass environment
+		rl_attempted_completion_function = ReadlinePromptCompletion::readline_completion;
+	} );
+
 /* ========================================================================= */
 
 std::set < std::string > ReadlinePromptCompletion::addPrefix ( const std::set < std::string > & collection, const std::string & prefix ) {