{"id":26,"date":"2017-01-23T18:53:22","date_gmt":"2017-01-23T23:53:22","guid":{"rendered":"http:\/\/commons.trincoll.edu\/trinityrobotics\/?p=26"},"modified":"2017-01-29T22:20:10","modified_gmt":"2017-01-30T03:20:10","slug":"how-i-learned-to-stop-worrying-and-love-the-terminal","status":"publish","type":"post","link":"https:\/\/commons.trincoll.edu\/trinityrobotics\/how-i-learned-to-stop-worrying-and-love-the-terminal\/","title":{"rendered":"How I Learned to Stop Worrying and Love the Terminal"},"content":{"rendered":"<p>zGiven that most of you will access ROS through the terminal (the -X next to ssh indicates that you can try to run GUI tools, but the speed is excessively slow), here are some terminal commands and tools that will make working in the terminal a lot easier.<\/p>\n<p><strong>tmux\u00a0<\/strong><\/p>\n<p>Tmux is a terminal multiplexer, which means that you can run multiple terminal shells in one window. Type <code>tmux<\/code>\u00a0<em>\u00a0<\/em>into the terminal, and it should take you a nearly identical terminal window.<\/p>\n<p>Commands are<\/p>\n<ul>\n<li><code>Ctrl-b + %<\/code> &#8211; Split the terminal vertically into two panes<\/li>\n<li><code>Ctrl-b + \"<\/code> &#8211; Split the terminal horizontally into two panes<\/li>\n<li><code>Ctrl-b (with continued press) + arrow_key<\/code> &#8211; Resize the pane<\/li>\n<li><code>Ctrl-b + arrow_key<\/code> &#8211; Change pane selection<\/li>\n<li><code>Ctrl-b + x<\/code> &#8211; terminal the current selected pane<\/li>\n<li><code>Ctrl-b + [<\/code> &#8211; Read mode (ESC and move cursor to escape)<\/li>\n<\/ul>\n<p><strong>vim\u00a0<\/strong>(or nano)<\/p>\n<div>Vim is a text editor that requires the users to use key commands. You could either type <code>vimtutor<\/code>\u00a0for practice (which will take about 10 minutes), or google for basic vim commands. You only really use ~10 commands, so I think it&#8217;s worth learning vim.<\/div>\n<div><\/div>\n<div>I highly recommend you go through\u00a0<code>vimtutor<\/code> multiple times.<\/div>\n<div><\/div>\n<div>Currently, there is a file explorer pane in vim (called netrw)\u00a0&#8211; you can switch between panes using <code>Ctrl-W + Arrow_keys\u00a0<\/code> and terminate each pane using\u00a0<code>Esc and typing :wq (for editor) and :q (file explorer)<\/code>.<\/div>\n<div><\/div>\n<div><strong>Terminal commands<\/strong><\/div>\n<div><\/div>\n<div>\n<p>To redirect the terminal output to a file (so you can read the error output)<\/p>\n<pre class=\"lang-sh prettyprint prettyprinted\"><code><span class=\"pln\">some_command <\/span><span class=\"pun\">&gt;<\/span><span class=\"pln\">file<\/span><span class=\"pun\">.<\/span><span class=\"pln\">log <\/span><span class=\"lit\">2<\/span><span class=\"pun\">&gt;&amp;<\/span><span class=\"lit\">1<\/span> <\/code><\/pre>\n<p><strong>Run a command in the background:<\/strong><\/p>\n<p><code>some_command &amp;\u00a0<\/code><\/p>\n<p><strong>Move out of current folder<\/strong><\/p>\n<p><code>cd ..<\/code><\/p>\n<p><strong>How to run a command every terminal launch<\/strong><\/p>\n<p>Modify <code>~\/.bashrc<\/code>\u00a0(e.g. vim ~\/.bashrc) and put commands at the bottom.<\/p>\n<\/div>\n<p><code>~\/.bashrc<\/code>\u00a0is essentially a shell (bash) command that runs when you first open the terminal, which means that you can put setup commands in <code>~\/.bashrc<\/code>\u00a0so that you would not have to type them over and over again.<\/p>\n<p>In <code>~\/.bashrc<\/code>, you can put<code> ~\/catkin_ws\/devel\/setup.bash<\/code> (which is within ROS workspace) as one of the setup files to execute at launch.\u00a0What<code>setup.bash<\/code>\u00a0does is that it sets up the path variables for ROS, allowing commands like <code>roscd<\/code>\u00a0to find where the directory with packages is.<\/p>\n<p>For those who are not so familiar with the terminal language, a &#8220;shell&#8221; is the terminal &#8211; a way for the user to interact with the operating system (Linux, in this case).<\/p>\n<div>\n<p><strong>ROS commands<\/strong><\/p>\n<p><code>roscd &lt;package_name&gt; &lt;folder_name&gt;<\/code><\/p>\n<p><code>rosed &lt;pacakge_name&gt; &lt;file_name&gt;<\/code> &#8211; Opens file for editing<\/p>\n<p>Commands like <code>roscd<\/code> (ros + cd) and\u00a0<code>rosed<\/code> (ros + ed), they are essentially shortcuts for cd and ed to edit ROS\u00a0package files quickly.<\/p>\n<p>&nbsp;<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>zGiven that most of you will access ROS through the terminal (the -X next to ssh indicates that you can try to run GUI tools, but the speed is excessively slow), here are some terminal commands and tools that will make working in the terminal a lot easier. tmux\u00a0 Tmux is a terminal multiplexer, which &hellip; <a href=\"https:\/\/commons.trincoll.edu\/trinityrobotics\/how-i-learned-to-stop-worrying-and-love-the-terminal\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How I Learned to Stop Worrying and Love the Terminal&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1933,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/commons.trincoll.edu\/trinityrobotics\/wp-json\/wp\/v2\/posts\/26"}],"collection":[{"href":"https:\/\/commons.trincoll.edu\/trinityrobotics\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/commons.trincoll.edu\/trinityrobotics\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/commons.trincoll.edu\/trinityrobotics\/wp-json\/wp\/v2\/users\/1933"}],"replies":[{"embeddable":true,"href":"https:\/\/commons.trincoll.edu\/trinityrobotics\/wp-json\/wp\/v2\/comments?post=26"}],"version-history":[{"count":4,"href":"https:\/\/commons.trincoll.edu\/trinityrobotics\/wp-json\/wp\/v2\/posts\/26\/revisions"}],"predecessor-version":[{"id":34,"href":"https:\/\/commons.trincoll.edu\/trinityrobotics\/wp-json\/wp\/v2\/posts\/26\/revisions\/34"}],"wp:attachment":[{"href":"https:\/\/commons.trincoll.edu\/trinityrobotics\/wp-json\/wp\/v2\/media?parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/commons.trincoll.edu\/trinityrobotics\/wp-json\/wp\/v2\/categories?post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/commons.trincoll.edu\/trinityrobotics\/wp-json\/wp\/v2\/tags?post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}