Skip to content

Instantly share code, notes, and snippets.

@pongstr
Last active September 26, 2022 11:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pongstr/f7dd48d639e37abb3de9ef9d436b472f to your computer and use it in GitHub Desktop.
Save pongstr/f7dd48d639e37abb3de9ef9d436b472f to your computer and use it in GitHub Desktop.
Bash useful commands :D

dirs

# display the directory stack vertically, prefixing each
# entry with its index in the stack.
$ dirs -v

# cd and push the path to the directory stack.
$ pushd /path/to/directory

# this command is the opposite of push,
# where it removes a directory from the  
# stack starting at index 0
$ popd

# Try dirs -v again to see the updated stack.
# Now you may use the stack index to refer to
# the directory or the path
$ ls -ls ~1

history

# Displays the list of commands you've performed
# prefixed with and index
$ history

# To put it in use, you may execute a command
# from that list based on the index
$ ![index] # square brackets not included

# You may also use the first two letters
# of the previous command
$ !cl # assuming `clear` was the previously excuted command

# As a precaution, you may append `:p`
# to print it first before executing it
$ !cl:p

# `!` is useful to also use the arguments
# from the previous command, e.g., `$ echo a b c`
$ echo !:3 # outputs `c`

# Now in unison
$ ![index]  / # history command index
  !:1         # history command arguments

tmux

# Start Tmux
$ tmux

Key Bindings

# List Sessions 
tmux list-sessions 

# Attach to Session
tmux attach-session -t [index from list || session name]

# Kill session
tmux kill-session -t [index from list || session name]


# Sessions
ctrl-b + c        # new session
ctrl-b + ,        # rename session
ctrl-b + p        # previous session
ctrl-b + n        # next session
ctrl-b + [num]    # go to session
ctrl-b + d        # close session

# Split Panes
ctrl-b + "        # split pane horizontally
ctrl-b + %        # split pane vertically
ctrl-b + o        # cycle: go to next pane
ctrl-b + ;        # cycle: go to prev pane
ctrl-b + [arrow]  # go directly to pane
ctrl-b + x        # remove pane


# Misc
ctrl-b + t        # show time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment