开发时使用控制台的最佳方法是什么?

时间:2021-01-29 00:30:49

For scripting languages, what is the most effective way to utilize a console when developing? Are there ways to be more productive with a console than a "compile and run" only language?

对于脚本语言,在开发时使用控制台的最有效方法是什么?有没有办法通过控制台提高效率而不仅仅是“编译和运行”语言?

Added clarification: I am thinking more along the lines of Ruby, Python, Boo, etc. Languages that are used for full blown apps, but also have a way to run small snippets of code in a console.

补充说明:我正在考虑更多的Ruby,Python,Boo等语言。这些语言用于完整的应用程序,但也有办法在控制台中运行小代码片段。

5 个解决方案

#1


2  

I am thinking more along the lines of Ruby, ...

我正在考虑更多Ruby,......

Well for Ruby the irb interactive prompt is a great tool for "practicing" something simple. Here are the things I'll mention about the irb to give you an idea of effective use:

对于Ruby来说,irb交互式提示是一个很好的“练习”简单工具。以下是我将提到的关于irb的内容,以便您了解有效使用方法:

  • Automation. You are allowed a .irbrc file that will be automatically executed when launching irb. That means you can load your favorite libraries or do whatever you want in full Ruby automatically. To see what I mean check out some of the ones at dotfiles.org.

    自动化。您可以在启动irb时自动执行.irbrc文件。这意味着您可以自动加载您喜欢的库或在完整的Ruby中执行任何操作。看看我的意思,请查看dotfiles.org上的一些内容。

  • Autocompletion. That even makes writing code easier. Can't remember that string method to remove newlines? "".ch<tab> produces chop and chomp. NOTE: you have to enable autocompletion for irb yourself

    自动完成。这甚至使编写代码更容易。不记得删除换行符的字符串方法了吗? “”。ch 产生印章和chomp。注意:您必须自己启用自动完成功能

  • Divide and Conquer. irb makes the small things really easy. If you're writing a function to manipulate strings, the ability to test the code interactively right in the prompt saves a lot of time! For instance you can just open up irb and start running functions on an example string and have working and tested code already ready for your library/program.

    分而治之。 irb使小事变得非常简单。如果您正在编写一个函数来操作字符串,那么在提示符中以交互方式测试代码的能力可以节省大量时间!例如,您可以打开irb并开始在示例字符串上运行函数,并且已经为您的库/程序准备好工作和测试的代码。

  • Learning, Experimenting, and Hacking. Something like this would take a very long time to test in C/C++, even Java. If you tried testing them all at once you might seg-fault and have to start over.

    学习,试验和黑客攻击。像这样的东西需要很长时间才能用C / C ++,甚至Java进行测试。如果您尝试一次性测试它们,则可能会出现故障,必须重新开始。

    Here I'm just learning how the String#[] function works.

    这里我只是学习String#[]函数的工作原理。

    joe[~]$ irb
    >> "12341:asdf"[/\d+/]
    # => "12341"  
    >> "12341:asdf"[/\d*/]
    # => "12341"  
    >> "12341:asdf"[0..5]
    # => "12341:"  
    >> "12341:asdf"[0...5]
    # => "12341"  
    >> "12341:asdf"[0, ':']
    TypeError: can't convert String into Integer
      from (irb):5:in `[]'
      from (irb):5
    >> "12341:asdf"[0, 5]
    # => "12341"  
    
  • Testing and Benchmarking. Now they are nice and easy to perform. Here is someone's idea to emulate the Unix time function for quick benchmarking. Just add it to your .irbrc file and its always there!

    测试和基准测试。现在它们很好并且易于执行。这是某人想要模拟Unix时间函数以进行快速基准测试的想法。只需将其添加到.irbrc文件中,它就在那里!

  • Debugging - I haven't used this much myself but there is always the ability to debug code like this. Or pull out some code and run it in the irb to see what its actually doing.

    调试 - 我自己没有用过这么多,但总有能力调试这样的代码。或者拉出一些代码并在irb中运行它以查看它实际上在做什么。

I'm sure I'm missing some things but I hit on my favorite points. You really have zero limitation in shells so you're limited only by what you can think of doing. I almost always have a few shells running. Bash, Javascript, and Ruby's irb to name a few. I use them for a lot of things!

我确定我错过了一些东西,但我点击了我最喜欢的点。你真的没有贝壳限制所以你只能受到你能想到的限制。我几乎总是跑几个炮弹。 Bash,Javascript和Ruby的irb仅举几例。我用它们做了很多事情!

#2


1  

I think it depends on the console. The usefulness of a CMD console on windows pails in comparison to a Powershell console.

我认为这取决于控制台。与Powershell控制台相比,CMD控制台在Windows窗口上的用处。

#3


1  

You didn't say what OS you're using but on Linux I been using a tabbed window manager (wmii) for a year or so and it has radically changed the way I use applications - consoles or otherwise.

你没有说你正在使用什么操作系统,但在Linux上我使用标签窗口管理器(wmii)已经有一年左右了,它彻底改变了我使用应用程序的方式 - 控制台或其他方式。

I often have four or more consoles and other apps on a virtual desktop and with wmii I don't have to fiddle with resizing windows to line everything up just so. I can trivially rearrange them into vertical columns, stack them up vertically, have them share equal amounts of vertical or horizontal space, and move them between screens.

我经常在虚拟桌面上安装四个或更多控制台和其他应用程序,而且使用wmii我不必调整窗口大小来排列所有内容。我可以简单地将它们重新排列成垂直列,垂直堆叠,让它们共享相等数量的垂直或水平空间,并在屏幕之间移动它们。

Say you open two consoles on your desktop. You'd get this (with apologies for the cronkey artwork):

假设您在桌面上打开两个控制台。你会得到这个(为cronkey作品道歉):

 ----------------
|                |
|       1        |
|                |
 ----------------
 ----------------
|                |
|       2        |
|                |
 ----------------

Now I want them side-by-side. I enter SHIFT-ALT-L in window 2 to move it rightwards and create two columns:

现在我想要他们并排。我在窗口2中输入SHIFT-ALT-L以向右移动并创建两列:

 -------  -------
|       ||       |
|       ||       |
|   1   ||   2   |
|       ||       |
|       ||       |
 -------  -------

Now I could open another console and get

现在我可以打开另一个控制台了

 -------  -------
|       ||   2   |
|       ||       |
|       | -------
|   1   | -------
|       ||   3   |
|       ||       |
 -------  -------

Then I want to temporarily view console 3 full-height, so I hit ALT-s in it and get:

然后我想暂时查看控制台3全高,所以我点击ALT-s并得到:

 -------  -------
|       | -------
|       ||       |
|   1   ||   3   |
|       ||       |
|       ||       |
 -------  -------

Consoles 2 and 3 are stacked up now.

控制台2和3现在堆叠起来。

I could also give windows tags. For example, in console 2 I could say ALT-SHIFT-twww+dev and that console would be visible in the 'www' and 'dev' virtual desktops. (The desktops are created if they don't already exist.) Even better, the console can be in a different visual configuration (e.g., stacked and full-screen) on each of those desktops.

我也可以给windows标签。例如,在控制台2中,我可以说ALT-SHIFT-twww + dev,并且该控制台将在“www”和“dev”虚拟桌面中可见。 (如果桌面尚不存在,则会创建桌面。)更好的是,控制台可以在每个桌面上采用不同的可视配置(例如,堆叠和全屏)。

Anyway, I can't do tabbed window managers justice here. I don't know if it's relevant to your environment but if you get the chance to try this way of working you probably won't look back.

无论如何,我不能在这里做标签窗口管理员的正义。我不知道它是否与您的环境有关,但如果您有机会尝试这种工作方式,您可能不会回头看。

#4


0  

I've added a shortcut to my Control-Shift-C key combination to bring up my Visual Studio 2008 Console. This alone has saved me countless seconds when needing to register a dll or do any other command. I imagine if you leverage this with another command tool and you may have some massive productivity increases.

我已经为我的Control-Shift-C组合键添加了一个快捷方式来启动我的Visual Studio 2008控制台。当需要注册dll或执行任何其他命令时,仅此一项就为我节省了无数秒。我想如果你利用另一个命令工具来利用它,你可能会有一些大规模的生产力提升。

#5


0  

Are you kidding?

你在开玩笑吗?

In my Linux environment, the console is my lifeblood. I'm proficient in bash scripting, so to me a console is very much like sitting in a REPL for Python or Lisp. You can quite literally do anything.

在我的Linux环境中,控制台是我的生命线。我精通bash脚本,所以对我来说一个控制台非常像坐在REPL for Python或Lisp。你可以完全做任何事情。

I actually write tools used by my team in bash, and the console is the perfect place to do that development. I really only need an editor as a backing store for things as I figure them out.

我实际上是在bash中编写我的团队使用的工具,而控制台是进行该开发的最佳位置。我真的只需要一个编辑器作为事物的后盾存储,因为我弄明白了。

#1


2  

I am thinking more along the lines of Ruby, ...

我正在考虑更多Ruby,......

Well for Ruby the irb interactive prompt is a great tool for "practicing" something simple. Here are the things I'll mention about the irb to give you an idea of effective use:

对于Ruby来说,irb交互式提示是一个很好的“练习”简单工具。以下是我将提到的关于irb的内容,以便您了解有效使用方法:

  • Automation. You are allowed a .irbrc file that will be automatically executed when launching irb. That means you can load your favorite libraries or do whatever you want in full Ruby automatically. To see what I mean check out some of the ones at dotfiles.org.

    自动化。您可以在启动irb时自动执行.irbrc文件。这意味着您可以自动加载您喜欢的库或在完整的Ruby中执行任何操作。看看我的意思,请查看dotfiles.org上的一些内容。

  • Autocompletion. That even makes writing code easier. Can't remember that string method to remove newlines? "".ch<tab> produces chop and chomp. NOTE: you have to enable autocompletion for irb yourself

    自动完成。这甚至使编写代码更容易。不记得删除换行符的字符串方法了吗? “”。ch 产生印章和chomp。注意:您必须自己启用自动完成功能

  • Divide and Conquer. irb makes the small things really easy. If you're writing a function to manipulate strings, the ability to test the code interactively right in the prompt saves a lot of time! For instance you can just open up irb and start running functions on an example string and have working and tested code already ready for your library/program.

    分而治之。 irb使小事变得非常简单。如果您正在编写一个函数来操作字符串,那么在提示符中以交互方式测试代码的能力可以节省大量时间!例如,您可以打开irb并开始在示例字符串上运行函数,并且已经为您的库/程序准备好工作和测试的代码。

  • Learning, Experimenting, and Hacking. Something like this would take a very long time to test in C/C++, even Java. If you tried testing them all at once you might seg-fault and have to start over.

    学习,试验和黑客攻击。像这样的东西需要很长时间才能用C / C ++,甚至Java进行测试。如果您尝试一次性测试它们,则可能会出现故障,必须重新开始。

    Here I'm just learning how the String#[] function works.

    这里我只是学习String#[]函数的工作原理。

    joe[~]$ irb
    >> "12341:asdf"[/\d+/]
    # => "12341"  
    >> "12341:asdf"[/\d*/]
    # => "12341"  
    >> "12341:asdf"[0..5]
    # => "12341:"  
    >> "12341:asdf"[0...5]
    # => "12341"  
    >> "12341:asdf"[0, ':']
    TypeError: can't convert String into Integer
      from (irb):5:in `[]'
      from (irb):5
    >> "12341:asdf"[0, 5]
    # => "12341"  
    
  • Testing and Benchmarking. Now they are nice and easy to perform. Here is someone's idea to emulate the Unix time function for quick benchmarking. Just add it to your .irbrc file and its always there!

    测试和基准测试。现在它们很好并且易于执行。这是某人想要模拟Unix时间函数以进行快速基准测试的想法。只需将其添加到.irbrc文件中,它就在那里!

  • Debugging - I haven't used this much myself but there is always the ability to debug code like this. Or pull out some code and run it in the irb to see what its actually doing.

    调试 - 我自己没有用过这么多,但总有能力调试这样的代码。或者拉出一些代码并在irb中运行它以查看它实际上在做什么。

