Coder Social home page Coder Social logo

math2001 / filemanager Goto Github PK

View Code? Open in Web Editor NEW
107.0 5.0 18.0 2.06 MB

⚡️ A Sublime Text 3 package to help with file (duplicate, move, create...) ⚡️

Home Page: https://math2001.github.io/FileManager

License: MIT License

Python 100.00%
sublime-text sublime-text-3 sidebar speed

filemanager's Introduction

File Manager

File Manager is a plugin for Sublime Text that is suppose to replace SideBarEnhancement and AdvancedNewFile.

Why? Because those to plugin basically do the same thing: They manage files from sublime text.

With this package, you can create, rename, move, duplicate and delete files or folders. You can also copy there relative/absolute path, or their name.

"Spirit"

The idea is to make you save time, not to propose you features you're never going to use.

This package has as main goal to be 100% optimized.

So, for example, there is an auto completion system (based on the folders/files, both, you choose) on every input that is showed by FileManager. Just press tab to cycle through the auto completion.

There shouldn't be 2 commands when 1 can do the job.

FileManager doesn't have a command create_new_file and create_new_folder. Just fm_create. It opens up an input, and the last character you type in is a / (or a \), it creates a folder instead of a file.

Docs

Although they're a fair bit of information in there, the docs are still a work in progress. Here they are: math2001.github.io/FileManager. Go have a quick look, you won't regret it 😄

Installation

Using package control

  1. Open up the command palette: ctrl+shift+p
  2. Search for Package Control: Install Package
  3. Search for FileManager
  4. Hit enter 😉

Using the command line

If you want to contribute to this package, first thanks, and second, you should download this using git so that you can propose your changes.

cd "%APPDATA%\Sublime Text 3\Packages"             # on Windows
cd ~/Library/Application\ Support/Sublime\ Text\ 3 # on Mac
cd ~/.config/sublime-text-3                        # on Linux

git clone "https://github.com/math2001/FileManager"

How to open the README

