Hot answers tagged

31

dialog --backtitle "Package configuration" \ --title "Configuration sun-java-jre" \ --yesno "\nBla bla bla...\n\nDo you accept?" 10 30 The user response is stored in the exit code, so can be printed as usual: echo $? (note that 0 means "yes", and 1 is "no" in the shell world). Concerning other question from the comments: to put output ...


25

The screenshot in the question looks like whiptail (a functionally-reduced program imitating dialog, using newt rather than ncurses). The way the title and buttons are rendered is built into each program, making them look different. Here is a script which duplicates the original screenshot, for either whiptail or dialog: #!/bin/sh : ${DIALOG:=dialog} case ...


20

Most such programs only output colour codes to a terminal by default; they check to see if their output is a TTY, using isatty(3). There are usually options to override this behaviour: disable colours in all cases, or enable colours in all cases. For GNU grep for example, --color=never disables colours and --color=always enables them. In a shell you can ...


14

As Julie said, you can use df to display free space, passing it either the mount point or the device name: df --human-readable /home df --human-readable /dev/sda1 You'll get something like this: Filesystem Size Used Avail Use% Mounted on /dev/sda1 833G 84G 749G 10% /home To run it continuously, use watch. Default update interval is 2 seconds, but ...


13

Make yourself some symbolic links in your home directory: ln -s /opt/really/long/obnoxiously/long/path/to/some/projectname This command will make a link called projectname in your home directory into which you can cd, and everything will work perfectly.


13

z is a very nice "plugin" for bash or zsh (it's included in Oh My Zsh) which keeps track of directories you cd to, and allows you to quickly switch to directories using parts of their names, based on how frequently you use them. So after a little while, it will know that z git-repo should cd to the git-repo directory you use most often. You can qualify ...


11

Is there some environment variable? Yes. It is the TERM environment variable. This is because there are several things that are used as part of the decision process. It's difficult to generalize here, because not all programs agree on a single decision flowchart. In fact GNU grep, mentioned in M. Kitt's answer, is a good example of an outlier that ...


10

I believe the package you are looking for is ncurses. Wikipedia describes ncurses as follows: ncurses (new curses) is a programming library providing an API that allows the programmer to write text-based user interfaces in a terminal-independent manner. It is a toolkit for developing "GUI-like" application software that runs under a terminal ...


9

Once inside the directory, you do: repo=`pwd` and later you do cd $repo If you want to keep it for next time, you could do: echo "export repo=`pwd`" >> ~/.profile


8

bash's CDPATH shell variable might be a convenient solution for you. A command such as cd foo searches for the subdirectory called foo inside the directories listed in CDPATH.


6

Just to mention another useful tool, there is the pushd builtin. With $ pushd dirname the current directory will be pushed on the directory stack (you can look at that stack with dirs) and the current directory will be changed to dirname. You can later change back to the latest (top-most in the stack) directory using the popd builtin command. This should ...


5

You could use a program such as rlwrap (readline wrapper) for this: rlwrap at now Further reading: hanslub42/rlwrap (github) * HOW TO USE IT: If $ <command> <args> doesn't let you use arrow keys to edit input, or if you just want decent input history and completion, try: $ rlwrap [-options] <command> <args>


5

That eol setting is not for the key that would take you to the end of some line-editing buffer, that's a setting of the tty line discipline. It is for its very basic line editor, the one used when entering input for applications (like cat, sed) that don't have their own line editor. That editor doesn't have cursor positioning, the only editing it can do is ...


4

Instead of >(cmd), assuming it's cmd's stdin you wish be a tty instead of a pipe, you could try and use: >(socat -u - exec:'cmd',pty) socat would use a pseudo-tty pair and have cmd's stdin connected to the slave part ([ -t 0 ] would then return true). The pseudo-terminal will be put in raw mode, so the line discipline should not interfere with the ...


4

This is how I would do it; create an alias in ~/.bashrc (if using Bash): alias thatgitrepo='cd /opt/a/b/c/d/e/f/g/git-repo' And use source .bashrc to have the alias for the current shell.


4

AIX has a /proc filesystem (since about 5.1?) and you can list the open file descriptors for a pid with procfiles: $ procfiles -n 15502 15502 : /home/guest/test Current rlimit: 2000 file descriptors 0: S_IFCHR mode:0622 dev:10,4 ino:2584 uid:100 gid:100 rdev:28,1 O_RDONLY 1: S_IFCHR mode:0622 dev:10,4 ino:2584 ...


4

When you press Ctrl-V, the shell will start by ignoring keyboard interrupts and simply take the pressed key combination as the input character. This is easily possible as ASCII is designed to hold all control characters. Of course, on display it has to cheat a bit and show the ^ followed by the corresponding key or otherwise it would output control ...


4

An application running in a terminal has no way to find out from the terminal what the glyphs that the terminal has drawn look like (or even if they are substitute/placeholder characters). One thing the application can do is find out if the terminal supports UTF-8 at all, and if it does, if it supports variable width characters. The method is as follows: ...


3

If you don't like the idea of dedicating a whole terminal to watching the output of df, you could consider a tool such as conky. There are countless examples of using conky to monitor everything from HDD usage, HDD temp, ram usage, local weather, news headlines... you name it.


3

You're probably thinking of the alternate screen feature, which allows full-screen applications such as htop to display in a different view, and on completion returning to the normal view (without the application showing). That is the altscreen setting in your .screenrc, described in the manual: Command: altscreen state If set to on, "alternate ...


3

If the output is very long you could use the less command like below: your_command_here | less And then scroll all the way down by pressing keys like Enter, Space etc. For more see the less manpage. You could even use more you_command_here | more more works like less but uses different key combinations to page through the text. For more see the more ...


3

Use emacs, start an inferior shell and issue your command. The output will be available in the shell buffer and can be selected using the usual commands. Alternatively, select file in $(find <whatever>); do vi $file; break; done The emacs approach is more practical if you already know the editor. Emacs can run arbitrary "inferior processes", ie. ...


2

df is a simple command line utility that shows you disk usage, including free space. Check man df for details.


2

You can also use ps ax | grep sshd


2

You can use screen multiplexer such tmux. It is available via apt-get on ubuntu machines


2

It sounds as if you are using the Linux console (rather than one of the X-based terminal emulators), and that it is not running in UTF-8 mode. I would use this script to turn it on (and investigate to see why it is off): #!/bin/sh # send character-string to enable UTF-8 mode if test ".$1" = ".off" ; then printf '\033%%@' else printf ...


2

The test command runs isatty(fd) to check whether a descriptor is related to a TTY. isatty(3) is a C library function that checks whether a file descriptor allows to send terminal ioctl(2) calls to the descriptor. You therefore cannot fake the result unless you use LD_PRELOAD= to overwrite the isatty() function in the shell.


2

Based on the clarification, I'm quite certain you use the words user and process incorrectly. It looks to me that you believe something is either a user, or a process (exactly one of them). This is absolutely not the case. Every running instance of an executable program code (no matter if it's started "automatically" (e.g. as part of the boot process) or ...


2

Open the terminal and type the following commands: sudo apt-get update sudo apt-get install mpb


2

The behavior of C-m, C-i, etc. is implemented by bash, but the fact that they're the same thing as Return, Tab, etc. is due to the behavior of the terminal. All terminals behave like this because all terminals have always behaved like this and it's what applications expect. The interface between a terminal and an application is based on characters (in fact, ...



Only top voted, non community-wiki answers of a minimum length are eligible