I'm sure I'm missing some things but I hit on my favorite points. You really have zero limitation in shells so you're limited only by what you can think of doing. I almost always have a few shells running. Bash, Javascript, and Ruby's irb to name a few. I use them for a lot of things!

我确定我错过了一些东西,但我点击了我最喜欢的点。你真的没有贝壳限制所以你只能受到你能想到的限制。我几乎总是跑几个炮弹。 Bash,Javascript和Ruby的irb仅举几例。我用它们做了很多事情!

#2


1  

I think it depends on the console. The usefulness of a CMD console on windows pails in comparison to a Powershell console.

我认为这取决于控制台。与Powershell控制台相比,CMD控制台在Windows窗口上的用处。

#3


1  

You didn't say what OS you're using but on Linux I been using a tabbed window manager (wmii) for a year or so and it has radically changed the way I use applications - consoles or otherwise.

你没有说你正在使用什么操作系统,但在Linux上我使用标签窗口管理器(wmii)已经有一年左右了,它彻底改变了我使用应用程序的方式 - 控制台或其他方式。

I often have four or more consoles and other apps on a virtual desktop and with wmii I don't have to fiddle with resizing windows to line everything up just so. I can trivially rearrange them into vertical columns, stack them up vertically, have them share equal amounts of vertical or horizontal space, and move them between screens.

