Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As others have mentioned, the usual way to do that would be to store your long commands as either aliases or bash functions. A nice way to organise them would the to put them all in a file (say <code>$HOME/.custom_funcs</code>) then source it from <code>.bashrc</code>.</p> <p>If you <em>really really</em> want to be able to load commands into your bash history, you can use the <code>-r</code> option of the <code>history</code> command. </p> <p>From the <a href="http://ss64.com/bash/history.html" rel="nofollow">man page</a>:</p> <pre><code>-r Read the current history file and append its contents to the history list. </code></pre> <p>Just store all your entries in a file, and whenever you need your custom history loaded simply run <code>history -r &lt;your_file&gt;</code>. </p> <p>Here's a demo:</p> <pre><code>[me@home]$ history | tail # see current history 1006 history | tail 1007 rm x 1008 vi .custom_history 1009 ls 1010 history | tail 1011 cd /var/log 1012 tail -f messages 1013 cd 1014 ls -al 1015 history | tail # see current history [me@home]$ cat $HOME/.custom_history # content of custom history file echo "hello world" ls -al /home/stack/overflow (cd /var/log/messages; wc -l *; cd -) [me@home]$ history -r $HOME/.custom_history # load custom history [me@home]$ history | tail # see updated history 1012 tail -f messages 1013 cd 1014 ls -al 1015 history | tail # see current history 1016 cat .custom_history 1017 history -r $HOME/.custom_history 1018 echo "hello world" 1019 ls -al /home/stack/overflow 1020 (cd /var/log/messages; wc -l *; cd -) 1021 history | tail # see updated history </code></pre> <p>Note how entries <code>1018-1020</code> weren't actually run but instead were loaded from the file. </p> <p>At this point you can access them as you would normally using the <code>history</code> or <code>!</code> commands, or the <kbd>Ctrl</kbd>+<kbd>r</kbd> shortcuts and the likes.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload