How to open a terminal file in TextEdit

5,857

Since you're on Ubuntu, there is no textedit command or application out of the box.

From your question:

  1. open -e settings.py On osx, this would execute the python file instead of opening it in your default text editor. Use open -t settings.py to open the python file with the default text editor.

  2. open -a TextEdit This doesn't work op Ubuntu because TextEdit simply doesn't exist (works on mac). For your purpose, try gedit settings.py

  3. xdg-open settings.py On Ubuntu, try xdg-open. This is the equivalent of Macs' open command which opens any file with the associated default application for the file type. I'm not sure what application would launch if you try to open a python file though.

Share:
5,857

Related videos on Youtube

Zorgan
Author by

Zorgan

Updated on September 18, 2022

Comments

  • Zorgan
    Zorgan over 1 year

    I use nano <file_name> to open/edit files on terminal. However it's very hard to edit so is there a way to open terminal files in TextEdit?

    EDIT:

    open -a TextEdit <my_file_name> and open -a TextEdit both return this:

    open: invalid option -- 'a'
    Usage: open [OPTIONS] -- command
    
    This utility help you to start a program on a new virtual terminal (VT).
    
    Options:
      -c, --console=NUM   use the given VT number;
      -e, --exec          execute the command, without forking;
      -f, --force         force opening a VT without checking;
      -l, --login         make the command a login shell;
      -u, --user          figure out the owner of the current VT;
      -s, --switch        switch to the new VT;
      -w, --wait          wait for command to complete;
      -v, --verbose       print a message for each action;
      -V, --version       print program version and exit;
      -h, --help          output a brief help message.
    

    open -e <my_file_name> returns:

    Couldn't get a file descriptor referring to the console
    
    • Tamerz
      Tamerz over 6 years
      open -a TextEdit filename Taken from: apple.stackexchange.com/questions/25844/…
    • Zorgan
      Zorgan over 6 years
      Both not working for me (shown in my edit). Any idea why?
    • Tamerz
      Tamerz over 6 years
      It looks like you have something called openvt installed that perhaps is linked as open? What happens if you run which open? By default on OSX it should point to /usr/bin/open. What happens if you try /usr/bin/open -a TextEdit filename?
    • Zorgan
      Zorgan over 6 years
      My server is set like this: /home/user/project_name/env/bin so I did /james/postr/env/bin/open -a TextEdit settings.py which returned -bash: /james/postr/env/bin/open: No such file or directory. There is no open file in my bin directory.
    • Zorgan
      Zorgan over 6 years
      I tried the alternate method in the link you posted - I added alias textedit='open -a TextEdit' to my .profile. After that I tested it with textedit settings.py and it returned The program 'textedit' is currently not installed. You can install it by typing: sudo apt install xview-clients. So I installed it - but after I tried textedit settings.py again, it returned XView error: Cannot open connection to window server: :0 (Server package). Any idea?
    • Tamerz
      Tamerz over 6 years
      I'm confused, what are you using? You have this tagged as osx but it is telling you about apt install which sounds like some type of Debian/Ubuntu OS.
    • Zorgan
      Zorgan over 6 years
      Sorry I forgot to mention this is on Ubuntu 16.04 on my remote Digital Ocean server. The method you told me works on offline on my Mac OSX.
    • dan
      dan over 3 years
      Please fix your tags so as to avoid wasting your time and the time of colleagues who try to help.