Guest User

Untitled

a guest
Jun 13th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. Some of my favorite bash tricks (most of these come straight from Emacs):
  2.  
  3. Of course, most of these will ONLY work when 'set -o emacs'
  4.  
  5. C-L Clean screen (in emacs it means center screen at cursor line)
  6. C-F Move to next character
  7. C-B Move to previous character
  8. C-A Jump to beginning of line (bol)
  9. C-E Jump to end of line (eol)
  10. M-B Jump to previous word
  11. M-F Jump to next word
  12. C-/ Undo
  13. C-X C-X Swap point. There are two marks. You can move around, C-X C-X, move
  14. some more, and then switch between points.
  15. C-X C-E Edit command in $EDITOR
  16.  
  17. C-K Kill line from point to eol
  18. C-U Kill line from point to bol
  19. M-D Kill next word
  20. M-Backspace Kill previous word
  21. C-W Kill previous word (to previous space)
  22. C-H Kill previous character (doesn't go into kill ring)
  23. C-D Kill next character (doesn't go into kill ring)
  24. C-Y Yank killed text
  25.  
  26. C-R Recall text backward
  27. C-S Recall text forward (might not work depending on terminal settings. It
  28. could stop flow. If this happens, C-Q restores it)
  29.  
  30. history Show history
  31.  
  32.  
  33. In .bashrc (or .bash_profile, .profile, etc.), I like to add
  34. "$(parse_git_branch)$(parse_svn_revision)$(parse_cvs_tag)" to PS1 and define
  35.  
  36. parse_cvs_tag()
  37. {
  38. [[ -d "CVS" ]] && ([[ -e "CVS/Tag" ]] && sed -e 's/^T/ (/' -e 's/^N/ (/' -e 's/^D/ Date /' -e 's/$/)/' CVS/Tag || echo ' (HEAD)')
  39. }
  40.  
  41. parse_git_branch()
  42. {
  43. local DIRTY STATUS
  44. STATUS=$(git status 2>/dev/null)
  45. [ $? -eq 128 ] && return
  46. [[ "$STATUS" == *'working directory clean'* ]] || DIRTY=' *'
  47. echo " ($(git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* //')$DIRTY)"
  48. }
  49.  
  50. parse_svn_revision()
  51. {
  52. local REV=$(svnversion 2>/dev/null)
  53. [ $? -eq 0 ] || return
  54. [ "$REV" == 'exported' ] && return
  55. echo " ($REV)"
  56. }
  57.  
  58. Note: for some big repositories, this PS1 format might slow things down a bit. Use at your own risk :)
Add Comment
Please, Sign In to add comment