----BEGIN CLASS---- [13:57] #startclass [13:57] Roll call [13:58] Shiva Saxena [13:58] Amitrajit Bose [13:58] Mayank Singhal [13:58] Anu Kumari Gupta [13:58] Neeraj Kumar Arya [13:58] Robin Schubert [13:58] Bhavin Gandhi [13:58] Akshay Gaikwad [13:58] Prashant Sharma [13:58] Siddhant N Trivedi [13:58] Aman Verma [13:59] Today, we are going to work with Dired mode [13:59] Before, we learn to use, let us first create few test directories and files to play around [13:59] Open Emacs using "emacs -Q", and enter a shell and type these commands [13:59] Priyanka Saggu [14:00] => mkdir /tmp/dired-demo/network -p [14:00] => mkdir /tmp/dired-demo/kernel [14:00] => date > /tmp/dired-demo/date.txt [14:00] => locale > /tmp/dired-demo/locale.txt [14:00] => cp /etc/resolv.conf /tmp/dired-demo/network/resolv.conf [14:00] => ip addr > /tmp/dired-demo/network/ip.output [14:00] => dmesg > /tmp/dired-demo/kernel/dmesg.log [14:00] We are basically creating a /tmp/dired-demo directory, with two sub-directories [14:01] We are then creating some test files at the top-level directory, and also in the sub-directory [14:01] Hopefully, these commands should be available in your distribution [14:01] Sandeep Kumar Choudhary [14:03] I will give some time for you to type these commands and create the directory structure [14:03] Since, it is created in /tmp, you can safely remove it after the session, or in some distros, /tmp content is removed on reboot [14:04] Dired-mode is used to operate on directories and files inside GNU Emacs [14:04] You can enter into it using: [14:04] => C-x d [14:05] At the minibuffer, it will prompt with the message, "Dired (directory): ~/" [14:05] Here you can enter "/tmp/dired-demo" [14:05] You will now see the dired buffer with the name 'dired-demo' [14:06] To quit dired, you can simple use: [14:06] => q [14:07] Once, you enter into the dired-demo directory in Dired mode, you should see the date.txt, kernel/, locale.txt and network/ listing [14:07] Of course, this is already in sorted order [14:07] And you also see the permissions, ownership, group, size, date and time [14:07] Let us now look at some basic motion commands in dired mode [14:08] You can move to the previous line using: [14:08] => p [14:08] You can move down to the next line using: [14:08] => n [14:08] mbuf: after entering the commands into emacs ,What do we have to do ? [14:09] Actually its my first emacs sessions [14:10] nightwarriorxxx, use "!" to ask question [14:10] ! [14:10] next [14:10] mbuf: after entering the commands into emacs ,What do we have to do ? Actually its my first emacs sessions [14:10] nightwarriorxxx, which commands did you enter? [14:11] nightwarriorxxx, I suggest you go through the previous sessions first [14:11] You can move to the previous directory line using: [14:11] => < [14:11] You can move down to the next directory line using: [14:11] => > [14:12] mbuf: ok [14:13] If you move the cursor to the "kernel" line, and hit enter, dired will now show the contents of the "kernel" directory [14:13] You can move to the parent directory using: [14:14] => ^ [14:14] ! [14:14] next [14:14] mkdir command to be typed on the terminal right? [14:15] jeet__, yes [14:16] If you are in the kernel/ directory, and cursor is on the dmesg.log entry, you can view the file using: [14:16] => v [14:16] OR [14:16] => f [14:16] If you want to open the file in another window, you can use: [14:16] => o [14:18] Move to the top-level directory, /tmp/dired-demo. You can create a new directory using: [14:18] => + [14:18] You will get a prompt message, "Create directory /tmp/dired-demo", where you can type "disk", and this directory will be created [14:20] Just as how you learn to mark and unmark buffers, you can similarly operate in the Dired buffer [14:20] To mark a file or subdirectory for later commands, use: [14:20] => m [14:21] To unmark a file or all files of a subdirectory, use: [14:21] => u [14:22] Let's say, you have marked the "disk" directory, and you want to invert your mark selection. You can use: [14:22] => t [14:23] If you want to mark all directories, you can use: [14:23] => * / [14:24] If you try the above in the top-level directory, you will see that the disk, kernel and network directories are selected [14:25] If you simply want to undo the previous change, you can use the same short-cut for undo operation, and GNU Emacs is smart enough to revert your previous operation [14:25] => C-x u [14:26] If you want to mark all files (and directories) in the current directory, use: [14:26] => * s [14:26] You can mark files matching a regular expression using: [14:27] => * % [14:27] At the minibuffer, you will get a prompt message "Mark files (regexp):", and you can input .txt [14:27] So, both date.txt and locale.txt will get marked [14:28] The above are different ways to mark and unmark files in the Dired buffer [14:30] You can insert another subdirectory into the current Dired buffer using: [14:30] => i [14:30] For example, if your cursor is in the 'kernel' entry, and you press 'i', the directory contents of the 'kernel' directory are pasted into the Dired buffer [14:31] If you want to remove the subdirectory listing, you can use: [14:31] => C-u k [14:33] ! [14:33] If you have marked 'date.txt', and if you want to remove it from the listing, you can use: [14:33] => k [14:34] This does not delete the file, it only does not show it in the listing [14:34] You can re-read all directories using: [14:34] => g [14:34] next [14:35] Any reasons why this happened: when I was running dmesg > /tmp/dired-demo/kernel/ ... the auto completion using tab was not working [14:35] Whereas for other commands it did work [14:36] jeet__, 1. Where did you run it? 2. For which part of the command did you expect auto-completion? [14:36] 1) On Terminal [14:36] jeet__, be specific [14:36] 2) dmesg > /tmp/dire [now press tab] nothing shows up [14:37] whereas for other commands it automatically completed the path [14:37] Although on typing the entire thing it worked. But why the autocomplete failed. I tried twice. Just curious. [14:37] jeet__, 3. which terminal 4. How did you open it? [14:38] 3)the normal ubuntu terminal ; 4) Ctrl+Alt+T [14:39] jeet__, there is nothing called "normal Ubuntu terminal". If you have created the /tmp/dired-demo directory, it will auto-complete. [14:39] jeet__, check that later [14:40] Yes. I will ask you after the session [14:40] Sorry for interrupting [14:40] If you have have inserted multiple directories in the Dired buffer, you can selectively, hide the sub-directory listing using: [14:40] => $ [14:40] You can press it again to unhide [14:41] Similarly, if you want to hide and unhide all subdirectories, you can use: [14:41] => M-$ [14:42] Let us now look at some commands you can use on marked files and directories [14:43] Mark date.txt, and if you want to copy the file, you can use: [14:43] => C [14:43] It will prompt in the minibuffer with the message, "Copy date.txt to: /tmp/dired-demo/", and you can enter date2.txt [14:44] Let us say, you now want to rename this file, you can mark date2.txt and use: [14:44] => R [14:45] It will prompt in the minibuffer with the message, "Rename date2.txt to: /tmp/dired-demo/" and you can input "date-new.txt" [14:47] You can change the mode of the file using: [14:47] => M [14:48] If you press 'M' on date-new.txt, it will prompt in the minibuffer with the message, "Change mode of date-new.txt to:" [14:48] and you can give, say 755 [14:48] You will now see that the permissions are modified! [14:50] You can convert the filename to upper-case using: [14:50] => % u [14:50] Emacs will prompt in the minibuffer with the message "Rename upcase date-new.txt' to 'DATE-NEW.txt' [Type yn!q or C-h] [14:51] If you enter 'y', it will rename the file with all upper case [14:51] Similarly, you can convert the filename to lower case using: [14:51] => %l [14:52] You can delete a file using: [14:52] => D [14:53] At the minibuffer, you will get the prompt message, "Delete DATE-NEW.TXT (yes or no)", and you can input 'yes' [14:53] And the file will be deleted [14:54] You can compress or uncompress a file using: [14:54] => Z [14:54] Try this on /tmp/dired-demo/kernel/dmesg.log [14:56] If you want to search files for a regular expression, you can use: [14:56] => A [14:56] Try this on the /tmp/dired-demo/network/resolv.conf entry [14:57] You will get a prompt message in the minibuffer with "Search marked files (regexp):", and you can input 'nameserver' [14:57] Emacs will open a new *xref* buffer matching the 'nameserver' entris [14:57] *entries [14:58] You can also run a query replace with regexp on marked files using: [14:58] => Q [14:58] Let's say for the /tmp/dired-demo/network/ip.output file, you want to change all 'link' to 'llink' [14:59] If you press 'Q' in the ip.output entry, in the minibuffer, you will get a prompt message, "Query replace regexp in marked files:" [14:59] You can input 'link' [15:00] And then it will prompt you again with the message "Query replace regexp in marked files link with:" [15:00] You can now input 'llink' [15:00] It will open the buffer, and will prompt with the message, "Query replacing link with llink: (? for help) [15:00] You can press 'y' to keep replacing the entries [15:01] You can run a shell command on a file using: [15:01] => ! [15:02] Keep the cursor on /tmp/dired-demo/locale.txt and press '!' [15:02] You will get a prompt message with "! on locale.txt:" [15:02] You can input 'wc' [15:02] It will produce the word count output in the minibuffer itself [15:03] You can also run asynchronous shell command on file(s) using: [15:03] => & [15:04] Let's say we want to run the 'wc' command on /tmp/dired-demo/kernel/dmesg.log' asynchronously, you can use '&' on its entry [15:04] You will get the prompt message "& on dmesg.log:", and you can input 'wc' [15:05] Emacs will open a new *Async Shell Command* buffer with the output of wc [15:05] You can mark file for deletion using: [15:05] => d [15:06] Go ahead and mark the locale.txt for deletion. [15:06] To execute the deletions requested (flagged files), use: [15:06] => x [15:06] You will be prompted in the minibuffer with the message: [15:06] "Delete locale.txt (yes or no)" and you can input 'yes' [15:07] The file will be deleted and the Dired buffer will also be refreshed to show you the current state of the buffer [15:08] Emacs will create backup files at times that end with ~. If you find them in a directory, and you want to mark them for deletion, you can use: [15:08] => ~ [15:08] Similarly, Emacs may create auto-save files, that begin and end with '#'. You can again flag these files in a directory using: [15:09] => # [15:09] If you want to flag files for deletion based on a regular expression, you can use: [15:09] => % d [15:11] You can use regexp to copy marked files [15:11] => % C [15:11] If you use the above command in the top-level /tmp/dired-demo directory, you will get a prompt message: [15:11] "Copy from (regexp):", and you can input '.txt' [15:12] It will then prompt you with the message "Copy .txt to:", and you can input '.log' [15:13] You will get the message "Copy [-p] 'date.txt' to 'date.log'? [Type yn!q or C-h]", and you can input 'y' [15:14] So, the date.txt will now be copied to date.log [15:15] Similarly, you can rename marked files by regexp using: [15:15] => %R [15:15] => % R [15:16] You can search for dired file(s) that match a pattern using: [15:16] => M-x find-name-dired [15:17] You will get a prompt "Find-name (directory): /tmp/dired-demo/", and you can simply hit enter [15:17] It will then ask "Find-name (filename wildcard):" and you can input '.txt' [15:17] The results will be shown in a *Find* buffer [15:18] You can also grep for text on dired file(s) with a pattern using: [15:18] => M-x find-grep-dired [15:19] If you use the above command at the top-level directory, it will prompt with the message in the minibuffer, "Find-grep (directory): /tmp/dired-demo/" [15:19] You can simply hit enter, and it will again prompt with the message "Find-grop (grep regexp):", and you can input 'link' [15:20] All the files that have 'link' in them will show up in the *Find* buffer [15:21] ! [15:21] You can also customize the find output, if you like, using: [15:21] => M-x find-dired [15:21] next [15:21] What are the differences between c and Z ? [15:21] jeet__, which context? [15:22] To Compress a file [15:22] jeet__, 'Z' is used to compress or uncompress a file [15:22] When I pressed small c accidentally it showed me Compress to: /.. [15:23] jeet__, from the help, c runs the command dired-do-compress-to - compress selected files and directories to an archive. Prompt for the archive file name. [15:24] jeet__, I have already taught you "C-h k" [15:24] jeet__, Z runs the command dired-do-compress [15:24] You can get the dired help using: [15:24] => h [15:24] Thanks mbuf [15:24] You can also get a short dired summary (in the minibuffer) using: [15:25] => ? [15:25] These are basic Dired mode commands that you can use on files and directories inside GNU Emacs [15:25] Any questions? [15:26] Roll call [15:26] Shiva Saxena [15:26] Amitrajit Bose [15:26] Priyanka Saggu [15:26] Bhavin Gandhi [15:26] Anu Kumari Gupta ----END CLASS----