xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
Commit c5023e7dae97c29a394b0f119d9b185af1fb5973

Added C command (clone file).
Author: xaizek
Author date (UTC): 2011-05-26 17:21
Committer name: xaizek
Committer date (UTC): 2011-05-26 17:21
Parent(s): de020c3bfc09ec1dd3fc34dd5e70904eb3a41b72
Signing key:
Tree: 0e92071635ef8fa343e2bb1670a0d495af94eb09
File Lines added Lines deleted
ChangeLog 2 0
src/fileops.c 29 12
src/fileops.h 1 0
src/normal.c 11 0
src/vifm-help.txt 1 0
src/vifm.1 4 1
src/vifm.txt 1 0
File ChangeLog changed (mode: 100644) (index 44e20bc98..310a265da)
70 70 Added detection of file handlers with GTK+ or libmagic and .desktop files Added detection of file handlers with GTK+ or libmagic and .desktop files
71 71 (it works only for :file command). (it works only for :file command).
72 72
73 Added C command (clone file).
74
73 75 Changed keys input handling. Changed keys input handling.
74 76
75 77 Changed force dot files appear at the beginning of file list. Changed force dot files appear at the beginning of file list.
File src/fileops.c changed (mode: 100644) (index d002142ce..76b3d95e1)
... ... yank_selected_files(FileView *view, int reg)
178 178
179 179 for(x = 0; x < view->selected_files; x++) for(x = 0; x < view->selected_files; x++)
180 180 { {
181 if(view->selected_filelist[x])
182 {
183 char buf[PATH_MAX];
184 namelen = strlen(view->selected_filelist[x]);
185 snprintf(buf, sizeof(buf), "%s/%s", view->curr_dir,
186 view->selected_filelist[x]);
187 append_to_register(reg, buf);
188 }
189 else
190 {
191 x--;
181 if(!view->selected_filelist[x])
192 182 break; break;
193 }
183
184 char buf[PATH_MAX];
185 namelen = strlen(view->selected_filelist[x]);
186 snprintf(buf, sizeof(buf), "%s/%s", view->curr_dir,
187 view->selected_filelist[x]);
188 append_to_register(reg, buf);
194 189 } }
195 190 } }
196 191
 
... ... put_files_from_register(FileView *view, int name, int force_move)
957 952 return 1; return 1;
958 953 } }
959 954
955 void
956 clone_file(FileView* view)
957 {
958 char buf[PATH_MAX + NAME_MAX*2 + 4];
959 char *escaped;
960 const char *filename;
961
962 filename = get_current_file_name(view);
963 if(strcmp(filename, ".") == 0)
964 return;
965 if(strcmp(filename, "..") == 0)
966 return;
967
968 if(view->dir_entry[view->list_pos].type == DIRECTORY)
969 escaped = escape_filename(filename, strlen(filename) - 1, 1);
970 else
971 escaped = escape_filename(filename, strlen(filename), 1);
972 snprintf(buf, sizeof(buf), "cp -pR %s %s_clone", escaped, escaped);
973 background_and_wait_for_errors(buf);
974 free(escaped);
975 }
976
960 977 /* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab : */ /* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab : */
File src/fileops.h changed (mode: 100644) (index 476a67543..a31cc0229)
... ... void change_owner(FileView *view);
54 54 void change_group(FileView *view); void change_group(FileView *view);
55 55 /* Returns new value for save_msg flag. */ /* Returns new value for save_msg flag. */
56 56 int put_files_from_register(FileView *view, int name, int force_move); int put_files_from_register(FileView *view, int name, int force_move);
57 void clone_file(FileView* view);
57 58
58 59 #endif #endif
59 60
File src/normal.c changed (mode: 100644) (index b600f9d15..ac90ab75e)
... ... static void cmd_colon(struct key_info, struct keys_info *);
76 76 static void cmd_semicolon(struct key_info, struct keys_info *); static void cmd_semicolon(struct key_info, struct keys_info *);
77 77 static void cmd_slash(struct key_info, struct keys_info *); static void cmd_slash(struct key_info, struct keys_info *);
78 78 static void cmd_question(struct key_info, struct keys_info *); static void cmd_question(struct key_info, struct keys_info *);
79 static void cmd_C(struct key_info, struct keys_info *);
79 80 static void cmd_F(struct key_info, struct keys_info *); static void cmd_F(struct key_info, struct keys_info *);
80 81 static void find_F(int ch); static void find_F(int ch);
81 82 static void cmd_G(struct key_info, struct keys_info *); static void cmd_G(struct key_info, struct keys_info *);
 
