How to remove an "Alias" in cmDer? - cmder

I created a test "alias" in cmDer
alias testalias = "dir * a ".
How to remove the alias I created?

If the alias isn't gone after restarting your console, it means that it got created permanent.
Removing a created alias is pretty simple, you just need to execute the following command:
alias /d [alias name]
In your case will be something like:
alias /d testalias
Also, if you didn't change the default alias that are created when you unzip the app, you can simple rely on another alias which is:
unalias [alias name]
Hope this helps
PS: if you want to see which are your available aliases, just execute alias and you will get them

Related

How do I copy aliases in my cmder without typing them like alias

How do I copy aliases in my cmder without typing them like
$ alias e.=explorer...
in the terminal ?? for example this
https://gist.github.com/DavidMCarek/87687a81e2574df615ed8a48299a5023
I want to copy most of these entries in a file..
One method is to actually copy and paste these aliases into your actual aliases file.
You can do this by going to your cmder download location > config > user-aliases.cmd
Open your user-aliases.cmd file in an editor and paste all of the aliases you want to use. For example, I have a few aliases for git commands to speed up my workflow:
Save the file and then restart cmder. You should be able to use your aliases now. For example, here's my git status alias (gs) now in use:

how do I change default editor for sudo vipw from "vi" to "vim" by tcsh in FreeBSD

When I use command sudo vipw to edit my password file, It's always use vi as editor. I don't like this very much and want to change it to vim.
I already tried:
Add export EDITOR=/usr/local/bin/vim in /etc/profile.
But shell told me "export: Command not found". I thought the reason is export is built-in function only in bash. And I don't want to change my shell.
AddEDITOR=/usr/lcoal/bin/vim in default block of /etc/login.conf
Add setenv EDITOR vim in /root/.cshrc, /.cshrc, ~/.cshrc
All above didn't work at all.
I have google for hours but could not find anything help.
Your /etc/sudoers file doesn't keep your EDITOR environment variable.
I personally have an /etc/sudoers.d/local file, something like
# We don't need to worry about wheel users breaking in to get root access because they already have it.
Defaults:%wheel env_keep+="HOME EDITOR",!set_home,shell_noargs
I'm not sure why this isn't the default, since wheel users have already been given full access. But it's apparently prevailing wisdom to continue hassling them.
Note: If you're using an older /etc/sudoers file that doesn't support an /etc/sudoers.d directory, these lines can be dropped in there... or you could add #includedir /etc/sudoers.d as the last line of your /etc/sudoers file to enable an /etc/sudoers.d directory. Um, yes, the # is a required part of that line, because someone thought it was important for that directive to look like a comment.
Try adding this to the root user /root/.chsrc:
setenv EDITOR vim
or to set it globally to all users using shell tcsh/csh add it in /etc/csh.cshrc
From the man:
A login shell begins by executing commands from the system files /etc/csh.cshrc
and /etc/csh.login. It then executes commands from files in the user's home directory:
first ~/.tcshrc or, if ~/.tcshrc is not found, ~/.cshrc ...
Non-login shells read only /etc/csh.cshrc and ~/.tcshrc or ~/.cshrc on startup.
Also verify vim is installed since is not by default, you could try:
pkg install vim-console
setting the EDITOR or VISUAL environment variable is the key.
if you don't want to go to the trouble of modifying config files (which is indeed the long term solution) then you could sudo su - to get to the root prompt and then you could export EDITOR=/usr/bin/vim before running vipw
There is an empty file called .selected_editor in $HOME (/root).
Remove it and the next call to vipw will ask you to select the editor.

Alias that refers to another alias

I need to identify an alias command that refers to another alias command in Cmder, for example let's say i define firstAlias like:
alias firstAlias=cd blah/blah
than i create another alias that uses above alias like:
alias secondAlias=firstAlias $t another command
I have already tried these options(including above one) but no luck so far:
alias secondAlias=firstAlias $t another command
alias secondAlias=$firstAlias $t another command
alias secondAlias=`firstAlias` $t another command
alias secondAlias=%firstAlias% $t another command
alias secondAlias=/firstAlias $t another command
any idea appreciated,
Thanks in advance.
From what it seems you can't use an alias w/ in another alias. So a workaround is to merely call a .bat file or something with all the commands you want in it. Kind of a hassle, but that's what I had to do for my scenario.
I created a .bat file and set my alias to call that file. I put all the commands I cared about in that file...
status=%CMDER_ROOT%\config\status.bat

How to create rails alias command

I have seen some developers used alias command for there projects. Like rs to run rails server.
How to create that alias rs="rails server"?
where to config that?
Is it works for window?
Is need any specific ruby or rails version?
It's about shell and not about rails. You can create alias to all commands you want. Those aliases are created on your profile like ~/.bash_profile or ~/.zshrc for example. Then to use aliases you need to study about them on documentation of shell you are using. On Windows I think Powershell supports aliases.
You don't have to put that command into a file (unless you want it to persist into the next session. To test what will work for you just put it in your terminal:
alias rs="rails server"
Then type rs. If it works you need alias, if not continue reading for doskey macros.
Now for windows, if you are running cygwin or a linux virtual machine, you use ALIAS. If you are using the Windows shell you ise DOSKEY.
doskey alias_name="some command here"
alias alias_name="some command here"
If you are on windows or 8 it doesn't like files without extensions. To create a .bashrc file, create a .bashrc. (notice the trailing .) and Windows will remove the last dot.

How to permanently change sudo's $PATH variable (Ubuntu 9.x)

I want add some directory to the $PATH when running sudo, this is a (semi) permanent requirement, not something that needs to be added to the scripts themselves. I notice that Django has managed to do it, (my $PATH when running sudo is "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/django/django-trunk/django/bin") - so how did it do that?
This is the line in the sudoers file that resets:
Defaults env_reset
You can work around this by adding PATH to env_keeps or by adding this line:
Defaults env_keep = "PATH"
EDIT: meder, you do not disable env_reset, you simply bypass the path reset
Or you can remove the offending env_reset line.
Even better though, you can declare a secure_path that will replace PATH when sudo is run:
Defaults secure_path="/bin:/usr/bin"
That way you can control what specific directories to include in the path.
I think this should work out if you save it in /root/.bashrc:
export PATH=/www/foo:$PATH
I forget if it's PATH or PYTHONPATH and if it actually matters, this is based on my user's .bashrc:
export PYTHONPATH=/www/django:$PYTHONPATH
You can set the variable in /etc/environment, and then use "sudo -i" to run the script (works in ubuntu 10.10).

Resources