User Tools

Site Tools


search_command_line_history_using_glob_pattern_matching

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
search_command_line_history_using_glob_pattern_matching [2022/05/05 12:52] – created adminsearch_command_line_history_using_glob_pattern_matching [2022/05/05 13:09] (current) – [System Information] admin
Line 5: Line 5:
 When reverse searching the command line history using ctrl-r, a lot of characters have to be typed before arriving at the correct command. For example, to go to "cd ~/work/gitlab/rutils", one approach is to When reverse searching the command line history using ctrl-r, a lot of characters have to be typed before arriving at the correct command. For example, to go to "cd ~/work/gitlab/rutils", one approach is to
  
 +<WRAP indent>
 <code> <code>
 ctrl-r ctrl-r
 cd<space> cd<space>
 </code> </code>
 +</WRAP>
 and keep hitting ctrl-r until arriving at and keep hitting ctrl-r until arriving at
 +<WRAP indent>
 <code> <code>
 cd ~/work/gitlab/rutils cd ~/work/gitlab/rutils
 </code> </code>
 +</WRAP>
  
 Another approach is to Another approach is to
 +<WRAP indent>
 <code> <code>
 ctrl-r ctrl-r
Line 20: Line 25:
 <enter> <enter>
 </code> </code>
 +</WRAP>
  
 Here almost the entire command had to be typed since the user did many "cd ~/work/gitlab/xxx" type of commands after doing "cd ~/work/gitlab/rutils". Here almost the entire command had to be typed since the user did many "cd ~/work/gitlab/xxx" type of commands after doing "cd ~/work/gitlab/rutils".
Line 27: Line 33:
 ==== Solution ==== ==== Solution ====
 Add the following lines to ~/.zshrc. Add the following lines to ~/.zshrc.
 +<WRAP indent>
 <code> <code>
 # Use glob patterns when using ctrl-r # Use glob patterns when using ctrl-r
Line 38: Line 45:
 fi fi
 </code> </code>
 +</WRAP>
  
 After this After this
 +<WRAP indent>
 <code> <code>
 ctrl-r ctrl-r
 cd*rutils cd*rutils
 </code> </code>
 +</WRAP>
 will match commands where cd is followed by rutils. will match commands where cd is followed by rutils.
  
Line 49: Line 59:
 Tested this tip using zsh 5.0.7 on a machine running Debian Jessie. Tested this tip using zsh 5.0.7 on a machine running Debian Jessie.
  
 +<WRAP indent>
 <code> <code>
 % dpkg -l zsh | grep ^ii % dpkg -l zsh | grep ^ii
 ii  zsh            5.0.7-5      amd64        shell with lots of features ii  zsh            5.0.7-5      amd64        shell with lots of features
 </code> </code>
 +</WRAP>
  
 tags | reverse search using partial matches shell, reverse search using multiple words shell, use glob patterns in ctrl-r tags | reverse search using partial matches shell, reverse search using multiple words shell, use glob patterns in ctrl-r
search_command_line_history_using_glob_pattern_matching.1651755176.txt.gz · Last modified: 2022/05/05 12:52 by admin