w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Custom terminal prompt colors results in cycling issue
You need to surround nonprinting characters in your prompt with [] so that bash can accurately count the length of the prompt. It looks like you have the end of (most of) those pairs but not the beginnings - perhaps you thought the e[... sequences had to be closed? They don't. Here's what it should look like: export PS1='[e[0;36m][u] w:[e[0;31m]$(__git_ps1 " (%s)") [e[00m] [e[1;33m]342230200 >[e[0m] '

Categories : Osx

How do you set the 16 Terminal Colors for Git-Bash?
Console colors are stored in the registry under HKCU/Console/[window name]/ColorTable00-15. [window name] is either "Git Bash" for the start menu entry or something like "C:_Program Files (x86)_Git_git-cheetah_.._bin_sh.exe" for the Windows Explorer context menu entry (supplied by Git-Cheetah). Alternatively, the registry settings can be overridden by storing an NT_CONSOLE_PROPS structure with appropriate ColorTable settings in the "Git Bash.lnk" shortcut via IShellLinkDataList::AddDataBlock. This happens e.g. if you edit the properties of a console window started via shortcut, or if you edit the shortcut properties directly. If you want the values from the registry instead, create a new "Git Bash.lnk" shortcut from scratch and leave the Options/Font/Layout/Colors tabs alone.

Categories : Windows

Pseudo-terminal will not be allocated because stdin is not a terminal ssh bash
You seem to assume that when you run ssh to connect to a server, the rest of the commands in the file are passed to the remote shell running in ssh. They are not; instead they will be processed by the local shell once ssh terminates and returns control to it. To run remote commands through ssh there are a couple of things you can do: Write the commands you want to execute to a file. Copy the file to the remote server using scp, and execute it with ssh user@remote command Learn a bit of TCL and use expect Write the commands in a heredoc, but be careful with variable substitution: substitution happens in the client, not on the server. For example this will output your local home directory, not the remote: ssh remote <<EOF echo $HOME EOF To make it print the remote home directory

Categories : Bash

Vim colors too bright (terminal)
You shouldn't compare colorschemes in GUI Vim and in CLI Vim: the number of colors that can be used in both contexts is very different and it makes any comparison worthless. You can get very subtle colors in GUI Vim but you can only approximate them in CLI Vim. The values used for the gui and those used for the cli are probably different which explains what you see. The only way to have the same colors in gui and cli vim is to use only colors from the xterm palette for the gui. In Vim, you could :set background=light (and read :help 'background') to see if it makes the colors less bright. In your terminal emulator, you could see if there's a setting that deals with color brightness or the usage of bold.

Categories : Vim

find out if a python script is running in idle or terminal/command prompt
This seems to work on Python3/Linux import sys print("idlelib" in sys.modules) If will return True if the script is run from Idle, False otherwise. Please test for other combination of Python/OS !

Categories : Python

how to migrate my bash prompt to zsh
Notes: First, you should search on the internet for zsh prompt customisation. It's pretty easy, and your question betrays an inability to do a cursory search prior to running here... Secondly, your question is ... illogical. You said: ... I am very picky about my prompt... it took me a long time to get my prompt to look and behave the way I want it to. You've customised your bash prompt, which took a long time to do - why would you expect somebody to have an identical zsh prompt? Answer: Use colors. For path truncation, look at this. Fairly detailed discussion on how his works (I've used something similar in my prompt). Color directory names differently: read this answer, which addresses something similar (I think: I'm not really sure what you're asking there). Change the te

Categories : Bash

Searching for a character in the bash prompt
Ignoring for a moment the security issues associated with everybody in your office sharing the same user, you could add a key binding to the readline command character-search: # ~/.inputrc C-]: character-search To use the search, type Ctrl-] followed by the character you want to search for. You can bind the command to any key sequence, not just Ctrl-], but for obvious reasons you probably don't want to emulate vi mode by binding it to the letter f. This would be less invasive than turning on vi mode so most users would probably not even notice the change. However, somebody could easily stumble upon your key sequence by accident and become very confused. You would also have to use three keystrokes instead of the two you're accustomed to with vi.

Categories : Bash

Long lines overlap in Bash PS1 prompt
When using non-printing characters in a bash prompt, you have to specify non-printing sequences (e.g. color codes) as non-printing, using [...]: PS1=' [e[0;33m]☛ W[e[0m] [e[1;35m]⤷[e[0m] '

Categories : Bash

Bash non scrolling terminal output
Instead of printing whole lines (as with println or printing %n), write backspace characters () or bare carriage returns without linefeeds ( ) to move the cursor back in front of what you want to print over.

Categories : Java

bash script, prompt user to select ID or name completion
select choises in ${list_files[@]}; do if CONTAINS_ELEMENT $choises "${list_files[@]}" || CONTAINS_ELEMENT $REPLY "${list_files[@]}"; then break else echo "invalid choise (PS use the ID numbers)! Try again:" fi done This makes both the ID number and the full directory name work, the code is a bit ugly though, and there is no name completion.

Categories : Bash

bash script that has sudo PW already in it so it doesn't prompt user
Short version: No. Longer version: sudo uses the users own password, so you cannot put it in the script. A better approach is to configure sudo so that people can run the script. For example, if the script is /usr/local/bin/root_stuff.sh then put something like Cmnd_Alias ROOTCMD = /usr/local/bin/root_stuff.sh %users ALL=ROOTCMD, NOPASSWD: ROOTCMD Your users can then run sudo root_stuff.sh Or if that is really beyond them, put the code in /usr/local/bin/root_stuff_inner.sh (changing ROOTCMD above) and put this in root_stuff.sh #!/bin/sh sudo /usr/local/bin/root_stuff.sh

Categories : Misc

Capturing exit value of previous command in bash prompt
From bash(1) PROMPT_COMMAND If set, the value is executed as a command prior to issuing each primary prompt. Use this, instead of PS1. Your assignment of PS1 is expanded once, on assigment, but NOT every time the prompt is displayed. Yes, when it is dipslayed, some expansion is done, but it is mor limited (and uses -style substitution "variables" - again, see bash(1)).

Categories : Bash

stop bash script from outputting in terminal
Append >> /path/to/outputfile/outputfile.txt to the end of every echo statement echo "Process is running." >> /path/to/outputfile/outputfile.txt Alternatively, send the output to the file when you run the script from the shell [~]# sh check.sh >> /path/to/outputfile/outputfile.txt

Categories : Bash

Multiple tab-completion routines in Bash terminal
The keybindings themselves are part of readline, and can be changed in your ~/.inputrc or use the bind command in your .bashrc (etc.), but they don't bind directly to user-defined functions, only indirectly as macros that might call those functions. "C-xhf": dump-functions # for ~/.inputrc bind '"C-xhf":dump-functions' # in .bashrc (etc.) bind -l will show you builtin functions you can bind to. You can add macros this way, which let's you run any bash function you want, although not in completion context, so the results don't get stuffed back into the command line. Example: "C-xc": "echo hi " # note it's a just macro, not a direct binding. I'm guessing you already know you can override completion with the complete builtin for commands at the left on the command line.

Categories : Bash

relation between init and bash terminal process
Nothing is shared between init and its terminal children, nor between the first terminal and its terminal child. This is because, although fork() will make both processes (father and child) to share some objects, exec() family functions completely replaces the current process image with a new process image. This means that all references to previous objects, such as shared file descriptors from the father, are forgotten.

Categories : Linux

Prompt for `sudo` only if Bash script runs into "Permission denied"
I don't know of any ways to categorize ln exit reasons, or at least any documentation about specific exit codes you could test with $?, but you can test for relevant permissions with the standard test or [ command: SOURCEFILE="/opt/myapp" DESTDIR="${1}" DESTTARGET="${DESTDIR}/myapp" if [ ! -d "$DESTDIR" -o ! -e "$SOURCEFILE" ]; then echo "Source file does not exist or destination directory does not exist." >&2 elif [ ! -r "$SOURCEFILE" -o ! -w "$DESTDIR" ]; then echo "Source file is not readable or destination directory is not writable." >&2 # Run sudo command here else # Should work, run command here fi

Categories : Bash

Insert text and Numbers in bash script Menu prompt
Use bash's select command to simplify the menu: echo "-----------------------------" echo " Data Processing Menu " echo "-----------------------------" choices=( "Enter Number $Number of Files $FileName to output.txt" "Show Classifiers only" "Auto All $All of Files $AllFileName to output.txt" "Exit/Abort" ) PS3="Enter your choice: " select Pmenu in "${choices[@]}"; do case $Pmenu in 1) "Building"; break ;; 2) cut -f 4 input.txt; break ;; 3) "Building"; break ;; 4) exit 0;; esac done I'm not clear on what help you need for 1 and 3.

Categories : Bash

New tab in Terminal.app does not open in same directory/bash fails (Mountain Lion)
I had this problem too, and discovered that I had accidentally changed a setting in the "Startup" tab of the Terminal preferences. The setting was "Shells open with: Command (complete path): ." I changed it back to "Shells open with: Default login shell" and that solved the problem.

Categories : Bash

sentence as user input - multiple times from terminal - bash script
This is because in your second call to read, you are using the -a argument which does: The words are assigned to sequential indices of the array variable aname, starting at 0. aname is unset before any new values are assigned. Other name arguments are ignored. That appears to be not what you want.

Categories : Bash

Start and stop logging terminal output to file from within bash script
You can use the braces to redirect commands to tee through a pipe #!/bin/bash # to terminal and logfile.log { echo "aaa" echo "bbb" echo "ccc" } 2>&1 | tee logfile.log # only terminal echo "ddd" echo "eee"

Categories : Bash

`-bash: rbenv: command not found` comes up every time I open a terminal window. How do I fix this?
Without being able to see your .bashrc or .bash_profile files, I would guess that you have a line in one of them what is supposed to be loading something from rbenv. I would check there to see if there is something that might be loading is.

Categories : Osx

How to print out error messages into terminal screen while doing pipes (linux bash)
Error messages written to standard error will not be sent to the piped command. I mean if your command is: cmd | cmd2 then only the stdout messages from cmd will be piped to cmd2 and not stderr messages. Here is an example I used. I tried cating a non-existing file and tried greping some text: $ cat non-existing-file.txt | grep something > grepped-text.txt cat: non-existing-file.txt: No such file or directory

Categories : Bash

Adding ANSI color escape sequences to a bash prompt results in bad cursor position when recalling/editing commands
You need to enclose the non-printing characters in [ ... ] so that bash knows to ignore them when computing the length of the prompt: export PS1='[33[0;33m][u@h w]$ [33[00m]'

Categories : Bash

Running a .py script from bash, how can I pass a python variable back to the terminal once the .py is done running?
You can write your variable and its value into an ini file from the python script. In Values.ini file my_var="value" After executing python script, just invoke Values.ini using . operator . Values.ini Now your shell variable $my_var will be having the assigned value. The advantage with this method is that you can assign any number of variables like this. var1="value1" var2="value2" var3="value3"

Categories : Python

How to make this command open a new terminal & execute the command within it ( Exec=bash -c "tail -n 10 -f /var/log/httpd/error_log" )
To open a terminal Exec=nameOfYourTerminalApp (eg:gnome-terminal, lxterminal, xterm) Then you can run your commands in the opened terminal. Otherwise, you can create a script with some command and run it. In that case you have to put tail -n 10 -f /var/log/httpd/error_log in the script and make it executable. Then call it with a shortcut file.

Categories : Linux

CSS faded section at top of scrolling div
Pretty simple, use position:fixed instead of position:absolute: .fadedScroller:after { content:''; position: fixed; top: 0; left: 0; height: 20px; right: 0; background: linear-gradient(to bottom, rgba(251, 251, 251, 1) 0%, rgba(251, 251, 251, 0) 100%); } http://fiddle.jshell.net/hP3wu/4/ Update1 http://fiddle.jshell.net/hP3wu/7/ Update2 http://fiddle.jshell.net/hP3wu/9/

Categories : HTML

right-faded text optimization
I don't think it's possible to skip the intermediate pixmap without having to draw the text multiple times. I'd hope that a pixmap is way more efficient than double rendering of the text. About the only thing I'd do is to retain the drawText semantics. The implementation below tries to do it and to optimize by drawing the pixmap at integral coordinates within the target painter. Whether this improves the quality of the output is to be seen, but it can't hurt. If you want to special-case a non-portable solution into the code, then it's worth noting that QBackingStore::paintDevice() may happen to return a QImage. You could then add a specialized path in your code to access this, should it happen to be a QImage. Do note that you should use dynamic_cast<QImage*>(backingStore()->pain

Categories : C++

Unix $RANDOM function not random in Bash terminal
You kept seeding RANDOM with the same number. Try not to seed it or seed it with a more random item instead: RANDOM=$$ Apparently $$ doesn't change always as it's always the main PID (not subshell PID) of your shell. If you're actually calling different shells, probably there isn't much difference since the numbers seeded by every PID increments only by ones. So either you could remove that or get another random seed somewhere like /dev/urandom, etc. One good way to apply a random seed by /dev/urandom: RANDOM=$(tr -dc 0-9 < /dev/urandom | head -c10) Another through nanoseconds (seeding larger numbers than these seems to not give a good effect): RANDOM=$(date '+%N') Also to make it look more unique among different subprocesses, add BASHPID (better than $$) to your seed: RANDOM

Categories : Bash

How to put the faded hover effect on the button?
You're going to need to use CSS to apply a transition to the anchor. Here's an example: /* replace 0.5s in each one with the time you want it to take */ a { text-decoration: none; color: #007edf; /* starting color */ transition: color 0.5s ease; -webkit-transition: color 0.5s ease; -moz-transition: color 0.5s ease; -o-transition: color 0.5s ease; -ms-transition: color 0.5s ease; } a:hover { color: #0069ba; /* ending color */ }

Categories : HTML

How to faded top a Single character in a TextView
You could use TextSwitcher. Take a look to the API Demo for TextSwitcher. You can use setInAnimation() and setOutAnimation() in combination con setText(), so the text will change animatedly. UPDATE I found a good solution here!

Categories : Android

PIL paste image with alpha appears faded
The background you are creating is black and fully transparent the original is blue but with an alpha of 179 so you have 2 pixels (0,0,0,0) and (0,0,255,179) assuming 100% blue - since you are pasting the image in it will be over the background so will use the alpha of the new image allowing (255-179)/255 or about 30% black. (N.B. The alpha of the background makes no difference since it is behind the new image) You could use overlayImage.putalpha to set the alpha to 255 start from your image rather than a black background.

Categories : Python

Bash script to wait for gnome-terminal to finish before continuing script, only works for first instance of script
#!/bin/bash date bash -c "sleep 7" & bash -c "sleep 5" & wait date As you can see while running this script, both sleep commands will run in parallel, but main thread stalls, while they are running. Sat. Jule 27 01:11:49 2013 Sat. Jule 27 01:11:56 2013 Replace sleep 7 with expect launchneuron.exp and sleep 5 with expect launchmpj.exp and add your plot commands after calling "wait": echo "Simulation Complete" ...(your code to plot results)

Categories : Bash

Navigation bar/menu not showing in customised colors with Safari (Correct colors in other browsers)
nav ul { margin: 80px 0 20px 0; padding: 0em; float: left; list-style: none; background: #1A1A1A; background: rgba(26,26,26,.2); -moz-border-radius: .5em; -webkit-border-radius: .5em; border-radius: .5em; -moz-box-shadow: 0 1px 0 rgba(255,255,255,.2), 0 2px 1px rgba(0,0,0,.8) inset; -webkit-box-shadow: 0 1px 0 rgba(26,26,26,.2), 0 2px 1px rgba(0,0,0,.8) inset; box-shadow: 0 1px 0 rgba(26,26,26,.2), 0 2px 1px rgba(0,0,0,.8) inset; } You've got background twice once as hex the other as rgba, I think you only need one.

Categories : Javascript

How to display text over a faded image on hover using jquery
Set the text inside a span or a div and position it absolutely corresponding to the container which is relatively positioned. Then hide or show the corresponding text $(document).ready(function () { $('#wb_Image3 a img').hover(function () { $(this).stop().animate({ opacity: .4 }, 200); $('.text').removeClass('hide'); }, function () { $(this).stop().animate({ opacity: 1 }, 500); $('.text').addClass('hide'); }); }); Check Fiddle

Categories : Javascript

Weird colors in background of UIImage when trying to replace all white colors
Using a different code I slipped in my loop and it no longer showed the random background static: -(UIImage *)replaceWhiteWith{ NSString *str = [[NSUserDefaults standardUserDefaults] objectForKey:@"color"]; UIColor *color = [NSString colorFromNSString:str]; CGFloat red = 0.0, green = 0.0, blue = 0.0, alpha =0.0; [color getRed:&red green:&green blue:&blue alpha:&alpha]; CGImageRef inImage = self.CGImage; CFDataRef ref = CGDataProviderCopyData(CGImageGetDataProvider(inImage)); UInt8 * buf = (UInt8 *) CFDataGetBytePtr(ref); int length = CFDataGetLength(ref); for(int i=0; i<length; i+=4) { int r = buf[i]; int g = buf[i+1]; int b = buf[i+2]; if(r == 255 && g == 255 && b == 255){

Categories : IOS

How to i make my prompt alert accordingly to if the user has answered what i've got pre typed in the prompt?
If you look at the definition of JavaScript's prompt() method, you could see that the second parameter is the default text that the method should return in case the user has not entered anything. Try this instead: var name = prompt("Enter your name"); if (name === "") { prompt("Oops, looks like you didn't enter anything"); } else if(name != null) { alert("Welcome" + " " + name); } Hope this helps! Live demo here.

Categories : Javascript

How execute other prompt when prompt previous is true on Yeoman?
Yeoman uses a thing called Inquirer.js for the prompt system. Here's an example of how you can ask Question 2 if Question 1 was true: inquirer.prompt([{ name: 'movie', type: 'confirm', message: 'Have you seen a movie lately?' }, { when: function (response) { return response.movie; }, name: 'good-or-not', message: 'Sweet! Was it any good?' }], function (response) {}); From the Inquirer.js documentation: when: (Function) Receive the current user answers hash and should return true or false depending on wheter or not this question should be asked.

Categories : Javascript

Add alternating row colors with column grouping colors-is it possible?
Since your rows are alternating light/dark, you could take advantage of an alpha transparent background color: http://cssdeck.com/labs/6rgab657 <table> <colgroup class="a" span="4" /> <colgroup class="b" span="4" /> <colgroup class="c" span="4" /> <colgroup class="d" span="4" /> <tr> <td>A</td> <td>A</td> <td>A</td> <td>A</td> <td>B</td> <td>B</td> <td>B</td> <td>B</td> <td>C</td> <td>C</td> <td>C</td> <td>C</td> <td>D</td> <td>D</td> <td>D</td> <td>D</td> </tr> <tr> &l

Categories : Jquery

How is interacting with a prompt of a third party command line program different from a Windows Command prompt?
Most likely the program starts its own shell and does no longer interact with the original one. (You would notice this if the program opens a new window) Or the program needs some specific library to be present to be able to interact with a shell (readline seems to be the case here) and that is not present in your Java Environment. As a quick hack you might try to start bash (or cmd) that then starts the tool. bash and cmd have readline library. I don't have a windows ready here but as a guess just try to call your program like cmd urjtag.exe instead of just urjtag.exe that way you start a cmd process (with that you can interact) and that cmd starts the urjtag.exe where you already know that it can interact with. Either way the problem lies in the way the program you want to call intera

Categories : Java

gnome-terminal font resize (zoom in, zoom out), but adjust terminal height and width contrariwise for getting a "lock in" of window dimensions
I can’t tell you for sure, but since this is GNOME and moreover GNOME 3, it’s unlikely that the Terminal has this kind of customization built-in. But in Linux, you can always improvise. How about the following. Find a program that can send keys to an X11 window. Maybe xdotool. Find a program that can control an X11 window’s geometry. Maybe xdotool. Write a short script that locates the terminal window (probably just the focused one), sends it Ctrl-Plus / Ctrl-Minus, waits a tiny bit, then sets its geometry to the one you like (or to whatever it was initially, which you can also query with xdotool). Bind this script to a keyboard shortcut of your choice, say Win+Plus / Win+Minus. No idea how to do this in modern Ubuntu / GNOME 3, but GNOME 2’s Metacity used to have GConf keys f

Categories : Misc



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.