To open their README, some of the package add a command in the menus, others in the command palette, or other nowhere. None of those options are really good, especially the last one on ST3 because the packages are compressed. But, fortunately, there is plugin that exists and will solve this problem for us (and he has a really cute name, don't you think?): ReadmePlease. 🎉

Contributing

You want to contribute? Great! There's two different things you can contribute to:

  1. the package itself
  2. the docs

If you want to contribute to the package, then you're at the right place. Otherwise, please go have a look at the contributing part of the docs

First, whatever you want to do, please raise an issue. Then, if you feel in a hacky mood, go ahead and code it:

  • create a branch: my-feature-name
  • don't hesitate to change stuff in the .tasks file.
  • Push and PR

Note: This plugin is only working on Sublime Text 3.

filemanager's People

Contributors

akhiljalagam avatar ameistad avatar deathaxe avatar dependabot[bot] avatar jfcherng avatar kud avatar math2001 avatar terminalfi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

filemanager's Issues

"New file relative to current view" command

It would be nice to have a "New file relative to current view" command or change the "New File" command to operate relative to the current view (if triggered from command palette). I usually want new files to be in the same directory as the file I am currently working on so I would like to have that option.

[Bug] New file open in top sidebar folder

1. Summary

I can to create file via File Manager in top folder of my sidebar, but not in current folder. Some features into GIFs don't work for me.

2. Settings

My sidebar:

Sidebar

  • Киролайна — top folder of my sidebar,
  • KristinitaLuckyLink/KristinitaLuckyLink.py — opened file.

3. Steps to reproduce

I reproduce the problem in a version of Sublime Text without plugins and user settings.

I install File Manager → I restart Sublime Text → I open file KristinitaLuckyLink.pyCtrl+Shift+PFile Manager: New File.

4. Expected behavior

Create file in current folder.

5. Actual behavior

See image in 2 section. I create file in top folder, not current.

6. Environment

Operating system and version:
Windows 10 Enterprise LTSB 64-bit EN
Sublime Text:
Build 3126

Thanks.

Auto close empty file not work?

@math2001 I set auto_close_empty_groups=true, but it doesn't work like SideBarEnhancements (I try on ubuntu with subl3). Besides, is there any possibility to add cut/paste to the menu?

stopped working for me

hi

love the package and have used it for ages but suddenly it has stopped working - the context menu no longer appears

i uninstalled and reinstalled with no errors - did not touch the package settings - nothing works

i am running debian + gnome ST3 latest

thanks

Allow user to remap key commands

Since your commit 3e76d1c, you remap the fm_create command to alt+n shortcut.

However on macOS this shortcut is triggered to write tilde char ~, which is heavily used on dev purpose. As workaround, I edited my macOS keymap Default (OSX).sublime-keymap to "revert" your change like this:

{ "keys": ["alt+n"], "command": "insert", "args": {"characters": "~"} },
{ "keys": ["ctrl+n"], "command": "fm_create" },

It would be nice if you could give us the possibility to choose our own keymap depending on the OSes for this command as does the package PlainTasks for example.

Thanks anyway for this useful package!

Command to use browser from current directory...

Hello. Great plugin! I'm trying to add a key binding / command that browses files from the current directory. I have tried this:

{ "keys": ["super+o"], "command": "fm_create", "args": {
    "paths": ["${folder}"],
    "initial_text": "",
    "start_with_browser": true,
    "no_browser_action": true,
} },

and this:

{ "keys": ["super+o"], "command": "fm_create", "args": {
    "paths": ["."],
    "initial_text": "",
    "start_with_browser": true,
    "no_browser_action": true,
} },

to no avail. How would I do this?

Copy and paste file / directory [feature request]

Hi first let me thank you for the great work there.

I switched to your package after the SidebarEnhancements fiasco and I really appreciate the lean and clean nature of this one. 👍

There is one feature that I miss however and it’s the ability to copy and paste a file or directory directly from Sublime Text: not just the name or paths but the file itself. Let’s say I have two projects open in ST and I want to quickly copy some configuration file I’ve been using in one of the project for the other: currently I need to open the file, copy its content, create the new file in the other project, paste the content… It’s tedious and there’s no good way to do this with directories apart from relying on the OS file manager.

I think it would be great to have this implemented in FM if it does not bloat it too much. 😀

Create file from shortcut (Alt+N) doesn't create file from current opened file's containing folder

Platform:
macOS

Action:
Create new file via shortcut (Alt+N) while there is a file open in the view

Expected behaviour:
New file should be created from the opened file's container folder

Actual behaviour:
New file is default to create from project root


I have a bit of a dive into the code, and if I commented out this block of code in FMcommands/create.py:

...
elif self.folders:
     # it is going to be interactive, so it'll be
     # understood from the input itself
    create_from = None
...

then creating new file feature works as expected.

FileManager shouldn't create so many commands

Currently, FileManager pollutes the public namespace with all these fm_ prefixed commands (fm_create, fm_rename, etc). I doubt it affects anyone whatsoever, but it's definitely not ideal, especially as there is a better solution (which I first saw in Emmet).

The solution is to have one entry-point command, maybe called file_manager, which takes an argument, say command, specifying which "command" it should run (and command would be a simple function). So, for example, instead of having:

{
    "caption": "File Manager: Open Terminal",
    "command": "fm_open_terminal" // badd!! namespace pollution
},
{
    "caption": "File Manager: Copy Absolute Path",
    "command": "fm_copy", // badd!! namespace pollution
    "args": {
        "which": "absolute path"
    }
}

We would have:

{
    "caption": "File Manager: Open Terminal",
    "command": "file_manager",
    "args": {
        "command": "open_terminal",
    }
},
{
    "caption": "File Manager: Copy Absolute Path",
    "command": "file_manager",
    "args": {
        "command": "copy",
        "which": "absolute path"
    }
}

Hence, FileManager would only expose 1 command 🙂 So much cleaner!

The command file_manager would pass on all the extra arguments to the sub-command.

This will need a bit of restructuring for each sub-command (currently a full-blown command), but since everything is already neatly organized, it shouldn't be too hard.

Create multiple files like in shell

When creating files, it could be great to do something like:

/path/index.{js,css,html}

to create:

  • /path/index.js
  • /path/index.css
  • /path/index.html

fm_create_file_from_selection AttributeError

File "FMcommands.create_from_selection in /home/username/.config/sublime-text-3/Installed Packages/FileManager.sublime-package", line 34, in run
File "pathhelper in /home/username/.config/sublime-text-3/Installed Packages/FileManager.sublime-package", line 14, in computer_friendly
AttributeError: 'NoneType' object has no attribute 'path'

Also get this on right click on selection

File "FMcommands.appcommand in /home/username/.config/sublime-text-3/Installed Packages/FileManager.sublime-package", line 9, in is_visible
File "sublimefunctions in /home/username/.config/sublime-text-3/Installed Packages/FileManager.sublime-package", line 24, in get_settings
AttributeError: 'NoneType' object has no attribute 'load_settings'

Setting for not opening files on rename

When a file is renamed, it it automatically opened. In most cases I don't want to see or edit the contents of the file at that moment. However, to allow for that behavior I would suggest to add a setting to prevent it.

Moving multiple files deletes without warning

When multiple files are selected, the move command deletes all files after text input for the path. However, this only happens on my Linux machine. On Windows the behavior is as expected.

[macos?] bug when creating a folder and move a file just after

Hard to explain but.

When you create a folder, and just after try to move a file, the base path isn't correct and will move files INTO sublimetext.app folder.

2019-02-26 18-34-57 2019-02-26 18_40_21

A workaround is to create the folder, click on another file, click on the file you want to move, and choose "move".

folder selection is not working

First thanks a lot for creating this awesome extension.
Hope you are fine in this time of pandemic.
I am facing problem with selecting folder with folder_no> this is not selecting any folder rather creating file at the project root.
my system is archlabs linux. i am using ST version 3.2.2 build 3211.
here are some images depicting the issue.
ArchLabs_2020-04-17-10_1366x768
ArchLabs_2020-04-17-13_1366x768
ArchLabs_2020-04-17-28_1366x768
ArchLabs_2020-04-17-34_1366x768

I hope you will have the time to help me.
thanks in advance.

fm_create_file_from_selection OSError: [Errno 36] File name too long

ezgif com-video-to-gif 1

it show all selection in context menu and when I click on it it gives me an error

Traceback (most recent call last):
  File "/home/username/Desktop/sublime_text_3/sublime_plugin.py", line 780, in run_
    return self.run(**args)
  File "FMcommands.create in /home/username/.config/sublime-text-3/Installed Packages/FileManager.sublime-package", line 18, in run
OSError: [Errno 36] File name too long: ' : [];\n        File.progress = File.progress || 0;\n        this.progress = 0;\n        this.object = object;\n        this.url = url;\n .....

looks like it try to set filename all selection
when selection is short it open new blank file saved on disk (name of file the text I select)

Copy the current file's path keybinding [feature request]

Hi!

First of all, thank you for this awesome plugin!

I often want to copy the current file's (relative) path to the clipboard, which works like a charm using left click -> copy -> relative path on the file tree. However, I intend to minimize the usage of a mouse in my workflow, so I think a keybinding would be of great use for copying the relative / absolute path of the currently opened file.

As I looked over the docs, I couldn't find a way of binding this action to a keyboard shortcut. For now, I use this plugin to achieve this, but is is possible to add this feature to FileManager?

Cannot move files to different directories

I'm trying to move a file from the C drive on the desktop to another path.

It's not working.

Moving to the same drive works okay.

The current file is:
C:\Users\username\Desktop\powershell.ps1

To this path:
W:\Apps (Portable)\FreeCommanderXE\FavouriteToolbarTools\powershell.ps1

conflict of hotkey "alt+n"

Hi math2001,
I am so excited about this plugin. I am crazy about file management a lot.
I want to use the short cut "alt+n" to create a file anywhere in my project folder, but I find "alt+n" will trigger "Preferences" in the menu bar ("alt" will trigger the menu bar, and "preferences" is triggered by n"), resulting this:
image
Is there a solution of this?
Thanks.

Plugin stopped working

Menuitems became missing from context menu. Right-clicking on a file or a folder makes many console errors like:

Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 949, in is_visible_
ret = self.is_visible(**args)
File "/Users/xxxx/Library/Application Support/Sublime Text 3/Installed Packages/FileManager.sublime-package/FMcommands/appcommand.py", line 9, in is_visible
File "/Users/xxxx/Library/Application Support/Sublime Text 3/Installed Packages/FileManager.sublime-package/sublimefunctions.py", line 24, in get_settings
AttributeError: 'NoneType' object has no attribute 'load_settings'

Or the AttributeError sometimes is:

AttributeError: 'NoneType' object has no attribute 'active_window'

OS: MacOS Mojave 10.14.4
Sublime version: 3.2.1 Build 3207

Update for delete confirm dialog

Hi,

So there are two reasons for this update:
1- When you select many files for delete, it is hard to click on the cancel option by mouse.
2- It is better to use a dialog instead of panel so it will follow Sublime principles.

ToDo:
1- If there were more than for example 3 files selected, we will only show the number of selected files, and no file path will be shown.
2- We will use ok_cancel_dialog instead of show_quick_panel here.

P.S. I can send a PR for this.

Screencast from 2019-07-27 03 09 05

Copy relative path function outputs a string starting with "/"

Hi, I'm a very happy user of Filemanager plugin.

I have a relatively frequent use of the "copy relative path" function, but I could not find in the code/doc the reason why the string starts with a "/", making the relative intention to an absolute path.

Is it intentional? Then why? And could it be setup through a parameter?

Thanks a lot anyway for you work.

How to accept an intermediate path completion?

Firstly, many thanks for this project. Hits the sweet spot. Nice work!

Say I want to create a new file in a subfolder of a subfolder (say figs) of the first folder in the project (index 0). Hitting tab cycles through candidate folders. When I get to figs how do I stop cycling and accept it ready to tab through the canditates of the next level of folders? The only way I have found is to enter a random letter, then delete that and invoke tab again.

Duplicate chokes on non-ascii files

Love the plugin, but it's failing to duplicate files that contain unicode characters.
For some characters (e.g. ✓) it still duplicates the file but with missing chars.
For some other unicode characters (e.g. ⊎) it crashes with exception:

Traceback (most recent call last):
  File "/Users/bordaigorl/Library/Application Support/Sublime Text 3/Installed Packages/FileManager.sublime-package/libs/input_for_path.py", line 304, in input_on_done
  File "/Users/bordaigorl/Library/Application Support/Sublime Text 3/Installed Packages/FileManager.sublime-package/commands/duplicate.py", line 58, in duplicate
  File "./python3.3/encodings/ascii.py", line 26, in decode
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 8: ordinal not in range(128)

Sounds like a decode was called with default encoding of ascii.
I wonder if it would be better to just use a syscall to copy the file...

[Bug] Sidebar missing entries when file is open

Sublime Text build 4098

File Manager changes the sidebar commands when a file is open

When I try to create a new folder within a folder when a file is open, the 'New..' command ( and others ) is missing.

Video example:

filemanager-bug.mp4

cannot delete file

Thanks for your updating, now creating file works. However, I cannot delete file.

Traceback (most recent call last):
  File "FileManager in /Users/divinites/Library/Application Support/Sublime Text 3/Installed Packages/FileManager.sublime-package", line 476, in delete
  File "FileManager in /Users/divinites/Library/Application Support/Sublime Text 3/Installed Packages/FileManager.sublime-package", line 169, in close_file_poyfill
TypeError: 'NoneType' object is not callable

The Open in Browser doesn't work

Description

I can't open the browser to click the file and select “Open in Browser”.

Steps to Reproduce

  1. You click the file inside editor or in the sidebar
  2. Select “Open in Browser”
  3. Nothing happened and it didn't open the browser.

Versions

  • Sublime Text 3143
  • macOS High Sierra 10.13.1
  • I use the latest versions of Google Chrome Canary, Brave or Firefox Developer Edition as default browsers.

[help wanted] Remove useless things. Make this package intuitive.

I like the aim I had a few years ago: everything should be fast, and as small as possible (compare FileManager's context menu to SideBarEnhancements). But I now think (realize?) I was wrong about one thing: settings. I just put way too many possible settings that no one uses, and it hides the options that are actually useful (which leads me to doing things like #52).

A good plugin isn't configurable: it takes the decision for you, because the author thought about it a lot, and found the perfect solution, so the user doesn't have to. If there is no perfect solution, only then should the author be allowed to add a setting/option to his plugin. Adding a configuration option should feel like a failure.

I really like andreas kling's opinion about software being discoverable. Having a lot of "useless" options just limits users from enjoying spending time looking around in the settings.

The discoverability of an option should be proportional to the distance between the perfect solution and the current solution. (horrible wording here, it's late ok)

For example, the setting index_folder_separator is technically required in case someone has the good idea of putting > in the root folder name. Come on. Who does that? If you do that, you are pretty much asking for trouble. So, the current solution is nearly perfect, because it works for 99.9999% of the cases. Hence, index_folder_separator shouldn't be "advertised" too hard, because it's not going to serve many people.

But making this package "fun" to explore is also something I do NOT want to do. After spending a few years learning and using vim, I realize that using fancy tools can be a bottle neck too. It takes a lot of time to learn and it clusters your finite brain with more information which might not be that useful. In fact, this is why I'm trying to switch back from vim to sublime text. I feel slower coding like a wizard, because I have to think about how to use my wizard skills rather than thinking about the code.

For example: if someone reads the entire FileManager documentation, then they will have wasted several hours, and clustered their brain with a lot knowledge that will probably never be useful to them.

So, I don't want users to spent any time learning how to use this package. That's a bit extreme, but that's what I'm aiming for. A more realistic version: users should "feel" how to use the plugin straight away. The little that will not be intuitive should be discoverable and succinctly documented. If just an example of code block to copy/paste will do, then just use that. Think of code blocks as pictures. They convey so much more information at once, it's crazy. Words are slow. Use as little of them as possible.

An example where this is done well: when a user right clicks a folder/file. You look at every options, and provided you've used a computer before, you know exactly what each option will do. No need for documentation.

An example where this is not done well: more than one user has thought "How can I disable the default keybinding" alt+n. Why would they think that? Because it overrides their AZERTY default key binding (ref #32).

Where would I look? Probably google first, something like sublime text disable plugin keybinding which gives a few useless links, with the interesting one here.

But that's kind of a pain, and hopefully the user would realize that. Instead, and it's not the most obvious thing in the world, the user could look in FileManager's settings. This should be everyone's default behavior. A plugin doesn't do what I want it to do? Look at it's setting, someone's probably already thought of that. (TODO: quote this in the README).

Right now, the poor user would have to scroll pass useless options to the bottom of the file to find the unclear "create_keybinding_enabled" and set that to false. So, it's not discoverable, though the documentation (the comment above) is succinct.

In fact, it is that unclear and hidden that I even forgot about it, and an issue was raised and remained open for a year, whilst the solution which was implemented 2 years prior to the issue being raised was just lingering around (ref #32)

And that's by no mean the raiser's fault. It's the plugin's fault (so by extension mine). It's not well organized, so people don't know where to look. But that can be fixed 🙂 And this is what this issue is all about.

How can you help

If you have a problem, and it takes more than a minute for you to find the solution, then you should definitely let the package know. Please raise an issue, there's definitely something that can be done about it (change the default behavior so you don't have the problem anymore, and if that can't be done, document it succinctly and somewhere where people will look ie. the readme is my best idea right now).

Document tips and tricks

There should be a list of tips and tricks or like popular settings/mappings that people use. It probably should be in the readme.

  • create new file from the current file location (use $here)
  • aliases
  • disable default keymapping

The mkdocs website (on github.io) reference section should be really succinct and to the point.

Tab key inserts tab character in input field

  1. Trigger fm_create
  2. Type name (full name) of existing directory and press tab

Actual:
Tab character is inserted

Expected:
Either nothing happening or better, add slash like when autocompleting partial directory name.

Test tab completion logic

I'm really suprised that I haven't seen any bug with tab completion. I guess not many people know about it.

Regardless, it should be tested properly. It's gonna be a pain because it uses os.listdir though... But just one big test case would already be pretty good

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.