... ... init_normal_mode(int *key_mode)
251 252 curr = add_cmd(L"?", NORMAL_MODE); curr = add_cmd(L"?", NORMAL_MODE);
252 253 curr->data.handler = cmd_question; curr->data.handler = cmd_question;
253 254
255 curr = add_cmd(L"C", NORMAL_MODE);
256 curr->data.handler = cmd_C;
257
254 258 curr = add_cmd(L"F", NORMAL_MODE); curr = add_cmd(L"F", NORMAL_MODE);
255 259 curr->type = BUILDIN_WAIT_POINT; curr->type = BUILDIN_WAIT_POINT;
256 260 curr->data.handler = cmd_F; curr->data.handler = cmd_F;
 
... ... selector_S(struct key_info key_info, struct keys_info *keys_info)
666 670 keys_info->count = i; keys_info->count = i;
667 671 } }
668 672
673 /* Clone file. */
674 static void
675 cmd_C(struct key_info key_info, struct keys_info *keys_info)
676 {
677 clone_file(curr_view);
678 }
679
669 680 static void static void
670 681 cmd_F(struct key_info key_info, struct keys_info *keys_info) cmd_F(struct key_info key_info, struct keys_info *keys_info)
671 682 { {
File src/vifm-help.txt changed (mode: 100644) (index c5c6b22dc..10fdeae76)
... ... The basic vi key bindings are used to move through the files and popup
21 21 cp change file permissions. cp change file permissions.
22 22 cw change word is used to rename a file. cw change word is used to rename a file.
23 23 cW change WORD is used to change only name of file (without extension). cW change WORD is used to change only name of file (without extension).
24 C clone file.
24 25 m [a-z][A-Z][0-9] to set bookmark m [a-z][A-Z][0-9] to set bookmark
25 26 ' letter to goto bookmark ' letter to goto bookmark
26 27 v start or stop visualy selecting files. This works with the j and k keys v start or stop visualy selecting files. This works with the j and k keys
File src/vifm.1 changed (mode: 100644) (index 15e806dd2..9683620b3)
... ... change file group.
169 169 .BI cp .BI cp
170 170 change file permissions. change file permissions.
171 171 .TP .TP
172 .BI C
173 clone file.
174 .TP
172 175 .BI "[count]d[selector] or [count]dd in compatibility mode" .BI "[count]d[selector] or [count]dd in compatibility mode"
173 176 moves the selected files to the trash directory. moves the selected files to the trash directory.
174 177 .TP .TP
 
... ... sets a new user command.
219 222 will remove the command_name user command will remove the command_name user command
220 223 .TP .TP
221 224 .BI ":file [mime]" .BI ":file [mime]"
222 popup menu of programs set for the file type of the current file. When argument passed, show programs set based on file mimetype.
225 popup menu of programs set for the file type of the current file. When argument passed, show programs set based on file mimetype. Add ' &' at the end of command to run program in background.
223 226 .TP .TP
224 227 .BI ":fil regular_expression pattern" .BI ":fil regular_expression pattern"
225 228 will filter all the files out of the directory listing that match the regular expression. will filter all the files out of the directory listing that match the regular expression.
File src/vifm.txt changed (mode: 100644) (index a0e4dcf96..fe0f31c89)
... ... co - change owner of file.
171 171 cp - change file permissions. cp - change file permissions.
172 172 cw - change word is used to rename a file. cw - change word is used to rename a file.
173 173 cW - change WORD is used to change only name of file (without extension). cW - change WORD is used to change only name of file (without extension).
174 C - clone file.
174 175 dd - move selected file or files to ~/.vifm/Trash (if option USE_TRASH is set dd - move selected file or files to ~/.vifm/Trash (if option USE_TRASH is set
175 176 otherwise delete) otherwise delete)
176 177 d<selector> - like dd. d<selector> - like dd.
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master