omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Show hidden files

    Pythonista
    4
    16
    4484
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • JonB
      JonB last edited by

      As an example:

      editor.open_file('~/.ssh/authorized_keys', new_tab=True)
      
      1 Reply Last reply Reply Quote 0
      • cvp
        cvp @gee4vee last edited by cvp

        @gee4vee please, try this quick and dirty, select a file, it will be edited

        import ui
        import editor
        import os
        
        class MyTableViewDelegate (object):
        	def tableview_did_select(tableview, section, row):
        		# Called when a row was selected.
        			editor.open_file(tableview.data_source.items[row], new_tab=True)
        			tableview.close()
        tv = ui.TableView()
        path = './'
        files = []
        for file in os.listdir(path):
        	if not os.path.isdir(path + file):
        		files.append(file)
        files.sort()
        tv.data_source = ui.ListDataSource(items=files)
        
        tv.delegate = MyTableViewDelegate
        tv.present()
        

        1 Reply Last reply Reply Quote 0
        • cvp
          cvp last edited by

          @JonB sorry, we crossed our posts

          1 Reply Last reply Reply Quote 0
          • cvp
            cvp @gee4vee last edited by

            @gee4vee in my little script, you could really delete the file (without confirmation) by swiping left, if you add these lines before tv.present()

            def Mytableview_delete(tableview, section, row):
            	# Called when the user confirms deletion of the given row.
            	os.remove(tableview.data_source.items[row])
            	del tableview.data_source.items[row]
            tv.data_source.tableview_delete = Mytableview_delete
            

            1 Reply Last reply Reply Quote 0
            • brumm
              brumm last edited by

              PhoneManager

              cvp 1 Reply Last reply Reply Quote 1
              • cvp
                cvp @brumm last edited by cvp

                @brumm did you already try filenav of @dgelessus ?
                No, you should

                1 Reply Last reply Reply Quote 0
                • gee4vee
                  gee4vee last edited by gee4vee

                  Hmm I guess I’m not using Pythonista the way you guys are. I’m just using it as a code editor. How can I make Pythonista use that code you’re providing in its UI? You mean I can alter its code at runtime?

                  cvp 1 Reply Last reply Reply Quote 0
                  • cvp
                    cvp @gee4vee last edited by

                    @gee4vee said:

                    I need to edit these pretty regularly and they cannot be renamed.

                    I don't understand why and how hou have these hidden files in Pythonista.
                    Please explain and perhaps we could help you

                    1 Reply Last reply Reply Quote 0
                    • gee4vee
                      gee4vee last edited by

                      I am loading an external folder that was created with Working Copy. The source code repository has files that begin with a dot and those are pretty common for many kinds of source code repositories.

                      1 Reply Last reply Reply Quote 0
                      • JonB
                        JonB last edited by JonB

                        If you create a script, then tap the little wrench icon, you can add new shortcuts to the wrench menu. That let's you keep useful scripts, such as the filenav, available at all times. Of course you can also just open a script, and press "play" -- pythonista is more than just an editor, it is a full featured python interpreter.

                        You can also run code from the console (swipe left from editor), for instance my one liner (actually two lines, since you would need to import editor first). The console won't let you paste multiple lines, so that is less useful for copying code from the forum.

                        Many people find stash to be very useful.
                        https://github.com/ywangd/stash
                        See the install section for a one liner that you can paste to the console and run.

                        Then, when you run stash, you get a bash-like shell, which does allow you to use edit to launch the editor with any file you can find. Stash also has many useful commands that you might expect in a shell, you can mv files, use wget to download, it has some tar, zip, ssh, ftp, git support (albeit limited), also iirc some smb support.

                        gee4vee 1 Reply Last reply Reply Quote 0
                        • gee4vee
                          gee4vee @JonB last edited by

                          @JonB thanks so much! Will try stash. I understand now.

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post
                          Powered by NodeBB Forums | Contributors