Facebook

Showing posts with label Terminal. Show all posts
Showing posts with label Terminal. Show all posts

How to shorten the bash shell prompt


So sometimes it happens that you are working on command terminal and you navigate inside a directory then again in inner directory and so on until half of the screen width is filled with prompt string. Example below....

rana@Brahma: dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8 $ ls 

Now I want to display just the last directory in terminal prompt string so that I am left with enough width space to execute length commands.

For this We need to change the prompt string from .bashrc file. Below are the steps -

1. Go to your home directory.
2. Open .bashrc file.
3. Search for string 'PS1'. To search quick open the file in vi and type /PS1 and hit enter.
4. now you will find below code. (or similar to it) [ I am working on Ubuntu 16.04]
if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
5. Replace the 'w' (highlighted in blue color) with capital W. So your new code will be.
if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]: \[\033[01;34m\]\W\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
6. Restart the terminal and navigate inside any directory. You will see just the last directory in teminal prompt.
rana@Brahma: dir8$

Happy Learning.


 

Finding file and directory in ubuntu


To find a file in your system by name use below command -

find -name "query"

For case insensitive search -
find -iname "query"

StopWatch and other Hacks




Say Yes to all confirmations


So sometimes it happens that you are installing some package or compiling some source code and it asks for your confirmation
Do you want to continue (y/n)?
 so instead of pressing 'y' everytime you just can do this

Download YouTube video in One Go




How to download single video - 


$ youtube-dl   is a very powerful utility in Linux to download videos from Youtube or other similar sites.


To download just one video use the below syntax


Train on Your Terminal



Did it ever happened to you that instead of typing 'ls' for listing the files in a directory , you type 'sl' in hurry and got the no-so-pleasant error saying that 

"The program 'sl' is currently not installed.  You can install it by typing:
sudo apt-get install sl


StarWars in Terminal




This is for Geeks and Nerds only. Others may not found it interesting.

To watch StarWars  in command-line terminal, run the below command 

$ telnet  towel.blinkenlights.nl