我经常在虚拟桌面上安装四个或更多控制台和其他应用程序,而且使用wmii我不必调整窗口大小来排列所有内容。我可以简单地将它们重新排列成垂直列,垂直堆叠,让它们共享相等数量的垂直或水平空间,并在屏幕之间移动它们。

Say you open two consoles on your desktop. You'd get this (with apologies for the cronkey artwork):

假设您在桌面上打开两个控制台。你会得到这个(为cronkey作品道歉):

 ----------------
|                |
|       1        |
|                |
 ----------------
 ----------------
|                |
|       2        |
|                |
 ----------------

Now I want them side-by-side. I enter SHIFT-ALT-L in window 2 to move it rightwards and create two columns:

现在我想要他们并排。我在窗口2中输入SHIFT-ALT-L以向右移动并创建两列:

 -------  -------
|       ||       |
|       ||       |
|   1   ||   2   |
|       ||       |
|       ||       |
 -------  -------

Now I could open another console and get

现在我可以打开另一个控制台了

 -------  -------
|       ||   2   |
|       ||       |
|       | -------
|   1   | -------
|       ||   3   |
|       ||       |
 -------  -------

Then I want to temporarily view console 3 full-height, so I hit ALT-s in it and get:

然后我想暂时查看控制台3全高,所以我点击ALT-s并得到:

 -------  -------
