Black Bytes » bash http://www.blackbytes.info Sat, 30 Nov 2013 17:18:48 +0000 en-US hourly 1 http://wordpress.org/?v=3.5.2 Bash expansionshttp://www.blackbytes.info/2013/11/bash-expansions/ http://www.blackbytes.info/2013/11/bash-expansions/#comments Sat, 30 Nov 2013 17:18:35 +0000 admin http://www.blackbytes.info/?p=1080 In this post you will learn about bash expansions, you probably already used them if you have done something like “ls *.txt”, basically the shell does some processing on the command line before actually executing it, which enables us to do a numbers of things, like using variables.

Here is a small cheatsheet of the most useful expansions:

Brace expansion
List: {1,2,3}
brace-expansion

Range: {20..30}
range

Filename expansion (also know as globbing)
*.sh -> expands to all file names that have an extension of .sh
[st]* -> expands to all file names that start with either an 's' or a 't'

filename-expansion

Tip: if you want to use a especial character without it being expanded you can enclose it in quotes, for example: echo “test*”

Variable expansion
$SHELL -> /usr/bin/zsh

You can learn more here: http://www.gnu.org/software/bash/manual/html_node/Shell-Expansions.html

]]>
http://www.blackbytes.info/2013/11/bash-expansions/feed/ 0
Beyond Bashhttp://www.blackbytes.info/2012/03/beyond-bash/ http://www.blackbytes.info/2012/03/beyond-bash/#comments Sun, 04 Mar 2012 22:50:32 +0000 admin http://blackbytes.wordpress.com/?p=212 If you use Linux you are probably using the bash shell, but turns out there is life beyond bash!

When using aptitude or apt-get I’m sure you tried this at least once:

aptitude ins;
"Oops, that didn't work but I wish it did!"

Well that and much more is possible using another shell: ZSH, to get started you will want to install it (should be available in your distro repo) , after that just run ‘zsh’ you may get a dialog asking if you would like to create a basic configuration file (.zshrc just like .bashrc) just skip it but don’t get scared when your prompt looks like this:

[e]0;u@h: wa]${debian_chroot:+($debian_chroot)}u@h:w$

This is happening because it’s trying to use your bash prompt which uses a different syntax, now we are going to install “oh-my-zsh” which contains a decent default config, various plugins and it will set zsh as your default shell (you can revert using chsh -s /bin/bash user) also it comes with themes which are nothing more than prompt configurations, you can see images on how they look here:

https://github.com/robbyrussell/oh-my-zsh/wiki/themes

To install oh-my-zsh issue this command:

curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh

Now we are ready to start playing with our new shell, let’s explore some of the features.

- Better Tab completion

Zsh is able to autocomplete the arguments for most system commands, and even give us a menu-like interface if you tab twice.

This also works with the kill command:

- Typo correction

Zsh will help you to fix those annoying typos you make all the time:

- Auto pushd

If you jump a lot between different dirs you are going to love this, zsh can autopush the dirs you cd into, this means you will be able to list the recent dirs you have been in using the ‘d’ command (which is an alias for dirs -v) and then change to them just typing the corresponding number.

And that’s just a small taste of what zsh has to offer, now it’s your turn to try it and decide if you like it.

Zsh FAQ: http://zsh.sourceforge.net/FAQ/
Zsh documentation: http://zsh.sourceforge.net/Doc/

]]>
http://www.blackbytes.info/2012/03/beyond-bash/feed/ 0