|       | -------
|       ||       |
|   1   ||   3   |
|       ||       |
|       ||       |
 -------  -------

Consoles 2 and 3 are stacked up now.

控制台2和3现在堆叠起来。

I could also give windows tags. For example, in console 2 I could say ALT-SHIFT-twww+dev and that console would be visible in the 'www' and 'dev' virtual desktops. (The desktops are created if they don't already exist.) Even better, the console can be in a different visual configuration (e.g., stacked and full-screen) on each of those desktops.

我也可以给windows标签。例如,在控制台2中,我可以说ALT-SHIFT-twww + dev,并且该控制台将在“www”和“dev”虚拟桌面中可见。 (如果桌面尚不存在,则会创建桌面。)更好的是,控制台可以在每个桌面上采用不同的可视配置(例如,堆叠和全屏)。

Anyway, I can't do tabbed window managers justice here. I don't know if it's relevant to your environment but if you get the chance to try this way of working you probably won't look back.

无论如何,我不能在这里做标签窗口管理员的正义。我不知道它是否与您的环境有关,但如果您有机会尝试这种工作方式,您可能不会回头看。

#4


0  

I've added a shortcut to my Control-Shift-C key combination to bring up my Visual Studio 2008 Console. This alone has saved me countless seconds when needing to register a dll or do any other command. I imagine if you leverage this with another command tool and you may have some massive productivity increases.

我已经为我的Control-Shift-C组合键添加了一个快捷方式来启动我的Visual Studio 2008控制台。当需要注册dll或执行任何其他命令时,仅此一项就为我节省了无数秒。我想如果你利用另一个命令工具来利用它,你可能会有一些大规模的生产力提升。

#5


0  

Are you kidding?

你在开玩笑吗?

In my Linux environment, the console is my lifeblood. I'm proficient in bash scripting, so to me a console is very much like sitting in a REPL for Python or Lisp. You can quite literally do anything.

在我的Linux环境中,控制台是我的生命线。我精通bash脚本,所以对我来说一个控制台非常像坐在REPL for Python或Lisp。你可以完全做任何事情。

I actually write tools used by my team in bash, and the console is the perfect place to do that development. I really only need an editor as a backing store for things as I figure them out.

我实际上是在bash中编写我的团队使用的工具,而控制台是进行该开发的最佳位置。我真的只需要一个编辑器作为事物的后盾存储,因为我弄明白了。